um--reset-cursor-intangible-property : remove all first

This commit is contained in:
bth 2026-07-06 10:13:42 -07:00
commit 45aeb73848

15
um.el
View file

@ -563,15 +563,16 @@ A negative prefix argument moves it backward.
(defun um-previous-line () (defun um-previous-line ()
(interactive) (move-beginning-of-line nil) (previous-line)) (interactive) (move-beginning-of-line nil) (previous-line))
(defun um--set-cursor-intangible-property () (defun um--reset-cursor-intangible-property ()
(let ((modified (buffer-modified-p))) (let ((modified (buffer-modified-p)))
;; NOTE: remove all first, because otherwise we might miss a newline:
(remove-text-properties (point-min) (point-max) '(cursor-intangible t))
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(while (not (eobp)) (while (not (eobp))
;; NOTE: reset all properties as side-effect. But this is what we want.
;; NOTE: actually the newline is the only position not included, but this ;; NOTE: actually the newline is the only position not included, but this
;; positions the cursor visually at the bol: ;; positions the cursor visually at the bol:
(set-text-properties (pos-bol) (pos-eol) '(cursor-intangible t)) (add-text-properties (pos-bol) (pos-eol) '(cursor-intangible t))
(forward-line 1))) (forward-line 1)))
;; we don't want to fuck with the modified state just to change text ;; we don't want to fuck with the modified state just to change text
;; properties, but we also don't want to obscure it if it was already modified. ;; properties, but we also don't want to obscure it if it was already modified.
@ -580,12 +581,10 @@ A negative prefix argument moves it backward.
(defun um--iro (cmd &optional args) (defun um--iro (cmd &optional args)
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(apply cmd args) (apply cmd args)
;; NOTE: every modification of buffer needs to reset the props: (um--reset-cursor-intangible-property)))
(um--set-cursor-intangible-property)))
(defun um-drag-stuff-up () (interactive) (um--iro 'drag-stuff-up '(1))) (defun um-drag-stuff-up () (interactive) (um--iro 'drag-stuff-up '(1)))
;; HACK: drag-stuff-down breaks um--set-cursor-intangible-property for some reason. just use drag-stuff-up with negative arg: (defun um-drag-stuff-down () (interactive) (um--iro 'drag-stuff-down '(1)))
(defun um-drag-stuff-down () (interactive) (um--iro 'drag-stuff-up '(-1)))
(defun um-kill-line () (interactive) (um--iro 'kill-line)) (defun um-kill-line () (interactive) (um--iro 'kill-line))
(defun um-kill-region () (interactive) (um--iro 'kill-region '(nil nil t))) (defun um-kill-region () (interactive) (um--iro 'kill-region '(nil nil t)))
;; NOTE: parallel to dired-copy-filename-as-kill ;; NOTE: parallel to dired-copy-filename-as-kill
@ -618,7 +617,7 @@ A negative prefix argument moves it backward.
\\{um-mode-map} \\{um-mode-map}
" "
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(um--set-cursor-intangible-property)) (um--reset-cursor-intangible-property))
(cursor-intangible-mode) (cursor-intangible-mode)
(read-only-mode)) (read-only-mode))