a `~' followed by an extended-character mode -- such as `~.tex'.
The last occurring definition in the buffer will be used.")
+(defun ispell--\\w-filter (char)
+ "Return CHAR in a string when CHAR doesn't have \"word\" syntax,
+nil otherwise. CHAR must be a character."
+ (let ((str (string char)))
+ (and
+ (not (string-match "\\w" str))
+ str)))
+
+(defun ispell--make-\\w-expression (chars)
+ "Make a regular expression like \"\\(\\w\\|[-_]\\)\".
+This (parenthesized) expression matches either a character of
+\"word\" syntax or one in CHARS.
+
+CHARS is a string of characters. A member of CHARS is omitted
+from the expression if it already has word syntax. (Be careful
+about special characters such as ?\\, ?^, ?], and ?- in CHARS.)
+If after this filtering there are no chars left, or only one, a
+special form of the expression is generated."
+ (let ((filtered
+ (mapconcat #'ispell--\\w-filter chars "")))
+ (concat
+ "\\(\\w"
+ (cond
+ ((equal filtered "")
+ "\\)")
+ ((eq (length filtered) 1)
+ (concat "\\|" filtered "\\)"))
+ (t
+ (concat "\\|[" filtered "]\\)"))))))
+
+(defun ispell--make-filename-or-URL-re ()
+ "Construct a regexp to match some file names or URLs or email addresses.
+The expression is crafted to match as great a variety of these
+objects as practicable, without too many false matches happening."
+ (concat ;"\\(--+\\|_+\\|"
+ "\\(/\\w\\|\\("
+ (ispell--make-\\w-expression "-_")
+ "+[.:@]\\)\\)"
+ (ispell--make-\\w-expression "-_")
+ "*\\([.:/@]+"
+ (ispell--make-\\w-expression "-_~=?&")
+ "+\\)+"
+ ;"\\)"
+ ))
+
;;;###autoload
(defvar ispell-skip-region-alist
`((ispell-words-keyword forward-line)
;; Matches e-mail addresses, file names, http addresses, etc. The
;; `-+' `_+' patterns are necessary for performance reasons when
;; `-' or `_' part of word syntax.
- (,(purecopy "\\(--+\\|_+\\|\\(/\\w\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)"))
+; (,(purecopy "\\(--+\\|_+\\|\\(/\\w\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)"))
;; above checks /.\w sequences
;;("\\(--+\\|\\(/\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)")
;; This is a pretty complex regexp. It can be simplified to the following:
(if (string= "" comment-end) "^" (regexp-quote comment-end)))
(if (and (null ispell-check-comments) comment-start)
(regexp-quote comment-start))
- (ispell-begin-skip-region ispell-skip-region-alist)))
+ (ispell-begin-skip-region ispell-skip-region-alist)
+ (ispell--make-filename-or-URL-re)))
"\\|"))
The list is of the form described by variable `ispell-skip-region-alist'.
Must be called after `ispell-buffer-local-parsing' due to dependence on mode."
(let ((skip-alist ispell-skip-region-alist))
+ (setq skip-alist (append (list (list (ispell--make-filename-or-URL-re)))
+ skip-alist))
;; only additional explicit region definition is tex.
(if (eq ispell-parser 'tex)
(setq case-fold-search nil
(ispell-non-empty-string vm-included-text-prefix)))
(t default-prefix)))
(ispell-skip-region-alist
- (cons (list (concat "^\\(" cite-regexp "\\)")
- (function forward-line))
- ispell-skip-region-alist))
+ (cons (list (ispell--make-filename-or-URL-re))
+ (cons (list (concat "^\\(" cite-regexp "\\)")
+ (function forward-line))
+ ispell-skip-region-alist)))
(old-case-fold-search case-fold-search)
(dictionary-alist ispell-message-dictionary-alist)
(ispell-checking-message t))