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

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

Re: How to avoid loading file when just testing if function is bound?


From: Sebastien Vauban
Subject: Re: How to avoid loading file when just testing if function is bound?
Date: Mon, 02 Apr 2012 14:53:25 +0200
User-agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.0.94 (windows-nt)

Hi Michael,

Michael Albinus wrote:
> "Sebastien Vauban"
> <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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


reply via email to

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