search string to change or the window to scroll). It is also used
by other Emacs features."
(when (and (null executing-kbd-macro)
- (sit-for 0) ;make sure (window-start) is credible
+ ;; This used to read `(sit-for 0)', but that has proved
+ ;; unreliable when called from within
+ ;; after-change-functions bound to certain special events.
+ (redisplay) ;make sure (window-start) is credible
(or (not (equal isearch-string
isearch-lazy-highlight-last-string))
(not (memq (selected-window)
(end (progn (forward-sexp 1) (point))))
(indent-region start end nil))))
+(declare-function treesit-node-at "treesit.c")
+
(defun prog-fill-reindent-defun (&optional argument)
"Refill or reindent the paragraph or defun that contains point.
(<= end (cdr bounds))))
region-bounds)))))
+(defvar overriding-text-conversion-style)
+
(defun perform-replace (from-string replacements
query-flag regexp-flag delimited-flag
&optional repeat-count map start end backward region-noncontiguous-p)
(limit nil)
(region-filter nil)
+ ;; Disable text conversion during the replacement operation.
+ (old-text-conversion-style overriding-text-conversion-style)
+ overriding-text-conversion-style
+
;; Data for the next match. If a cons, it has the same format as
;; (match-data); otherwise it is t if a match is possible at point.
(match-again t)
-
(message
(if query-flag
(apply #'propertize
(push-mark)
(undo-boundary)
+ (when query-flag
+ (setq overriding-text-conversion-style nil)
+ (when (fboundp 'set-text-conversion-style)
+ (set-text-conversion-style text-conversion-style)))
(unwind-protect
;; Loop finding occurrences that perhaps should be replaced.
(while (and keep-going
last-was-act-and-show nil))))))
(replace-dehighlight)
(when region-filter
- (remove-function isearch-filter-predicate region-filter)))
+ (remove-function isearch-filter-predicate region-filter))
+ (when query-flag
+ ;; Resume text conversion.
+ (setq overriding-text-conversion-style
+ old-text-conversion-style)
+ (when (fboundp 'set-text-conversion-style)
+ (set-text-conversion-style text-conversion-style))))
(or unread-command-events
(message (ngettext "Replaced %d occurrence%s"
"Replaced %d occurrences%s"