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-20 21:27 recentf improvement Richard Stallman
@ 2003-09-20 22:47 ` David Ponce
  2003-09-20 23:07   ` Miles Bader
                     ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: David Ponce @ 2003-09-20 22:47 UTC (permalink / raw)
  Cc: emacs-devel

Hi,

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

I would prefer to rename `recentf-install-to-file-name-history' to
`recentf-init-file-name-history'.  I found that name clearer.

Also, IMO, it is better to handle initialization of the
file-name-history just after the recent list is loaded, that is in
function `recentf-load-list'.

Finally, I don't see the point of calling `abbreviate-file-name' on
every recent file before copying them to file-name-history?

So I suggest you this simplified patch.

David

2003-09-21  David Ponce  <david@dponce.com>

	* recentf.el (recentf-init-file-name-history): New option.
	(recentf-load-list): Initialize file-name-history if necessary.

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	20 Sep 2003 22:30:10 -0000
***************
*** 240,245 ****
--- 240,251 ----
              ;; Unavailable until recentf has been loaded.
              (recentf-auto-cleanup))))

+ (defcustom recentf-init-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,1164 ----

   (defun recentf-load-list ()
     "Load a previously saved recent list.
! Read data from the file specified by `recentf-save-file'.
! When `recentf-init-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-init-file-name-history
!            (not file-name-history)
!            (setq file-name-history 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

* Re: recentf improvement
  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 22:33   ` Richard Stallman
  2 siblings, 1 reply; 11+ messages in thread
From: Miles Bader @ 2003-09-20 23:07 UTC (permalink / raw)
  Cc: rms, emacs-devel

On Sun, Sep 21, 2003 at 12:47:51AM +0200, David Ponce wrote:
> I would prefer to rename `recentf-install-to-file-name-history' to
> `recentf-init-file-name-history'.  I found that name clearer.

I agree, but `initialize' is even clearer than `init' (especially to
non-programmers); using it also avoids embedding the term `init-file' in the
name (`init-file' is a common idiom that's wrong in this context).

The name's so long already it hardly makes a difference in that respect.. :-)

-Miles
-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff

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

* Re: recentf improvement
  2003-09-20 22:47 ` David Ponce
  2003-09-20 23:07   ` Miles Bader
@ 2003-09-21  6:40   ` Masatake YAMATO
  2003-09-21  6:50     ` David Ponce
  2003-09-21 22:33   ` Richard Stallman
  2 siblings, 1 reply; 11+ messages in thread
From: Masatake YAMATO @ 2003-09-21  6:40 UTC (permalink / raw)
  Cc: rms, emacs-devel

David Ponce <david.ponce@wanadoo.fr>:
> Finally, I don't see the point of calling `abbreviate-file-name' on
> every recent file before copying them to file-name-history?

I have no strong opinion about this.  I added it because it is easier
for me to read an abosolute path than a relative path against home
directory.

Masatake YAMATO

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

* Re: recentf improvement
  2003-09-21  6:40   ` Masatake YAMATO
@ 2003-09-21  6:50     ` David Ponce
  2003-09-21  7:03       ` Masatake YAMATO
  2003-09-21 22:34       ` Richard Stallman
  0 siblings, 2 replies; 11+ messages in thread
From: David Ponce @ 2003-09-21  6:50 UTC (permalink / raw)
  Cc: emacs-devel

>>Finally, I don't see the point of calling `abbreviate-file-name' on
>>every recent file before copying them to file-name-history?
> 
> 
> I have no strong opinion about this.  I added it because it is easier
> for me to read an abosolute path than a relative path against home
> directory.

`recentf-list' already contains absolute paths.

David

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

* Re: recentf improvement
  2003-09-20 23:07   ` Miles Bader
@ 2003-09-21  7:00     ` David Ponce
  0 siblings, 0 replies; 11+ messages in thread
From: David Ponce @ 2003-09-21  7:00 UTC (permalink / raw)
  Cc: emacs-devel

Hi,

 >>I would prefer to rename `recentf-install-to-file-name-history' to
 >>`recentf-init-file-name-history'.  I found that name clearer.
 >
 > I agree, but `initialize' is even clearer than `init' (especially to
 > non-programmers); using it also avoids embedding the term `init-file' in the
 > name (`init-file' is a common idiom that's wrong in this context).
 >
 > The name's so long already it hardly makes a difference in that respect.. :-)

Good suggestion.  Here is a new patch.

David

2003-09-21  David Ponce  <david@dponce.com>

	* recentf.el (recentf-initialize-file-name-history): New option.
	(recentf-load-list): Initialize file-name-history if necessary.

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	21 Sep 2003 06:54:19 -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,1164 ----

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

* Re: recentf improvement
  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
  1 sibling, 1 reply; 11+ messages in thread
From: Masatake YAMATO @ 2003-09-21  7:03 UTC (permalink / raw)
  Cc: emacs-devel

> >>Finally, I don't see the point of calling `abbreviate-file-name' on
> >>every recent file before copying them to file-name-history?
> > 
> > 
> > I have no strong opinion about this.  I added it because it is easier
> > for me to read an abosolute path than a relative path against home
> > directory.
> 
> `recentf-list' already contains absolute paths.

Sorry, I made a mistake.  What I'd like to say it is easier for me to
read a relative path against home directory than an abosolute path.

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

* Re: recentf improvement
  2003-09-21  7:03       ` Masatake YAMATO
@ 2003-09-21  7:35         ` David Ponce
  0 siblings, 0 replies; 11+ messages in thread
From: David Ponce @ 2003-09-21  7:35 UTC (permalink / raw)
  Cc: emacs-devel

> Sorry, I made a mistake.  What I'd like to say it is easier for me to
> read a relative path against home directory than an abosolute path.

I can understand that ;-)

However that seems not consistent with the way `file-name-history' is
updated internally, that is with absolute file names.

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

* Re: recentf improvement
  2003-09-20 22:47 ` David Ponce
  2003-09-20 23:07   ` Miles Bader
  2003-09-21  6:40   ` Masatake YAMATO
@ 2003-09-21 22:33   ` Richard Stallman
  2 siblings, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2003-09-21 22:33 UTC (permalink / raw)
  Cc: emacs-devel

    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.

I cannot install the patch--there seem to be collisions
of some sort.  Can someone else please install it?

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

* Re: recentf improvement
  2003-09-21  6:50     ` David Ponce
  2003-09-21  7:03       ` Masatake YAMATO
@ 2003-09-21 22:34       ` Richard Stallman
  1 sibling, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2003-09-21 22:34 UTC (permalink / raw)
  Cc: jet, emacs-devel

    `recentf-list' already contains absolute paths.

abbreviate-file-name does more than just make the file name absolute.
(expand-file-name does that.)  It also uses ~ when possible, and makes
other predefined abbreviations, to make a shorter absolute file name.

Note that `~/foo' is an absolute file name.
Just `foo' is a relative file name.
The names in file-name-history should be absolute;
the question is whether to convert them to shorter absolute forms.

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