help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bind-string-match: comments please


From: weber
Subject: bind-string-match: comments please
Date: Tue, 30 Sep 2008 08:02:46 -0700 (PDT)
User-agent: G2/1.0

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!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]