diff --git a/um.el b/um.el index aadf519..9114f0a 100644 --- a/um.el +++ b/um.el @@ -563,15 +563,16 @@ A negative prefix argument moves it backward. (defun um-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))) + ;; NOTE: remove all first, because otherwise we might miss a newline: + (remove-text-properties (point-min) (point-max) '(cursor-intangible t)) (save-excursion (goto-char (point-min)) (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 ;; 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))) ;; 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. @@ -580,12 +581,10 @@ A negative prefix argument moves it backward. (defun um--iro (cmd &optional args) (let ((inhibit-read-only t)) (apply cmd args) - ;; NOTE: every modification of buffer needs to reset the props: - (um--set-cursor-intangible-property))) + (um--reset-cursor-intangible-property))) (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-up '(-1))) +(defun um-drag-stuff-down () (interactive) (um--iro 'drag-stuff-down '(1))) (defun um-kill-line () (interactive) (um--iro 'kill-line)) (defun um-kill-region () (interactive) (um--iro 'kill-region '(nil nil t))) ;; NOTE: parallel to dired-copy-filename-as-kill @@ -618,7 +617,7 @@ A negative prefix argument moves it backward. \\{um-mode-map} " (let ((inhibit-read-only t)) - (um--set-cursor-intangible-property)) + (um--reset-cursor-intangible-property)) (cursor-intangible-mode) (read-only-mode))