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
0answers
275 views

How do I define a function in my init.el and make it available with M-x? [duplicate]

I have the following function, which does what it says on the tin -- swaps the values of the ns-alternate-modifier and ns-right-alternate-modifier variables. (defun swap-left-and-right-alt () "Swap ...
-1
votes
1answer
163 views

how to get region start and region end from the whole buffer as variables to call another func

(defun buffer-to-shell() (let (buffer mark-whole-buffer))) (shell-command-on-region start end "sed s/foo/bar/") ;; start, end not defined ) As you might see there are undefined variables start ...
2
votes
1answer
56 views

repeat string-inflection command

I would like to repeat M-x string-inflection-camelcase on several words. For example in: foo_bar baz qux-quux quuz CORGE_GRAULT GARPLY I place my cursor on foo_bar and then enter M-x string-...
0
votes
1answer
129 views

How to `transpose-chars' backwards

I'm trying to make a trivial function that simply transposes chars backwards. This is what I got so far: (defun jd:backward-transpose-chars () (interactive) (transpose-chars -1)) (define-key ...
0
votes
1answer
474 views

insert a single character

My goal Write code in my init.el file so that from now on, M-v will just print the BELL character (character number 27 in hexadecimal) instead of scrolling down as it does by default. My failed ...
1
vote
2answers
2k 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 [.
0
votes
3answers
1k views

How show minibuffer's history of commands

windows 10, Emacs 25.1, Helm I open buffer scratch and execute 3 commands sequence: M-x I-search helm-occur replace-string here sreenshots: Nice. It's work fine. But now I want to show in list ...
2
votes
1answer
58 views

Emacs execute keymap entry

Emacs defines a fair variety of objects that can be bound to keys, with e.g. global-set-key. (The canonical list can be found here). I would like to simulate the invocation of a keymap entry. For ...
0
votes
0answers
38 views

dig.el broken when invoking with type? How to fix?

Running emacs 26.1 on window using bind tools x64 9.13. When I M-x dig heise.de MX it seems the question gets mangled: ; <<>> DiG 9.13.0 <<>> heise.de MX ;; global options: +...
2
votes
2answers
717 views

How can I pass the NO-LINE-BREAK argument to base64-encode-region in M-x?

I'm editing YAML files where I have to frequently encode and decode base64 values in a buffer. base64-encode-region and base64-decode-region are perfect for this, but very long strings get encoded as ...
2
votes
1answer
313 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 ...
2
votes
2answers
530 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
1answer
136 views

Execute shell command and then some text into document

I have a python script ss.py that gets a screenshot from a connected device and puts into particular dir. From terminal I run it with the target path as an arg: $ python ss.py {document-name}/{image-...
0
votes
1answer
41 views

How to find all active bindings which act on a region?

As explained https://emacs.stackexchange.com/a/733/ C-h b lists all bindings available in a buffer. Is there a way to list all bindings which act on a region? For example C-w (kill-region) is one of ...
6
votes
3answers
2k views

lazy find/search for commands within emacs

Is there a way to do a lazy find/search within EMACS, for commands using their description? Something in the lines of: Say I am looking for how to add indent to org mode I suspect there is a ...
3
votes
1answer
245 views

Call function interactively and set initial content

I would like to call a function (find-file) interactively and then set the initial content of the mini buffer to my server's home folder. I got as far as using call-interactively, but after that I'm ...
1
vote
1answer
82 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 `(...
2
votes
0answers
535 views

Interactive lambda functions [closed]

How do I create interactive lambda functions? (use-package general :ensure t :config (general-evil-setup t) ;;(setq general-default-keymaps 'evil-normal-state-map) (general-define-key :...
3
votes
1answer
64 views

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....
0
votes
1answer
582 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 ...
4
votes
2answers
280 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-...
0
votes
1answer
84 views

how to fixup line breaks?

I'm looking for a command that behaves similiar to fixup-whitespace, but I want it to also remove line breaks between objects around point.
2
votes
1answer
337 views

How to use unread-command-events variable?

I want to generate some input from my command programmatically. I have tried using unread-command-events variable for that, see: (defun unread_test () "Repeat input after toggling input method" (...
39
votes
1answer
3k 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 ...
2
votes
1answer
46 views

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 ...
-1
votes
1answer
82 views

Emacs Lisp Error when called as command but works well when called as function

https://github.com/Cheatinikle/Spacemacs-settings/blob/master/emacs-package/preetest-mode.el This is my full source code, and 'just-utils package is also included in the repository. The problem is, ...
0
votes
0answers
222 views

How to change the command for comment toggling

spacemacs with Evil uses gcc to toggle whether a line is commented or not. I'd like to change it to ,cc. How should I go about this in my .spacemacs file?
1
vote
1answer
173 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
2answers
131 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 ...
16
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
172 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 ...
0
votes
1answer
297 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?
1
vote
3answers
112 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
119 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
60 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
331 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
81 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
1k 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 ...
9
votes
4answers
5k 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 ...
5
votes
2answers
711 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 ...
8
votes
3answers
213 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 ...
2
votes
1answer
78 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
271 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
60 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.
3
votes
1answer
390 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
3answers
712 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 ...
4
votes
1answer
217 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
807 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?
4
votes
1answer
2k 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
2k 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 ...