Emacsにはデフォルトでkill-word
(M-dにバインド)やbackward-kill-word
(M-backspaceにバインド)がある。削除系コマンドとして確かに便利なのだが、削除したものをkill-ringにどんどん放りこむのがイヤだと思ったので、純粋に削除のみを実行するコマンドを書いたということ。
(defun delete-word (arg)
"Delete characters forward until encountering the end of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (forward-word arg) (point))))
(defun backward-delete-word (arg)
"Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-word (- arg)))
適当なキーバインドに設定して中々便利に使っている。例えば私は以下のように設定している。
(global-set-key (kbd "C-M-<backspace>") 'backward-delete-word)
車輪の再発明感は高い。