unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to avoid loading file when just testing if function is bound?
@ 2012-04-02  9:54 Sebastien Vauban
  2012-04-02 11:44 ` Peter Münster
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Sebastien Vauban @ 2012-04-02  9:54 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

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?

Best regards,
  Seb

-- 
Sebastien Vauban


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

* Re: How to avoid loading file when just testing if function is bound?
  2012-04-02  9:54 How to avoid loading file when just testing if function is bound? Sebastien Vauban
@ 2012-04-02 11:44 ` Peter Münster
       [not found] ` <mailman.337.1333367079.20052.help-gnu-emacs@gnu.org>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Peter Münster @ 2012-04-02 11:44 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, Apr 02 2012, Sebastien Vauban wrote:

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

Perhaps `featurep' can help here.

-- 
           Peter




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

* Re: How to avoid loading file when just testing if function is bound?
       [not found] ` <mailman.337.1333367079.20052.help-gnu-emacs@gnu.org>
@ 2012-04-02 11:54   ` Sebastien Vauban
  2012-04-02 13:38     ` Peter Münster
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2012-04-02 11:54 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Hello Peter,

Peter Münster wrote:
> On Mon, Apr 02 2012, Sebastien Vauban wrote:
>
>> 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...
>
> Perhaps `featurep' can help here.

Adjusted code block:

--8<---------------cut here---------------start------------->8---
  (if (and (featurep 'org-clock)
           (org-clocking-p)
	   (y-or-n-p "You are currently clocking time, clock out? "))
      (org-clock-out)
    t))
--8<---------------cut here---------------end--------------->8---

When reading your proposition, I thought it should be it... but no. It still
loads Org whenever quitting Emacs (before doing anything).

Any other idea?

Best regards,
  Seb

-- 
Sebastien Vauban


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

* Re: How to avoid loading file when just testing if function is bound?
  2012-04-02  9:54 How to avoid loading file when just testing if function is bound? Sebastien Vauban
  2012-04-02 11:44 ` Peter Münster
       [not found] ` <mailman.337.1333367079.20052.help-gnu-emacs@gnu.org>
@ 2012-04-02 12:10 ` Michael Albinus
       [not found] ` <mailman.340.1333368652.20052.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Albinus @ 2012-04-02 12:10 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-help-gnu-emacs-mXXj517/zsQ



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

> Best regards,
>   Seb

Best regards, Michael.




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

* Re: How to avoid loading file when just testing if function is bound?
       [not found] ` <mailman.340.1333368652.20052.help-gnu-emacs@gnu.org>
@ 2012-04-02 12:53   ` Sebastien Vauban
  0 siblings, 0 replies; 8+ messages in thread
From: Sebastien Vauban @ 2012-04-02 12:53 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Hi Michael,

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


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

* Re: How to avoid loading file when just testing if function is bound?
  2012-04-02 11:54   ` Sebastien Vauban
@ 2012-04-02 13:38     ` Peter Münster
  2012-04-02 13:48       ` Michael Albinus
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Münster @ 2012-04-02 13:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, Apr 02 2012, Sebastien Vauban wrote:

> Adjusted code block:
>
>   (if (and (featurep 'org-clock)
>            (org-clocking-p)
> 	   (y-or-n-p "You are currently clocking time, clock out? "))
>       (org-clock-out)
>     t))
>
> When reading your proposition, I thought it should be it... but no. It still
> loads Org whenever quitting Emacs (before doing anything).
>
> Any other idea?

On my system, (featurep 'org-clock) does not load anything. So I think,
the problem must be somewhere else. Did you try with edebug?

-- 
           Peter




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

* Re: How to avoid loading file when just testing if function is bound?
  2012-04-02 13:38     ` Peter Münster
@ 2012-04-02 13:48       ` Michael Albinus
  2012-04-02 14:02         ` Peter Münster
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Albinus @ 2012-04-02 13:48 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Münster <pmlists@free.fr> writes:

>> Adjusted code block:
>>
>>   (if (and (featurep 'org-clock)
>>            (org-clocking-p)
>> 	   (y-or-n-p "You are currently clocking time, clock out? "))
>>       (org-clock-out)
>>     t))
>>
>> When reading your proposition, I thought it should be it... but no. It still
>> loads Org whenever quitting Emacs (before doing anything).
>>
>> Any other idea?
>
> On my system, (featurep 'org-clock) does not load anything. So I think,
> the problem must be somewhere else. Did you try with edebug?

Maybe the mere existence of (org-clocking-p) in the if-clause causes the
autoload. What happens, if you use (funcall 'org-clocking-p) instead?

Best regards, Michael.



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

* Re: How to avoid loading file when just testing if function is bound?
  2012-04-02 13:48       ` Michael Albinus
@ 2012-04-02 14:02         ` Peter Münster
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Münster @ 2012-04-02 14:02 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, Apr 02 2012, Michael Albinus wrote:

>>>   (if (and (featurep 'org-clock)
>>>            (org-clocking-p)
>>> 	   (y-or-n-p "You are currently clocking time, clock out? "))
>>>       (org-clock-out)
>>>     t))
>
> Maybe the mere existence of (org-clocking-p) in the if-clause causes the
> autoload. What happens, if you use (funcall 'org-clocking-p) instead?

I've done `eval-region' on the whole if-clause, and org-clock was not
loaded.

-- 
           Peter




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

end of thread, other threads:[~2012-04-02 14:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-02  9:54 How to avoid loading file when just testing if function is bound? Sebastien Vauban
2012-04-02 11:44 ` Peter Münster
     [not found] ` <mailman.337.1333367079.20052.help-gnu-emacs@gnu.org>
2012-04-02 11:54   ` Sebastien Vauban
2012-04-02 13:38     ` Peter Münster
2012-04-02 13:48       ` Michael Albinus
2012-04-02 14:02         ` Peter Münster
2012-04-02 12:10 ` Michael Albinus
     [not found] ` <mailman.340.1333368652.20052.help-gnu-emacs@gnu.org>
2012-04-02 12:53   ` Sebastien Vauban

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