emacs: make prot-simple-delete-line not err when end is out of bounds

This commit is contained in:
Protesilaos Stavrou 2025-07-29 06:42:01 +03:00
parent bb4895da05
commit 7a7f9418ef
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
2 changed files with 16 additions and 12 deletions

View file

@ -16726,12 +16726,14 @@ This command can then be followed by the standard
(defun prot-simple-delete-line ()
"Delete (not kill) from point to the end of the line."
(interactive)
(let ((point (point))
(end (line-end-position)))
(if (eq point end)
(delete-region point (+ end 1))
(delete-region point end)))
(setq this-command 'kill-whole-line))
(let* ((point (point))
(end (line-end-position))
(end+ (+ end 1)))
(cond
((> end+ (point-max)))
((= point end) (delete-region point end+))
(t (delete-region point end))))
(setq this-command 'delete-region))
;;;###autoload
(defun prot-simple-delete-line-backward ()

View file

@ -320,12 +320,14 @@ This command can then be followed by the standard
(defun prot-simple-delete-line ()
"Delete (not kill) from point to the end of the line."
(interactive)
(let ((point (point))
(end (line-end-position)))
(if (eq point end)
(delete-region point (+ end 1))
(delete-region point end)))
(setq this-command 'kill-whole-line))
(let* ((point (point))
(end (line-end-position))
(end+ (+ end 1)))
(cond
((> end+ (point-max)))
((= point end) (delete-region point end+))
(t (delete-region point end))))
(setq this-command 'delete-region))
;;;###autoload
(defun prot-simple-delete-line-backward ()