unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* [ANN] drx.el --- declarative dynamic regexps
@ 2014-04-10 17:43 Thorsten Jolitz
  0 siblings, 0 replies; only message in thread
From: Thorsten Jolitz @ 2014-04-10 17:43 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

I wrote a library ([[https://github.com/tj64/drx][drx.el]]) that allows
to write regexps in Emacs Lisp in a more declarative style and to
replace static regexp strings with function calls that calculate a
regexp dynamically at runtime.

Unfortunately I learned about rx.el only when I was almost done, but
anyway, maybe drx.el has a different approach and its use cases too.

Its main purpose is to abstract from hardcoded  "^", "$" and "\\*" in
regexps. Here are a few examples:

# basic usage
#+begin_src emacs-lisp
 (drx "foo" t nil t)
#+end_src

#+results:
: ^foo$

# org-mode version
#+begin_src emacs-lisp
 (drx " foo" t '(t "+") t)
#+end_src

#+results:
: ^\(\*+\) foo$

# css-mode version with # as star 
#+begin_src emacs-lisp
  (let ((drx-BOL "^/* ")
        (drx-EOL "*/$")
        (drx-STAR "#"))
    (drx " foo" t '(t "+") t))
#+end_src

#+results:
: ^/* \(#+\) foo*/$

Many more things are possible, the more than 80 ERT tests in drx.el give
many examples with expected output.

-- 
cheers,
Thorsten




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-10 17:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-10 17:43 [ANN] drx.el --- declarative dynamic regexps Thorsten Jolitz

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