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

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

Re: Using re-builder


From: Kevin Rodgers
Subject: Re: Using re-builder
Date: Fri, 18 Jun 2004 10:05:00 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Phil_C wrote:
> Michael Slass <address@hidden> wrote in message news:<address@hidden>...
>>Try this:
>>
>>(defun reb-copy-unquoted ()
>>  "Copy current RE into the kill ring for later insertion as unquoted."
>>  (interactive)
>>  (reb-update-regexp)
>>  (let ((re (with-temp-buffer
>>              (insert (reb-target-binding reb-regexp))
>>              (replace-string "\\\\" "\\" nil (point-min) (point-max))
>>              (buffer-substring (point-min) (point-max)))))
>>    (kill-new re)
>>    (message "Regexp copied to kill-ring")))
>
> Thanks, that just about does it - except the beginning and ending
> quotes are still there. Still, that's much better than it was before,
> since now I don't have to go through the whole regex deleting "\"s.

Well, you could either replace "\\`\"" and "\"\\'" with "", or avoid
inserting them in the first place:

(let ((regexp (reb-target-binding reb-regexp)))
  (insert (substring regexp 1 (1- (length regexp)))))

Another approach would be to leave the regexp string in the kill ring,
but define a new command to yank the regexp itself into the minibuffer.

And instead of using replace-string to replace "\\\\" with "\\", you
might be able to get the lisp reader to do it for you (e.g. with
make-symbol).

--
Kevin Rodgers



reply via email to

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