A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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
14
votes
1answer
119 views

Turning active M-! into M-& (a'ka emacs equiv to bash Ctrl-Z)

From time to time I happen to M-! some_command just to find that the command runs longer than I expected and keeps my emacs frozen for long seconds. So I glaze at my frozen emacs and kick myself for ...
3
votes
2answers
236 views

Delete file (if it exists) before saving

My problem is that I can create, but not overwrite existing files. This is probably due to a bug in MegaFuse. Because of this, when I finish editing a file I must first save it under a different ...
7
votes
3answers
176 views

Swap default behavior of command with C-u behavior

Many Emacs commands alter their behavior when called with one or more C-u prefixes. In some cases the default behavior of a command is less useful to me than the behavior I get when prefixing it with ...
7
votes
3answers
942 views

Sum numbers in region

How can I sum a set of numbers interspersed with text in the region (not a rectangular region). For example, if the region contains this text: Widgets 234 Sprockets 44 Nubbins 12 Fork handles 4 4 ...
3
votes
2answers
502 views

What does C-Mouse-2 mean?

I'm entirely new with Emacs. I'm trying to split vertically my window, but I can't. Googling, I've discovered the commands to do it is C-Mouse-2. So I clicked Ctrl+scroll button+2 but it matched C-...
3
votes
3answers
134 views

Reading info files without knowing their path

If I'm in a terminal, I can just type info glibc and get info about glibc. Since emacs reads info files, it's silly to use M-x term to read info files from within emacs. I know you can use C-u C-h i ...
2
votes
1answer
386 views

Repeat regexp from isearc-forward-regexp on a subsequent replace-regexp?

I use C-M-s to search for a regexp. Then I use M-x replace-regexp to replace the same regexp with some string. Can I save typing the regexp for the second time? Generally, when typing an argument ...
0
votes
1answer
83 views

How to get the default input value in minibuffer and edit it?

For example, I am using M-x occur, and want to edit the default regexp (which is shown in the prompt), and then enter your edited regexp. can we edit the default value ^ *[[:digit:]]\.[[:digit:]]\.[[:...
1
vote
1answer
573 views

how to give optional arguments to commands

Looking at the documentation for shell-command (M-!) I see there are two optional arguments, OUTPUT-BUFFER, and ERROR-BUFFER. But when I type M-! it only asks me for the shell command. How do I ...
1
vote
2answers
882 views

Is there an equivalent of `M-x check-parens` for finding unmatches braces or ['s in any buffer (not a particular mode)

M-x check-parens finds unmatched parentheses in a buffer. I am wondering if there is a similar command which finds unmatched { or [.
2
votes
3answers
157 views

M-x command completions to all occurrences of a substring

If I do M-x insert TAB Emacs shows a list of possible completions like below Possible completions are: insert-abbrevs insert-anniversary-diary-entry insert-block-diary-entry insert-...
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 ...
7
votes
1answer
161 views

Getting the key binding for the current command

this-command-keys and this-command-keys-vector return the entire key sequence that fired the current command. However, such sequence will contain any prefix argument, too. Is there a function or ...
36
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 ...
3
votes
1answer
206 views

Bind C-e C-j and C-a C-o TAB to single key, aka insert and jump to newline

C-e C-j will insert a newline below and jump to it indented. C-a C-o TAB will insert a newline above and jump to it indented. Is there a single bind to these or where/how should I bind these commands?...
5
votes
2answers
265 views

Define an emacs function to take arguments in the same way as something like M-x goto-line

I want to write an emacs function for debug purposes in c++ code. Basically I'm fed up typing the following: std::cout << "variable is: " << variable << std::endl; Instead I want ...
4
votes
4answers
1k views

Repeating a command n times

For posting code to stackexchange I repeatedly have to do indentation in emacs. I mark a piece of text and then do M-X indent-rigidly four times. Is there an elegant way to do this indentation of text ...
2
votes
1answer
209 views

Is it possible to alias an internal command?

Since I discovered multi-term, I use it exclusively over term or eshell. But, I'm lazy and would prefer to be able to simply type term to activate multi-term. Is this possible?
8
votes
2answers
3k 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 ...
15
votes
2answers
619 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 ...