Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elisp: How do you combine interactive "r" with interactive "p"?

Tags:

emacs

elisp

I have an existing command (increment-numbers-in-region) which is declared using interactive "r" to get region start and end points as arguments. I would now like to extend this command to take a prefix argument as well. Is there a way to combine interactive "r" with interactive "p" or should I go about it in some other way?

I guess I could write a command which uses interactive "p" only, and then read point and mark from the command body, but it feels like that might not be the most idiomatic way.

Any ideas?

like image 399
Erik Öjebo Avatar asked Apr 07 '13 08:04

Erik Öjebo


1 Answers

C-hf interactive RET

"To get several arguments, concatenate the individual strings, separating them by newline characters."

(defun increment-numbers-in-region (start end arg)
  (interactive "r\np")
  ...)
like image 131
phils Avatar answered Oct 26 '22 13:10

phils