Let `org-agenda-set-restriction-lock' remove restriction at point
* lisp/org-compat.el (org-speedbar-set-agenda-restriction): * lisp/org-agenda.el (org-agenda-set-restriction-lock): If there is an agenda restriction at point, remove it. * doc/org-manual.org: * etc/ORG-NEWS: Document the new feature.
This commit is contained in:
parent
bc37b32580
commit
011f1c6181
|
@ -8338,20 +8338,20 @@ scope for an extended period, use the following commands:
|
||||||
|
|
||||||
#+kindex: C-c C-x <
|
#+kindex: C-c C-x <
|
||||||
#+findex: org-agenda-set-restriction-lock
|
#+findex: org-agenda-set-restriction-lock
|
||||||
Permanently restrict the agenda to the current subtree. When
|
Restrict the agenda to the current subtree. If there already is
|
||||||
called with a prefix argument, or with the cursor before the
|
a restriction at point, remove it. When called with a universal
|
||||||
first headline in a file, set the agenda scope to the entire
|
prefix argument or with the cursor before the first headline in a
|
||||||
file. This restriction remains in effect until removed with
|
file, set the agenda scope to the entire file. This restriction
|
||||||
{{{kbd(C-c C-x >)}}}, or by typing either {{{kbd(<)}}} or
|
remains in effect until removed with {{{kbd(C-c C-x >)}}}, or by typing
|
||||||
{{{kbd(>)}}} in the agenda dispatcher. If there is a window
|
either {{{kbd(<)}}} or {{{kbd(>)}}} in the agenda dispatcher. If there is a
|
||||||
displaying an agenda view, the new restriction takes effect
|
window displaying an agenda view, the new restriction takes
|
||||||
immediately.
|
effect immediately.
|
||||||
|
|
||||||
- {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
|
- {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
|
||||||
|
|
||||||
#+kindex: C-c C-x >
|
#+kindex: C-c C-x >
|
||||||
#+findex: org-agenda-remove-restriction-lock
|
#+findex: org-agenda-remove-restriction-lock
|
||||||
Remove the permanent restriction created by {{{kbd(C-c C-x <)}}}.
|
Remove the restriction created by {{{kbd(C-c C-x <)}}}.
|
||||||
|
|
||||||
#+texinfo: @noindent
|
#+texinfo: @noindent
|
||||||
When working with =speedbar.el=, you can use the following commands in
|
When working with =speedbar.el=, you can use the following commands in
|
||||||
|
@ -8360,15 +8360,16 @@ the Speedbar frame:
|
||||||
- {{{kbd(<)}}} (~org-speedbar-set-agenda-restriction~) ::
|
- {{{kbd(<)}}} (~org-speedbar-set-agenda-restriction~) ::
|
||||||
|
|
||||||
#+findex: org-speedbar-set-agenda-restriction
|
#+findex: org-speedbar-set-agenda-restriction
|
||||||
Permanently restrict the agenda to the item---either an Org file
|
Restrict the agenda to the item---either an Org file or a subtree
|
||||||
or a subtree in such a file---at the cursor in the Speedbar
|
in such a file---at the cursor in the Speedbar frame. If agenda
|
||||||
frame. If there is a window displaying an agenda view, the new
|
is already restricted there, remove the restriction. If there is
|
||||||
restriction takes effect immediately.
|
a window displaying an agenda view, the new restriction takes
|
||||||
|
effect immediately.
|
||||||
|
|
||||||
- {{{kbd(>)}}} (~org-agenda-remove-restriction-lock~) ::
|
- {{{kbd(>)}}} (~org-agenda-remove-restriction-lock~) ::
|
||||||
|
|
||||||
#+findex: org-agenda-remove-restriction-lock
|
#+findex: org-agenda-remove-restriction-lock
|
||||||
Lift the restriction.
|
Remove the restriction.
|
||||||
|
|
||||||
** The Agenda Dispatcher
|
** The Agenda Dispatcher
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
|
|
@ -298,6 +298,13 @@ parameters. See example bellow.
|
||||||
,#+END_SRC
|
,#+END_SRC
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
*** ~org-agenda-set-restriction-lock~ toggle agenda restriction at point
|
||||||
|
|
||||||
|
You can set an agenda restriction lock with =C-x C-x <= or with =<= at the
|
||||||
|
beginning of a headline when using Org speed commands. Now, if there
|
||||||
|
is already a restriction at point, hitting =<= again (or =C-x C-x <=) will
|
||||||
|
remove it.
|
||||||
|
|
||||||
** New functions
|
** New functions
|
||||||
|
|
||||||
*** ~org-insert-structure-template~
|
*** ~org-insert-structure-template~
|
||||||
|
|
|
@ -7124,43 +7124,50 @@ Argument ARG is the prefix argument."
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun org-agenda-set-restriction-lock (&optional type)
|
(defun org-agenda-set-restriction-lock (&optional type)
|
||||||
"Set restriction lock for agenda, to current subtree or file.
|
"Set restriction lock for agenda to current subtree or file.
|
||||||
Restriction will be the file if TYPE is `file', or if type is the
|
When in a restricted subtree, remove it.
|
||||||
universal prefix \\='(4), or if the cursor is before the first headline
|
|
||||||
in the file. Otherwise, restriction will be to the current subtree."
|
The restriction will span over the entire file if TYPE is `file',
|
||||||
|
or if type is '(4), or if the cursor is before the first headline
|
||||||
|
in the file. Otherwise, only apply the restriction to the current
|
||||||
|
subtree."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(org-agenda-remove-restriction-lock 'noupdate)
|
(if (and org-agenda-overriding-restriction
|
||||||
(and (equal type '(4)) (setq type 'file))
|
(member org-agenda-restriction-lock-overlay
|
||||||
(setq type (cond
|
(overlays-at (point))))
|
||||||
(type type)
|
(org-agenda-remove-restriction-lock 'noupdate)
|
||||||
((org-at-heading-p) 'subtree)
|
(org-agenda-remove-restriction-lock 'noupdate)
|
||||||
((condition-case nil (org-back-to-heading t) (error nil))
|
(and (equal type '(4)) (setq type 'file))
|
||||||
'subtree)
|
(setq type (cond
|
||||||
(t 'file)))
|
(type type)
|
||||||
(if (eq type 'subtree)
|
((org-at-heading-p) 'subtree)
|
||||||
(progn
|
((condition-case nil (org-back-to-heading t) (error nil))
|
||||||
(setq org-agenda-restrict (current-buffer))
|
'subtree)
|
||||||
(setq org-agenda-overriding-restriction 'subtree)
|
(t 'file)))
|
||||||
(put 'org-agenda-files 'org-restrict
|
(if (eq type 'subtree)
|
||||||
(list (buffer-file-name (buffer-base-buffer))))
|
(progn
|
||||||
(org-back-to-heading t)
|
(setq org-agenda-restrict (current-buffer))
|
||||||
(move-overlay org-agenda-restriction-lock-overlay
|
(setq org-agenda-overriding-restriction 'subtree)
|
||||||
(point)
|
(put 'org-agenda-files 'org-restrict
|
||||||
(if org-agenda-restriction-lock-highlight-subtree
|
(list (buffer-file-name (buffer-base-buffer))))
|
||||||
(save-excursion (org-end-of-subtree t t) (point))
|
(org-back-to-heading t)
|
||||||
(point-at-eol)))
|
(move-overlay org-agenda-restriction-lock-overlay
|
||||||
(move-marker org-agenda-restrict-begin (point))
|
(point)
|
||||||
(move-marker org-agenda-restrict-end
|
(if org-agenda-restriction-lock-highlight-subtree
|
||||||
(save-excursion (org-end-of-subtree t t)))
|
(save-excursion (org-end-of-subtree t t) (point))
|
||||||
(message "Locking agenda restriction to subtree"))
|
(point-at-eol)))
|
||||||
(put 'org-agenda-files 'org-restrict
|
(move-marker org-agenda-restrict-begin (point))
|
||||||
(list (buffer-file-name (buffer-base-buffer))))
|
(move-marker org-agenda-restrict-end
|
||||||
(setq org-agenda-restrict nil)
|
(save-excursion (org-end-of-subtree t t)))
|
||||||
(setq org-agenda-overriding-restriction 'file)
|
(message "Locking agenda restriction to subtree"))
|
||||||
(move-marker org-agenda-restrict-begin nil)
|
(put 'org-agenda-files 'org-restrict
|
||||||
(move-marker org-agenda-restrict-end nil)
|
(list (buffer-file-name (buffer-base-buffer))))
|
||||||
(message "Locking agenda restriction to file"))
|
(setq org-agenda-restrict nil)
|
||||||
(setq current-prefix-arg nil)
|
(setq org-agenda-overriding-restriction 'file)
|
||||||
|
(move-marker org-agenda-restrict-begin nil)
|
||||||
|
(move-marker org-agenda-restrict-end nil)
|
||||||
|
(message "Locking agenda restriction to file"))
|
||||||
|
(setq current-prefix-arg nil))
|
||||||
(org-agenda-maybe-redo))
|
(org-agenda-maybe-redo))
|
||||||
|
|
||||||
(defun org-agenda-remove-restriction-lock (&optional noupdate)
|
(defun org-agenda-remove-restriction-lock (&optional noupdate)
|
||||||
|
|
|
@ -688,6 +688,8 @@ This also applied for speedbar access."
|
||||||
|
|
||||||
(defun org-speedbar-set-agenda-restriction ()
|
(defun org-speedbar-set-agenda-restriction ()
|
||||||
"Restrict future agenda commands to the location at point in speedbar.
|
"Restrict future agenda commands to the location at point in speedbar.
|
||||||
|
If there is already a restriction lock at the location, remove it.
|
||||||
|
|
||||||
To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'."
|
To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(require 'org-agenda)
|
(require 'org-agenda)
|
||||||
|
@ -698,7 +700,11 @@ To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'."
|
||||||
(setq m (get-text-property p 'org-imenu-marker))
|
(setq m (get-text-property p 'org-imenu-marker))
|
||||||
(with-current-buffer (marker-buffer m)
|
(with-current-buffer (marker-buffer m)
|
||||||
(goto-char m)
|
(goto-char m)
|
||||||
(org-agenda-set-restriction-lock 'subtree)))
|
(if (and org-agenda-overriding-restriction
|
||||||
|
(member org-agenda-restriction-lock-overlay
|
||||||
|
(overlays-at (point))))
|
||||||
|
(org-agenda-remove-restriction-lock 'noupdate)
|
||||||
|
(org-agenda-set-restriction-lock 'subtree))))
|
||||||
((setq p (text-property-any (point-at-bol) (point-at-eol)
|
((setq p (text-property-any (point-at-bol) (point-at-eol)
|
||||||
'speedbar-function 'speedbar-find-file))
|
'speedbar-function 'speedbar-find-file))
|
||||||
(setq tp (previous-single-property-change
|
(setq tp (previous-single-property-change
|
||||||
|
|
Loading…
Reference in New Issue