Menurut dokumentasi:
<C-delete>
menjalankan perintah kill-word (ditemukan di global-map), yang merupakan fungsi Lisp yang dikompilasi interaktif di ‘simple.el’
.
Pasti terikat <C-delete>, M-d
.
(kill-word ARG)
Bunuh karakter-karakter ke depan sampai menemukan akhir kata. Dengan argumen ARG, lakukan ini berkali-kali.
Sekarang, mari kita telusuri kode sumber:
(defun kill-word (arg)
"Kill characters forward until encountering the end of a word.
With argument ARG, do this that many times."
(interactive "p")
(kill-region (point) (progn (forward-word arg) (point))))
Kemudian, di dalam dokumentasi untuk kill-region
fungsi yang kami temukan:
Bunuh ("potong") teks antara titik dan tanda.
This deletes the text from the buffer and saves it in the kill ring
. Perintah [yank] dapat mengambilnya dari sana. (Jika Anda ingin menyelamatkan wilayah tanpa membunuhnya, gunakan [kill-ring-save].)
[...]
Program Lisp harus menggunakan fungsi ini untuk membunuh teks. (Untuk menghapus teks, gunakan delete-region
.)
Sekarang, jika Anda ingin melangkah lebih jauh, ini adalah beberapa fungsi yang dapat Anda gunakan, untuk menghapus tanpa menyalin ke kill-ring:
(defun my-delete-word (arg)
"Delete characters forward until encountering the end of a word.
With argument, do this that many times.
This command does not push text to `kill-ring'."
(interactive "p")
(delete-region
(point)
(progn
(forward-word arg)
(point))))
(defun my-backward-delete-word (arg)
"Delete characters backward until encountering the beginning of a word.
With argument, do this that many times.
This command does not push text to `kill-ring'."
(interactive "p")
(my-delete-word (- arg)))
(defun my-delete-line ()
"Delete text from current position to end of line char.
This command does not push text to `kill-ring'."
(interactive)
(delete-region
(point)
(progn (end-of-line 1) (point)))
(delete-char 1))
(defun my-delete-line-backward ()
"Delete text between the beginning of the line to the cursor position.
This command does not push text to `kill-ring'."
(interactive)
(let (p1 p2)
(setq p1 (point))
(beginning-of-line 1)
(setq p2 (point))
(delete-region p1 p2)))
; bind them to emacs's default shortcut keys:
(global-set-key (kbd "C-S-k") 'my-delete-line-backward) ; Ctrl+Shift+k
(global-set-key (kbd "C-k") 'my-delete-line)
(global-set-key (kbd "M-d") 'my-delete-word)
(global-set-key (kbd "<M-backspace>") 'my-backward-delete-word)
Atas perkenan ErgoEmacs
undo
. Tapi tebakan liar.