From 706932bec3b59a47ff2736dc9b8f34d13738352a Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 7 Sep 2017 15:51:30 +0200 Subject: [PATCH 1/2] Restriction lock means no extra files in agenda search view * lisp/org-agenda.el (org-search-view): Restriction lock means no extra files in agenda search view. Reported-by: Samuel Wales --- lisp/org-agenda.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 2a40146d1..42c599a03 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4368,8 +4368,9 @@ as a whole, to include whitespace. with a colon, this will mean that the (non-regexp) snippets of the Boolean search must match as full words. -This command searches the agenda files, and in addition the files listed -in `org-agenda-text-search-extra-files'." +This command searches the agenda files, and in addition the files +listed in `org-agenda-text-search-extra-files' unless a restriction lock +is active." (interactive "P") (if org-agenda-overriding-arguments (setq todo-only (car org-agenda-overriding-arguments) @@ -4479,9 +4480,12 @@ in `org-agenda-text-search-extra-files'." (if hdl-only (setq regexp (concat org-outline-regexp-bol ".*?" regexp)))) (setq files (org-agenda-files nil 'ifmode)) - (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives) - (pop org-agenda-text-search-extra-files) - (setq files (org-add-archive-files files))) + ;; Add `org-agenda-text-search-extra-files' unless there is some + ;; restriction. + (unless (get 'org-agenda-files 'org-restrict) + (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives) + (pop org-agenda-text-search-extra-files) + (setq files (org-add-archive-files files)))) (setq files (append files org-agenda-text-search-extra-files) rtnall nil) (while (setq file (pop files)) From 22e916fb369629606d919a0e4f33ec2954c87e04 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 7 Sep 2017 15:52:56 +0200 Subject: [PATCH 2/2] org-agenda: Remove duplicate files when building a search view * lisp/org-agenda.el (org-search-view): Remove duplicate files when building a search view. Reported-by: Samuel Wales --- lisp/org-agenda.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 42c599a03..76bfa90d1 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4486,7 +4486,14 @@ is active." (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives) (pop org-agenda-text-search-extra-files) (setq files (org-add-archive-files files)))) - (setq files (append files org-agenda-text-search-extra-files) + ;; Uniquify files. However, let `org-check-agenda-file' handle + ;; non-existent ones. + (setq files (cl-remove-duplicates + (append files org-agenda-text-search-extra-files) + (lambda (a b) + (and (file-exists-p a) + (file-exists-p b) + (file-equal-p a b)))) rtnall nil) (while (setq file (pop files)) (setq ee nil) @@ -4541,12 +4548,12 @@ is active." (point-at-bol) (if hdl-only (point-at-eol) end))) (mapc (lambda (wr) (when (string-match wr str) - (goto-char (1- end)) - (throw :skip t))) + (goto-char (1- end)) + (throw :skip t))) regexps-) (mapc (lambda (wr) (unless (string-match wr str) - (goto-char (1- end)) - (throw :skip t))) + (goto-char (1- end)) + (throw :skip t))) (if todo-only (cons (concat "^\\*+[ \t]+" org-not-done-regexp)