开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜