From 9b23b33921a2d6eddf09f52dfb429bc053fdbba0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 12 Apr 2022 13:15:36 -0500 Subject: [PATCH] Add +crux-kill-and-join-forward This one is visual-line-mode aware --- init.el | 2 +- lisp/+crux.el | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 4ea6f90..ec82d73 100644 --- a/init.el +++ b/init.el @@ -1288,7 +1288,7 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers." (:global "C-o" #'crux-smart-open-line "C-x 4 t" #'crux-transpose-windows "M-w" #'+crux-kill-ring-save - "C-k" #'crux-kill-and-join-forward + "C-k" #'+crux-kill-and-join-forward "C-c d" #'+crux-insert-date-or-time) (crux-with-region-or-buffer indent-region) diff --git a/lisp/+crux.el b/lisp/+crux.el index 45b4dee..c55a0b9 100644 --- a/lisp/+crux.el +++ b/lisp/+crux.el @@ -44,5 +44,15 @@ prompt for the time format." (format-time-string +crux-alternate-date-format time)) (t (format-time-string (read-string "Time Format: ") time)))))) +(defun +crux-kill-and-join-forward (&optional arg) + "If at end of line, join with following; else (visual)-kill line. +In `visual-line-mode', runs command `kill-visual-line'; in other +modes, runs command `kill-line'. Passes ARG to command when +provided. Deletes whitespace at join." + (interactive "P") + (if (and (eolp) (not (bolp))) + (delete-indentation 1) + (funcall (if visual-line-mode #'kill-visual-line #'kill-line) arg))) + (provide '+crux) ;;; +crux.el ends here