Add +crux-kill-and-join-forward

This one is visual-line-mode aware
This commit is contained in:
Case Duckworth 2022-04-12 13:15:36 -05:00
parent c0fa442767
commit 9b23b33921
2 changed files with 11 additions and 1 deletions

View File

@ -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)

View File

@ -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