Mapping: More user control over the location from where mapping continues.

Mapping call a function for each matching entry.  So far this has
always assumed that the entry stays in the buffer and search can
continue from there.  However, when the mapper function removes the
tree, more control is needed to specify from where the search should
continue.

The action function handed to the mapping function can now set the
variable `org-map-continue-from' to the position from where mapping
should continue.
This commit is contained in:
Carsten Dominik 2009-04-05 13:41:36 +02:00
parent b811ec9cb0
commit c9675ebc96
3 changed files with 40 additions and 6 deletions

View File

@ -6348,7 +6348,7 @@ on or after October 11, 2008.
Accessing TODO, LEVEL, and CATEGORY during a search is fast. Accessing any
other properties will slow down the search. However, once you have payed the
price by accessig one property, testing additional properties is cheap
price by accessing one property, testing additional properties is cheap
again.
You can configure Org mode to use property inheritance during a search, but
@ -11031,6 +11031,17 @@ arguments, with the cursor positioned at the beginning of the headline.
The return values of all calls to the function will be collected and
returned as a list.
The call to FUNC will be wrapped into a save-excursion form, so FUNC
does not need to preserve point. After evaluaton, the cursor will be
moved to the end of the line (presumably of the headline of the
processed entry) and search continues from there. Under some
circumstances, this may not produce the wanted results. For example,
if you have removed (e.g. archived) the current (sub)tree it could
mean that the next entry will be skipped entirely. In such cases, you
can specify the position from where search should continue by making
FUNC set the variable `org-map-continue-from' to the desired buffer
position.
MATCH is a tags/property/todo match as it is used in the agenda match view.
Only headlines that are matched by this query will be considered during
the iteration. When MATCH is nil or t, all headlines will be

View File

@ -4,6 +4,8 @@
after todo keyword.
(org-todo): When changing TODO state, do matching
case-sensitively.
(org-map-continue-from): New variable.
(org-scan-tags): Respect values in `org-map-continue-from'.
2009-04-04 Carsten Dominik <carsten.dominik@gmail.com>

View File

@ -9964,6 +9964,10 @@ ACTION can be `set', `up', `down', or a character."
;;;; Tags
(defvar org-agenda-archives-mode)
(defvar org-map-continue-from nil
"Position from where mapping should continue.
Can be set byt the action argument to `org-scan-tag's and `org-map-entries'.")
(defvar org-scanner-tags nil
"The current tag list while the tags scanner is running.")
(defvar org-trust-scanner-tags nil
@ -10006,6 +10010,7 @@ only lines with a TODO keyword are included in the output."
(or (buffer-file-name (buffer-base-buffer))
(buffer-name (buffer-base-buffer)))))))
(case-fold-search nil)
(org-map-continue-from nil)
lspos tags tags-list
(tags-alist (list (cons 0 org-file-tags)))
(llast 0) rtn rtn1 level category i txt
@ -10093,15 +10098,20 @@ only lines with a TODO keyword are included in the output."
'priority priority 'type "tagsmatch")
(push txt rtn))
((functionp action)
(setq org-map-continue-from nil)
(save-excursion
(setq rtn1 (funcall action))
(push rtn1 rtn))
(goto-char (point-at-eol)))
(push rtn1 rtn)))
(t (error "Invalid action")))
;; if we are to skip sublevels, jump to end of subtree
(or org-tags-match-list-sublevels (org-end-of-subtree t))))
(and (= (point) lspos) (forward-char 1))))
(unless org-tags-match-list-sublevels
(org-end-of-subtree t)
(backward-char 1))))
;; Get the correct position from where to continue
(if org-map-continue-from
(goto-char org-map-continue-from)
(and (= (point) lspos) (end-of-line 1)))))
(when (and (eq action 'sparse-tree)
(not org-sparse-tree-open-archived-trees))
(org-hide-archived-subtrees (point-min) (point-max)))
@ -10869,7 +10879,18 @@ Returns the new tags string, or nil to not change the current settings."
FUNC is a function or a lisp form. The function will be called without
arguments, with the cursor positioned at the beginning of the headline.
The return values of all calls to the function will be collected and
returned as a list.
returned as a list.
The call to FUNC will be wrapped into a save-excursion form, so FUNC
does not need to preserve point. After evaluaton, the cursor will be
moved to the end of the line (presumably of the headline of the
processed entry) and search continues from there. Under some
circumstances, this may not produce the wanted results. For example,
if you have removed (e.g. archived) the current (sub)tree it could
mean that the next entry will be skipped entirely. In such cases, you
can specify the position from where search should continue by making
FUNC set the variable `org-map-continue-from' to the desired buffer
position.
MATCH is a tags/property/todo match as it is used in the agenda tags view.
Only headlines that are matched by this query will be considered during