Questions tagged [interactive]

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

Emacs-Lisp functions are made interactive (i.e., commands, which are invocable usingM-x or a key binding) by placing an interactive spec (a special form) in the function definition. The spec provides the actual arguments to the command. The argument to the spec is either a literal string with predefined codes) or a sexp that is evaluated to return the list of actual arguments.

147 questions
10
votes
1 answer

ielm, bound to a certain buffer

Is there a way to run ielm, but with variables bound to a certain buffer? I know about M-:, but having a shell like ielm to inspect things would be much easier.
ustun
  • 203
  • 1
  • 5
8
votes
1 answer

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 "sPROMPT: default") so that the users can supply "default" as the…
George
  • 919
  • 5
  • 17
4
votes
4 answers

How can I determine which function was called interactively in the stack?

Say I have two functions (defun tmp:a () (interactive) (tmp:b)) (defun tmp:b () (message "called from %S" "?")) If I call M-x tmp:a, how can I determine this from tmp:b?
Sean Allred
  • 6,921
  • 18
  • 86
4
votes
2 answers

Can an emacs command tell if it was called via key binding or via M-x command-name?

Is there a way to program some Emacs command in elisp that could tell whether it is called interactively through some key binding or by typing its full name after M-x? I thought this could be done using called-interactively-p but it seems that it…
phs
  • 1,227
  • 7
  • 13
4
votes
1 answer

Partial input to interactive command

Let's say I want to provide partial input to an interactive function such as insert-char. For example, I might want to have a command that automatically starts typing GREEK SMALL LETTER or BOX DRAWINGS. This does not work, because call-interactively…
Matthew Piziak
  • 6,038
  • 3
  • 31
  • 79
3
votes
1 answer

Can I make a function non-interactive after it's been defined?

I'm defining a minor-mode not meant to be interactively activated. I'd like to use define-minor-mode because it's very convenient, but the downside is that it always sets the mode function as interactive. Is there a way to make an already-defined…
Malabarba
  • 23,148
  • 6
  • 79
  • 164
1
vote
2 answers

Prompt for user input flexibly with interactive

I have a function that uses smartparens to replace specified pairs of parentheses. (defun replace-paren-at-point (paren) (interactive "sReplace with: ") (if (looking-at "[「『《〈(〔【]") (progn (set-mark-command nil) (forward-sexp) …
Sati
  • 775
  • 6
  • 23
1
vote
1 answer

setting font-height interactively

I thought it would be handy to be able to change the font height of a buffer on the fly by invoking a key press and giving the font height you would want, e.g. C-t 130 would set the local buffer font size to 130. I've been able to write a function…
0
votes
1 answer

Interactive input, strings and quoted items

(defun ecli-metadata-single (ecli meta) "meta needs to be quotes \n example: (case-metadata ECLI:NL:HR:2013:BY6108 'identifier)" (interactive "sEnter ecli: \nxEnter identifier: ") (insert (car (cddr (assoc meta (ecli-metadata-full ecli))))) …
coenttb
  • 3
  • 1
0
votes
1 answer

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) ))) I want to call it as M-x kill-arg-words 5 ,…
0
votes
2 answers

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 confused because customarily, let returns only…
Dilna
  • 1
  • 3
  • 11
0
votes
1 answer

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 "mixed") (dflt "extended") (cseq…
Dilna
  • 1
  • 3
  • 11
0
votes
1 answer

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 arguments to an interactive function from within Elisp. I…
Joseph Tesfaye
  • 419
  • 3
  • 13
0
votes
1 answer

Trying to use `pdfgrep` program from within my command

I want to be asked what string %s I want [0] pdfgrep to search for? While M-x pdfgrep mysearchString works, I'm somehow missing something on wrapping it up as sole function? (require 'pdfgrep) (pdfgrep-mode) (defun myPdfSearch () (interactive) …
jjk
  • 734
  • 4
  • 18
0
votes
1 answer

Prompt for command to reset variable to 1 or any other number

I have a command that semi-automates the insertion of numbered chapter headings in an org-mode file. (defun reset-counter () (interactive) (setq n 1)) (defun insert-numbered-chapter-headings () "Insert **** 第x章 at cursor point." …
Sati
  • 775
  • 6
  • 23
1
2