org-agenda: Respect narrowing for agenda restricted to buffer

* lisp/org-agenda.el (org-agenda): Add a condition to check if
  narrowing is in effect and in case set the agenda restriction markers.
* etc/ORG-NEWS (Respect narrowing when agenda command is restricted to buffer):
* doc/org-manual.org (The Agenda Dispatcher): Mention the behavior.
This commit is contained in:
Marco Wahl 2019-07-15 00:22:51 +02:00
parent 5e9c170f38
commit dc2198971b
3 changed files with 12 additions and 3 deletions

View File

@ -8491,8 +8491,9 @@ commands:
- {{{kbd(<)}}} ::
#+kindex: < @r{(Agenda dispatcher)}
Restrict an agenda command to the current buffer[fn:91]. After
pressing {{{kbd(<)}}}, you still need to press the character
Restrict an agenda command to the current buffer[fn:91]. If
narrowing is in effect restrict to the narrowed part of the buffer.
After pressing {{{kbd(<)}}}, you still need to press the character
selecting the command.
- {{{kbd(< <)}}} ::

View File

@ -398,6 +398,8 @@ leave unfolded subtrees unfolded.
I.e. treat the whole file as if it was a subtree.
*** Respect narrowing when agenda command is restricted to buffer
* Version 9.2
** Incompatible changes
*** Removal of OrgStruct mode mode and radio lists

View File

@ -2848,7 +2848,13 @@ Pressing `<' twice means to restrict to the current subtree or region
(org-back-to-heading t)
(move-marker org-agenda-restrict-begin (point))
(move-marker org-agenda-restrict-end
(progn (org-end-of-subtree t)))))))
(progn (org-end-of-subtree t)))))
((and (eq restriction 'buffer)
(or (< 1 (point-min))
(< (point-max) (1+ (buffer-size)))))
(setq org-agenda-restrict (current-buffer))
(move-marker org-agenda-restrict-begin (point-min))
(move-marker org-agenda-restrict-end (point-max)))))
;; For example the todo list should not need it (but does...)
(cond