From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: [ANN] drx.el --- declarative dynamic regexps
Date: Thu, 10 Apr 2014 19:43:48 +0200 [thread overview]
Message-ID: <87ob09f5bf.fsf@gmail.com> (raw)
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
reply other threads:[~2014-04-10 17:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ob09f5bf.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).