While searching in groups, I came across the following discussion.
http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/c7...%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