From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/17054 Path: main.gmane.org!not-for-mail From: Hallvard B Furuseth Newsgroups: gmane.emacs.gnus.general Subject: Re: User interface confusion; p0.30 invokes VM? Date: 13 Sep 1998 20:48:32 +0200 Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035155823 31346 80.91.224.250 (20 Oct 2002 23:17:03 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 23:17:03 +0000 (UTC) Return-Path: Original-Received: from gizmo.hpc.uh.edu (gizmo.hpc.uh.edu [129.7.102.31]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id OAA25596 for ; Sun, 13 Sep 1998 14:50:33 -0400 (EDT) Original-Received: from sina.hpc.uh.edu (sina.hpc.uh.edu [129.7.3.5]) by gizmo.hpc.uh.edu (8.7.6/8.7.3) with ESMTP id NAF22112; Sun, 13 Sep 1998 13:21:36 -0500 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Sun, 13 Sep 1998 13:49:02 -0500 (CDT) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [209.195.19.139]) by sina.hpc.uh.edu (8.7.3/8.7.3) with ESMTP id NAA17325 for ; Sun, 13 Sep 1998 13:48:54 -0500 (CDT) Original-Received: from mons (6089@mons.uio.no [129.240.130.14]) by sclp3.sclp.com (8.8.5/8.8.5) with SMTP id OAA25563 for ; Sun, 13 Sep 1998 14:48:49 -0400 (EDT) Original-Received: from bombur2.uio.no (actually bombur2.uio.no [129.240.200.72]) by mons with SMTP (PP); Sun, 13 Sep 1998 20:48:35 +0200 Original-Received: by bombur2.uio.no ; Sun, 13 Sep 1998 20:48:34 +0200 (MET DST) Original-To: ding@gnus.org In-Reply-To: Lars Magne Ingebrigtsen's message of "Sun, 13 Sep 1998 16:46:05 GMT" Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:17054 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:17054 Lars Magne Ingebrigtsen 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