0

代码如下,但似乎有错误,因为它说启动时找不到删除重复项功能。任何人都知道如何解决这个问题?在同一页面上还有第二个代码存在问题。基本上我可以让它工作,但我希望它删除目录名称。我不太关心是否有重复。此代码发布在此页面上:

http://www.emacswiki.org/emacs/RecentFiles

(defun recentf-interactive-complete ()
"find a file in the recently open file using ido for completion"
(interactive)
(let* ((all-files recentf-list)
 (file-assoc-list (mapcar (lambda (x) (cons (file-name-nondirectory x) x)) all-files))
 (filename-list (remove-duplicates (mapcar 'car file-assoc-list) :test 'string=))
 (ido-make-buffer-list-hook
  (lambda ()
    (setq ido-temp-list filename-list)))
 (filename (ido-read-buffer "Find Recent File: "))
 (result-list (delq nil (mapcar (lambda (x) (if (string= (car x) filename) (cdr x))) file-assoc-list)))
 (result-length (length result-list)))
     (find-file 
  (cond 
   ((= result-length 0) filename)
   ((= result-length 1) (car result-list))
   ( t
     (let ( (ido-make-buffer-list-hook
         (lambda ()
           (setq ido-temp-list result-list))))
       (ido-read-buffer (format "%d matches:" result-length))))
4

1 回答 1

2

“remove-duplicates”函数位于 cl-seq.el 文件中,并且包含在所有最新版本的 Emacs 中。它作为“cl”包的一部分加载,因此您只需要在 Emacs 初始化文件中添加以下行:

(require 'cl)
于 2011-08-31T06:27:56.697 回答