[comp.emacs] Directory Files

eric@AI.MIT.EDU (Eric Hanchrow) (05/24/91)

Beats me.
      Can't the people of UNIX come to some kind of agreement on this
      issue?
Probable not (although Emacs' syntax is almost compatible with
grep's).

   2. In the emacs syntax to represent the period, I need to escape it but
      that is not enough. I need to escape the escape (\\). This is
      totally counter-intuitive (as many things in emacs are). Why o why?
Well, technically speaking, the regular expression syntax only
requires one backslash.  It's the syntax for strings which requires
double backslashes.  Here's an example: If you wanted to look for a
period using M-x isearch-forward-regexp, you would type
	M-x isearch-forward-regexp RET \ .
This is becuase isearch-forward-regexp reads individual characters
from the keyboard and builds a regular expression from them.  If, on
the other hand, you were writing a Lisp program and wanted to include
a call to re-search-forward (which takes a string argument), you'd
need to write it like this:
	(re-search-forward "\\.")
This is because in Lisp, you must escape backslashes that appear in
strings.


   3. Why not make grep of emacs accept emacs reg.exp syntax? That way I
      have to know only one syntax.
Good question.  The reason is that the `grep' in emacs really isn't
*in* emacs at all.  When you do M-x grep, what happens is that Emacs
creates an asynchronous subprocess, and runs the program `grep' in it.
Since Emacs is simply running an unrelated program, it has no control
over how that program interprets its input.  There's a good reason why
Emacs does things this way: If you don't like the `grep' that came
with your computer, you can get another one (like e.g. the one that
the Free Software Foundataion's GNU project wrote) and use that
instead.

You might investigate the function `tags-search', which is sort of
like a built-in grep, and uses Emacs' own regular expression syntax.

In general, you should probably read the Emacs manual, specifically
the section on regular expressions; then you should (deep breath) read
the Emacs Lisp manual, specifically the sections on regular
expressions and string syntax.
       ------------------------------------------------------------------------
       |Eric Hanchrow		sun.com!nosun!yamada-sun!eric		      |
       |Phase III Logic, Inc.	cse.ogi.edu!yamada-sun!eric		      |
       |1600 N.W. 167th Place		Beaverton, OR 97006-4800 USA	      |
       |Voice: (503)-645-0313		Fax: (503)-645-0207     as of 4-Oct-89|
       --------------Crackling-noises-OK--do-not-correct!----------------------