help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to load recentf only after opening/saving a file for the firstti


From: Drew Adams
Subject: RE: How to load recentf only after opening/saving a file for the firsttime?
Date: Fri, 7 Sep 2012 07:34:19 -0700

> I guess the right time to require recentf is the first time 
> we open or save a file.
> Though, for opening, the only hook available is run after 
> find-file, so too late to save the first opened file, it seems.
> What would be a correct way to delay the require of recentf?

So you want recentf to be loaded when you use any command that might visit a
file?  There is no way to know (absolutely) what all those commands might be.

You could certainly use `find-file-hook' to load recentf _after_ the first file
visit.  Or `(before|after)-save-hook' to do so before/after the first save.

Of if you limit yourself to a known set of file-visiting commands then you could
do what you want on `pre-command-hook', testing for those commands.  But that
seems a bit heavy-handed.

Or if you want this only for some particular command (e.g. `file-file') that you
use often, then you could define your own version (e.g. `my-find-file') that
does (require 'recentf nil t) as part of the `interactive' spec.

All that said, I cannot imagine using Emacs interactively without ever using a
file-visiting command!  So I cannot imagine why, if you want recentf for such
commands, you do not just load recentf from the get-go, in your .emacs.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]