unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Suggestions for corrections to executable.el - use of PATHEXT
@ 2004-09-11  0:05 Lennart Borgman
  2004-09-11  1:07 ` Davis Herring
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2004-09-11  0:05 UTC (permalink / raw)


I believe there is an error in the definition of executable-binary-suffixes
in the w32 part. The environment var PATHEXT is not taken into account and
the order of the default suffixes is incorrect as far as I can see. There is
also a suffix ".btm" I do not know about.

This error is present in Emacs 21.3 and I do not know if it has been
corrected in CVS. Below is my fix to this error:

- Lennart

;; The PATHEXT environment variable defines the list of file
;; extensions checked by Windows NT when searching for an executable
;; file. Like the PATH variable, semi-colons separate individual items
;; in the PATHEXT variable. The default value of PATHEXT is
;; .COM;.EXE;.BAT;.CMD.

(defvar executable-binary-suffixes
  (if (memq system-type '(ms-dos windows-nt))
      (let ((pathext (getenv-internal "PATHEXT")))
 (if (eq nil pathext)
     '(".com" ".exe" ".bat" ".cmd")
   (split-string pathext ";")))
    '("")))

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

* Re: Suggestions for corrections to executable.el - use of PATHEXT
  2004-09-11  0:05 Suggestions for corrections to executable.el - use of PATHEXT Lennart Borgman
@ 2004-09-11  1:07 ` Davis Herring
  2004-09-11  1:20   ` Davis Herring
  0 siblings, 1 reply; 6+ messages in thread
From: Davis Herring @ 2004-09-11  1:07 UTC (permalink / raw)
  Cc: Emacs Devel

Tiny augmentation:

(defvar executable-binary-suffixes
  (if (memq system-type '(ms-dos windows-nt))
      (let ((pathext (getenv-internal "PATHEXT")))
        (if pathext
             (nconc (split-string pathext ";") '(""))
          '(".com" ".exe" ".bat" ".cmd" ".pif" "")))
    '("")))

(Indentation made into spaces; don't compare to nil with `eq'; add ".pif" 
and "".  I add back "" because with Cygwin, you have commands with no 
extension; if my assumption is wrong and `system-type' isn't set 
Windowsishly then, drop that entry.)

Davis Herring

-- 
This product is sold by volume, not by mass.  If it seems too dense or too 
sparse, it means mass-energy conversion has occurred during shipping.

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

* Re: Suggestions for corrections to executable.el - use of PATHEXT
  2004-09-11  1:07 ` Davis Herring
@ 2004-09-11  1:20   ` Davis Herring
  2004-09-11 11:40     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Davis Herring @ 2004-09-11  1:20 UTC (permalink / raw)
  Cc: Emacs Devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 467 bytes --]

If I'm going to contribute, let's do it usefully.  This is a patch against 
the CVS `bindings.el' (where `executable-binary-suffixes' has migrated and 
become `exec-suffixes').  I also have done my homework now and see that 
'cygwin is a valid `system-type', which means we don't need the ""s.

Enjoy,
Davis Herring

-- 
This product is sold by volume, not by mass.  If it seems too dense or too 
sparse, it means mass-energy conversion has occurred during shipping.

[-- Attachment #2: Patch for `exec-suffixes' in `bindings.el' --]
[-- Type: TEXT/PLAIN, Size: 648 bytes --]

diff -Nacr cvs/bindings.el new/bindings.el
*** cvs/bindings.el	2004-09-10 19:13:47.000000000 -0600
--- new/bindings.el	2004-09-10 19:16:26.000000000 -0600
***************
*** 535,541 ****
  (setq exec-suffixes
        (cond
         ((memq system-type '(ms-dos windows-nt))
! 	'(".exe" ".com" ".bat" ".cmd" ".btm" ""))
         (t
  	'(""))))
  
--- 535,544 ----
  (setq exec-suffixes
        (cond
         ((memq system-type '(ms-dos windows-nt))
! 	(let ((pathext (getenv-internal "PATHEXT")))
! 	  (if pathext
! 	      (split-string pathext ";")
! 	    '(".com" ".exe" ".bat" ".cmd" ".pif"))))
         (t
  	'(""))))
  

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Suggestions for corrections to executable.el - use of PATHEXT
  2004-09-11  1:20   ` Davis Herring
@ 2004-09-11 11:40     ` Eli Zaretskii
  2004-09-11 12:12       ` Jason Rumney
  2004-09-12 10:56       ` Lennart Borgman
  0 siblings, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2004-09-11 11:40 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> Date: Fri, 10 Sep 2004 19:20:17 -0600 (MDT)
> From: Davis Herring <herring@lanl.gov>
> Cc: Emacs Devel <emacs-devel@gnu.org>
> 
> If I'm going to contribute, let's do it usefully.  This is a patch against 
> the CVS `bindings.el' (where `executable-binary-suffixes' has migrated and 
> become `exec-suffixes').  I also have done my homework now and see that 
> 'cygwin is a valid `system-type', which means we don't need the ""s.

Thanks.

This is something for the Windows experts to respond; mine are just
questions and superficial comments.

First, I'm not sure we should look at PATHEXT.  That variable is AFAIK
looked at by the shell, so if we want Emacs behave _exactly_ like the
shell does, we should at least look at the value of SHELL and/or
ComSpec (and COMSPEC for older systems).  I mean, what if the user's
shell is Bash, which AFAIK doesn't look at PATHEXT at all?  And if the
shell is COMMAND.COM, then ".cmd" should not be in the list.  Etc.,
etc.

More generally, I'm not sure Emacs _should_ behave like a Windows
shell.  There's nothing wrong in expanding or improving on the shell's
functionality, especially since Windows shells are not too smart, even
on XP.  For example, ".btm" is the extension of 4DOS and 4NT
replacement shells; why shouldn't Emacs know about that, even if
PATHEXT doesn't include it?

As for Cygwin being part of the condition--do users of the
Cygwin-compiled Emacs really want to disregard Windows batch files?
If not, `cygwin' should be part of the condition.

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

* Re: Suggestions for corrections to executable.el - use of PATHEXT
  2004-09-11 11:40     ` Eli Zaretskii
@ 2004-09-11 12:12       ` Jason Rumney
  2004-09-12 10:56       ` Lennart Borgman
  1 sibling, 0 replies; 6+ messages in thread
From: Jason Rumney @ 2004-09-11 12:12 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

"Eli Zaretskii" <eliz@gnu.org> writes:

>> If I'm going to contribute, let's do it usefully.  This is a patch against 
>> the CVS `bindings.el' (where `executable-binary-suffixes' has migrated and 
>> become `exec-suffixes').  I also have done my homework now and see that 
>> 'cygwin is a valid `system-type', which means we don't need the ""s.

Cygwin is a valid system-type meaning an Emacs built for the cygwin
environment, but that does not mean that users of the native W32 Emacs
port do not want to run Cygwin shell scripts or commands. If it makes
sense for "" to be in exec-suffixes (I'm not sure that it does, but
someone who knows Cygwin better than I do can probably explain why it
is needed), then it should be in there, probably conditional on SHELL
being bash or sh.

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

* Re: Suggestions for corrections to executable.el - use of PATHEXT
  2004-09-11 11:40     ` Eli Zaretskii
  2004-09-11 12:12       ` Jason Rumney
@ 2004-09-12 10:56       ` Lennart Borgman
  1 sibling, 0 replies; 6+ messages in thread
From: Lennart Borgman @ 2004-09-12 10:56 UTC (permalink / raw)
  Cc: Emacs Devel

From: "Eli Zaretskii" <eliz@gnu.org>

> First, I'm not sure we should look at PATHEXT.  That variable is AFAIK
> looked at by the shell, so if we want Emacs behave _exactly_ like the
> shell does, we should at least look at the value of SHELL and/or
> ComSpec (and COMSPEC for older systems).  I mean, what if the user's
> shell is Bash, which AFAIK doesn't look at PATHEXT at all?  And if the
> shell is COMMAND.COM, then ".cmd" should not be in the list.  Etc.,
> etc.

PATHEXT is looked at by cmd.exe (the default shell on the NT hereditary
line). I do not know if it is used by command.com (the default shell on the
95 line) but I doubt it. When I tested now I found that the Run entry in
Windows Start menu honor the default extensions for PATHEXT (.com, .exe.,
.bat, .cmd). It does not however not recognize .pl which I have in my
PATHEXT (cmd.exe recognize it). I am using NT4 when testing this.

So perhaps not even ms windows is consistent here. What seems clear however
is that the main purpose of PATHEXT is as far as I can see to make it easier
for the user when entering a command interactively. The user may for example
type "notepad" instead of "notepad.exe".

PATHEXT is set by the user and expresses the users wish to type less. It
seems reasonable to use PATHEXT for this purpose in Emacs too. The variable
executable-binary-suffixes is (if I understand this correctly) used for this
purpose by executable-find. This is however not clearly expressed in the
documentation.

A note: w32-shell-execute does something quite different. It calls the ms
windows API ShellExecute to do the action associated with a certain "verb"
on a file type (on windows this means file extension). Typical verbs are
"open" and "print". Windows Explorer uses this.

Having said all this I just want to say that I regret that I took this issue
up without looking closer at the problem.

- Lennart

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

end of thread, other threads:[~2004-09-12 10:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-11  0:05 Suggestions for corrections to executable.el - use of PATHEXT Lennart Borgman
2004-09-11  1:07 ` Davis Herring
2004-09-11  1:20   ` Davis Herring
2004-09-11 11:40     ` Eli Zaretskii
2004-09-11 12:12       ` Jason Rumney
2004-09-12 10:56       ` Lennart Borgman

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

	https://git.savannah.gnu.org/cgit/emacs.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).