From: Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
Subject: Re: User interface confusion; p0.30 invokes VM?
Date: 13 Sep 1998 20:48:32 +0200 [thread overview]
Message-ID: <HBF.980913ylx6@bombur2.uio.no> (raw)
In-Reply-To: Lars Magne Ingebrigtsen's message of "Sun, 13 Sep 1998 16:46:05 GMT"
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> (when (and (file-exists-p
> (setq file (expand-file-name command (pop path))))
> (file-executable-p file))
Why file-exists-p? Can a file be executable but not exist?
Also, don't search the path for absolute file names.
(defun mailcap-command-p (command)
"Say whether COMMAND is in the exec path."
(let ((path (if (file-name-absolute-p command) '(nil) exec-path))
file)
(catch 'found
(while path
(when (and (file-executable-p
(setq file (expand-file-name command (pop path))))
(not (file-directory-p file)))
(throw 'found file))))))
However, neither version works on operating systems that append a file
type to command file names (.COM, .BAT, .EXE, whatever). You can do it
in C, though. Maybe you can get RMS to make lread.c:openp() available
to emacs-lisp commands. Something like this (untested, a slight fix to
something I wrote a long time ago):
extern Lisp_Object Qidentity;
DEFUN ("locate-file", Flocate_file, Slocate_file, 0, 2, 0,
"Find first FILE in PATH with one of SUFFIXES, checking EXEC-ONLY.
EXEC_ONLY is nil to find all files, t to only find executables.
PATH and SUFFIXES are lists or colon-separated strings.
SUFFIXES may also be t, then the system's suffixes for executables are used.")
(file, path, suffixes, exec_only)
Lisp_Object file, path, suffixes, exec_only;
{
char *suff;
if (STRINGP (path))
path = decode_env_path (NULL, XSTRING (path)->data);
if (EQ (suffixes, Qt))
suff = EXEC_SUFFIXES;
else if (NILP (suffixes))
suff = "";
else
{
if (!STRINGP (suffixes))
{
struct gcpro gcpro1, gcpro2, gcpro3;
GCPRO3 (path, file, exec_only); /* Is this necessary? */
suffixes = Fmapconcat (Qidentity, suffixes, build_string (":"));
UNGCPRO;
}
suff = XSTRING(suffixes)->data;
}
(void) openp (path, file, suff, &file, !NILP(exec_only));
return file;
}
--
Hallvard
next prev parent reply other threads:[~1998-09-13 18:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-09-13 13:48 Karl Kleinpaste
1998-09-13 16:04 ` William M. Perry
2002-10-20 23:17 ` Lars Magne Ingebrigtsen
1998-09-13 18:48 ` Hallvard B Furuseth [this message]
1998-09-14 5:38 ` Lars Magne Ingebrigtsen
1998-09-16 13:22 ` Hrvoje Niksic
1998-09-16 14:43 ` Edward J. Sabol
1998-09-19 12:02 ` Lars Magne Ingebrigtsen
1998-09-13 19:13 ` Karl Kleinpaste
1998-09-13 20:05 ` William M. Perry
1998-09-13 20:15 ` Karl Kleinpaste
1998-09-13 16:35 ` Chris Halverson
1998-09-14 6:31 ` SL Baur
1998-09-14 5:44 ` Lars Magne Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=HBF.980913ylx6@bombur2.uio.no \
--to=h.b.furuseth@usit.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).