From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: How to load recentf only after opening/saving a file for the firsttime? Date: Fri, 7 Sep 2012 07:34:19 -0700 Message-ID: <28B2EAF7CF5C4D9D8315286C73552765@us.oracle.com> References: <80txvarlnv.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347028480 32639 80.91.229.3 (7 Sep 2012 14:34:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Sep 2012 14:34:40 +0000 (UTC) To: "'Sebastien Vauban'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 07 16:34:42 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T9zdn-0004ck-NN for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Sep 2012 16:34:39 +0200 Original-Received: from localhost ([::1]:58787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9zdk-0004xk-LB for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Sep 2012 10:34:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9zdb-0004xH-Md for help-gnu-emacs@gnu.org; Fri, 07 Sep 2012 10:34:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9zda-0007yb-Kf for help-gnu-emacs@gnu.org; Fri, 07 Sep 2012 10:34:27 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:30549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9zda-0007yW-E2 for help-gnu-emacs@gnu.org; Fri, 07 Sep 2012 10:34:26 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q87EYO7A018428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 14:34:25 GMT Original-Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q87EYNCl028791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 7 Sep 2012 14:34:23 GMT Original-Received: from abhmt101.oracle.com (abhmt101.oracle.com [141.146.116.53]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q87EYN47003573; Fri, 7 Sep 2012 09:34:23 -0500 Original-Received: from dradamslap1 (/71.202.147.44) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Sep 2012 07:34:23 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <80txvarlnv.fsf@somewhere.org> Thread-Index: Ac2M/7S2KKXCGBOrSBm9ZaEg00drSQABOpCA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 148.87.113.117 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:86684 Archived-At: > 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.