Questions tagged [commands]

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

170 questions
13
votes
1 answer

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 which would call it. The following fails: (defun…
Pradhan
  • 2,370
  • 15
  • 28
8
votes
1 answer

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?
Brian Fitzpatrick
  • 2,325
  • 1
  • 20
  • 42
6
votes
2 answers

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 in a buffer of emacs and then running the program…
Tim
  • 5,007
  • 7
  • 32
  • 61
5
votes
2 answers

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 information lost?
Vass
  • 723
  • 1
  • 5
  • 13
4
votes
1 answer

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 short amount of time, an alternative command is invoke…
shackra
  • 2,782
  • 19
  • 49
4
votes
1 answer

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 open-file but it doesn't work. I've tried Googling…
Josh Pinto
  • 623
  • 10
  • 20
3
votes
1 answer

How to specify a command that should be called by #'repeat?

I want to create a command that, when you call it for the first time, it's executed normally, but when you repeat it with C-x z, some other command is executed and the original command is never called. I tried defining it like that (I want…
mkcms
  • 1,370
  • 12
  • 13
3
votes
1 answer

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.
falematte
  • 423
  • 2
  • 16
2
votes
1 answer

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 supply a value for OUTPUT-BUFFER and ERROR-BUFFER?
clarkep
  • 133
  • 3
2
votes
1 answer

How to create a command that runs all of those functions on the current buffer?

I'm a total noob so be patient with me. I wrote a piece of elisp code that reads a .csv file (FILE.CSV) on which every line has the format Key, Value It composes a mail using the keys and values in this CSV file. When reading from the file…
jajpater
  • 323
  • 1
  • 9
1
vote
1 answer

Creating shortcut key for repetitive work

I create short text files in a folder c:/Dropbox/daily/ and insert them in various documents using shortcut C-x i. I would like to define a shortcut so that I don't have to type the path of folder again and again while allowing me to choose the…
Vaibhav
  • 583
  • 3
  • 16
1
vote
2 answers

Simple and fast way to show interactive functions associated with a package

I am using M-x protoc to show me the interactive functions provided by the package protoc. Is it possible to have a shortcut for displaying protoc related functions without having to write protoc TAB after calling M-x? For instance, the following…
Dilna
  • 1
  • 3
  • 11
1
vote
2 answers

Are commands not equivalent to functions in Emacs?

The documentation for M-x says: M-x runs the command execute-extended-command (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’. It is bound to , , M-x. (execute-extended-command PREFIXARG…
herophant
  • 223
  • 1
  • 8
0
votes
1 answer

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:]]\.[[:digit:]] + to create a new input e.g. deleting +…
Tim
  • 5,007
  • 7
  • 32
  • 61
0
votes
1 answer

How to append some behavior to a command?

How do I string together functions and actions in a key binding. Say I want to make a binding that does comment-dwim and then appends "TODO: " to achieve /* TODO: */ in C. (global-set-key (kbd "C-c T") 'comment-dwim "TODO: ") This doesn't work…
mcp
  • 546
  • 3
  • 15
1
2