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
37
votes
1answer
2k views

What is the difference between a function and a command?

When posting questions and answers here, people sometimes use the terms "function" and "command" interchangeably. In other cases, people only use one of the two terms to discuss specific pieces of ...
13
votes
1answer
1k views

Why can't I bind my function to a key or call it with M-x?

I wrote a function, and I want to call it via M-x, and bind it to a key. This is my function: (defun my-function () (message "This is a great function")) If I try to call it with M-x my-function,...
12
votes
1answer
1k views

How to use 'interactive' arguments when calling the command from code

I have a command called test which simply takes an input from the user and echoes it back: (defun test (input) (interactive "MInput: ") (message "%s" input)) I want to write another function ...
8
votes
2answers
4k views

How can I customize the compile command?

In one of my projects I need to run make package install when building instead of make. It remembers the last compile command I used, but resets to make -k every time emacs starts up. How can I ...
16
votes
2answers
699 views

How can I test and use a Perl regular expression interactively?

Say I have a buffer with text. I would like to test a regular expression (ideally Perl type) against my buffer and have Emacs highlight the matches on it. For example, the following regexp (taken ...
5
votes
2answers
907 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 ...
4
votes
2answers
213 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-...
1
vote
1answer
145 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 ...
1
vote
1answer
76 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
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?
5
votes
2answers
191 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 ...
2
votes
1answer
917 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 ...
2
votes
1answer
243 views

How to scroll back through the command line history in the Emacs interactive subshell?

Let us say in the interactive subshell I run these commands: command_a command-b command_c ... command_z I type M-p to go back to command_z. But how can I scroll back the history of commands until ...
1
vote
1answer
136 views

How to disable C-<number>

I don't know the name of the command C-<number> <entry> to repeat the <entry>, <number> times. For me it is more annoying than useful, several times I have accidentally ...
1
vote
2answers
609 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 ...
0
votes
1answer
452 views

Wrong type argument: commandp cscope

My question is how to let the command SPC-m-c-Cget the function name automatically? I am using 0.200.10@25.3.1 (spacemacs), on Ubuntu 16.04 64 bit I am using cscope layer, it is great but with one ...