Questions tagged [interactive]

`interactive` spec of an Emacs-Lisp command (function invocable using `M-x` or a key binding)

Filter by
Sorted by
Tagged with
0 votes
1 answer
34 views

let* equivalent for interactive

I'd like to call a series of completing-read prompts via interactive, where every prompt after the first takes the previous result as its only argument. (defun make-prompt () (completing-read "...
treeblah's user avatar
  • 123
0 votes
1 answer
46 views

How can I pass arguments to a function called interactively?

Consider this: (defun kill-arg-words (arg) "kill `arg' words ahead of you" (interactive) (kill-region (point) (progn (forward-word arg) (point) ))) ...
user129393192's user avatar
0 votes
1 answer
61 views

Interactive call aware function test problem ( Wrong type argument: commandp ) [duplicate]

Below what the *Messages* buffer tells me: Loading init.el (source)... interactive-aware-fun called-interactively-p : nil command-execute: Wrong type argument: commandp, interactive-aware-fun and an ...
Claudio's user avatar
  • 420
0 votes
1 answer
105 views

How do I pass an optional argument to a command called programmatically?

I would like to call a certain command from Emacs Lisp. This function takes two arguments plus a third optional argument. This third argument, when non-nil, doesn't ask for confirmation. I would like ...
Pablo's user avatar
  • 184
0 votes
1 answer
27 views

How can I make a function that interactively passes a time to run-at-time?

I want to make a function that calls run-at-time while setting its repeat to nil. The only thing I want to be asked to supply is the duration after which run-at-time should call a function. Evaluating ...
Orixi's user avatar
  • 5
-1 votes
2 answers
32 views

interactively prompt for a list (or regex) rather than just a single item

I have a function to kill buffers matching a given regex: ;; Like kill-matching-buffers, but doesn't prompt every time. ;; TODO: get this to use vertico (defun kill-matching-buffers-just-do-it () &...
firstname gklsodascb's user avatar
0 votes
2 answers
46 views

Interactive function with two functions

Would like to have an interactive function that enables or disables two features (either auto-complete or company). Is this how I can use the interactive clause to pass two function arguments? I get ...
Dilna's user avatar
  • 1,183
0 votes
1 answer
98 views

How to call a interactive function with prompt from a lambda?

I have this little LaTeX helper function: (defun my--insert-chord (chord) "Prompt for a CHORD and insert it at point. TODO: make it agnostic to the package used." (interactive "...
Alessandro Bertulli's user avatar
0 votes
1 answer
80 views

Does any package exist that can make interactive emacs-style regular expressions more readable by using font-locking?

Ideally the package would allow one to display emacs-style regular expressions, as they are entered interactively during a search and replace command, in a more human-readable form. Perhaps fewer ...
StackExchanger's user avatar
0 votes
1 answer
68 views

Call an interactive elisp-function inside an YaSnippet

When trying to evaluate an interactive elisp-function which needs an argument in a yasnippet, it gives the error wrong number of arguments. I assume, the reason is, that the function is interactive ...
Sinthoras's user avatar
-3 votes
1 answer
28 views

Taking word at point interactively

I would like to adapt this function for the interactive case, that takes the word at point. (defun rules-tablet (word) "Shorten word at point according to specific rules." (interactive) ...
Dilna's user avatar
  • 1,183
0 votes
1 answer
21 views

Passing numeric value to a function

I have got the following function but want to pass a numeric mode even if completing-read asks for a string. (defun mycompany (mode) "Enables or disables company text completion in buffer."...
Dilna's user avatar
  • 1,183
0 votes
1 answer
71 views

Is it possible to get the line number of the nearest regex match above the current cursor position?

I'd like to write an elisp function that tells me the line number of the closest regex match above my current cursor position. For example, if my cursor is on line 9 of the following file and my regex ...
Brian Fitzpatrick's user avatar
0 votes
1 answer
42 views

Placing of list within interactive

I am making an interactive function and encountering a difficulty on the placing of the command list to set the function argument. This code (interactive (list (let ( (rqmatch t) (initpk &...
Dilna's user avatar
  • 1,183
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.
Dilna's user avatar
  • 1,183
0 votes
1 answer
30 views

Behaviour of Code Characters and Lists on Optional Arguments

Although the use of optional arguments to functions are easy to understand when running functions non-interactively. But things get complicated when declaring the function interactive, where you want ...
Dilna's user avatar
  • 1,183
0 votes
1 answer
60 views

Getting prefix as argument

With this function, I get the error test: Wrong type argument: stringp, 2 Is it good to pass prefix this way? Thought that the argument prefix would be filled up with the prefix value. (defun test (...
Dilna's user avatar
  • 1,183
1 vote
1 answer
927 views

Function arguments and interactive

I am having difficulty seeing how to properly use function arguments with the interactive command. Suppose I have a function with three arguments myfunc (arg1 &optional arg2 arg3), the last two ...
Dilna's user avatar
  • 1,183
0 votes
1 answer
41 views

Using function both as interactive command and in elisp code

I am trying to understand the use of the interactive and the intern commands so I can use a function both within an interactive context and an elisp context. Require some explanation of how intern is ...
Dilna's user avatar
  • 1,183
3 votes
1 answer
76 views

interactive function: Meaning of Does not do I/O

I'm going through the documentation for the interactive function and there are some code letters which are documented like this: d -- Value of point as number. Does not do I/O. P -- Prefix arg in raw ...
Sibi's user avatar
  • 3,623
2 votes
2 answers
262 views

Can there be two prefix arguments?

I am very confused by the definitions of define-skeleton and skeleton-proxy-new in skeleton.el in the emacs source (version 28.1). The command generated by the define-skeleton macro has the ...
q.undertow's user avatar
1 vote
1 answer
48 views

How to preselect initial text in the minibuffer with Elisp?

I'm using read-string to read a string from the minibuffer, with an initial input. How can I highlight the initial input, so that I can start replacing it with one key stroke? IOW, given (read-string &...
Arch Stanton's user avatar
  • 1,555
1 vote
1 answer
449 views

project.el: override project-find-regexp with use-package to show live results like project-find-file (preferably with consult)?

When switching projects, there's a few commands available off the bat that can be selected from the mini-buffer after selecting a project. [f] Find file [g] Find regexp [d] Find directory ... Both ...
ldeck's user avatar
  • 205
0 votes
2 answers
239 views

Pass default value to org-set-property

The documentation says: (org-set-property PROPERTY VALUE) When called interactively, this will prompt for a property name, offering completion on existing and default properties. And then it will ...
xeruf's user avatar
  • 324
1 vote
1 answer
66 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.
element's user avatar
  • 27
1 vote
1 answer
200 views

Interactive option for function with optional arguments

Am unsure whether making brcmk-end optional is possible for interactive use. If one can have optional arguments, what would be the changed necessary? Would the interactive expression change? (...
Dilna's user avatar
  • 1,183
1 vote
1 answer
48 views

Displaying character input with interactive declaration

I have the following code for reading two characters, using the interactive declaration. When I run the interactive function the input character is not being shown after the description string. (...
Dilna's user avatar
  • 1,183
0 votes
1 answer
49 views

Command that accepts a string and a selected region

Would like to have a function that selects a string (from a list or from a user-defined string, using the mini-buffer) and a selected region. User would input (), [], {} specifying the opening and ...
Dilna's user avatar
  • 1,183
1 vote
1 answer
79 views

How to use `projectile-multi-occur` to find a symbol at point?

I am trying to make projectile-multi-occur to work with the symbol at point. I have done that for occur already, this works: (defun occur-symbol-at-point () (interactive) (let ((sym (thing-at-...
Gauthier's user avatar
  • 499
1 vote
2 answers
286 views

Using defadvice to add an interactive argument to a non-interactive function?

Is there a way to wrap a non-interactive function within defadvice so that the new function can accept an interactive argument which can alter the way that the wrapped function gets called? In other ...
HippoMan's user avatar
  • 594
2 votes
2 answers
91 views

How to avoid the prompt in `revert-buffer` [duplicate]

I'm trying to get rid of the annoying prompt at the end of revert-buffer. This prompt would make sense in a lesser text editor where reverting the buffer is an irreversible action (pardon the pun). ...
Alex Petrosyan's user avatar
3 votes
1 answer
40 views

command print no results with (interactive "r")

Consider this test function (tested in emacs -q): (defun foo (start end) "for testing purposes" (interactive "r") (when (region-active-p) (cons start end))) ...
gigiair's user avatar
  • 2,134
1 vote
1 answer
214 views

How to pass a string argument to a function from global-set-key definition inside .emacs

Inside my .emacs file I have these two functions: (defun bh/switch-to-vs () (interactive) (universal-argument) (shell "*vs*")) (defun bh/switch-to-android () (interactive) (...
W.M.'s user avatar
  • 113
0 votes
2 answers
107 views

Pass arguments captured from minibuffer to shell command in a function

I'm struggling with passing arguments read from the minibuffer to a shell command in a elisp function. I've written the following so far: (defun perlclean (review clean) "Script PERL blablabla&...
Guillaume's user avatar
  • 189
1 vote
1 answer
1k views

Call an interactive function and pass argument to it in elisp without user input

I am new to elisp and am trying to write an Elisp function that calls org-pandoc-export-to-html5-pdf-and-open. org-pandoc-export-to-html5-pdf-and-open is an interactive function that will write to a ...
nonreligious's user avatar
0 votes
0 answers
256 views

Read multiples arguments for interactive function without sequential read functions

I have an interactive function taking 2 arguments. I can read them with (defun example-fct (arg1 arg2) "This function take two arguments" (interactive (let ((arg1 (read-string "...
Balaïtous's user avatar
0 votes
1 answer
55 views

How to prompt for function use be used within a function?

Consider the following example function (defun simple-function () (dotimes (counter 10) (input-function))) This requires input-function to be hard coded within the definition of simple-...
Tian's user avatar
  • 288
1 vote
1 answer
114 views

Is there an easy way to use thing-at-point to initialize interactive read string (interactive "sfoo:")

Is there an easy way to use thing-at-point to initialize the contents of an interactive string reading? I have a function the looks something like this: (defun foo (string) (interactive "...
intel_chris's user avatar
8 votes
1 answer
674 views

Default argument for interactive function?

Using (interactive "sPROMPT: ") one can set a prompt for, e.g., a string function. Question: Is it possible to also supplement a default argument to the function? Say (interactive "...
George's user avatar
  • 879
0 votes
2 answers
469 views

copy string at point func

I'm trying to build a simple proc that copies the text on which the point is set and returns the point to where it was, but can't make it work properly. Before you say "thing-at-point" - I ...
user2141046's user avatar
0 votes
1 answer
118 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) ...
Youjun Hu's user avatar
  • 121
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 ...
cammil's user avatar
  • 509
2 votes
1 answer
271 views

How do I make C-x b (switch-to-buffer) ignore some buffers?

I want C-x b (i.e. switch-to-buffer) to ignore some buffers. For example, I want to ignore *Ibuffer*. In other words, when I press C-x b, I should not see Switch to buffer (default *Ibuffer*): . *...
Flux's user avatar
  • 593
1 vote
0 answers
224 views

How to override a value inside a function temporarily?

There is this function in tide: ;; Defined in ~/.emacs.d/.local/straight/repos/tide/tide.el (defun tide-rename-file () "Rename current file and all it's references in other files." (...
Jose V's user avatar
  • 141
1 vote
1 answer
89 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) ...
user2567544's user avatar
5 votes
1 answer
266 views

Combine two interactive functions

For example, I want to sort a file, then remove the duplicate lines. I run M-x sort followed by M-x delete-duplicate-lines. I wanted to combine them into a single interactive function. Here is an ...
nomad's user avatar
  • 247
1 vote
1 answer
390 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, ...
user avatar
0 votes
1 answer
304 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 ...
breathe_in_breathe_out's user avatar
1 vote
1 answer
60 views

How to disable "/" 's default behavior on the F interactive mode?

I use interactive mode with Ivy and Dired for interactively creating new files, like so: (evil-local-set-key 'normal (kbd "t") (lambda (file) (...
resolritter's user avatar
0 votes
1 answer
532 views

How to call an interactive function and pass arguments to it from within Elisp?

I'm trying to compose a link to the describe-package help buffer to the xref package like this: [[(elisp:(describe-package "xref"))][xref]] But it can't execute. So I wonder how to pass ...
Joseph Tesfaye's user avatar