* default value of file-name-history
@ 2003-09-19 10:12 Masatake YAMATO
2003-09-19 16:40 ` Kevin Rodgers
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Masatake YAMATO @ 2003-09-19 10:12 UTC (permalink / raw)
How do you think initialize file-name-history with the
value of `recentf-list'? So you can do C-x C-f M-p M-p M-p...
just after launching emacs.
(M-x describe-variable recentf-list: "List of recently opened files.")
Masatake YAMATO
Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.620
diff -u -r1.620 simple.el
--- lisp/simple.el 8 Sep 2003 08:01:41 -0000 1.620
+++ lisp/simple.el 19 Sep 2003 10:09:24 -0000
@@ -900,10 +900,23 @@
elt))
(goto-char (or minibuffer-temporary-goal-position (point-max))))))
+(defvar previous-history-element-used-recentf nil)
(defun previous-history-element (n)
"Inserts the previous element of the minibuffer history into the minibuffer."
(interactive "p")
- (next-history-element (- n)))
+ (let (result)
+ (unwind-protect
+ (setq result (next-history-element (- n)))
+ (if (and (= 0 (length (symbol-value minibuffer-history-variable)))
+ (eq minibuffer-history-variable 'file-name-history)
+ (not previous-history-element-used-recentf))
+ (progn (require 'recentf)
+ (recentf-load-list)
+ (setq previous-history-element-used-recentf t
+ file-name-history (mapcar
+ 'abbreviate-file-name
+ recentf-list))))
+ result)))
(defun next-complete-history-element (n)
"Get next history element which completes the minibuffer before the point.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: default value of file-name-history
2003-09-19 10:12 default value of file-name-history Masatake YAMATO
@ 2003-09-19 16:40 ` Kevin Rodgers
2003-09-19 17:00 ` Henrik Enberg
2003-09-20 5:43 ` Masatake YAMATO
2003-09-19 16:57 ` Stefan Monnier
2003-09-19 23:11 ` Stefan Daschek
2 siblings, 2 replies; 9+ messages in thread
From: Kevin Rodgers @ 2003-09-19 16:40 UTC (permalink / raw)
Masatake YAMATO wrote:
> How do you think initialize file-name-history with the
> value of `recentf-list'? So you can do C-x C-f M-p M-p M-p...
> just after launching emacs.
Please, not unless the user already has recentf-mode turned on!
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: default value of file-name-history
2003-09-19 16:40 ` Kevin Rodgers
@ 2003-09-19 17:00 ` Henrik Enberg
2003-09-20 5:43 ` Masatake YAMATO
1 sibling, 0 replies; 9+ messages in thread
From: Henrik Enberg @ 2003-09-19 17:00 UTC (permalink / raw)
Cc: emacs-devel
Kevin Rodgers <ihs_4664@yahoo.com> writes:
> Masatake YAMATO wrote:
>
>> How do you think initialize file-name-history with the value of
>> recentf-list'? So you can do C-x C-f M-p M-p M-p...
>> just after launching emacs.
>
> Please, not unless the user already has recentf-mode turned on!
Or if desktop.el has saved values.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: default value of file-name-history
2003-09-19 16:40 ` Kevin Rodgers
2003-09-19 17:00 ` Henrik Enberg
@ 2003-09-20 5:43 ` Masatake YAMATO
2003-09-20 7:20 ` David Ponce
1 sibling, 1 reply; 9+ messages in thread
From: Masatake YAMATO @ 2003-09-20 5:43 UTC (permalink / raw)
Cc: emacs-devel
> > How do you think initialize file-name-history with the
> > value of `recentf-list'? So you can do C-x C-f M-p M-p M-p...
> > just after launching emacs.
>
> Please, not unless the user already has recentf-mode turned on!
How about this one?
Masatake YAMATO
Index: lisp/recentf.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/recentf.el,v
retrieving revision 1.27
diff -u -r1.27 recentf.el
--- lisp/recentf.el 15 Sep 2003 16:24:35 -0000 1.27
+++ lisp/recentf.el 20 Sep 2003 05:39:28 -0000
@@ -251,6 +251,13 @@
If it returns nil, the filename is left unchanged."
:group 'recentf
:type 'function)
+
+(defcustom recentf-install-to-file-name-history t
+ "Use the `recentf-list' as the initial value of `file-name-history' or not.
+If non-nil and `file-name-history' is empty, use `recentf-list' as its initial.
+Else do nothing."
+ :group 'recentf
+ :type 'boolean)
\f
;;; Utilities
;;
@@ -1161,6 +1168,14 @@
(setq recentf-list (nreverse newlist))
(message "Cleaning up the recentf list...done")))
+(defun recentf-install-to-file-name-history ()
+ "Use the value of `recentf-list' as the initial value for `file-name-history'.
+If `file-name-history' is not empty, do nothing."
+ (when (= 0 (length file-name-history))
+ (setq file-name-history (mapcar
+ 'abbreviate-file-name
+ recentf-list))))
+
;;;###autoload
(define-minor-mode recentf-mode
"Toggle recentf mode.
@@ -1173,7 +1188,9 @@
:group 'recentf
(unless (and recentf-mode (recentf-enabled-p))
(if recentf-mode
- (recentf-load-list)
+ (progn (recentf-load-list)
+ (if recentf-install-to-file-name-history
+ (recentf-install-to-file-name-history)))
(recentf-save-list))
(recentf-auto-cleanup)
(recentf-clear-data)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: default value of file-name-history
2003-09-19 10:12 default value of file-name-history Masatake YAMATO
2003-09-19 16:40 ` Kevin Rodgers
@ 2003-09-19 16:57 ` Stefan Monnier
2003-09-19 23:11 ` Stefan Daschek
2 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2003-09-19 16:57 UTC (permalink / raw)
Cc: emacs-devel
> How do you think initialize file-name-history with the
> value of `recentf-list'? So you can do C-x C-f M-p M-p M-p...
> just after launching emacs.
Sounds good, but it should be done in recentf.el, not in simple.el.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: default value of file-name-history
2003-09-19 10:12 default value of file-name-history Masatake YAMATO
2003-09-19 16:40 ` Kevin Rodgers
2003-09-19 16:57 ` Stefan Monnier
@ 2003-09-19 23:11 ` Stefan Daschek
2003-09-20 2:13 ` Miles Bader
2003-09-20 21:27 ` Richard Stallman
2 siblings, 2 replies; 9+ messages in thread
From: Stefan Daschek @ 2003-09-19 23:11 UTC (permalink / raw)
Masatake YAMATO <jet@gyve.org> writes:
> How do you think initialize file-name-history with the
> value of `recentf-list'? So you can do C-x C-f M-p M-p M-p...
> just after launching emacs.
Funny, I had exactly the same idea some days ago and thus added the
following to my .emacs:
(require 'recentf)
(setq file-name-history (append recentf-list file-name-history))
I also wanted files opened via Drag'n'Drop or emacsclient to
appear in file-name-history:
(add-hook 'find-file-hook (defun nq-find-file-add-to-history-hook ()
(when (and (buffer-file-name)
(not (member (buffer-file-name) file-name-history)))
(push (buffer-file-name) file-name-history))))
Well, everything seems to work as it should and I'm really happy :-)
ciao,
noniq
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-09-20 21:27 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-19 10:12 default value of file-name-history Masatake YAMATO
2003-09-19 16:40 ` Kevin Rodgers
2003-09-19 17:00 ` Henrik Enberg
2003-09-20 5:43 ` Masatake YAMATO
2003-09-20 7:20 ` David Ponce
2003-09-19 16:57 ` Stefan Monnier
2003-09-19 23:11 ` Stefan Daschek
2003-09-20 2:13 ` Miles Bader
2003-09-20 21:27 ` Richard Stallman
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.