Function: org-agenda-change-all-lines

org-agenda-change-all-lines is a byte-compiled function defined in org-agenda.el.gz.

Signature

(org-agenda-change-all-lines NEWHEAD HDMARKER &optional FIXFACE JUST-THIS)

Documentation

Change all lines in the agenda buffer which match HDMARKER.

The new content of the line will be NEWHEAD (as modified by org-agenda-format-item). HDMARKER is checked with equal against all org-hd-marker text properties in the file. If FIXFACE is non-nil, the face of each item is modified according to the new TODO state. If JUST-THIS is non-nil, change just the current line, not all. If FORCE-TAGS is non-nil, the car of it returns the new tags.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-change-all-lines (newhead hdmarker
                                            &optional fixface just-this)
  "Change all lines in the agenda buffer which match HDMARKER.
The new content of the line will be NEWHEAD (as modified by
`org-agenda-format-item').  HDMARKER is checked with
`equal' against all `org-hd-marker' text properties in the file.
If FIXFACE is non-nil, the face of each item is modified according to
the new TODO state.
If JUST-THIS is non-nil, change just the current line, not all.
If FORCE-TAGS is non-nil, the car of it returns the new tags."
  (let* ((inhibit-read-only t)
	 (line (org-current-line))
	 (org-agenda-buffer (current-buffer))
	 (thetags (with-current-buffer (marker-buffer hdmarker)
		    (org-get-tags hdmarker)))
	 props m undone-face done-face finish new dotime level cat tags
         effort effort-minutes) ;; pl
    (save-excursion
      (goto-char (point-max))
      (beginning-of-line 1)
      (while (not finish)
	(setq finish (bobp))
	(when (and (setq m (org-get-at-bol 'org-hd-marker))
		   (or (not just-this) (= (org-current-line) line))
		   (equal m hdmarker))
	  (setq props (text-properties-at (point))
		dotime (org-get-at-bol 'dotime)
		cat (org-agenda-get-category)
		level (org-get-at-bol 'level)
		tags thetags
                effort (org-get-at-bol 'effort)
                effort-minutes (org-get-at-bol 'effort-minutes)
		new
		(let ((org-prefix-format-compiled
		       (or (get-text-property (min (1- (point-max)) (point)) 'format)
			   org-prefix-format-compiled))
		      (extra (org-get-at-bol 'extra)))
		  (with-current-buffer (marker-buffer hdmarker)
		    (org-with-wide-buffer
		     (org-agenda-format-item extra
                                   (org-add-props newhead nil
                                     'effort effort
                                     'effort-minutes effort-minutes)
                                   level cat tags dotime))))
                ;; pl (text-property-any (line-beginning-position)
                ;;                       (line-end-position) 'org-heading t)
		undone-face (org-get-at-bol 'undone-face)
		done-face (org-get-at-bol 'done-face))
	  (beginning-of-line 1)
	  (cond
	   ((equal new "") (delete-region (point) (line-beginning-position 2)))
	   ((looking-at ".*")
	    ;; 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 (line-beginning-position)
                                 (line-end-position) props)
	    (when fixface
	      (add-text-properties
               (line-beginning-position) (line-end-position)
	       (list 'face
		     (if org-last-todo-state-is-todo
			 undone-face done-face))))
	    (org-agenda-highlight-todo 'line)
	    (beginning-of-line 1))
	   (t (error "Line update did not work")))
	  (save-restriction
            (narrow-to-region (line-beginning-position) (line-end-position))
	    (org-agenda-finalize)))
	(beginning-of-line 0)))))