Created
March 17, 2011 11:29
-
-
Save emasaka/874182 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defvar *replace-count-base* 0) | |
| (defvar *replace-count-format* "%d") | |
| (defadvice query-replace-compile-replacement | |
| (after replace-count-format) | |
| "Change \\# format of (query-)replace-regexp" | |
| (when (consp ad-return-value) | |
| (let ((oldexp '(number-to-string replace-count)) | |
| (newexp '(format *replace-count-format* | |
| (+ replace-count *replace-count-base*) ))) | |
| (if (and (eq (car ad-return-value) 'replace-eval-replacement) | |
| (equal (cdr ad-return-value) oldexp) ) | |
| (setcdr ad-return-value newexp) ; only \# | |
| (let ((lst ad-return-value)) | |
| (while lst | |
| (if (equal (car lst) oldexp) (setcar lst newexp)) | |
| (pop lst) )) )))) | |
| (ad-activate 'query-replace-compile-replacement) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment