开发者

How to I remap the Emacs command M-d into the macro M-b, M-d?

开发者 https://www.devze.com 2022-12-31 03:16 出处:网络
I would like the \"delete to end of word\" command to delete the word, regardless of 开发者_高级运维cursor position. (defun my-kill-word ()

I would like the "delete to end of word" command to delete the word, regardless of 开发者_高级运维cursor position.


(defun my-kill-word ()
  (interactive)
  (backward-word)
  (kill-word 1))

(global-set-key (kbd "M-d") 'my-kill-word)


A better code could be:

(defun my-kill-word ()
   (interactive)
   (unless (looking-at "\\<")
     (backward-word))
   (kill-word 1))

(global-set-key (kbd "M-d") 'my-kill-word)

So we move backward only if we are not at the beginning of the word yet.

0

精彩评论

暂无评论...
验证码 换一张
取 消