浏览代码

Archive: Avoid problems when multiple files use the same archive.

Matt Lundin writes:

   When I have multiple org files archive to a single file, as in

   ,----
   | (setq org-archive-location "~/2009.org_archive::")
   `----

   I find that including archive files in the agenda display (C-u v)
   results in multiple identical entries in the agenda display (in my
   case, when doing a word search).

   In fact, the number of duplicate lines exactly matches the number of
   agenda files that archive to that file (in my case 16). Is the agenda
   function perhaps searching the archive file once for each of the
   agenda files and then displaying the results as separate lines?

Indeed, when putting together the list o archive files to search,
Org did not check for duplicates.  This commit implements
uniquification of the list.
Carsten Dominik 16 年之前
父节点
当前提交
5a8f775d79
共有 2 个文件被更改,包括 16 次插入10 次删除
  1. 5 0
      lisp/ChangeLog
  2. 11 10
      lisp/org-archive.el

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2009-01-10  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-archive.el (org-add-archive-files): Uniquify the list before
+	returning it.
+
 2009-01-09  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-compat.el (org-fit-window-to-buffer): Use

+ 11 - 10
lisp/org-archive.el

@@ -102,18 +102,19 @@ information."
 	 (t org-archive-location (match-string 1)))))))
 
 (defun org-add-archive-files (files)
-  "Splice the archive files into the list f files.
+  "Splice the archive files into the list of files.
 This implies visiting all these files and finding out what the
 archive file is."
-  (apply
-   'append
-   (mapcar
-    (lambda (f)
-      (if (not (file-exists-p f))
-	  nil
-	(with-current-buffer (org-get-agenda-file-buffer f)
-	  (cons f (org-all-archive-files)))))
-    files)))
+  (org-uniquify
+   (apply
+    'append
+    (mapcar
+     (lambda (f)
+       (if (not (file-exists-p f))
+	   nil
+	 (with-current-buffer (org-get-agenda-file-buffer f)
+	   (cons f (org-all-archive-files)))))
+     files))))
 
 (defun org-all-archive-files ()
   "Get a list of all archive files used in the current buffer."