Questions tagged [commands]
Commands are functions that can be invoked interactively either through `M-x` or by a key binding.
168
questions
0
votes
0
answers
22
views
How to implement a looped/repeated command until pressing exit
I have a question how to implement looped commands, which should repeat arbitrary many times until pressing exit (esc).
Let's say I want to define a function executing
avy-kill-whole-line or avy-kill-...
0
votes
1
answer
48
views
Define command that executes several functions
I apologize for this question, for which I know an elementary answer exists that I can't find for the life of me. I would simply like to define a command that executes several functions sequentially. ...
2
votes
2
answers
55
views
Make "M-x repeat" Ignore Movement Commands
Is there a standard way to make M-x repeat ignore movement commands or does it require custom elisp?
I read a [Mastering Emacs blog post about repeating commands][1] and immediately started using &...
2
votes
1
answer
59
views
When does Emacs enter command loop?
I'm reading (info "(elisp) Command Overview"):
Variable: post-command-hook
: ... ...
: This hook is also run when Emacs first enters the command loop (at which point this-command and last-...
0
votes
1
answer
62
views
Command that does absolutely nothing
Is there an Emacs command that does absolutely nothing ?
1
vote
1
answer
58
views
`completion` In Declare Form Not Working
Why is this function:
(defun shyn/func ()
(declare (completion (lambda (symbol current-buffer)
nil)))
(interactive))
still listed by pressing M-x TAB in buffer *scratch*?
...
1
vote
0
answers
64
views
Effect of `modes` In Declare Form [duplicate]
13.14 The declare Form:
(modes MODES)
Specify that this command is meant to be applicable for MODES only.
What is the practical effect of (modes ...) in declare form?
I find that I can still call ...
0
votes
1
answer
128
views
Which GNU Emacs command resizes visible windows to equal sizes?
tmux has ctrl b, shift e, to equalize pane sizes.
Does GNU emacs have similar to equalize window sizes?
3
votes
2
answers
67
views
How can I toggle between two functions in Elisp?
I would like to use the F9 key to toggle between the modus-themes-select and ef-themes-select functions. When I call the ef-themes-select, a minibuffer pops up to select an Ef theme:
Now when I press ...
0
votes
1
answer
51
views
How can I get the Msys2 CLI to recognise the emacs ctrl + h key chord?
OK, I hope this is in the right department because I think although this is a problem with using emacs it may be the console window settings causing the problem.
In emacs in most console or GUI ...
1
vote
1
answer
33
views
When a merge-conflict happens and two options are shown, what is the magit command that allows the user to easily pick one of them?
Suppose a merge conflict happens. There are two options shown the upper (in red) and the lower (in green):
I would like to avoid complex ediff-mode stuff to pick one. I have seen some tutorial where ...
1
vote
2
answers
116
views
How to find Emacs Lisp Org Mode functions
How can I find Org Mode emacs lisp functions like org-current-level which is used in the answer for Org subtree from yasnippet?
I looked for the command in the Org Mode Manual but didn't find it there....
2
votes
2
answers
97
views
How to prevent `M-<digit>` from invoking `digit-argument`?
In Windows, it is possible to type the Alt key together with some number to obtain the character associated to that number.
This is useful when your keyboard is not properly mapped or is missing that ...
1
vote
4
answers
85
views
how to define keyboard macro from text
I am using shell inside Emacs. Often I need to execute a series of shell commands around ~40 chars, as of now I copy all the commands together and paste it from documentation. Is there any way to ...
1
vote
1
answer
42
views
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 ...
1
vote
2
answers
69
views
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 ...
1
vote
1
answer
24
views
How to pass the prefix argument using a list in the `interactive` clause of a command definition?
How can I use prefix argument with list in the interactive clause? It is the more general way instead of Code Characters.
0
votes
1
answer
199
views
To remove characters in the beginnings of lines
To add // in the beginnings of multiple lines I can use either string-insert-rectangle or string-rectangle (C-x r t).
But how is it possible to remove these characters instead?
This question is not ...
1
vote
0
answers
90
views
How can I temporarily disable all (other) key bindings?
How can I write a command, and bind it to a key, so that when invoked it disables all key bindings other than the current key, until that same key binding is pressed again?
The goal is to facilitate ...
1
vote
1
answer
77
views
What makes an elisp function available with M-x [duplicate]
Why some functions in simple.el are invokable with M-x and some others aren't?
For example I can do M-x what-line but I can't do M-x line-number-at-pos.
2
votes
1
answer
173
views
Why is ivy-switch-buffer not found in counsel-M-x, but works when called by C-x b (or from the scratch buffer)
According to helpful-key, C-x b is bound to ivy switch buffer:
According to the code, that is an interactive function. However, when I look for it in the Counsel-M-x menu, it's not found:
I figured ...
1
vote
1
answer
57
views
Hide a command from user
Is there a way to hide a command from user?
Or, in other words, is there a way to undo an interactive spec?
Background:
I have a derived mode, which is used in a special buffer as the buffer's mode. ...
1
vote
1
answer
76
views
How to write a Lisp representation of a keyboard macro and bind it to a command name?
I'm using spacemacs with vim-bindings, but I only mention it so you
don't scratch your head too long at the keystrokes of the macro. A
regular emacs solution will work just the same.
I've read through ...
1
vote
1
answer
50
views
Why does `C-h b` show `??` as the command name for my key binding?
I've just added a nice custom key binding:
;; Open files in dired mode using 'open'
(eval-after-load "dired"
'(progn
(define-key dired-mode-map (kbd "z")
(lambda () (...
0
votes
1
answer
51
views
How to define a command to switch to the current candidate buffer in Ido?
I'm trying to write a command that I would call while using ido-switch-buffer or ido-kill-buffer to open the current candidate in another window. Ideally it would be able to open virtual buffers as ...
1
vote
1
answer
537
views
How can I apply ansi-color to complete buffer?
I am using following code to apply colorize text in emacs, such as for ^[ characters to apply color. In order to use this code I have to select text to apply it
reference: https://unix.stackexchange....
0
votes
1
answer
342
views
Error /bin/bash: line 1: nil: command not found
I have the following code to auto format python code using autopep8:
(defcustom python-autopep8-path (executable-find "autopep8")
"autopep8 executable path."
:group 'python
:...
2
votes
1
answer
256
views
How to move from one source block to another, in Org-mode?
Is there a key-binding, command, or even evil extension for Emacs, so that I can move from one source block to another?
For example,org-forward-heading-same-level, which is bound in my system to C-j, ...
3
votes
1
answer
139
views
Keymap that is dependent on the buffer
I want to create a "toggle shell" shortcut with F1 such that it will run shell when I'm in any other buffer, but will call mode-line-other-buffer when I'm in the shell buffer. What is an ...
0
votes
1
answer
143
views
How to know (in Elisp) what buffer was current when a command is invoked?
I want to give an arbitrary command some buffer-local
behavior without advising it. (I can do it by advising, but I want to also be able to do it without
advising.)
E.g., just looking at some ...
0
votes
0
answers
13
views
How to create commands to search specific kinds of files using `helm-projectile`?
I want to be able to search python, typescript, and markdown files separely with helm-projectile. Is there a way to create distinct keybindings to search the contents of files with each extension.
...
1
vote
1
answer
99
views
How to check if point moved or is on a different line in a buffer since the last user command?
I would like to make a snippet of code that only executes if the point is on a different line in a particular buffer since the last user command. The only way I could think to do it was using the post-...
0
votes
1
answer
48
views
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 (...
0
votes
1
answer
132
views
How to modify interactive function `occur` to a non-interactive function
occur is an interactive compiled Lisp function in ‘replace.el’.
The definition is as follows:
(defun occur (regexp &optional nlines region)
(interactive
(nconc (occur-read-primary-args)
...
1
vote
3
answers
1k
views
(load-theme) at the bottom of .emacs, or manually renders a different screen
Adding this line at the very end of the .emacs file, that loads a default theme coming with the Emacs package,
(load-theme 'tsdh-dark)
the (main) screen looks like
Note the black-on-dark text, the ...
1
vote
0
answers
13
views
How to write an interactive function which repeats when the last key in the keybinding is repeatedly pressed? [duplicate]
I want to repeat a function when the last key in the key binding is repeatedly pressed.
For example, say the keybinding is C-n for next-line, what I want to happen is that next-line is repeated when I ...
0
votes
0
answers
21
views
how to insert leaders with periods around dot?
(This is not about org-mode.)
Assume point is between "left" and "right" below
left right
Is there a command that will change that to, for example,
left . . . right
...
1
vote
1
answer
198
views
Why ivy-immediate-done is not shown in counsel-M-x
I realize that ivy-immediate-done is not shown in counsel-M-x. Since it's an interactive command, I'm assuming counsel-M-x somehow filters it from its result. But a quick search of the function name ...
1
vote
2
answers
86
views
Are commands not equivalent to functions in Emacs? [duplicate]
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 <execute>, <...
1
vote
1
answer
97
views
How to script a bookmark-jump call
I am trying to write a function which will perform a bookmark-jump but then reset the the bookmark line to the top of the screen. So far I have:
(defun foo ()
(interactive)
(bookmark-jump)
...
0
votes
0
answers
616
views
A command to get buffer content centered in the window
I'm looking for the built-in command, probably a minor mode, that got my text unstuck from the left border of the window and showed more or less horizontally centered.
The command doesn't modify the ...
4
votes
2
answers
225
views
Display summary information on command when running Meta-x
Since I'm new to GNU Emacs (version 26.1 running on Debian Stable) I'd like to get some information when invoking a command using Meta-x. Currently I'm only able to see a list of possible completions ...
0
votes
1
answer
639
views
View a history of commands
While in web-mode, when I type {{ emacs will add }} to the end, and when I press SPC it will then add another }} to the end with a space either side and one extra space to the right, so it looks like ...
1
vote
2
answers
602
views
Efficiently calling multiple variants of the grep command
The context
I commonly execute the following variants of the grep command
grep --color -RHIn '' (search in the current working directory)
grep --color -RHIn --include='*.org' '' ~/repos/dotfiles/...
1
vote
1
answer
412
views
Break key as a shortcut -- what am I doing wrong?
I would like to define a keyboard shortcut in my .emacs file so that the Break (a.k.a. Pause) key does a C-x C-s C-x C-c. As a warmup, I thought I would try something simpler, so as a test I did this, ...
6
votes
1
answer
624
views
How to change the default transient level temporarily? ("Show hidden magit commands")
Many commands that are rarely used in magit are hidden by default. Magit uses the transient.el library for popups and the visibility of infix and suffix commands are controlled by transient-default-...
0
votes
1
answer
333
views
Switch to *scratch* buffer (global-set-key)
I am reading the Intro to Lisp Programing and got to the chapter where switch-to-buffer is introduced.
I tried to bind (switch-to-buffer "*scratch*") via global-set-key
But this does not ...
0
votes
1
answer
108
views
Asterisk in interactive specification
Just when is it appropriate to put the asterisk * into the interactive spec of a command function? The elisp manual says the effect is to cause an error if the command is attempted in a read only ...
5
votes
2
answers
364
views
Display keybindings typed in a buffer
On this video stream, the window on right displays the keybindings typed with its corresponding command bound.
Is there any package that does that, or a way to achieve it?
0
votes
2
answers
204
views
Interactive function to convert Windows path to POSIX path
Here at 'dayjob I'm often sent paths from developers using Windows in Windows format:
D:\Some\Path
These paths can uniformly be converted to paths valid on at least some Linux machines at 'dayjob ...