Questions tagged [commands]

Commands are functions that can be invoked interactively either through `M-x` or by a key binding.

Filter by
Sorted by
Tagged with
1
vote
1answer
132 views

Command abbreviation

After running M-x magit-status Emacs provided me this suggestion in the mini-buffer: You can run the command ‘magit-status’ with M-x m-stat RET Is this a built-in feature of emacs? If not, does ...
8
votes
2answers
2k views

How to find out what command I just accidentally ran with a keyboard shortcut?

Is there a place where emacs stores commands the user has recently executed, in particular via keyboard shortcuts, and if not, would it be possible to tell it to store them somewhere? I sometimes type ...
1
vote
1answer
91 views

deactivate active region after `eval-region`

I do the following to activate the region and evaluate it M-x spc to begin mark C-n C-n C-n M-x eval-region The region is still active (highlighted) after the eval-region is performed. I would ...
1
vote
2answers
85 views

how does optional argument `ALLOW-EXTEND` in `mark-word` work?

I am switching from VIM to Emacs for just a couple weeks and trying to write some Elisp. Having difficulties to adapt, I am exploring different options to do marking and reached this function. (defun ...
0
votes
1answer
252 views

Equivalent to the ViM :smile command

In ViM, there is a :smile command that displays lighthearted ASCII graphics of a figure that smiles. Is there an equivalent command available in Emacs?
2
votes
2answers
357 views

C-g has stopped breaking out of commands like `C-x C-f` and `M-x` in graphical emacs-25

I have always used C-g (ie keyboard-quit) to break out of commands like M-x and C-x C-f. At some point not too long ago this stopped working. All that happens is that Quit flashes in the minibuffer ...
1
vote
3answers
92 views

Finding Numbers in Brackets and Summing Them

QUESTION: How can I make an emacs command M-x sum-the-brackets that scans highlighted text for all occurrences of [ <number> u ] and [ <number>u ], and sums them? EXAMPLE: Selecting ...
2
votes
2answers
115 views

How to limit when yasnippet fires?

I found that yasnippet suggests using this code to limit it to only expand when the trigger text has just been typed: (setq yas-expand-only-for-last-commands 'self-insert-command) Unfortunately when ...
4
votes
1answer
59 views

What keystrokes brings up the prompt to issue Lisp commands?

I am editing a file and I want to set the tab width (more likely the indent width) to 2 and I have come across a command (setq tab-width 2) but when I use M-x (i.e. Alt-x) on my system and I enter (...
2
votes
1answer
238 views

Run command on custom key binding [duplicate]

I am trying to customize emacs/spacemacs to run a command after a key stroke, like running eslint --fix command on the buffer to fix errors. I already tried (defun fix-errors-with-eslint () (shell-...
0
votes
1answer
78 views

My emacs doesn't contain a function in the online emacs manual

Command comment-line is not recognized by my version of emacs. How can I install this function? UPDATE: It may be relevant that my system shows at least two emacs, at /usr/local/bin/emacs; and at /...
2
votes
1answer
657 views

command works with M-x but gives “Wrong type argument: commandp” when calling through key binding [closed]

I wrote this command and key binding to use with cider for Clojure development: (defun reload-and-eval-in-repl () "Set the ns of the repl to the one in the current buffer, then eval the region of ...
5
votes
4answers
2k views

Get output of external command in the buffer

How do I get the output of (shell-command "df") (or some other more complex command, that I don't want to retype often) in the current buffer? I run it by typing C-c p after it, but then it opens ...
2
votes
2answers
332 views

Repeat n(th) last command in emacs?

I know that to repeat the last command, there is C-x z and then to keep using z to easily keep the last command in operation, but what can be done for the 2nd or 4th last command? Or is that ...
2
votes
1answer
34 views

Finding Like Variables or Functions

Is there a command that will jump cursor to other iteration of the variable or function name under the cursor? I suppose it wouldn't matter if the text is specifically a variable or function, but ...
1
vote
3answers
175 views

Emacs equivalent of the following vim operation

In the answer to a question on Quora, Gilles Castel wrote an answer highlighting the power of vim. The Question was: How would you write a C program to print 1 to 100 without loop, recursion, or ...
3
votes
1answer
45 views

Refile and keep the original

How to refile while keeping a copy of the original object in org-mode? In other words refiling works as a cut&paste while I would like to have a copy&paste.
1
vote
1answer
69 views

Reuse other command's “interactive” form

Example, I want to define a package-open-homepage command, which reuses C-h P (describe-package)'s "interactive" form. I don't want to copy-and-paste because it is too long. The following (eval `(...
5
votes
3answers
526 views

How to see the name of the command every time I run it by a shortcut?

Whenever one runs a function/command for which there is already a shortcut, Emacs shows briefly a message in the echo area to recall that there is a shortcut associated with that command. For example ...
3
votes
1answer
344 views

Prevent Spacemacs from creating double sr-speedbar

I'm trying to make Spacemacs and sr-speedbar work together smoothly. Without using Spacemacs: The command buffer is local to each buffer where it is called: Left is sr-speedbar, right is the main ...
5
votes
1answer
216 views

How to force the user to comply with a command?

First, here is the full source code of my package. Requirement Currently I'm working on a package that provides a feature which upon the user invoking several times in a row certain command in a ...
1
vote
3answers
584 views

Is there Sublime Text - style command palette in Emacs?

There is such feature as Command Palette in Sublime text: It provides searchable list of command with human-readable descriptions. Is there anything similar to this in Emacs?
3
votes
1answer
764 views

Open File and Directory: What's the Emacs command?

I would like to set custom keyboard shortcuts for the Open File and Open Directory commands listed in the File menu. The only problem is that I don't know the corresponding Lisp commands. I've tried ...
1
vote
1answer
1k views

How to change keyboard shortcuts for copy, cut and paste and set keyboard shortcut for debugger (GDB)?

I would like to set the following keyboard shortcuts: Copy (selected text): C-c Cut (selected text): C-x Paste from clipboard: C-v Debugger (GDB): M-g Now I realize that to do this I merely need the ...
1
vote
0answers
167 views

Error in using “helm-projectile-find-file”

This is my config in init.el: (require 'helm-projectile) (projectile-global-mode) (setq projectile-completion-system 'helm) (helm-projectile-on) (setq projectile-indexing-method 'alien) (setq ...
1
vote
1answer
282 views

Adding eldoc support to js2-mode

Since js2-mode does not have eldoc-mode support, I was wondering if I could get some similar functionality to js2-mode with the help of tern-mode. tern-mode has a command tern-get-type which will ...
4
votes
2answers
189 views

Custom C-arrow cursor movement

I was not satisfied with the behavior of standard C-arrow and C-S-arrow, so I wrote this functions to replace standard ones. (setq separators-regexp "[\-'\"();:,.\\/?!@#%&*+=]") (defun forward-...
2
votes
2answers
317 views

Move to the beginning of a heading smartly in Org-mode

I just started with Org-mode today and noticed whenever I press C-a on a heading, the cursor is moved all the way to the beginning of the line instead of the first character in the heading. Like so :-...
4
votes
2answers
659 views

How to make emacs automatically kill buffer after invoking delete-file command?

Whenever I delete a file that I no longer need in emacs using delete-file command, the buffer associated with the file is still open in emacs. Is there a way I can change this behaviour so that ...
4
votes
1answer
2k views

How to quickly create a new directory without using dired-mode?

Whenever I've to create a new directory in emacs, I enter dired mode, press "+" and enter the new directory name which creates the new directory. Is there a way I can avoid using dired-mode and ...
1
vote
1answer
71 views

How to retain selection after command run (indent-code-rigidly)?

I found a neat code snippet for ~/.emacs configuration: (global-set-key (kbd "C->") (lambda (b e &optional n) (interactive "r") (...
3
votes
2answers
158 views

How to disable query to turn on disabled command?

I have this in my .emacs file to disable mouse right clicks: (put 'mouse-save-then-kill 'disabled "mouse-save-then-kill disabled\n") How can I now disable the query generated by emacs to turn this ...
1
vote
2answers
680 views

How to reuse last input in command with a prompt?

Some existing functions have ability to remember last input, which you can use in the next command call - for example, replace-string will suggest the last replacement by default, while isearch will ...
5
votes
2answers
181 views

How to repeat a command immediately after calling it?

I've just called an interactive function (i.e., a command). I want to call it again, with the same arguments. I know that I can call a keyboard macro again by using e right after running it the ...
3
votes
1answer
2k views

Getting the full list of colors available in Emacs

When I run list-colors-display I get the following: which I think is a very small subset of colors that my Emacs supports, isn't it? For example, I know Emacs supports other colors (gray20, blue15, ...
1
vote
2answers
536 views

How can I set a key binding to run two other key bindings?

Specifically, I want the binding 'C-x C-a' to do 'C-x C-s' then 'C-c C-a'. (Context: I'd like to save my TeX document, then have AUCTeX render it.) How can I do this? I don't want to map 'C-x C-a' to ...
6
votes
2answers
898 views

Run shell commands in emacs by something similar to M-x …?

I have a program which can run as a command in bash. Can I run the program in emacs, in some way similar to run emacs' command (i.e.M-x , e.g. M-x occur), instead of first explicitly running a shell ...
6
votes
2answers
296 views

Exit minibuffer and execute a command afterwards?

I am trying to bind a key in minibuffer-local-map to a command which uses abort-recursive-edit or exit-minibuffer and then proceeds executing more elisp code. So I want to exit the minibuffer and then ...
1
vote
1answer
68 views

eshell backtrace when trying to use character command

I have written a custom interactive command that takes a character as an argument. When I happen to use the key binding for that command while in a eshell buffer where a long-running command is ...
2
votes
0answers
221 views

Trace Evil-mode commands

At the moment, I only know one way to determine which Emacs functions are called by any given Evil command (e.g. a sequence of key bindings in the Normal state): read the Evil source code. Is there a ...
5
votes
1answer
1k views

How can I change which shell script mode I'm in?

Occasionally, emacs opens a file in shell-script[fish] when I want it to open in shell-script[bash]. How can I manually change the subtype of shell-script mode that I'm in?
8
votes
2answers
831 views

How to see which functions are executed

When I do something inside Emacs, with the buffer *Messages* you get some idea what happened. But it's only if that function is echoing a message for the minibuffer. Then *Messages* keeps a record of ...
0
votes
1answer
65 views

man -K from emacs

There is M-x manual-entry that show concrete man page, but what if I don't know which manual page exactly I need, from shell I can run man -K apropos and see result, is equivalent functional in emacs, ...
0
votes
1answer
70 views

Programatically get available movements evil emacs

Is there a way to programatically get the available movement commands for evil emacs? Preferably also with the key they are currently bound to. (There are a lot of commands for movement, but I do ...
8
votes
1answer
66 views

Is there a column equivalent of `C-l`?

The command C-l scrolls the current line to center, top, bottom. Is there an analogous command that scrolls the current column to center, left, and right?
2
votes
1answer
226 views

Can helm-apropos display the key bindings for commands the way helm-M-x does?

I'm a recent convert to helm. helm-M-x displays commands and includes key-bindings in parens after the command name. helm-apropos displays commands and other things. I'd like it to display the key ...
3
votes
2answers
103 views

Can a command determine the event sequence that invoked it?

I have a command that I would like to bind to multiple key sequences differing only in the final decimal digit (e.g. C-. 0, C-. 1, ..., C-. 9). The command needs to determine that final digit. I ...
5
votes
2answers
835 views

Can emacs commands be called from a shell script?

I have a directory ~/foo that contains several org files. I'd like to use htmlize to convert each org file into an html file. Ideally this would be done with a shell script. Is there a way to make a ...
1
vote
2answers
94 views

How to push this command in to history?

I have this function in config (defun launch-separate-emacs-under-x () (interactive) (call-process "sh" nil nil nil "-c" "emacs &")) (defun restart-emacs () (interactive) (add-hook 'kill-...
3
votes
1answer
349 views

How can I speed up individual commands?

When I call commands such as helm-apropos and custom Org agendas there is often a noticeable delay between the key sequence and the results presented. How can I speed up these commands to respond ...