Question

The code is below but seems to have an error because it says when started can't find the remove duplicates function. Anyone have an idea how to fix this?? There is a second code on the same page with the problem. Essentially I can get it working but I want it to remove the directory names. I don't care as much about if there are duplicates. This code was posted on this page:

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))))
Was it helpful?

Solution

The "remove-duplicates" function is located in the cl-seq.el file and is included in all recent versions of Emacs. It is loaded as part of the "cl" package so you just need the following line in your Emacs init file:

(require 'cl)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top