diff --git a/doc/org-manual.org b/doc/org-manual.org index 8411d9d9a..f216b45dc 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -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(< <)}}} :: diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 557b398e0..68fa9ad00 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -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 diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 633bbf308..3e992bb91 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -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