0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-07-17 02:06:28 +00:00

org-clock: Preserve narrowing when building clock table

* lisp/org-clock.el (org-dblock-write:clocktable): Preserve current
  narrowing, if any, when building the table.

Reported-by: Christof Musik <ml-orgmode@litephone.org>
<http://permalink.gmane.org/gmane.emacs.orgmode/112872>
This commit is contained in:
Nicolas Goaziou 2017-03-29 16:33:10 +02:00
parent a08dd527d9
commit df0c7d96a2

View file

@ -2409,26 +2409,27 @@ the currently selected interval size."
(org-clock-get-table-data file params))))) (org-clock-get-table-data file params)))))
files) files)
;; Get the right restriction for the scope. ;; Get the right restriction for the scope.
(cond (save-restriction
((not scope)) ;use the restriction as it is now (cond
((eq scope 'file) (widen)) ((not scope)) ;use the restriction as it is now
((eq scope 'subtree) (org-narrow-to-subtree)) ((eq scope 'file) (widen))
((eq scope 'tree) ((eq scope 'subtree) (org-narrow-to-subtree))
(while (org-up-heading-safe)) ((eq scope 'tree)
(org-narrow-to-subtree)) (while (org-up-heading-safe))
((and (symbolp scope) (org-narrow-to-subtree))
(string-match "\\`tree\\([0-9]+\\)\\'" ((and (symbolp scope)
(symbol-name scope))) (string-match "\\`tree\\([0-9]+\\)\\'"
(let ((level (string-to-number (symbol-name scope)))
(match-string 1 (symbol-name scope))))) (let ((level (string-to-number
(catch 'exit (match-string 1 (symbol-name scope)))))
(while (org-up-heading-safe) (catch 'exit
(looking-at org-outline-regexp) (while (org-up-heading-safe)
(when (<= (org-reduced-level (funcall outline-level)) (looking-at org-outline-regexp)
level) (when (<= (org-reduced-level (funcall outline-level))
(throw 'exit nil)))) level)
(org-narrow-to-subtree)))) (throw 'exit nil))))
(list (org-clock-get-table-data nil params)))) (org-narrow-to-subtree))))
(list (org-clock-get-table-data nil params)))))
(multifile (multifile
;; Even though `file-with-archives' can consist of ;; Even though `file-with-archives' can consist of
;; multiple files, we consider this is one extended file ;; multiple files, we consider this is one extended file