2017-05-06 28 views
1

對於內置在像nextline命令,我可以通過鍵入C-u n M-x next-line重複n倍。然而,對於以下用戶定義的命令:爲什麼我不能重複這個用戶定義的函數?

(defun smsn-set-priority-public-and-drop-cursor() 
    (interactive) 
    (progn 
    (move-end-of-line 1) 
    (insert (concat "\n    @priority 0.75\n")) 
    (kill-line) 
    )) 

,如果我嘗試C-u 4 smsn-set-priority-public-and-drop-cursor,它只會發生一次。爲什麼?

回答

1

C-u n沒有指定重複次數,但一個數字前綴的說法。這個參數如何改變命令的行爲取決於該命令的定義。

你的命令忽略任何前綴的說法完全,這就是爲什麼C-×4沒有任何作用。

下面是該地重複給出一個前綴的示例命令:

(defun test (arg) 
    (interactive "p") 
    (while (plusp arg) 
    (insert "zonk") 
    (setq arg (1- arg)))) 

C-u自身給出了4的前綴值,順便說一下,並擁有其他一些巧妙的技巧 - 見C-u文檔字符串。 )

+0

參見'章˚Fdotimes'。 – Drew

相關問題