unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Accessing recent file history
@ 2006-01-04 13:45 Mathias Dahl
  2006-01-04 14:30 ` Matt Hodges
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Mathias Dahl @ 2006-01-04 13:45 UTC (permalink / raw)



I want to write a small function to open files using iswitchb
functions, using the recent file names list as input. Somewhat similar
to what I do in the following defun:

(defun my-switch-to-bookmark (bname)
  "Interactively switch to bookmark as `iswitchb' does."
  (interactive (list (flet ((iswitchb-make-buflist
                             (default)
                             (require 'bookmark)
                             (setq iswitchb-buflist (bookmark-all-names))))
                       (iswitchb-read-buffer "Jump to bookmark: "))))
  (bookmark-jump bname))

So, I want something exactly like the above, but instead of
`bookmark-jump' I want to use `find-file' and instead of
`bookmark-all-names' I want to get hold of the file history.

The file history that I see in the File -> Open Recently Visited would
be best, but I guess the minibuffer history for `find-file' would work
too.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Accessing recent file history
  2006-01-04 13:45 Accessing recent file history Mathias Dahl
@ 2006-01-04 14:30 ` Matt Hodges
  2006-01-04 16:55 ` Henrik Enberg
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Matt Hodges @ 2006-01-04 14:30 UTC (permalink / raw)


>>>>> Mathias Dahl writes:

 > I want to write a small function to open files using iswitchb
 > functions, using the recent file names list as input. Somewhat
 > similar to what I do in the following defun:

Like using iswitchb-use-virtual-buffers, or something subtly
different?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Accessing recent file history
  2006-01-04 13:45 Accessing recent file history Mathias Dahl
  2006-01-04 14:30 ` Matt Hodges
@ 2006-01-04 16:55 ` Henrik Enberg
  2006-01-04 16:56 ` Drew Adams
       [not found] ` <mailman.21390.1136393858.20277.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 6+ messages in thread
From: Henrik Enberg @ 2006-01-04 16:55 UTC (permalink / raw)
  Cc: help-gnu-emacs

> The file history that I see in the File -> Open Recently Visited would
> be best,

`recentf-list'

> but I guess the minibuffer history for `find-file' would work too.

`file-name-history'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Accessing recent file history
  2006-01-04 13:45 Accessing recent file history Mathias Dahl
  2006-01-04 14:30 ` Matt Hodges
  2006-01-04 16:55 ` Henrik Enberg
@ 2006-01-04 16:56 ` Drew Adams
       [not found] ` <mailman.21390.1136393858.20277.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2006-01-04 16:56 UTC (permalink / raw)


    I want to write a small function to open files using iswitchb
    functions, using the recent file names list as input. Somewhat similar
    to what I do in the following defun:

    (defun my-switch-to-bookmark (bname)
      "Interactively switch to bookmark as `iswitchb' does."
      (interactive (list (flet ((iswitchb-make-buflist
                                 (default)
                                 (require 'bookmark)
                                 (setq iswitchb-buflist
    (bookmark-all-names))))
                           (iswitchb-read-buffer "Jump to bookmark: "))))
      (bookmark-jump bname))

    So, I want something exactly like the above, but instead of
    `bookmark-jump' I want to use `find-file' and instead of
    `bookmark-all-names' I want to get hold of the file history.

    The file history that I see in the File -> Open Recently Visited would
    be best, but I guess the minibuffer history for `find-file' would work
    too.

Use `recentf-list' (library recentf.el).
See `icicle-recent-file' for an example:
http://www.emacswiki.org/cgi-bin/wiki/icicles.el.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Accessing recent file history
       [not found] ` <mailman.21390.1136393858.20277.help-gnu-emacs@gnu.org>
@ 2006-01-04 21:06   ` Mathias Dahl
  2006-01-05  7:17     ` Mathias Dahl
  0 siblings, 1 reply; 6+ messages in thread
From: Mathias Dahl @ 2006-01-04 21:06 UTC (permalink / raw)


Henrik Enberg <henrik.enberg@telia.com> writes:

>> The file history that I see in the File -> Open Recently Visited would
>> be best,
>
> `recentf-list'

Sorry, I was mistaken, I am using session.el and almost forgot
that. Right now, I have two submenus in my File menu: "Open...recently
changed" and "Open...recently visited" and I now know that session
placed them there.

>> but I guess the minibuffer history for `find-file' would work too.
>
> `file-name-history'

Works, thanks!

 (defun my-open-recent-file (fname)
   "Interactively open recently opened file, using `file-name-history' as history"
   (interactive (list (flet ((iswitchb-make-buflist
                              (default)
                              (setq iswitchb-buflist file-name-history)))
                        (iswitchb-read-buffer "Open file: "))))
   (find-file fname))

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Accessing recent file history
  2006-01-04 21:06   ` Mathias Dahl
@ 2006-01-05  7:17     ` Mathias Dahl
  0 siblings, 0 replies; 6+ messages in thread
From: Mathias Dahl @ 2006-01-05  7:17 UTC (permalink / raw)


Mathias Dahl <brakjoller@gmail.com> writes:

>  (defun my-open-recent-file (fname)
>    "Interactively open recently opened file, using `file-name-history' as history"
>    (interactive (list (flet ((iswitchb-make-buflist
>                               (default)
>                               (setq iswitchb-buflist file-name-history)))
>                         (iswitchb-read-buffer "Open file: "))))
>    (find-file fname))

Also, here is a version handling the history from session.el too (or
both):

(defun my-open-recent-file (fname)
  "Using iswitchb, interactively open recently opened file.
Configure `my-open-recent-file-history-source' to control from
where to get the file name history."
  (interactive (list (flet ((iswitchb-make-buflist
                             (default)
                             (setq iswitchb-buflist 
                                   (my-open-recent-file-list))))
                       (iswitchb-read-buffer "Open file: "))))
  (find-file fname))

;; One could even add `bookmark-all-names', maybe filtering file names
;; only, to this...

(defcustom my-open-recent-file-history-source  'file-name-history
  "*Determines which history source `my-open-recent-file' uses.
>From session.el uses `seccion-file-alist' from session.el. Normal
file name history uses the file name history saved by
`find-file', saved in the variable `file-name-history'. Both will
smash the two options together and use both sources."
  :type '(choice :tag "Recent file name history source"
                 (const :tag "From session.el" session)
		 (const :tag "Normal file name history" file-name-history)
                 (const :tag "Both" both))
  :group 'files)

(defun my-open-recent-file-list ()
  (cond ((eq my-open-recent-file-history-source 'session)
         (mapcar
          (lambda (x)
            (car x))
          session-file-alist))
        ((eq my-open-recent-file-history-source 'file-name-history)
         file-name-history)
        ((eq my-open-recent-file-history-source 'both)
         ;; Not sure if I should sort this or maybe only get the
         ;; unique items in the list, but iswitchb seems to sort it
         ;; out nicely for me...
         (nconc
          (mapcar
           (lambda (x)
             (car x))
           session-file-alist)
         file-name-history))
        (t file-name-history)))

;; I don't use `frame-configuration-to-register'
(global-set-key (kbd "C-x r f") 'my-open-recent-file)

Enjoy!

/Mathias

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-01-05  7:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-04 13:45 Accessing recent file history Mathias Dahl
2006-01-04 14:30 ` Matt Hodges
2006-01-04 16:55 ` Henrik Enberg
2006-01-04 16:56 ` Drew Adams
     [not found] ` <mailman.21390.1136393858.20277.help-gnu-emacs@gnu.org>
2006-01-04 21:06   ` Mathias Dahl
2006-01-05  7:17     ` Mathias Dahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).