emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-program-exists vs executable-find
@ 2012-04-18 12:46 Sebastien Vauban
  2012-04-18 13:25 ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastien Vauban @ 2012-04-18 12:46 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

While browsing the Org code, I've found the function `org-program-exists':

#+begin_src emacs-lisp
  (defun org-program-exists (program-name)
    "Checks whenever we can locate program and launch it."
    (if (member system-type '(gnu/linux darwin))
        (= 0 (call-process "which" nil nil nil program-name))))
#+end_src

It is used 3 times in `org-clock.el', nowhere else.

On the contrary, `executable-find' is used 10 times in the Org code base (in
4 different libraries).

Shouldn't we better use `executable-find' everywhere, instead of
`org-program-exists' (which, btw, fails on Windows systems, even when they
have the Cygwin `which' at their disposal)?

I'm ready to submit a patch for this.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: org-program-exists vs executable-find
  2012-04-18 12:46 org-program-exists vs executable-find Sebastien Vauban
@ 2012-04-18 13:25 ` Bastien
  2012-04-18 14:39   ` Sebastien Vauban
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-04-18 13:25 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Hi Sébastien,

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

> While browsing the Org code, I've found the function `org-program-exists':
>
> #+begin_src emacs-lisp
>   (defun org-program-exists (program-name)
>     "Checks whenever we can locate program and launch it."
>     (if (member system-type '(gnu/linux darwin))
>         (= 0 (call-process "which" nil nil nil program-name))))
> #+end_src
>
> It is used 3 times in `org-clock.el', nowhere else.

The name `org-program-exists' is actually misleading, it should be
`org-executable-call' instead, while still checking if the executable
exists before calling it.

> On the contrary, `executable-find' is used 10 times in the Org code base (in
> 4 different libraries).
>
> Shouldn't we better use `executable-find' everywhere, instead of
> `org-program-exists' (which, btw, fails on Windows systems, even when they
> have the Cygwin `which' at their disposal)?
>
> I'm ready to submit a patch for this.

Please submit a patch using `executable-find' in `org-executable-call'.
̀executable-find' takes care of (gnu/linux|darwin-windows).  Also add an
alias org-program-exists -> org-executable-call in case people are using 
org-program-exists in their programs.

Thanks!

-- 
 Bastien

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

* Re: org-program-exists vs executable-find
  2012-04-18 13:25 ` Bastien
@ 2012-04-18 14:39   ` Sebastien Vauban
  2012-04-20 11:22     ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastien Vauban @ 2012-04-18 14:39 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Bastien,

Bastien wrote:
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>
>> While browsing the Org code, I've found the function `org-program-exists':
>>
>> #+begin_src emacs-lisp
>>   (defun org-program-exists (program-name)
>>     "Checks whenever we can locate program and launch it."
>>     (if (member system-type '(gnu/linux darwin))
>>         (= 0 (call-process "which" nil nil nil program-name))))
>> #+end_src
>>
>> It is used 3 times in `org-clock.el', nowhere else.
>
> The name `org-program-exists' is actually misleading, it should be
> `org-executable-call' instead, while still checking if the executable exists
> before calling it.

Nope, the name is not misleading. The documentation string is false -- what I
hadn't noticed, btw.

That function just checks if the executable can be found; it does _not_ call
it afterward.

On Linux and Mac OS, it just calls "which + <program name>", no more...
On Windows, it simply fails immediately (even if the program could be found).

>> On the contrary, `executable-find' is used 10 times in the Org code base
>> (in 4 different libraries).
>>
>> Shouldn't we better use `executable-find' everywhere, instead of
>> `org-program-exists' (which, btw, fails on Windows systems, even when they
>> have the Cygwin `which' at their disposal)?
>>
>> I'm ready to submit a patch for this.
>
> Please submit a patch using `executable-find' in `org-executable-call'.
> ̀executable-find' takes care of (gnu/linux|darwin-windows). Also add an alias
> org-program-exists -> org-executable-call in case people are using
> org-program-exists in their programs.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: org-program-exists vs executable-find
  2012-04-18 14:39   ` Sebastien Vauban
@ 2012-04-20 11:22     ` Bastien
  2012-04-20 20:24       ` Sebastien Vauban
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-04-20 11:22 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Hi Sébastien,

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

>> The name `org-program-exists' is actually misleading, it should be
>> `org-executable-call' instead, while still checking if the executable exists
>> before calling it.
>
> Nope, the name is not misleading. The documentation string is false -- what I
> hadn't noticed, btw.
>
> That function just checks if the executable can be found; it does _not_ call
> it afterward.

You're right, I just fixed the docstring.

> On Linux and Mac OS, it just calls "which + <program name>", no more...
> On Windows, it simply fails immediately (even if the program could be found).

If there is an equivalent of `which' on windows let me know, we can
generalize this function.

Thanks,

-- 
 Bastien

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

* Re: org-program-exists vs executable-find
  2012-04-20 11:22     ` Bastien
@ 2012-04-20 20:24       ` Sebastien Vauban
  2012-04-20 20:42         ` Martyn Jago
                           ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Sebastien Vauban @ 2012-04-20 20:24 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Bastien,

Bastien wrote:
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>
>>> The name `org-program-exists' is actually misleading, it should be
>>> `org-executable-call' instead, while still checking if the executable
>>> exists before calling it.
>>
>> Nope, the name is not misleading. The documentation string is false -- what
>> I hadn't noticed, btw.
>>
>> That function just checks if the executable can be found; it does _not_
>> call it afterward.
>
> You're right, I just fixed the docstring.
>
>> On Linux and Mac OS, it just calls "which + <program name>", no more... On
>> Windows, it simply fails immediately (even if the program could be found).
>
> If there is an equivalent of `which' on windows let me know,

Not that I know, reason why I (must) have Cygwin...

> we can generalize this function.

Why not replacing it simply by `executable-find': I don't see what it adds to
it?  I would not say so if it was some upper abstraction, but I do feel
they're simply the same.

If not, the opposite should be done: replacing the 10 calls to
`executable-find' by calls to `org-program-exists'...

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: org-program-exists vs executable-find
  2012-04-20 20:24       ` Sebastien Vauban
@ 2012-04-20 20:42         ` Martyn Jago
  2012-04-21 10:13         ` Achim Gratz
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Martyn Jago @ 2012-04-20 20:42 UTC (permalink / raw)
  To: emacs-orgmode

Hi

"Sebastien Vauban"
<wxhgmqzgwmuf@spammotel.com> writes:

> Hi Bastien,
>
> Bastien wrote:
>> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>>
>>>> The name `org-program-exists' is actually misleading, it should be
>>>> `org-executable-call' instead, while still checking if the executable
>>>> exists before calling it.
>>>
>>> Nope, the name is not misleading. The documentation string is false -- what
>>> I hadn't noticed, btw.
>>>
>>> That function just checks if the executable can be found; it does _not_
>>> call it afterward.
>>
>> You're right, I just fixed the docstring.
>>
>>> On Linux and Mac OS, it just calls "which + <program name>", no more... On
>>> Windows, it simply fails immediately (even if the program could be found).
>>
>> If there is an equivalent of `which' on windows let me know,
>
> Not that I know, reason why I (must) have Cygwin...
>
>> we can generalize this function.
>
> Why not replacing it simply by `executable-find': I don't see what it adds to
> it?  I would not say so if it was some upper abstraction, but I do feel
> they're simply the same.
>
> If not, the opposite should be done: replacing the 10 calls to
> `executable-find' by calls to `org-program-exists'...
>
> Best regards,
>   Seb

IIRC on Mac OS `which' is not guaranteed to work anyway, since by default
the `which database' is not instantiated or maintained. I had to kick that
off manually here to have use of `which'.

Best, Martyn

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

* Re: org-program-exists vs executable-find
  2012-04-20 20:24       ` Sebastien Vauban
  2012-04-20 20:42         ` Martyn Jago
@ 2012-04-21 10:13         ` Achim Gratz
  2012-04-28 21:44         ` Bastien
  2012-06-14 13:05         ` Giovanni Ridolfi
  3 siblings, 0 replies; 9+ messages in thread
From: Achim Gratz @ 2012-04-21 10:13 UTC (permalink / raw)
  To: emacs-orgmode

Sebastien Vauban writes:
> Why not replacing it simply by `executable-find': I don't see what it
> adds to it?  I would not say so if it was some upper abstraction, but
> I do feel they're simply the same.

In principle, executable-find should (only) be used if the program in
question is called directly from Emacs.  If you invoke a shell to call a
program, then that shell might have a completely different idea of what
your path is and see different executables, so you'd have to check via
the shell in this instance or provide the full absolute filename that
executable-find gave you to the shell (which may have other problems
when the path in Emacs and shell are indeed different).


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

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

* Re: org-program-exists vs executable-find
  2012-04-20 20:24       ` Sebastien Vauban
  2012-04-20 20:42         ` Martyn Jago
  2012-04-21 10:13         ` Achim Gratz
@ 2012-04-28 21:44         ` Bastien
  2012-06-14 13:05         ` Giovanni Ridolfi
  3 siblings, 0 replies; 9+ messages in thread
From: Bastien @ 2012-04-28 21:44 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



"Sebastien Vauban"
<wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:

> Why not replacing it simply by `executable-find': I don't see what it
> adds to it?  I would not say so if it was some upper abstraction, but
> I do feel they're simply the same.

Actually `executable-find' is faster and already available, so yes, I
removed ̀org-program-exists'.

Thanks!

-- 
 Bastien

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

* Re: org-program-exists vs executable-find
  2012-04-20 20:24       ` Sebastien Vauban
                           ` (2 preceding siblings ...)
  2012-04-28 21:44         ` Bastien
@ 2012-06-14 13:05         ` Giovanni Ridolfi
  3 siblings, 0 replies; 9+ messages in thread
From: Giovanni Ridolfi @ 2012-06-14 13:05 UTC (permalink / raw)
  To: Sebastien Vauban, emacs-orgmode@gnu.org; +Cc: Bastien G

Da: Sebastien Vauban <wxhgmqzgwmuf@spammotel.com>
Inviato: Venerdì 20 Aprile 2012 22:24


> Bastien wrote:
>> If there is an equivalent of `which' on windows let me know,
> Not that I know 


the command where [1][2]
cheers,
Giovanni


[1] http://stackoverflow.com/questions/304319/is-there-an-equivalent-of-which-on-windows

[2] http://superuser.com/questions/207707/what-is-windows-equivalent-of-which-command-in-linux-is-there-is-equivalent

Some versions of Windows (I think Windows 2003 and up) have the where command:
c:\>where ping
C:\Windows\System32\PING.EXE

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

end of thread, other threads:[~2012-06-14 13:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-18 12:46 org-program-exists vs executable-find Sebastien Vauban
2012-04-18 13:25 ` Bastien
2012-04-18 14:39   ` Sebastien Vauban
2012-04-20 11:22     ` Bastien
2012-04-20 20:24       ` Sebastien Vauban
2012-04-20 20:42         ` Martyn Jago
2012-04-21 10:13         ` Achim Gratz
2012-04-28 21:44         ` Bastien
2012-06-14 13:05         ` Giovanni Ridolfi

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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