summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Wahl <marcowahlsoft@gmail.com>2019-07-15 00:22:51 +0200
committerMarco Wahl <marcowahlsoft@gmail.com>2019-07-15 00:22:51 +0200
commitdc2198971bbacab4093275b1c2f65afb3e1a0b21 (patch)
tree6bb8cad4974ded676c6c39d632fb6d5cafcb4999
parent5e9c170f3894242ec40b1c6dad5c9aa94fdcb5bd (diff)
downloadorg-mode-dc2198971bbacab4093275b1c2f65afb3e1a0b21.tar.gz
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.
-rw-r--r--doc/org-manual.org5
-rw-r--r--etc/ORG-NEWS2
-rw-r--r--lisp/org-agenda.el8
3 files changed, 12 insertions, 3 deletions
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 8411d9d..f216b45 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 557b398..68fa9ad 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 633bbf3..3e992bb 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