As I asked here, I can choose the lisp for running SLIME with prefix argument(C-u), and I is written in here, I see that C-u is a way to insert the output in the current buffer.
I use 'C-u 10 SOMETHING', in order to run SOMETHING 10 times.
What's the usage/purpose of using prefix argument (C-u)? Is C-u the only prefix argument?
A command prefix is a prefix of a command (in the sense of rule 2 of the dodekalogue, i.e., a sequence of words) that is constructed with the expectation that zero or more arguments will be appended to it and that the resulting command will be evaluated.
Like all other commands in Emacs, these commands can be given arguments which cause them to be executed repeatedly. The way you give a command a repeat count is by typing C-u and then the digits before you type the command.
Also bear in mind that C-u as a prefix on its own defaults to passing '(4) as the argument, and each C-u that you insert before the command multiplies this by 4.
Thus you can write a quick way of having a few simply choices that are selected between by using ctrl-u prefixes, for example:
(defun insert-date (prefix)
"Insert the current date. With prefix-argument, use ISO format. With
two prefix arguments, write out the day and month name."
(interactive "P")
(let ((format (cond
((not prefix) "%A, %d %B %Y %H:%M %Z" )
((equal prefix '(4)) "%d/%m/%Y %H:%M")
((equal prefix '(16)) "%d/%m/%Y")
((equal prefix '(64)) "%H:%M:%S")
))
(system-time-locale "en_GB"))
(insert (format-time-string format))))
(global-set-key (kbd "C-c d") 'insert-date)
(The above elisp produces a function that inserts a long format date on the key (in this case C-c d), the date + time in short format on C-u C-c d, the short format date on C-u C-u C-c d, and the short format time on C-u C-u C-u C-c d)
You could use this trick to make a 'start-slime' replacement that used clojure by default, but sbcl if you press C-u before the key binding.
Check out the documentation for prefix command arguments.
But, in short, it's a way to interactively provide more information to the command.
'self-insert
, it tells them how many of that character to insert'isearch-forward-regexp
instead of a regular 'isearch-forward
.So, it all depends on how the command uses the prefix argument.
As far as other "prefix arguments", there are C--, M--, M-3 (or any other digit), and some others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With