Browse Source

org-agenda: Effectively preserve persistent bulk marks

* lisp/org-agenda.el (org-agenda-change-all-lines): Preserve bulk mark
  overlay when replacing an entry.

Reported-by: Jesse Johnson <holocronweaver@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/107299>
Nicolas Goaziou 8 years ago
parent
commit
655fb33967
1 changed files with 11 additions and 4 deletions
  1. 11 4
      lisp/org-agenda.el

+ 11 - 4
lisp/org-agenda.el

@@ -8943,11 +8943,18 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 		done-face (org-get-at-bol 'done-face))
 	  (beginning-of-line 1)
 	  (cond
-	   ((equal new "")
-	    (and (looking-at ".*\n?") (replace-match "")))
+	   ((equal new "") (delete-region (point) (line-beginning-position 2)))
 	   ((looking-at ".*")
-	    (replace-match new t t)
-	    (beginning-of-line 1)
+	    ;; When replacing the whole line, preserve bulk mark
+	    ;; overlay, if any.
+	    (let ((mark (catch :overlay
+			  (dolist (o (overlays-in (point) (+ 2 (point))))
+			    (when (eq (overlay-get o 'type)
+				      'org-marked-entry-overlay)
+			      (throw :overlay o))))))
+	      (replace-match new t t)
+	      (beginning-of-line)
+	      (when mark (move-overlay mark (point) (+ 2 (point)))))
 	    (add-text-properties (point-at-bol) (point-at-eol) props)
 	    (when fixface
 	      (add-text-properties