Tôi không nghĩ rằng bạn có thể cấu hình Emacs để nó nào đó cho tất cả các lệnh. Tuy nhiên, bạn có thể thực hiện chức năng này trong chính các lệnh. Đây là những gì được thực hiện cho C-x e. Dưới đây là một macro tôi chỉ viết (hướng dẫn bởi độ nét tiêu chuẩn của kmacro-call-macro
trong GNU Emacs 23.1.1) mà làm cho nó dễ dàng để thêm chức năng này vào các lệnh của riêng bạn:
(defmacro with-easy-repeat (&rest body)
"Execute BODY and repeat while the user presses the last key."
(declare (indent 0))
`(let* ((repeat-key (and (> (length (this-single-command-keys)) 1)
last-input-event))
(repeat-key-str (format-kbd-macro (vector repeat-key) nil)))
,@body
(while repeat-key
(message "(Type %s to repeat)" repeat-key-str)
(let ((event (read-event)))
(clear-this-command-keys t)
(if (equal event repeat-key)
(progn ,@body
(setq last-input-event nil))
(setq repeat-key nil)
(push last-input-event unread-command-events))))))
Đây là cách bạn sử dụng nó:
(defun hello-world()
(interactive)
(with-easy-repeat
(insert "Hello, World!\n")))
(global-set-key (kbd "C-c x y z") 'hello-world)
Bây giờ bạn có thể gõ Cc xyzzz để chèn Hello, World!
ba lần.
Nguồn
2011-09-26 19:43:12
Hoạt động hoàn hảo. Cảm ơn bạn! – TheEzEzz
Xem thêm gói 'lặp lại 'của Emacs. –
@event_jr Đẹp !! Cảm ơn vì tiền hỗ trợ. –