emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Update filename history after several actions


From: Juri Linkov
Subject: Re: Update filename history after several actions
Date: Mon, 10 Oct 2005 09:14:45 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

The simplest solution is to use the same method as employed by
Recentf mode.  It maintains the list of recently opened files,
no matter what user-level command visited them, and doesn't include
automatically processed files.  It seems that users of Recentf
mode are satisfied with its file list.  So the same method could be
used to add recently opened files to the file name history.

To update the list of recently opened files, Recentf mode puts
the function `recentf-track-opened-file' in `find-file-hook'.
The following code does the same to add recently opened files
to the history:

(add-hook 'find-file-hook 'add-file-name-to-history)

(defun add-file-name-to-history ()
  "Add the name of the file just opened to the history."
  (when (and buffer-file-name
             (or (null file-name-history)
                 (not (equal buffer-file-name (car file-name-history)))))
    (if history-delete-duplicates (delete buffer-file-name file-name-history))
    (setq file-name-history (cons buffer-file-name file-name-history))))

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]