From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: How to avoid loading file when just testing if function is bound? Date: Mon, 02 Apr 2012 14:53:25 +0200 Organization: Sebastien Vauban Message-ID: <80hax2uwfu.fsf@somewhere.org> References: <80limempbs.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1333371314 5698 80.91.229.3 (2 Apr 2012 12:55:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 2 Apr 2012 12:55:14 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Mon Apr 02 14:55:14 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 1SEgmw-0002Qb-09 for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Apr 2012 14:55:14 +0200 Original-Received: from localhost ([::1]:44030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEgmv-0003Cr-Aj for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Apr 2012 08:55:13 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news.dfn.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Injection-Info: mx04.eternal-september.org; posting-host="No+jx9xcG75RY5G9Zb0asg"; logging-data="19684"; mail-complaints-to="abuse-VVbKFVtnif8H+i2N2EyTrmui9UKz+5OX@public.gmane.org"; posting-account="U2FsdGVkX18DgU8mPu94XWvJBBSKP8aY" User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.0.94 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:JNSYiynSgrfmWKQ9DCcr8SN2rNM= sha1:9SGMV9vWmyhWAJ4yYV2s+kxPA4w= X-Url: Under construction... Original-Xref: usenet.stanford.edu gnu.emacs.help:191833 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.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-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:84248 Archived-At: Hi Michael, Michael Albinus wrote: > "Sebastien Vauban" > writes: > >> Hi, > > Hi, > >> For the purpose of asking whether I eventually need to clock out (from Org) >> before exiting Emacs, I've written this chunk of code: >> >> --8<---------------cut here---------------start------------->8--- >> (if (and (fboundp 'org-clocking-p) >> (org-clocking-p) >> (y-or-n-p "You are currently clocking time, clock out? ")) >> (org-clock-out) >> t)) >> --8<---------------cut here---------------end--------------->8--- >> >> The problem is that if Org is not yet loaded, the above code does load it >> (because `org-clocking-p' is autoloaded) -- and that takes a while... and I >> just wanted to exit Emacs... >> >> How to avoid this? > > You could check whether `org-clocking-p' has still the 'autoload > property. It is a list then. Something like this (untested): > > (if (and (fboundp 'org-clocking-p) > (not (listp (symbol-function 'org-clocking-p))) > (org-clocking-p)) It's no better with: --8<---------------cut here---------------start------------->8--- (if (and (not (listp (symbol-function 'org-clocking-p))) (org-clocking-p) (y-or-n-p "You are currently clocking time, clock out? ")) (org-clock-out) t)) --8<---------------cut here---------------end--------------->8--- Note that I removed `fboundp' from your example, as that does load Org immediately, if present. Best regards, Seb -- Sebastien Vauban