默认通用参数emacs(C-u)

时间:2016-10-13 14:48:31

标签: emacs

如果按C-u C-n,光标会下降4行。 我可以将默认通用参数设为另一个大于4的数字吗?

1 个答案:

答案 0 :(得分:2)

可能有更好的方法可以做到这一点,但有一种可能性是创建自己的通用参数前缀函数。这是原始函数(如您所见,4在函数中是硬编码的):

(defun universal-argument ()
  "Begin a numeric argument for the following command.
Digits or minus sign following \\[universal-argument] make up the numeric argument.
\\[universal-argument] following the digits or minus sign ends the argument.
\\[universal-argument] without digits or minus sign provides 4 as argument.
Repeating \\[universal-argument] without digits or minus sign
 multiplies the argument by 4 each time.
For some commands, just \\[universal-argument] by itself serves as a flag
which is different in effect from any particular numeric argument.
These commands include \\[set-mark-command] and \\[start-kbd-macro]."
  (interactive)
  (setq prefix-arg (list 4))
  (universal-argument--mode))

在您的init文件中,您可以创建自己的自定义版本,并将其绑定到C-u

(defun my-universal-argument ()
  (interactive)
  (setq prefix-arg (list 10))
  (universal-argument--mode))

(global-set-key (kbd "C-u") 'my-universal-argument)

但是,请参阅下面的 @Drew 评论,了解为什么这可能不是一个好主意,可能会产生意外/意外后果。

此外,请记住,您可以多次按C-u作为前缀参数,将重复次数乘以4.例如,使用原始默认值4C-u C-u C-n将向下移动16(4 * 4)行,依此类推。