diff options
| author | Alan Mackenzie | 2015-12-20 12:33:30 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2015-12-20 12:33:30 +0000 |
| commit | df32db2f5f3dcad4b2b16fd52e51e1c7bd846609 (patch) | |
| tree | 74c24ce0fd04942ec496aab04d8f25482944107e /lisp/textmodes | |
| parent | 6a8a41c5104b29846ed6e69da7576e0960f2bf14 (diff) | |
| parent | a72a9fbbbc9cd5f5933719b11489c2578eb0aa59 (diff) | |
| download | emacs-df32db2f5f3dcad4b2b16fd52e51e1c7bd846609.tar.gz emacs-df32db2f5f3dcad4b2b16fd52e51e1c7bd846609.zip | |
Merge branch 'scratch/follow' into emacs-25
This allows Isearch, etc., to work well when Follow Mode is active.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/ispell.el | 79 |
1 files changed, 71 insertions, 8 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index aa51446d6b4..05a5da57b66 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -1782,6 +1782,51 @@ Extended character mode can be changed for this buffer by placing | |||
| 1782 | a `~' followed by an extended-character mode -- such as `~.tex'. | 1782 | a `~' followed by an extended-character mode -- such as `~.tex'. |
| 1783 | The last occurring definition in the buffer will be used.") | 1783 | The last occurring definition in the buffer will be used.") |
| 1784 | 1784 | ||
| 1785 | (defun ispell--\\w-filter (char) | ||
| 1786 | "Return CHAR in a string when CHAR doesn't have \"word\" syntax, | ||
| 1787 | nil otherwise. CHAR must be a character." | ||
| 1788 | (let ((str (string char))) | ||
| 1789 | (and | ||
| 1790 | (not (string-match "\\w" str)) | ||
| 1791 | str))) | ||
| 1792 | |||
| 1793 | (defun ispell--make-\\w-expression (chars) | ||
| 1794 | "Make a regular expression like \"\\(\\w\\|[-_]\\)\". | ||
| 1795 | This (parenthesized) expression matches either a character of | ||
| 1796 | \"word\" syntax or one in CHARS. | ||
| 1797 | |||
| 1798 | CHARS is a string of characters. A member of CHARS is omitted | ||
| 1799 | from the expression if it already has word syntax. (Be careful | ||
| 1800 | about special characters such as ?\\, ?^, ?], and ?- in CHARS.) | ||
| 1801 | If after this filtering there are no chars left, or only one, a | ||
| 1802 | special form of the expression is generated." | ||
| 1803 | (let ((filtered | ||
| 1804 | (mapconcat #'ispell--\\w-filter chars ""))) | ||
| 1805 | (concat | ||
| 1806 | "\\(\\w" | ||
| 1807 | (cond | ||
| 1808 | ((equal filtered "") | ||
| 1809 | "\\)") | ||
| 1810 | ((eq (length filtered) 1) | ||
| 1811 | (concat "\\|" filtered "\\)")) | ||
| 1812 | (t | ||
| 1813 | (concat "\\|[" filtered "]\\)")))))) | ||
| 1814 | |||
| 1815 | (defun ispell--make-filename-or-URL-re () | ||
| 1816 | "Construct a regexp to match some file names or URLs or email addresses. | ||
| 1817 | The expression is crafted to match as great a variety of these | ||
| 1818 | objects as practicable, without too many false matches happening." | ||
| 1819 | (concat ;"\\(--+\\|_+\\|" | ||
| 1820 | "\\(/\\w\\|\\(" | ||
| 1821 | (ispell--make-\\w-expression "-_") | ||
| 1822 | "+[.:@]\\)\\)" | ||
| 1823 | (ispell--make-\\w-expression "-_") | ||
| 1824 | "*\\([.:/@]+" | ||
| 1825 | (ispell--make-\\w-expression "-_~=?&") | ||
| 1826 | "+\\)+" | ||
| 1827 | ;"\\)" | ||
| 1828 | )) | ||
| 1829 | |||
| 1785 | ;;;###autoload | 1830 | ;;;###autoload |
| 1786 | (defvar ispell-skip-region-alist | 1831 | (defvar ispell-skip-region-alist |
| 1787 | `((ispell-words-keyword forward-line) | 1832 | `((ispell-words-keyword forward-line) |
| @@ -1798,7 +1843,7 @@ The last occurring definition in the buffer will be used.") | |||
| 1798 | ;; Matches e-mail addresses, file names, http addresses, etc. The | 1843 | ;; Matches e-mail addresses, file names, http addresses, etc. The |
| 1799 | ;; `-+' `_+' patterns are necessary for performance reasons when | 1844 | ;; `-+' `_+' patterns are necessary for performance reasons when |
| 1800 | ;; `-' or `_' part of word syntax. | 1845 | ;; `-' or `_' part of word syntax. |
| 1801 | (,(purecopy "\\(--+\\|_+\\|\\(/\\w\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)")) | 1846 | ; (,(purecopy "\\(--+\\|_+\\|\\(/\\w\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)")) |
| 1802 | ;; above checks /.\w sequences | 1847 | ;; above checks /.\w sequences |
| 1803 | ;;("\\(--+\\|\\(/\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)") | 1848 | ;;("\\(--+\\|\\(/\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)") |
| 1804 | ;; This is a pretty complex regexp. It can be simplified to the following: | 1849 | ;; This is a pretty complex regexp. It can be simplified to the following: |
| @@ -2248,6 +2293,11 @@ If so, ask if it needs to be saved." | |||
| 2248 | (setq ispell-pdict-modified-p nil)) | 2293 | (setq ispell-pdict-modified-p nil)) |
| 2249 | 2294 | ||
| 2250 | 2295 | ||
| 2296 | (defvar ispell-update-post-hook nil | ||
| 2297 | "A normal hook invoked from the ispell command loop. | ||
| 2298 | It is called once per iteration, before displaying a prompt to | ||
| 2299 | the user.") | ||
| 2300 | |||
| 2251 | (defun ispell-command-loop (miss guess word start end) | 2301 | (defun ispell-command-loop (miss guess word start end) |
| 2252 | "Display possible corrections from list MISS. | 2302 | "Display possible corrections from list MISS. |
| 2253 | GUESS lists possibly valid affix construction of WORD. | 2303 | GUESS lists possibly valid affix construction of WORD. |
| @@ -2315,8 +2365,10 @@ Global `ispell-quit' set to start location to continue spell session." | |||
| 2315 | count (ispell-int-char (1+ count)))) | 2365 | count (ispell-int-char (1+ count)))) |
| 2316 | (setq count (ispell-int-char (- count ?0 skipped)))) | 2366 | (setq count (ispell-int-char (- count ?0 skipped)))) |
| 2317 | 2367 | ||
| 2368 | (run-hooks 'ispell-update-post-hook) | ||
| 2369 | |||
| 2318 | ;; ensure word is visible | 2370 | ;; ensure word is visible |
| 2319 | (if (not (pos-visible-in-window-p end)) | 2371 | (if (not (pos-visible-in-window-group-p end)) |
| 2320 | (sit-for 0)) | 2372 | (sit-for 0)) |
| 2321 | 2373 | ||
| 2322 | ;; Display choices for misspelled word. | 2374 | ;; Display choices for misspelled word. |
| @@ -2845,13 +2897,20 @@ Also position fit window to BUFFER and select it." | |||
| 2845 | (prog1 | 2897 | (prog1 |
| 2846 | (condition-case nil | 2898 | (condition-case nil |
| 2847 | (split-window | 2899 | (split-window |
| 2848 | nil (- ispell-choices-win-default-height) 'above) | 2900 | ;; Chose the last of a window group, since |
| 2901 | ;; otherwise, the lowering of another window's | ||
| 2902 | ;; TL corner would cause the logical order of | ||
| 2903 | ;; the windows to be changed. | ||
| 2904 | (car (last (selected-window-group))) | ||
| 2905 | (- ispell-choices-win-default-height) 'above) | ||
| 2849 | (error nil)) | 2906 | (error nil)) |
| 2850 | (modify-frame-parameters frame '((unsplittable . t)))))) | 2907 | (modify-frame-parameters frame '((unsplittable . t)))))) |
| 2851 | (and (not unsplittable) | 2908 | (and (not unsplittable) |
| 2852 | (condition-case nil | 2909 | (condition-case nil |
| 2853 | (split-window | 2910 | (split-window |
| 2854 | nil (- ispell-choices-win-default-height) 'above) | 2911 | ;; See comment above. |
| 2912 | (car (last (selected-window-group))) | ||
| 2913 | (- ispell-choices-win-default-height) 'above) | ||
| 2855 | (error nil))) | 2914 | (error nil))) |
| 2856 | (display-buffer buffer)))) | 2915 | (display-buffer buffer)))) |
| 2857 | (if (not window) | 2916 | (if (not window) |
| @@ -3374,7 +3433,8 @@ Must be called after `ispell-buffer-local-parsing' due to dependence on mode." | |||
| 3374 | (if (string= "" comment-end) "^" (regexp-quote comment-end))) | 3433 | (if (string= "" comment-end) "^" (regexp-quote comment-end))) |
| 3375 | (if (and (null ispell-check-comments) comment-start) | 3434 | (if (and (null ispell-check-comments) comment-start) |
| 3376 | (regexp-quote comment-start)) | 3435 | (regexp-quote comment-start)) |
| 3377 | (ispell-begin-skip-region ispell-skip-region-alist))) | 3436 | (ispell-begin-skip-region ispell-skip-region-alist) |
| 3437 | (ispell--make-filename-or-URL-re))) | ||
| 3378 | "\\|")) | 3438 | "\\|")) |
| 3379 | 3439 | ||
| 3380 | 3440 | ||
| @@ -3413,6 +3473,8 @@ Manual checking must include comments and tib references. | |||
| 3413 | The list is of the form described by variable `ispell-skip-region-alist'. | 3473 | The list is of the form described by variable `ispell-skip-region-alist'. |
| 3414 | Must be called after `ispell-buffer-local-parsing' due to dependence on mode." | 3474 | Must be called after `ispell-buffer-local-parsing' due to dependence on mode." |
| 3415 | (let ((skip-alist ispell-skip-region-alist)) | 3475 | (let ((skip-alist ispell-skip-region-alist)) |
| 3476 | (setq skip-alist (append (list (list (ispell--make-filename-or-URL-re))) | ||
| 3477 | skip-alist)) | ||
| 3416 | ;; only additional explicit region definition is tex. | 3478 | ;; only additional explicit region definition is tex. |
| 3417 | (if (eq ispell-parser 'tex) | 3479 | (if (eq ispell-parser 'tex) |
| 3418 | (setq case-fold-search nil | 3480 | (setq case-fold-search nil |
| @@ -4106,9 +4168,10 @@ You can bind this to the key C-c i in GNUS or mail by adding to | |||
| 4106 | (ispell-non-empty-string vm-included-text-prefix))) | 4168 | (ispell-non-empty-string vm-included-text-prefix))) |
| 4107 | (t default-prefix))) | 4169 | (t default-prefix))) |
| 4108 | (ispell-skip-region-alist | 4170 | (ispell-skip-region-alist |
| 4109 | (cons (list (concat "^\\(" cite-regexp "\\)") | 4171 | (cons (list (ispell--make-filename-or-URL-re)) |
| 4110 | (function forward-line)) | 4172 | (cons (list (concat "^\\(" cite-regexp "\\)") |
| 4111 | ispell-skip-region-alist)) | 4173 | (function forward-line)) |
| 4174 | ispell-skip-region-alist))) | ||
| 4112 | (old-case-fold-search case-fold-search) | 4175 | (old-case-fold-search case-fold-search) |
| 4113 | (dictionary-alist ispell-message-dictionary-alist) | 4176 | (dictionary-alist ispell-message-dictionary-alist) |
| 4114 | (ispell-checking-message t)) | 4177 | (ispell-checking-message t)) |