all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to translate `rx' expressions to `rx-to-string'?
@ 2014-07-31 14:37 Thorsten Jolitz
  2014-07-31 15:07 ` Nicolas Richard
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2014-07-31 14:37 UTC (permalink / raw
  To: help-gnu-emacs


Hi List, 

this works fine
 
#+begin_src emacs-lisp
(format "%S"
   (rx bol "foo_" (+ word) eol))
#+end_src

#+results:
: "^foo_[[:word:]]+$"

but its surprisingly difficult to translate it to `rx-to-string':

#+begin_src emacs-lisp
(format "%S"
   (rx-to-string (list 'bol "foo_" '(+ word) 'eol)))
#+end_src

-> rx-form: Unknown rx form `bol'

When just using a string

#+begin_src emacs-lisp
(format "%S"
   (rx "foo_"))
#+end_src

#+results:
: "foo_"

this is ok, but different:

#+begin_src emacs-lisp
(format "%S"
   (rx-to-string "foo_"))
#+end_src

#+results:
: "\\(?:foo_\\)"

And this 

#+begin_src emacs-lisp
(format "%S"
   (rx-to-string (list "foo_" '+ 'word)))
#+end_src

or this 

#+begin_src emacs-lisp
(format "%S"
   (rx-to-string (list "foo_" '(+ word))))
#+end_src

both result in -> rx-form: Unknown rx form `foo_'

This works 

#+begin_src emacs-lisp
(format "%S"
   (rx-to-string "foo_" '(+ word)))
#+end_src

#+results:
: "foo_"

but ignores everything after the string. 

Seems I did not get the syntax for function rx-to-string yet - any hints
would be welcome.

-- 
cheers,
Thorsten




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

* Re: How to translate `rx' expressions to `rx-to-string'?
  2014-07-31 14:37 How to translate `rx' expressions to `rx-to-string'? Thorsten Jolitz
@ 2014-07-31 15:07 ` Nicolas Richard
  2014-07-31 18:33   ` Thorsten Jolitz
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Richard @ 2014-07-31 15:07 UTC (permalink / raw
  To: Thorsten Jolitz; +Cc: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:
> Seems I did not get the syntax for function rx-to-string yet - any hints
> would be welcome.

Read the code of rx.

(format "%S" (rx bol "foo_" (+ word) eol))
=> "\"^foo_[[:word:]]+$\""

(format "%S" (rx-to-string '(and bol "foo_" (+ word) eol) t))
=> "\"^foo_[[:word:]]+$\""

HTH,

-- 
Nico.



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

* Re: How to translate `rx' expressions to `rx-to-string'?
  2014-07-31 15:07 ` Nicolas Richard
@ 2014-07-31 18:33   ` Thorsten Jolitz
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2014-07-31 18:33 UTC (permalink / raw
  To: help-gnu-emacs

Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>> Seems I did not get the syntax for function rx-to-string yet - any hints
>> would be welcome.
>
> Read the code of rx.
>
> (format "%S" (rx bol "foo_" (+ word) eol))
> => "\"^foo_[[:word:]]+$\""
>
> (format "%S" (rx-to-string '(and bol "foo_" (+ word) eol) t))
> => "\"^foo_[[:word:]]+$\""
>
> HTH,

Yes, that helps, thank you!

OTOH, just a bit more info and maybe one little example in the docstring
of `rx-to-string' would help a lot. This is supposed to be easier to use
than regular regexp syntax ...

-- 
cheers,
Thorsten




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

end of thread, other threads:[~2014-07-31 18:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-31 14:37 How to translate `rx' expressions to `rx-to-string'? Thorsten Jolitz
2014-07-31 15:07 ` Nicolas Richard
2014-07-31 18:33   ` Thorsten Jolitz

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.