diff options
| author | Alan Mackenzie | 2015-12-07 15:12:15 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2015-12-07 15:12:15 +0000 |
| commit | 3194f1ccd99cfd13ddaf621d6e7f1e1aa1645165 (patch) | |
| tree | 3963195a29eea661a697516ad424567a05cfdfeb | |
| parent | f5c403d269f4f5079dc47853f16a51e9542ea238 (diff) | |
| download | emacs-3194f1ccd99cfd13ddaf621d6e7f1e1aa1645165.tar.gz emacs-3194f1ccd99cfd13ddaf621d6e7f1e1aa1645165.zip | |
Further progress making Isearch, Ispell, Replace work with Follow Mode.
* lisp/follow.el: (follow-mode): Remove references to sit*-for-function, which
no longer exists. Add follow-post-command-hook to three special purpose
hooks at setup, and remove them at tear down.
* lisp/isearch.el: (isearch-update): invoke isearch-update-post-hook before
isearch-lazy-highlight-new-loop.
(isearch-lazy-highlight-new-loop): Restore this function to what it previously
was, merging the functionality of isearch-lazy-highlight-maybe-new-loop into
it.
(isearch-lazy-highlight-maybe-new-loop): function removed.
* lisp/replace.el: (replace-update-post-hook): New hook variable.
(perform-replace): Add second (nil) argument to looking-back. Invoke
replace-update-post-hook before calling replace-highlight.
* lisp/textmodes/ispell.el: (ispell-update-post-hook): New hook variable.
(ispell-command-loop): invoke ispell-update-post-hook. Add GROUP argument to
call of pos-visible-in-window-p.
(ispell-display-buffer): Place *Choices* window at the top of the last window
in a window group.
| -rw-r--r-- | lisp/follow.el | 10 | ||||
| -rw-r--r-- | lisp/isearch.el | 31 | ||||
| -rw-r--r-- | lisp/replace.el | 8 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 20 |
4 files changed, 41 insertions, 28 deletions
diff --git a/lisp/follow.el b/lisp/follow.el index 2cbf0f2b93d..609b29f7ccd 100644 --- a/lisp/follow.el +++ b/lisp/follow.el | |||
| @@ -423,6 +423,9 @@ Keys specific to Follow mode: | |||
| 423 | (add-hook 'post-command-hook 'follow-post-command-hook t) | 423 | (add-hook 'post-command-hook 'follow-post-command-hook t) |
| 424 | (add-hook 'window-size-change-functions 'follow-window-size-change t) | 424 | (add-hook 'window-size-change-functions 'follow-window-size-change t) |
| 425 | (add-hook 'after-change-functions 'follow-after-change nil t) | 425 | (add-hook 'after-change-functions 'follow-after-change nil t) |
| 426 | (add-hook 'isearch-update-post-hook 'follow-post-command-hook nil t) | ||
| 427 | (add-hook 'replace-update-post-hook 'follow-post-command-hook nil t) | ||
| 428 | (add-hook 'ispell-update-post-hook 'follow-post-command-hook nil t) | ||
| 426 | 429 | ||
| 427 | (setq window-start-group-function 'follow-window-start) | 430 | (setq window-start-group-function 'follow-window-start) |
| 428 | (setq window-end-group-function 'follow-window-end) | 431 | (setq window-end-group-function 'follow-window-end) |
| @@ -431,8 +434,7 @@ Keys specific to Follow mode: | |||
| 431 | (setq pos-visible-in-window-p-group-function | 434 | (setq pos-visible-in-window-p-group-function |
| 432 | 'follow-pos-visible-in-window-p) | 435 | 'follow-pos-visible-in-window-p) |
| 433 | (setq selected-window-group-function 'follow-all-followers) | 436 | (setq selected-window-group-function 'follow-all-followers) |
| 434 | (setq move-to-window-line-group-function 'follow-move-to-window-line) | 437 | (setq move-to-window-line-group-function 'follow-move-to-window-line)) |
| 435 | (setq sit*-for-function 'follow-sit-for)) | ||
| 436 | 438 | ||
| 437 | ;; Remove globally-installed hook functions only if there is no | 439 | ;; Remove globally-installed hook functions only if there is no |
| 438 | ;; other Follow mode buffer. | 440 | ;; other Follow mode buffer. |
| @@ -445,7 +447,6 @@ Keys specific to Follow mode: | |||
| 445 | (remove-hook 'post-command-hook 'follow-post-command-hook) | 447 | (remove-hook 'post-command-hook 'follow-post-command-hook) |
| 446 | (remove-hook 'window-size-change-functions 'follow-window-size-change))) | 448 | (remove-hook 'window-size-change-functions 'follow-window-size-change))) |
| 447 | 449 | ||
| 448 | (kill-local-variable 'sit*-for-function) | ||
| 449 | (kill-local-variable 'move-to-window-line-group-function) | 450 | (kill-local-variable 'move-to-window-line-group-function) |
| 450 | (kill-local-variable 'selected-window-group-function) | 451 | (kill-local-variable 'selected-window-group-function) |
| 451 | (kill-local-variable 'pos-visible-in-window-p-group-function) | 452 | (kill-local-variable 'pos-visible-in-window-p-group-function) |
| @@ -454,6 +455,9 @@ Keys specific to Follow mode: | |||
| 454 | (kill-local-variable 'window-end-group-function) | 455 | (kill-local-variable 'window-end-group-function) |
| 455 | (kill-local-variable 'window-start-group-function) | 456 | (kill-local-variable 'window-start-group-function) |
| 456 | 457 | ||
| 458 | (remove-hook 'ispell-update-post-hook 'follow-post-command-hook t) | ||
| 459 | (remove-hook 'replace-update-post-hook 'follow-post-command-hook t) | ||
| 460 | (remove-hook 'isearch-update-post-hook 'follow-post-command-hook t) | ||
| 457 | (remove-hook 'after-change-functions 'follow-after-change t) | 461 | (remove-hook 'after-change-functions 'follow-after-change t) |
| 458 | (remove-hook 'compilation-filter-hook 'follow-align-compilation-windows t))) | 462 | (remove-hook 'compilation-filter-hook 'follow-align-compilation-windows t))) |
| 459 | 463 | ||
diff --git a/lisp/isearch.el b/lisp/isearch.el index 12ded02345f..8e9a686dca0 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -961,7 +961,8 @@ used to set the value of `isearch-regexp-function'." | |||
| 961 | 961 | ||
| 962 | (defun isearch-update () | 962 | (defun isearch-update () |
| 963 | "This is called after every isearch command to update the display. | 963 | "This is called after every isearch command to update the display. |
| 964 | The last thing it does is to run `isearch-update-post-hook'." | 964 | The second last thing it does is to run `isearch-update-post-hook'. |
| 965 | The last thing is to trigger a new round of lazy highlighting." | ||
| 965 | (unless (eq (current-buffer) isearch--current-buffer) | 966 | (unless (eq (current-buffer) isearch--current-buffer) |
| 966 | (when (buffer-live-p isearch--current-buffer) | 967 | (when (buffer-live-p isearch--current-buffer) |
| 967 | (with-current-buffer isearch--current-buffer | 968 | (with-current-buffer isearch--current-buffer |
| @@ -1018,12 +1019,12 @@ The last thing it does is to run `isearch-update-post-hook'." | |||
| 1018 | (setq ;; quit-flag nil not for isearch-mode | 1019 | (setq ;; quit-flag nil not for isearch-mode |
| 1019 | isearch-adjusted nil | 1020 | isearch-adjusted nil |
| 1020 | isearch-yank-flag nil) | 1021 | isearch-yank-flag nil) |
| 1021 | (when isearch-lazy-highlight | ||
| 1022 | (isearch-lazy-highlight-new-loop)) | ||
| 1023 | ;; We must prevent the point moving to the end of composition when a | 1022 | ;; We must prevent the point moving to the end of composition when a |
| 1024 | ;; part of the composition has just been searched. | 1023 | ;; part of the composition has just been searched. |
| 1025 | (setq disable-point-adjustment t) | 1024 | (setq disable-point-adjustment t) |
| 1026 | (run-hooks 'isearch-update-post-hook)) | 1025 | (run-hooks 'isearch-update-post-hook) |
| 1026 | (when isearch-lazy-highlight | ||
| 1027 | (isearch-lazy-highlight-new-loop))) | ||
| 1027 | 1028 | ||
| 1028 | (defun isearch-done (&optional nopush edit) | 1029 | (defun isearch-done (&optional nopush edit) |
| 1029 | "Exit Isearch mode. | 1030 | "Exit Isearch mode. |
| @@ -3068,21 +3069,7 @@ is nil. This function is called when exiting an incremental search if | |||
| 3068 | "22.1") | 3069 | "22.1") |
| 3069 | 3070 | ||
| 3070 | (defun isearch-lazy-highlight-new-loop (&optional beg end) | 3071 | (defun isearch-lazy-highlight-new-loop (&optional beg end) |
| 3071 | "Set an idle timer, which will trigger a new `lazy-highlight' loop. | 3072 | "Cleanup any previous `lazy-highlight' loop and begin a new one. |
| 3072 | BEG and END specify the bounds within which highlighting should | ||
| 3073 | occur. This is called when `isearch-update' is invoked (which | ||
| 3074 | can cause the search string to change or the window(s) to | ||
| 3075 | scroll). It is also used by other Emacs features. Do not start | ||
| 3076 | the loop when we are executing a keyboard macro." | ||
| 3077 | (setq isearch-lazy-highlight-start-limit beg | ||
| 3078 | isearch-lazy-highlight-end-limit end) | ||
| 3079 | (when (null executing-kbd-macro) | ||
| 3080 | (setq isearch-lazy-highlight-timer | ||
| 3081 | (run-with-idle-timer lazy-highlight-initial-delay nil | ||
| 3082 | 'isearch-lazy-highlight-maybe-new-loop)))) | ||
| 3083 | |||
| 3084 | (defun isearch-lazy-highlight-maybe-new-loop () | ||
| 3085 | "If needed cleanup any previous `lazy-highlight' loop and begin a new one. | ||
| 3086 | BEG and END specify the bounds within which highlighting should occur. | 3073 | BEG and END specify the bounds within which highlighting should occur. |
| 3087 | This is called when `isearch-update' is invoked (which can cause the | 3074 | This is called when `isearch-update' is invoked (which can cause the |
| 3088 | search string to change or the window to scroll). It is also used | 3075 | search string to change or the window to scroll). It is also used |
| @@ -3118,6 +3105,8 @@ by other Emacs features." | |||
| 3118 | ;; It used to check for `(not isearch-error)' here, but actually | 3105 | ;; It used to check for `(not isearch-error)' here, but actually |
| 3119 | ;; lazy-highlighting might find matches to highlight even when | 3106 | ;; lazy-highlighting might find matches to highlight even when |
| 3120 | ;; `isearch-error' is non-nil. (Bug#9918) | 3107 | ;; `isearch-error' is non-nil. (Bug#9918) |
| 3108 | (setq isearch-lazy-highlight-start-limit beg | ||
| 3109 | isearch-lazy-highlight-end-limit end) | ||
| 3121 | (setq isearch-lazy-highlight-window (selected-window) | 3110 | (setq isearch-lazy-highlight-window (selected-window) |
| 3122 | isearch-lazy-highlight-window-group (selected-window-group) | 3111 | isearch-lazy-highlight-window-group (selected-window-group) |
| 3123 | isearch-lazy-highlight-window-start (window-start nil t) | 3112 | isearch-lazy-highlight-window-start (window-start nil t) |
| @@ -3140,7 +3129,9 @@ by other Emacs features." | |||
| 3140 | isearch-lazy-highlight-regexp-function isearch-regexp-function | 3129 | isearch-lazy-highlight-regexp-function isearch-regexp-function |
| 3141 | isearch-lazy-highlight-forward isearch-forward) | 3130 | isearch-lazy-highlight-forward isearch-forward) |
| 3142 | (unless (equal isearch-string "") | 3131 | (unless (equal isearch-string "") |
| 3143 | (isearch-lazy-highlight-update)))) | 3132 | (setq isearch-lazy-highlight-timer |
| 3133 | (run-with-idle-timer lazy-highlight-initial-delay nil | ||
| 3134 | 'isearch-lazy-highlight-update))))) | ||
| 3144 | 3135 | ||
| 3145 | (defun isearch-lazy-highlight-search () | 3136 | (defun isearch-lazy-highlight-search () |
| 3146 | "Search ahead for the next or previous match, for lazy highlighting. | 3137 | "Search ahead for the next or previous match, for lazy highlighting. |
diff --git a/lisp/replace.el b/lisp/replace.el index 54b3a71bda2..d48f4f3fdf9 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -2011,6 +2011,9 @@ passed in. If LITERAL is set, no checking is done, anyway." | |||
| 2011 | (when backward (goto-char (nth 0 match-data))) | 2011 | (when backward (goto-char (nth 0 match-data))) |
| 2012 | noedit) | 2012 | noedit) |
| 2013 | 2013 | ||
| 2014 | (defvar replace-update-post-hook nil | ||
| 2015 | "Function(s) to call after query-replace has found a match in the buffer.") | ||
| 2016 | |||
| 2014 | (defvar replace-search-function nil | 2017 | (defvar replace-search-function nil |
| 2015 | "Function to use when searching for strings to replace. | 2018 | "Function to use when searching for strings to replace. |
| 2016 | It is used by `query-replace' and `replace-string', and is called | 2019 | It is used by `query-replace' and `replace-string', and is called |
| @@ -2264,7 +2267,7 @@ It must return a string." | |||
| 2264 | (and nonempty-match | 2267 | (and nonempty-match |
| 2265 | (or (not regexp-flag) | 2268 | (or (not regexp-flag) |
| 2266 | (and (if backward | 2269 | (and (if backward |
| 2267 | (looking-back search-string) | 2270 | (looking-back search-string nil) |
| 2268 | (looking-at search-string)) | 2271 | (looking-at search-string)) |
| 2269 | (let ((match (match-data))) | 2272 | (let ((match (match-data))) |
| 2270 | (and (/= (nth 0 match) (nth 1 match)) | 2273 | (and (/= (nth 0 match) (nth 1 match)) |
| @@ -2318,7 +2321,8 @@ It must return a string." | |||
| 2318 | ;; `real-match-data'. | 2321 | ;; `real-match-data'. |
| 2319 | (while (not done) | 2322 | (while (not done) |
| 2320 | (set-match-data real-match-data) | 2323 | (set-match-data real-match-data) |
| 2321 | (replace-highlight | 2324 | (run-hooks 'replace-update-post-hook) ; Before `replace-highlight'. |
| 2325 | (replace-highlight | ||
| 2322 | (match-beginning 0) (match-end 0) | 2326 | (match-beginning 0) (match-end 0) |
| 2323 | start end search-string | 2327 | start end search-string |
| 2324 | regexp-flag delimited-flag case-fold-search backward) | 2328 | regexp-flag delimited-flag case-fold-search backward) |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index fe27f0f158c..7d5bb6dbc59 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -2248,6 +2248,11 @@ If so, ask if it needs to be saved." | |||
| 2248 | (setq ispell-pdict-modified-p nil)) | 2248 | (setq ispell-pdict-modified-p nil)) |
| 2249 | 2249 | ||
| 2250 | 2250 | ||
| 2251 | (defvar ispell-update-post-hook nil | ||
| 2252 | "A normal hook invoked from the ispell command loop. | ||
| 2253 | It is called once per iteration, before displaying a prompt to | ||
| 2254 | the user.") | ||
| 2255 | |||
| 2251 | (defun ispell-command-loop (miss guess word start end) | 2256 | (defun ispell-command-loop (miss guess word start end) |
| 2252 | "Display possible corrections from list MISS. | 2257 | "Display possible corrections from list MISS. |
| 2253 | GUESS lists possibly valid affix construction of WORD. | 2258 | GUESS lists possibly valid affix construction of WORD. |
| @@ -2315,8 +2320,10 @@ Global `ispell-quit' set to start location to continue spell session." | |||
| 2315 | count (ispell-int-char (1+ count)))) | 2320 | count (ispell-int-char (1+ count)))) |
| 2316 | (setq count (ispell-int-char (- count ?0 skipped)))) | 2321 | (setq count (ispell-int-char (- count ?0 skipped)))) |
| 2317 | 2322 | ||
| 2323 | (run-hooks 'ispell-update-post-hook) | ||
| 2324 | |||
| 2318 | ;; ensure word is visible | 2325 | ;; ensure word is visible |
| 2319 | (if (not (pos-visible-in-window-p end)) | 2326 | (if (not (pos-visible-in-window-p end nil nil t)) |
| 2320 | (sit-for 0)) | 2327 | (sit-for 0)) |
| 2321 | 2328 | ||
| 2322 | ;; Display choices for misspelled word. | 2329 | ;; Display choices for misspelled word. |
| @@ -2844,13 +2851,20 @@ Also position fit window to BUFFER and select it." | |||
| 2844 | (prog1 | 2851 | (prog1 |
| 2845 | (condition-case nil | 2852 | (condition-case nil |
| 2846 | (split-window | 2853 | (split-window |
| 2847 | nil (- ispell-choices-win-default-height) 'above) | 2854 | ;; Chose the last of a window group, since |
| 2855 | ;; otherwise, the lowering of another window's | ||
| 2856 | ;; TL corner would cause the logical order of | ||
| 2857 | ;; the windows to be changed. | ||
| 2858 | (car (last (selected-window-group))) | ||
| 2859 | (- ispell-choices-win-default-height) 'above) | ||
| 2848 | (error nil)) | 2860 | (error nil)) |
| 2849 | (modify-frame-parameters frame '((unsplittable . t)))))) | 2861 | (modify-frame-parameters frame '((unsplittable . t)))))) |
| 2850 | (and (not unsplittable) | 2862 | (and (not unsplittable) |
| 2851 | (condition-case nil | 2863 | (condition-case nil |
| 2852 | (split-window | 2864 | (split-window |
| 2853 | nil (- ispell-choices-win-default-height) 'above) | 2865 | ;; See comment above. |
| 2866 | (car (last (selected-window-group))) | ||
| 2867 | (- ispell-choices-win-default-height) 'above) | ||
| 2854 | (error nil))) | 2868 | (error nil))) |
| 2855 | (display-buffer buffer)))) | 2869 | (display-buffer buffer)))) |
| 2856 | (if (not window) | 2870 | (if (not window) |