unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* bind-string-match: comments please
@ 2008-09-30 15:02 weber
  2008-09-30 18:30 ` Andreas Politz
  0 siblings, 1 reply; 3+ messages in thread
From: weber @ 2008-09-30 15:02 UTC (permalink / raw)
  To: help-gnu-emacs

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!


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

end of thread, other threads:[~2008-09-30 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-30 15:02 bind-string-match: comments please weber
2008-09-30 18:30 ` Andreas Politz
2008-09-30 19:22   ` weber

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