(add-hook 'post-command-hook 'follow-post-command-hook t)
(add-hook 'window-size-change-functions 'follow-window-size-change t)
(add-hook 'after-change-functions 'follow-after-change nil t)
+ (add-hook 'isearch-update-post-hook 'follow-post-command-hook nil t)
+ (add-hook 'replace-update-post-hook 'follow-post-command-hook nil t)
+ (add-hook 'ispell-update-post-hook 'follow-post-command-hook nil t)
(setq window-start-group-function 'follow-window-start)
(setq window-end-group-function 'follow-window-end)
(setq pos-visible-in-window-p-group-function
'follow-pos-visible-in-window-p)
(setq selected-window-group-function 'follow-all-followers)
- (setq move-to-window-line-group-function 'follow-move-to-window-line)
- (setq sit*-for-function 'follow-sit-for))
+ (setq move-to-window-line-group-function 'follow-move-to-window-line))
;; Remove globally-installed hook functions only if there is no
;; other Follow mode buffer.
(remove-hook 'post-command-hook 'follow-post-command-hook)
(remove-hook 'window-size-change-functions 'follow-window-size-change)))
- (kill-local-variable 'sit*-for-function)
(kill-local-variable 'move-to-window-line-group-function)
(kill-local-variable 'selected-window-group-function)
(kill-local-variable 'pos-visible-in-window-p-group-function)
(kill-local-variable 'window-end-group-function)
(kill-local-variable 'window-start-group-function)
+ (remove-hook 'ispell-update-post-hook 'follow-post-command-hook t)
+ (remove-hook 'replace-update-post-hook 'follow-post-command-hook t)
+ (remove-hook 'isearch-update-post-hook 'follow-post-command-hook t)
(remove-hook 'after-change-functions 'follow-after-change t)
(remove-hook 'compilation-filter-hook 'follow-align-compilation-windows t)))
(defun isearch-update ()
"This is called after every isearch command to update the display.
-The last thing it does is to run `isearch-update-post-hook'."
+The second last thing it does is to run `isearch-update-post-hook'.
+The last thing is to trigger a new round of lazy highlighting."
(unless (eq (current-buffer) isearch--current-buffer)
(when (buffer-live-p isearch--current-buffer)
(with-current-buffer isearch--current-buffer
(setq ;; quit-flag nil not for isearch-mode
isearch-adjusted nil
isearch-yank-flag nil)
- (when isearch-lazy-highlight
- (isearch-lazy-highlight-new-loop))
;; We must prevent the point moving to the end of composition when a
;; part of the composition has just been searched.
(setq disable-point-adjustment t)
- (run-hooks 'isearch-update-post-hook))
+ (run-hooks 'isearch-update-post-hook)
+ (when isearch-lazy-highlight
+ (isearch-lazy-highlight-new-loop)))
(defun isearch-done (&optional nopush edit)
"Exit Isearch mode.
"22.1")
(defun isearch-lazy-highlight-new-loop (&optional beg end)
- "Set an idle timer, which will trigger a new `lazy-highlight' loop.
-BEG and END specify the bounds within which highlighting should
-occur. This is called when `isearch-update' is invoked (which
-can cause the search string to change or the window(s) to
-scroll). It is also used by other Emacs features. Do not start
-the loop when we are executing a keyboard macro."
- (setq isearch-lazy-highlight-start-limit beg
- isearch-lazy-highlight-end-limit end)
- (when (null executing-kbd-macro)
- (setq isearch-lazy-highlight-timer
- (run-with-idle-timer lazy-highlight-initial-delay nil
- 'isearch-lazy-highlight-maybe-new-loop))))
-
-(defun isearch-lazy-highlight-maybe-new-loop ()
- "If needed cleanup any previous `lazy-highlight' loop and begin a new one.
+ "Cleanup any previous `lazy-highlight' loop and begin a new one.
BEG and END specify the bounds within which highlighting should occur.
This is called when `isearch-update' is invoked (which can cause the
search string to change or the window to scroll). It is also used
;; It used to check for `(not isearch-error)' here, but actually
;; lazy-highlighting might find matches to highlight even when
;; `isearch-error' is non-nil. (Bug#9918)
+ (setq isearch-lazy-highlight-start-limit beg
+ isearch-lazy-highlight-end-limit end)
(setq isearch-lazy-highlight-window (selected-window)
isearch-lazy-highlight-window-group (selected-window-group)
isearch-lazy-highlight-window-start (window-start nil t)
isearch-lazy-highlight-regexp-function isearch-regexp-function
isearch-lazy-highlight-forward isearch-forward)
(unless (equal isearch-string "")
- (isearch-lazy-highlight-update))))
+ (setq isearch-lazy-highlight-timer
+ (run-with-idle-timer lazy-highlight-initial-delay nil
+ 'isearch-lazy-highlight-update)))))
(defun isearch-lazy-highlight-search ()
"Search ahead for the next or previous match, for lazy highlighting.
(when backward (goto-char (nth 0 match-data)))
noedit)
+(defvar replace-update-post-hook nil
+ "Function(s) to call after query-replace has found a match in the buffer.")
+
(defvar replace-search-function nil
"Function to use when searching for strings to replace.
It is used by `query-replace' and `replace-string', and is called
(and nonempty-match
(or (not regexp-flag)
(and (if backward
- (looking-back search-string)
+ (looking-back search-string nil)
(looking-at search-string))
(let ((match (match-data)))
(and (/= (nth 0 match) (nth 1 match))
;; `real-match-data'.
(while (not done)
(set-match-data real-match-data)
- (replace-highlight
+ (run-hooks 'replace-update-post-hook) ; Before `replace-highlight'.
+ (replace-highlight
(match-beginning 0) (match-end 0)
start end search-string
regexp-flag delimited-flag case-fold-search backward)
(setq ispell-pdict-modified-p nil))
+(defvar ispell-update-post-hook nil
+ "A normal hook invoked from the ispell command loop.
+It is called once per iteration, before displaying a prompt to
+the user.")
+
(defun ispell-command-loop (miss guess word start end)
"Display possible corrections from list MISS.
GUESS lists possibly valid affix construction of WORD.
count (ispell-int-char (1+ count))))
(setq count (ispell-int-char (- count ?0 skipped))))
+ (run-hooks 'ispell-update-post-hook)
+
;; ensure word is visible
- (if (not (pos-visible-in-window-p end))
+ (if (not (pos-visible-in-window-p end nil nil t))
(sit-for 0))
;; Display choices for misspelled word.
(prog1
(condition-case nil
(split-window
- nil (- ispell-choices-win-default-height) 'above)
+ ;; Chose the last of a window group, since
+ ;; otherwise, the lowering of another window's
+ ;; TL corner would cause the logical order of
+ ;; the windows to be changed.
+ (car (last (selected-window-group)))
+ (- ispell-choices-win-default-height) 'above)
(error nil))
(modify-frame-parameters frame '((unsplittable . t))))))
(and (not unsplittable)
(condition-case nil
(split-window
- nil (- ispell-choices-win-default-height) 'above)
+ ;; See comment above.
+ (car (last (selected-window-group)))
+ (- ispell-choices-win-default-height) 'above)
(error nil)))
(display-buffer buffer))))
(if (not window)