Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie question on replace-eval-replacement , replace-quote

12 views
Skip to first unread message

bolega

unread,
Aug 26, 2011, 12:33:47 AM8/26/11
to
While searching in groups, I came across the following discussion.

http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/c723bde021ea8183/a2afe24ce98ed739?lnk=gst&q=%22\%2C%22+swap#a2afe24ce98ed739

which presents the following code.

,----
| (defun query-swap-regexp (regexp-a regexp-b)
| "Swap A and B regexp matches in current buffer or region."
| (interactive "sRegexp A: \nsRegexp B: ")
| (let ((match-a (save-excursion
| (re-search-forward regexp-a nil t)
| (match-string 0)))
| (match-b (save-excursion
| (re-search-forward regexp-b nil t)
| (match-string 0))))
| (query-replace-regexp
| (concat "\\(\\(" regexp-a "\\)\\|" regexp-b "\\)")
| `(replace-eval-replacement
| replace-quote
| (if (match-string 2) ,match-b ,match-a))
| nil
| (if (and transient-mark-mode mark-active) (region-beginning))
| (if (and transient-mark-mode mark-active) (region-end)))))
`----

I am find it hard to understand due to lack of any example or
documentation explaining the operations of

replace-eval-replacement
replace-quote

For the latter, emacs says

No apropos matches for 'replace-quote'

and for the former,

replace-eval-replacement is a compiled Lisp function in `replace'.
(replace-eval-replacement EXPRESSION REPLACE-COUNT)
not documented

I cant run the above and play with it.

Thank for any help.
Bolega

0 new messages