aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/ispell.el59
1 files changed, 54 insertions, 5 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 0f1806c8888..1b26b4905a2 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
1782a `~' followed by an extended-character mode -- such as `~.tex'. 1782a `~' followed by an extended-character mode -- such as `~.tex'.
1783The last occurring definition in the buffer will be used.") 1783The 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,
1787nil 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\\|[-_]\\)\".
1795This (parenthesized) expression matches either a character of
1796\"word\" syntax or one in CHARS.
1797
1798CHARS is a string of characters. A member of CHARS is omitted
1799from the expression if it already has word syntax. (Be careful
1800about special characters such as ?\\, ?^, ?], and ?- in CHARS.)
1801If after this filtering there are no chars left, or only one, a
1802special 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.
1817The expression is crafted to match as great a variety of these
1818objects 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:
@@ -3387,7 +3432,8 @@ Must be called after `ispell-buffer-local-parsing' due to dependence on mode."
3387 (if (string= "" comment-end) "^" (regexp-quote comment-end))) 3432 (if (string= "" comment-end) "^" (regexp-quote comment-end)))
3388 (if (and (null ispell-check-comments) comment-start) 3433 (if (and (null ispell-check-comments) comment-start)
3389 (regexp-quote comment-start)) 3434 (regexp-quote comment-start))
3390 (ispell-begin-skip-region ispell-skip-region-alist))) 3435 (ispell-begin-skip-region ispell-skip-region-alist)
3436 (ispell--make-filename-or-URL-re)))
3391 "\\|")) 3437 "\\|"))
3392 3438
3393 3439
@@ -3426,6 +3472,8 @@ Manual checking must include comments and tib references.
3426The list is of the form described by variable `ispell-skip-region-alist'. 3472The list is of the form described by variable `ispell-skip-region-alist'.
3427Must be called after `ispell-buffer-local-parsing' due to dependence on mode." 3473Must be called after `ispell-buffer-local-parsing' due to dependence on mode."
3428 (let ((skip-alist ispell-skip-region-alist)) 3474 (let ((skip-alist ispell-skip-region-alist))
3475 (setq skip-alist (append (list (list (ispell--make-filename-or-URL-re)))
3476 skip-alist))
3429 ;; only additional explicit region definition is tex. 3477 ;; only additional explicit region definition is tex.
3430 (if (eq ispell-parser 'tex) 3478 (if (eq ispell-parser 'tex)
3431 (setq case-fold-search nil 3479 (setq case-fold-search nil
@@ -4119,9 +4167,10 @@ You can bind this to the key C-c i in GNUS or mail by adding to
4119 (ispell-non-empty-string vm-included-text-prefix))) 4167 (ispell-non-empty-string vm-included-text-prefix)))
4120 (t default-prefix))) 4168 (t default-prefix)))
4121 (ispell-skip-region-alist 4169 (ispell-skip-region-alist
4122 (cons (list (concat "^\\(" cite-regexp "\\)") 4170 (cons (list (ispell--make-filename-or-URL-re))
4123 (function forward-line)) 4171 (cons (list (concat "^\\(" cite-regexp "\\)")
4124 ispell-skip-region-alist)) 4172 (function forward-line))
4173 ispell-skip-region-alist)))
4125 (old-case-fold-search case-fold-search) 4174 (old-case-fold-search case-fold-search)
4126 (dictionary-alist ispell-message-dictionary-alist) 4175 (dictionary-alist ispell-message-dictionary-alist)
4127 (ispell-checking-message t)) 4176 (ispell-checking-message t))