unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* recentf improvement
@ 2003-09-20 21:27 Richard Stallman
  2003-09-20 22:47 ` David Ponce
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2003-09-20 21:27 UTC (permalink / raw)
  Cc: Masatake YAMATO, emacs-devel

This looks good to me.  David, what do you think?

Date: Sat, 20 Sep 2003 14:43:53 +0900 (JST)
To: ihs_4664@yahoo.com
From: Masatake YAMATO <jet@gyve.org>
In-Reply-To: <3F6B318E.2000903@yahoo.com>
Cc: emacs-devel@gnu.org
Subject: Re: default value of file-name-history
Sender: emacs-devel-bounces+rms=gnu.org@gnu.org

> > 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)


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: recentf improvement
@ 2003-09-22  6:58 David PONCE
  0 siblings, 0 replies; 11+ messages in thread
From: David PONCE @ 2003-09-22  6:58 UTC (permalink / raw)
  Cc: emacs-devel

Hi Richard,

>     Finally, I don't see the point of calling `abbreviate-file-name' on
>     every recent file before copying them to file-name-history?
> 
> That is so the names in the history will be more concise.
> I think this is desirable, so I think you should put that call
> back in.

OK, here is a new patch.

David

Index: lisp/recentf.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/recentf.el,v
retrieving revision 1.27
diff -c -r1.27 recentf.el
*** lisp/recentf.el	15 Sep 2003 16:24:35 -0000	1.27
--- lisp/recentf.el	22 Sep 2003 06:52:58 -0000
***************
*** 240,245 ****
--- 240,251 ----
             ;; Unavailable until recentf has been loaded.
             (recentf-auto-cleanup))))
  
+ (defcustom recentf-initialize-file-name-history t
+   "*non-nil means to initialize `file-name-history' with the recent list.
+ If `file-name-history' is not empty, do nothing."
+   :group 'recentf
+   :type  'boolean)
+ 
  (defcustom recentf-load-hook nil
     "*Normal hook run at end of loading the `recentf' package."
    :group 'recentf
***************
*** 1143,1153 ****
  
  (defun recentf-load-list ()
    "Load a previously saved recent list.
! Read data from the file specified by `recentf-save-file'."
    (interactive)
    (let ((file (expand-file-name recentf-save-file)))
      (when (file-readable-p file)
!       (load-file file))))
  
  (defun recentf-cleanup ()
    "Remove all excluded or non-readable files from the recent list."
--- 1149,1165 ----
  
  (defun recentf-load-list ()
    "Load a previously saved recent list.
! Read data from the file specified by `recentf-save-file'.
! When `recentf-initialize-file-name-history' is non-nil, initialize an
! empty `file-name-history' with the recent list."
    (interactive)
    (let ((file (expand-file-name recentf-save-file)))
      (when (file-readable-p file)
!       (load-file file)
!       (and recentf-initialize-file-name-history
!            (not file-name-history)
!            (setq file-name-history (mapcar 'abbreviate-file-name
!                                            recentf-list))))))
  
  (defun recentf-cleanup ()
    "Remove all excluded or non-readable files from the recent list."

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

end of thread, other threads:[~2003-09-22  6:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-20 21:27 recentf improvement Richard Stallman
2003-09-20 22:47 ` David Ponce
2003-09-20 23:07   ` Miles Bader
2003-09-21  7:00     ` David Ponce
2003-09-21  6:40   ` Masatake YAMATO
2003-09-21  6:50     ` David Ponce
2003-09-21  7:03       ` Masatake YAMATO
2003-09-21  7:35         ` David Ponce
2003-09-21 22:34       ` Richard Stallman
2003-09-21 22:33   ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2003-09-22  6:58 David PONCE

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).