Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Honor case-replace and case-fold-search #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions phi-replace.el
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
(defvar phi-replace--mode-line-format
'(" *phi-replace*" (:eval (format " [ %d ]" (length phi-search--overlays)))))

(defun phi-replace--fixed-case ()
(not (and case-replace case-fold-search)))

(defun phi-replace--update-visual-preview (query replac)
(save-excursion
(dolist (ov phi-search--overlays)
Expand All @@ -117,7 +120,7 @@
ov 'after-string
(ignore-errors
(propertize
(concat "=>" (match-substitute-replacement replac))
(concat "=>" (match-substitute-replacement replac (phi-replace--fixed-case)))
'face 'phi-replace-preview-face))))))

(defun phi-replace--complete-function ()
Expand Down Expand Up @@ -149,14 +152,14 @@
(if (and phi-replace--query-mode
(let ((ch (read-char-choice
(format "replace with %s (y, n or !) ? "
(match-substitute-replacement str))
(match-substitute-replacement str (phi-replace--fixed-case)))
'(?y ?n ?!))))
(if (= ch ?!)
(setq phi-replace--query-mode nil)
(= ch ?n))))
(overlay-put ov 'face 'defualt)
(set-match-data match-data)
(replace-match str))
(replace-match str (phi-replace--fixed-case)))
(overlay-put ov 'after-string nil))
(when (and (not phi-replace--query-mode) phi-replace-weight)
(sit-for phi-replace-weight)))
Expand Down