[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master eae3841: [el-search] Improve "Make replacement editable an
From: |
Michael Heerdegen |
Subject: |
[elpa] master eae3841: [el-search] Improve "Make replacement editable and ediff'able" |
Date: |
Sun, 24 Feb 2019 06:04:42 -0500 (EST) |
branch: master
commit eae384118d336c285829afdf053a7c6141037907
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
[el-search] Improve "Make replacement editable and ediff'able"
* packages/el-search/el-search.el
(el-search-query-replace--comments-preserved-p): Be more accurate when
skipping the header to extract the edited replacement.
---
packages/el-search/el-search.el | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index f8751d8..1c26b49 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -4363,13 +4363,8 @@ exactly you did? Thanks!"))))
(edit-replacement
(lambda (&optional ediff-only)
(save-excursion ;user may copy stuff from
base buffer etc.
- (let* ((buffer (generate-new-buffer
"*Replacement*"))
- (window (display-buffer buffer)))
- (select-window window)
- (emacs-lisp-mode)
- (unless ediff-only
- (insert
- (propertize "\
+ (let* ((header
+ (propertize "\
;; This buffer shows the individual replacement for the current match.
;; You may edit it here while query-replace is interrupted by a
;; `recursive-edit'.
@@ -4377,9 +4372,21 @@ exactly you did? Thanks!"))))
;; to confirm.
;; Type C-c C-e to Ediff the current match with this buffer's content.
;; Type C-c C-r to revert this buffer."
- 'read-only t 'field t
- 'front-sticky t
'rear-nonsticky t)
- "\n\n"))
+ 'read-only t 'field t
+ 'front-sticky t
'rear-nonsticky t))
+ (find-replacement-beg
+ (lambda ()
+ (goto-char (point-min))
+ (when (looking-at (regexp-quote
header))
+ (goto-char (match-end 0)))
+ (while (and (not (eobp))
(looking-at "^$"))
+ (forward-line))))
+ (buffer (generate-new-buffer
"*Replacement*"))
+ (window (display-buffer buffer)))
+ (select-window window)
+ (emacs-lisp-mode)
+ (unless ediff-only
+ (insert header "\n\n"))
(save-excursion (insert to-insert))
(let ((inhibit-message t))
(indent-region (point) (point-max)))
@@ -4417,10 +4424,7 @@ exactly you did? Thanks!"))))
(define-key map [(control ?c)
(control ?r)]
(lambda ()
(interactive)
- (goto-char (point-min))
- (while (and (not (eobp))
- (looking-at
"^;;\\|^$"))
- (forward-line))
+ (funcall find-replacement-beg)
(delete-region (point)
(point-max))
(insert (funcall
get-replacement-string))))
map))
@@ -4435,11 +4439,9 @@ exactly you did? Thanks!"))))
(let ((new-to-insert
(and (buffer-modified-p buffer)
(with-current-buffer buffer
- (goto-char (point-min))
- (while (and (not (eobp))
- (looking-at
"^;;\\|^$"))
- (forward-line))
- (buffer-substring (point)
(point-max))))))
+ (funcall
find-replacement-beg)
+ (string-trim
+ (buffer-substring (point)
(point-max)))))))
(when (and new-to-insert
(y-or-n-p "Use modified
version?"))
(setq to-insert new-to-insert)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master eae3841: [el-search] Improve "Make replacement editable and ediff'able",
Michael Heerdegen <=