From: weber <hugows@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: bind-string-match: comments please
Date: Tue, 30 Sep 2008 08:02:46 -0700 (PDT) [thread overview]
Message-ID: <a420b1d5-13b7-4135-8213-fd515ac7efa0@s50g2000hsb.googlegroups.com> (raw)
I've written this helper function:
(defun bind-string-match (regexp string &optional start)
(let ((ret (string-match regexp string start)))
(when ret
(catch 'end
(dolist (i (number-sequence 1 10))
(let ((match (match-string i string)))
(if match
(eval `(setq ,(intern (concat "$" (number-to-string i))) ,match))
(throw 'end t))))))
ret))
so that I can access the match groups with $1.. instead of (match-
string 1 string).
Is there any recommendation against this type of functions? Other than
polluting the global namespace?
Also, can one rewrite it without the `eval'?
TIA,
weber
PS: I'm not a Perl programmer!
next reply other threads:[~2008-09-30 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-30 15:02 weber [this message]
2008-09-30 18:30 ` bind-string-match: comments please Andreas Politz
2008-09-30 19:22 ` weber
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a420b1d5-13b7-4135-8213-fd515ac7efa0@s50g2000hsb.googlegroups.com \
--to=hugows@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.
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.