1

current-prefix-arg's help doc says, the variable can contain a list (or) number (or) minus symbol. I mostly set a number as the prefix-arg by keypress, C-[1-9]. But how can i assign a list or string to current-prefix-arg? I ask this, since isearch-forward

(defun isearch-forward (&optional regexp-p no-recursive-edit)
  (interactive "P/np")
  (........))

takes the search string through interactive key "P" but i am having zero clue on how to set a string to this prefix-arg?

  • 1
    isearch-forward does not take a string. It's just a command that starts the search or makes isearch jump to the next occurrence. – wasamasa Mar 4 '15 at 7:14
  • current-prefix-arg corresponds to 'C-u', not the search string itself. – Lindydancer Mar 4 '15 at 9:38
  • 2
    The name regexp-p indicates that it's a boolean value, in this case it's probably about whether the search is involving regex or not. Same applies to the other argument. I don't know how it obtains the search string, but be assured, it's lots of advanced magic judging by the docstrings. – wasamasa Mar 4 '15 at 12:11
  • 1
    The minibuffer is not used for Isearch (except when you use M-e to edit the search string. Instead, each key you hit invokes a command (as usual), and for most self-inserting keys the command appends the key's character to the search string (and then searches for the updated string). – Drew Mar 5 '15 at 2:02
  • 2
    In Emacs, in general, each key you hit invokes a command. In Isearch, (speaking generally) the keys that normally invoke the command self-insert-command instead cause the Isearch code to append the character to the search string and then update the search based on the updated string. – Drew Mar 5 '15 at 4:02
1

You can assign a list with C-u, but not possible to assign a string.

current-prefix-arg's help doc says (at least in Emacs 24):

It may be a number, or the symbol `-' for just a minus sign as arg, or a list whose car is a number for just one or more C-u's or nil if no argument has been specified.

That is, a) it is not a general list nor Sequence, of which String is a member, b) the list is generated by a C-u or more of.

You can see the list generated by C-u with the following command, which is taken from Prefix Command Arguments in the GNU Emacs Lisp Reference Manual.

(defun display-prefix (arg)
  "Display the value of the raw prefix arg."
  (interactive "P")
  (message "%s" arg))

C-u M-x display-prefix shows a list whose value is (4) in the minibuffer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.