Просмотр исходного кода

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 <samologist@gmail.com>
<http://lists.gnu.org/archive/html/emacs-orgmode/2017-09/msg00112.html>
Nicolas Goaziou 7 лет назад
Родитель
Сommit
22e916fb36
1 измененных файлов с 12 добавлено и 5 удалено
  1. 12 5
      lisp/org-agenda.el

+ 12 - 5
lisp/org-agenda.el

@@ -4486,7 +4486,14 @@ is active."
 	(when (eq (car org-agenda-text-search-extra-files) 'agenda-archives)
 	(when (eq (car org-agenda-text-search-extra-files) 'agenda-archives)
 	  (pop org-agenda-text-search-extra-files)
 	  (pop org-agenda-text-search-extra-files)
 	  (setq files (org-add-archive-files 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)
 	    rtnall nil)
       (while (setq file (pop files))
       (while (setq file (pop files))
 	(setq ee nil)
 	(setq ee nil)
@@ -4541,12 +4548,12 @@ is active."
 				   (point-at-bol)
 				   (point-at-bol)
 				   (if hdl-only (point-at-eol) end)))
 				   (if hdl-only (point-at-eol) end)))
 			(mapc (lambda (wr) (when (string-match wr str)
 			(mapc (lambda (wr) (when (string-match wr str)
-					     (goto-char (1- end))
-					     (throw :skip t)))
+					(goto-char (1- end))
+					(throw :skip t)))
 			      regexps-)
 			      regexps-)
 			(mapc (lambda (wr) (unless (string-match wr str)
 			(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
 			      (if todo-only
 				  (cons (concat "^\\*+[ \t]+"
 				  (cons (concat "^\\*+[ \t]+"
                                                 org-not-done-regexp)
                                                 org-not-done-regexp)