@@ -2202,7 +2202,17 @@ string that it returns."
22022202(org-remap org-agenda-mode-map 'move-end-of-line 'org-agenda-end-of-line)
22032203
22042204(defvar org-agenda-menu) ; defined later in this file.
2205- (defvar org-agenda-restrict nil)
2205+ (defvar org-agenda-restrict nil
2206+ "Non-nil means agenda restriction is active.
2207+ This is an internal flag indicating either temporary or extended
2208+ agenda restriction. Specifically, it is set to t if the agenda
2209+ is restricted to an entire file, and is set to the corresponding
2210+ buffer if the agenda is restricted to a part of a file, e.g. a
2211+ region or a substree. In the latter case,
2212+ `org-agenda-restrict-begin' and `org-agenda-restrict-end' are set
2213+ to the beginning and the end of the part.
2214+
2215+ See also `org-agenda-set-restriction-lock'.")
22062216(defvar org-agenda-follow-mode nil)
22072217(defvar org-agenda-entry-text-mode nil)
22082218(defvar org-agenda-clockreport-mode nil)
@@ -2734,10 +2744,16 @@ that have been changed along."
27342744
27352745;;; Agenda dispatch
27362746
2737- (defvar org-agenda-restrict-begin (make-marker))
2738- (defvar org-agenda-restrict-end (make-marker))
2747+ (defvar org-agenda-restrict-begin (make-marker)
2748+ "Internal variable used to mark the restriction beginning.
2749+ It is only relevant when `org-agenda-restrict' is a buffer.")
2750+ (defvar org-agenda-restrict-end (make-marker)
2751+ "Internal variable used to mark the restriction end.
2752+ It is only relevant when `org-agenda-restrict' is a buffer.")
27392753(defvar org-agenda-last-dispatch-buffer nil)
2740- (defvar org-agenda-overriding-restriction nil)
2754+ (defvar org-agenda-overriding-restriction nil
2755+ "Non-nil means extended agenda restriction is active.
2756+ This is an internal flag set by `org-agenda-set-restriction-lock'.")
27412757
27422758(defcustom org-agenda-custom-commands-contexts nil
27432759 "Alist of custom agenda keys and contextual rules.
@@ -2962,12 +2978,12 @@ Pressing `<' twice means to restrict to the current subtree or region
29622978 (move-marker org-agenda-restrict-begin (point))
29632979 (move-marker org-agenda-restrict-end
29642980 (progn (org-end-of-subtree t)))))
2965- ((and ( eq restriction 'buffer)
2966- (or (< 1 (point-min ))
2967- (< (point-max) (1+ (buffer-size)))) )
2968- (setq org-agenda-restrict (current-buffer))
2969- (move-marker org-agenda-restrict-begin (point-min))
2970- (move-marker org-agenda-restrict-end (point-max)))))
2981+ ((eq restriction 'buffer)
2982+ (if (not (buffer-narrowed-p ))
2983+ (setq org-agenda-restrict t )
2984+ (setq org-agenda-restrict (current-buffer))
2985+ (move-marker org-agenda-restrict-begin (point-min))
2986+ (move-marker org-agenda-restrict-end (point-max) )))))
29712987
29722988 ;; For example the todo list should not need it (but does...)
29732989 (cond
@@ -7958,7 +7974,7 @@ subtree."
79587974 (message "Locking agenda restriction to subtree"))
79597975 (put 'org-agenda-files 'org-restrict
79607976 (list (buffer-file-name (buffer-base-buffer))))
7961- (setq org-agenda-restrict nil )
7977+ (setq org-agenda-restrict t )
79627978 (setq org-agenda-overriding-restriction 'file)
79637979 (move-marker org-agenda-restrict-begin nil)
79647980 (move-marker org-agenda-restrict-end nil)
@@ -7969,14 +7985,11 @@ subtree."
79697985(defun org-agenda-remove-restriction-lock (&optional noupdate)
79707986 "Remove agenda restriction lock."
79717987 (interactive "P")
7972- (if (not (or org-agenda-restrict org-agenda-overriding-restriction) )
7988+ (if (not org-agenda-restrict)
79737989 (message "No agenda restriction to remove.")
79747990 (delete-overlay org-agenda-restriction-lock-overlay)
79757991 (delete-overlay org-speedbar-restriction-lock-overlay)
79767992 (setq org-agenda-overriding-restriction nil)
7977- (unless org-agenda-keep-restricted-file-list
7978- ;; There is a request to keep the file list in place
7979- (put 'org-agenda-files 'org-restrict nil))
79807993 (setq org-agenda-restrict nil)
79817994 (put 'org-agenda-files 'org-restrict nil)
79827995 (move-marker org-agenda-restrict-begin nil)
0 commit comments