How to convert the Emacs Md command to the Mb, Md macro?

I want the delete to end of word command to delete the word, regardless of the cursor position.

+3
source share
2 answers
(defun my-kill-word ()
  (interactive)
  (backward-word)
  (kill-word 1))

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

The best 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 back only if we are not at the beginning of the word though.

+1
source

Source: https://habr.com/ru/post/1746272/


All Articles