gnu-emacs-sources
[Top][All Lists]
Advanced

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

Re: Access recent files menu from minibuffer


From: David Ponce
Subject: Re: Access recent files menu from minibuffer
Date: Thu, 16 Mar 2006 20:33:03 +0100
User-agent: Thunderbird 1.5.0.2 (X11/20060312)

Drew Adams wrote:
    As pointed out in the Emacs wiki, recentf.el lacks a minibuffer
    interface, and several ways of accessing recent files from the
    minibuffer are presented there (see
    http://www.emacswiki.org/cgi-bin/wiki/RecentFiles).

FYI - I have added your code to that Web page. Thanks. Please consider
posting it as a library to both address@hidden and
http://www.emacswiki.org/cgi-bin/wiki/ElispArea.

    These all use just the unstructured recentf-list. But one of the
    features of recentf.el that I find most useful is the possibility
    of filtering recentf-list and structuring the recent file menu in
    accordance with the filter.

Here is another possible implementation I use:

(defun my-recentf-open-file-from-minibuffer (&optional arg)
  "Open a recent file from the minibuffer, with completion.
Prompt for an item of the recentf menu, until a file is selected.
By default, consider only the `recentf-max-menu-items' most recent
files.  \\[universal-argument] \\[my-recentf-complete] consider all
files.  With optional argument ARG a positive integer, consider the
ARG most recent files."
  (interactive "P")
  (let* ((pr recentf-menu-title)
         (tb (recentf-apply-menu-filter
              recentf-menu-filter
              (mapcar 'recentf-make-default-menu-element
                      (cond
                       ((null arg)
                        (recentf-elements recentf-max-menu-items))
                       ((natnump arg)
                        (recentf-elements arg))
                       (recentf-list)))))
         (e (assoc (completing-read (concat pr ": ") tb nil t) tb)))
    (while (and (consp e) (consp (cdr e)))
      (setq tb (cdr e)
            pr (concat pr "/" (car e))
            e (assoc (completing-read (concat pr ": ") tb nil t) tb)))
    (when (and (consp e) (stringp (cdr e)))
      (funcall recentf-menu-action (cdr e)))))

David



reply via email to

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