[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Accessing recent file history
From: |
Mathias Dahl |
Subject: |
Re: Accessing recent file history |
Date: |
Thu, 05 Jan 2006 08:17:47 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt) |
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