unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to check regexp for syntax-errors?  (There HAS to be SOME way, yes?)
@ 2009-10-16 17:19 David Combs
  2009-10-16 17:39 ` rustom
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: David Combs @ 2009-10-16 17:19 UTC (permalink / raw)
  To: help-gnu-emacs

Trying to get this to work:

Trying to come up with a "dired-do-rename-regexp" that will transform
filenames like in these Dired-lines, I get an error printout.



  -rw-rw-rw-   1 David    root      10895733 10-16 09:51 091005_100001pilotmon.MP3
  -rw-rw-rw-   1 David    root      10895675 10-16 09:49 091012_100001pilotmon.MP3
  -rw-rw-rw-   1 David    root      10895673 10-16 09:49 091012_080001dn.MP3
  -rw-rw-rw-   1 David    root      10982376 10-16 09:48 091015_090001freeforum.MP3
  -rw-rw-rw-   1 David    root      10895675 10-16 09:47 091015_080001dn.MP3    ,

So, I simplify to an Occur, and so do M-: on this:

(Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")     ,

But here's what I get back:


Debugger entered--Lisp error: (void-function Occur)
  (Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")
  eval((Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3"))
  eval-expression((Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3") nil)
  call-interactively(eval-expression)
  recursive-edit()
  byte-code(" \x10	@ = !


Which is completely "Greek" to me!




Isn't there some .el that that will try to parse a regexp, and tell
me where it got confused, and what to look for for errors?


Thanks!




David




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

* Re: How to check regexp for syntax-errors? (There HAS to be SOME way, yes?)
  2009-10-16 17:19 How to check regexp for syntax-errors? (There HAS to be SOME way, yes?) David Combs
@ 2009-10-16 17:39 ` rustom
  2009-10-16 18:24   ` Joost Kremers
  2009-10-16 22:55 ` Andreas Politz
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: rustom @ 2009-10-16 17:39 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 16, 10:19 pm, dkco...@panix.com (David Combs) wrote:


> Isn't there some .el that that will try to parse a regexp, and tell
> me where it got confused, and what to look for for errors?
>
> Thanks!
>
> David
Have you seen this?

http://www.newartisans.com/2007/10/a-regular-expression-ide-for-emacs.html


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

* Re: How to check regexp for syntax-errors? (There HAS to be SOME way,  yes?)
  2009-10-16 17:39 ` rustom
@ 2009-10-16 18:24   ` Joost Kremers
  0 siblings, 0 replies; 7+ messages in thread
From: Joost Kremers @ 2009-10-16 18:24 UTC (permalink / raw)
  To: help-gnu-emacs

rustom wrote:
> On Oct 16, 10:19 pm, dkco...@panix.com (David Combs) wrote:
>
>> Isn't there some .el that that will try to parse a regexp, and tell
>> me where it got confused, and what to look for for errors?
>>
> Have you seen this?
>
> http://www.newartisans.com/2007/10/a-regular-expression-ide-for-emacs.html

or do M-x re-builder.

-- 
Joost Kremers                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

* Re: How to check regexp for syntax-errors? (There HAS to be SOME way, yes?)
  2009-10-16 17:19 How to check regexp for syntax-errors? (There HAS to be SOME way, yes?) David Combs
  2009-10-16 17:39 ` rustom
@ 2009-10-16 22:55 ` Andreas Politz
  2009-10-17  6:01 ` tomas
  2009-10-20  7:54 ` Kevin Rodgers
  3 siblings, 0 replies; 7+ messages in thread
From: Andreas Politz @ 2009-10-16 22:55 UTC (permalink / raw)
  To: help-gnu-emacs

dkcombs@panix.com (David Combs) writes:

>
> So, I simplify to an Occur, and so do M-: on this:
>
> (Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")     ,
>
> But here's what I get back:
>
>
> Debugger entered--Lisp error: (void-function Occur)
>
> Which is completely "Greek" to me!
>

Let me translate then.

The function you tried to invoke (Occur) is void aka undefined.


-ap





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

* Re: How to check regexp for syntax-errors?  (There HAS to be SOME way, yes?)
  2009-10-16 17:19 How to check regexp for syntax-errors? (There HAS to be SOME way, yes?) David Combs
  2009-10-16 17:39 ` rustom
  2009-10-16 22:55 ` Andreas Politz
@ 2009-10-17  6:01 ` tomas
  2009-10-20  7:54 ` Kevin Rodgers
  3 siblings, 0 replies; 7+ messages in thread
From: tomas @ 2009-10-17  6:01 UTC (permalink / raw)
  To: David Combs; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Oct 16, 2009 at 01:19:04PM -0400, David Combs wrote:
> Trying to get this to work:

[...]

As Andreas already noted, your (primary) problem here isn't with the
regexp. There just isn't a function named "Occur". I guess it's "occur"
you are after:

> (Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")     ,
> 
> But here's what I get back:
> 
> 
> Debugger entered--Lisp error: (void-function Occur)
                this is the clue ^^^^^^^^^^^^^^^^^^^
>   (Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")
>   eval((Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3"))
>   eval-expression((Occur "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3") nil)
>   call-interactively(eval-expression)
>   recursive-edit()
>   byte-code(" \x10	@ = !
> 
> 
> Which is completely "Greek" to me!

Understandable :-)

Emacs tries to be helpful showing you the "call stack", i.e. from where
the statement was called which gave it hiccups.

As to the regexp...

   "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3"

it is syntaactically fine as it is, but won't match your data:

      -rw-rw-rw-   1 David    root      10895733 10-16 09:51 091005_100001pilotmon.MP3

at least for several reasons:

  - the ".mp3" at the end is lowercase in the regexp, upercase in your
    data.
  - this long string of [0-9] with which you are trying to match the
    100001 in the example above _already_ matches all six digits -- thus
    the "1" after the parenthesis in the regexp turns out empty-handed.
  - I don't know whether the construct near the end:

          [a-zA-Z\\][0-9a-zA-Z]*

    is really doing what you think it should (it looks to me a bit like
    you wanted to say:

          [a-zA-Z][0-9a-zA-Z]*

    i.e. "one character and zero or more characters or digits")

> Isn't there some .el that that will try to parse a regexp, and tell
> me where it got confused, and what to look for for errors?

Others have answered this question in the thread.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFK2V3CBcgs9XrR2kYRAmmoAJ0cvr24IBhvCzguoaA/9+WUKF8J2wCfcSXx
dtll6FwQmTTwWEP5IWul5VQ=
=uRL7
-----END PGP SIGNATURE-----




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

* Re: How to check regexp for syntax-errors?  (There HAS to be SOME way,   yes?)
  2009-10-16 17:19 How to check regexp for syntax-errors? (There HAS to be SOME way, yes?) David Combs
                   ` (2 preceding siblings ...)
  2009-10-17  6:01 ` tomas
@ 2009-10-20  7:54 ` Kevin Rodgers
  3 siblings, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2009-10-20  7:54 UTC (permalink / raw)
  To: help-gnu-emacs

David Combs wrote:
> Isn't there some .el that that will try to parse a regexp, and tell
> me where it got confused, and what to look for for errors?

(defun valid-regexp-p (regexp)
   (interactive "sRegexp: ")
   (with-temp-buffer
     (condition-case error-data
	(progn
	  (re-search-forward regexp nil t)
	  t)
       (invalid-regexp
        (when (interactive-p) (message "Invalid regexp: %s" (cdr error-data)))
        nil))))

-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: How to check regexp for syntax-errors?  (There HAS to be SOME way, yes?)
@ 2009-10-20 12:05 martin rudalics
  0 siblings, 0 replies; 7+ messages in thread
From: martin rudalics @ 2009-10-20 12:05 UTC (permalink / raw)
  To: dkcombs; +Cc: help-gnu-emacs

 > Isn't there some .el that that will try to parse a regexp, and tell
 > me where it got confused, and what to look for for errors?

You might want to have a look at:

http://lists.gnu.org/archive/html/gnu-emacs-sources/2005-11/msg00004.html

martin




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

end of thread, other threads:[~2009-10-20 12:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-16 17:19 How to check regexp for syntax-errors? (There HAS to be SOME way, yes?) David Combs
2009-10-16 17:39 ` rustom
2009-10-16 18:24   ` Joost Kremers
2009-10-16 22:55 ` Andreas Politz
2009-10-17  6:01 ` tomas
2009-10-20  7:54 ` Kevin Rodgers
  -- strict thread matches above, loose matches on Subject: below --
2009-10-20 12:05 martin rudalics

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).