summaryrefslogtreecommitdiff
path: root/jakob.org
diff options
context:
space:
mode:
Diffstat (limited to 'jakob.org')
-rw-r--r--jakob.org31
1 files changed, 29 insertions, 2 deletions
diff --git a/jakob.org b/jakob.org
index a73abc3..ecb4c7e 100644
--- a/jakob.org
+++ b/jakob.org
@@ -308,8 +308,8 @@ Unbind <C-z> and <C-x C-z> so that I'm not accidentally calling =suspend-frame=.
** Kill-Ring
-Replace =kill-word= and =backward-kill-word= with equivalents that do not push the
-region to the kill ring.
+Replace =kill-word=, =backward-kill-word=, and =kill-visual-line= with equivalents
+that do not copy the region into the kill ring.
#+BEGIN_SRC elisp
(defun delete-word (arg)
@@ -324,8 +324,35 @@ With argument ARG, do this that many times."
(interactive "p")
(delete-word (- arg)))
+(defun delete-visual-line (&optional arg)
+ "Delete the rest of the visual line.
+With prefix argument ARG, delete that many visual lines from point.
+If ARG is negative, delete visual lines backward.
+If ARG is zero, delete the text before point on the current visual
+line."
+ (interactive "P")
+ ;; Like in `kill-line', it's better to move point to the other end
+ ;; of the kill before killing.
+ (let ((opoint (point))
+ (delete-whole-line (and kill-whole-line (bolp))))
+ (if arg
+ (vertical-motion (prefix-numeric-value arg))
+ (end-of-visual-line 1)
+ (if (= (point) opoint)
+ (vertical-motion 1)
+ ;; Skip any trailing whitespace at the end of the visual line.
+ ;; We used to do this only if `show-trailing-whitespace' is
+ ;; nil, but that's wrong; the correct thing would be to check
+ ;; whether the trailing whitespace is highlighted. But, it's
+ ;; OK to just do this unconditionally.
+ (skip-chars-forward " \t")))
+ (delete-region opoint (if (and delete-whole-line (= (following-char) ?\n))
+ (1+ (point))
+ (point)))))
+
(bind-key "M-d" #'delete-word)
(bind-key "M-DEL" #'backward-delete-word)
+(bind-key "C-k" #'delete-visual-line)
#+END_SRC
* Quality-of-Life

© 2015 - 2026 Jakob L. Kreuze