crux icon indicating copy to clipboard operation
crux copied to clipboard

crux-smart-kill-line ignores visual-line-mode

Open newhallroad opened this issue 2 years ago • 1 comments

Thanks for a wonderful package.

When I run crux-smart-kill-line with the point at the end of the line, it kills the entire line.

With visual-line-mode activated and (setq crux-move-visually t) I would expect it to kill just the visual line.

crux-move-beginning-of-line works as expected, moving to the beginning of the visual line.

Using the following environment: crux-20231013.520 Gnu emacs 29.1 Windows 10

newhallroad avatar Nov 21 '23 16:11 newhallroad

This is a suggestion for a replacement that takes visual lines into account.

(defun alk/crux-smart-kill-line ()
  "Kill to the end of the line and kill whole line on the next call. Takes visual line into account."
  (interactive)
  (let ((orig-point (point)))
    ;; If point at beginning of line, kill line from point to end of visual line
    (beginning-of-visual-line 1)
    (if (= orig-point (point))
        (kill-visual-line)
      ;; If point at end of line, kill line backward to beginning of visual line
      (end-of-visual-line 1)
      (if (= orig-point (point))
          (kill-visual-line 0)
        ;; If point in middle of line, kill line from point to end of visual line
        (goto-char orig-point)
        (kill-visual-line)))))

newhallroad avatar Dec 05 '23 01:12 newhallroad