🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #188866

Re: Directory Files

#188866
From: Gabriel
Date: Fri, 24 May 1991 17:38
34 lines
1922 bytes
   (directory-files default-directory nil "*.[ch]")

   and am getting back 

   nil

   where as there are files that match the reg-exp.

   What am I doing wrong? 

The problem is with the regexp you are using; you are getting confused
with the shell's syntax for regexps and Emacs' syntax.  "*.[ch]" means match an
asterisk, any character, then either a `c' or an `h'.  What you probably
mean to use is ".*\.[ch]", or:

	(directory-files default-directory nil ".*\\.[ch]"

This matches any sequence of characters, followed by a period, followed
by either a `c' or an `h'.  I.e., any files ending with `.c' or `.h'.
(Note the use of "\\." instead of "\." when actually writing the lisp
code; this is because the elisp reader uses backslashes to quote special
characters, so you have to type in \\ in the string so that is read as a
single backslash.)

See the "Syntax of Regexps" node in the elisp manual.
--
Raul Acevedo
acevedo@athena.mit.edu

"Remember, Information is not knowledge; Knowledge is not Wisdom;
Wisdom is not truth; Truth is not beauty; Beauty is not love;
Love is not music; Music is the best."
	 - Frank Zappa
Technical Details
Message-ID: <ACEVEDO.91May24133757@tailgunner.mit.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!unidui!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-picayune.mit.edu!athena.mit.edu!acevedo
References: <1991May21.213101.22515@m.cs.uiuc.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103b8b,47d8d87ddf6099a4
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-05-28 10:55:12 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!unidui!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-picayune.mit.edu!athena.mit.edu!acevedo
From: acevedo@athena.mit.edu (Gabriel)
Newsgroups: gnu.emacs.help
Subject: Re: Directory Files
Message-ID: <ACEVEDO.91May24133757@tailgunner.mit.edu>
Date: 24 May 91 17:38:04 GMT
References: <1991May21.213101.22515@m.cs.uiuc.edu>
Sender: news@athena.mit.edu (News system)
Organization: Massachusetts Institute of Technology
Lines: 34
In-Reply-To: joshi@m.cs.uiuc.edu's message of Tue, 21 May 1991 21:31:01 GMT