X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/8d3655be5a5c41b1f0a9985bcdb614693fce67e5..da95e2399e068eb87ea90a4617d80980d0601eb4:/lisp/textmodes/ispell.el diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 467ac00442..0fc6b4a999 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -1,6 +1,6 @@ ;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2 -;; Copyright (C) 1994-1995, 1997-2013 Free Software Foundation, Inc. +;; Copyright (C) 1994-1995, 1997-2014 Free Software Foundation, Inc. ;; Author: Ken Stevens ;; Maintainer: Ken Stevens @@ -931,16 +931,14 @@ Otherwise returns the library directory name, if that is defined." (defun ispell-call-process (&rest args) "Like `call-process' but defend against bad `default-directory'." (let ((default-directory default-directory)) - (unless (and (file-directory-p default-directory) - (file-readable-p default-directory)) + (unless (file-accessible-directory-p default-directory) (setq default-directory (expand-file-name "~/"))) (apply 'call-process args))) (defun ispell-call-process-region (&rest args) "Like `call-process-region' but defend against bad `default-directory'." (let ((default-directory default-directory)) - (unless (and (file-directory-p default-directory) - (file-readable-p default-directory)) + (unless (file-accessible-directory-p default-directory) (setq default-directory (expand-file-name "~/"))) (apply 'call-process-region args))) @@ -1383,7 +1381,8 @@ aspell is used along with Emacs).") ;; Unless default dict, re-add "-d" option with the mapped value (if dict-name (if dict-equiv - (nconc ispell-args (list "-d" dict-equiv)) + (setq ispell-args + (nconc ispell-args (list "-d" dict-equiv))) (message "ispell-set-spellchecker-params: Missing hunspell equiv for \"%s\". Skipping." dict-name) @@ -2217,7 +2216,7 @@ Global `ispell-quit' set to start location to continue spell session." (window-min-height (min window-min-height ispell-choices-win-default-height)) (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m )) - (dedicated (window-dedicated-p (selected-window))) + (dedicated (window-dedicated-p)) (skipped 0) char num result textwin dedicated-win) @@ -2328,10 +2327,14 @@ Global `ispell-quit' set to start location to continue spell session." ((= char ?i) ; accept and insert word into pers dict (ispell-send-string (concat "*" word "\n")) (setq ispell-pdict-modified-p '(t)) ; dictionary modified! + (and (fboundp 'flyspell-unhighlight-at) + (flyspell-unhighlight-at start)) nil) ((or (= char ?a) (= char ?A)) ; accept word without insert (ispell-send-string (concat "@" word "\n")) (add-to-list 'ispell-buffer-session-localwords word) + (and (fboundp 'flyspell-unhighlight-at) + (flyspell-unhighlight-at start)) (or ispell-buffer-local-name ; session localwords might conflict (setq ispell-buffer-local-name (buffer-name))) (if (null ispell-pdict-modified-p) @@ -2402,7 +2405,7 @@ Global `ispell-quit' set to start location to continue spell session." " -- word-list: " (or ispell-complete-word-dict ispell-alternate-dictionary)) - miss (lookup-words new-word) + miss (ispell-lookup-words new-word) choices miss line ispell-choices-win-default-height) (while (and choices ; adjust choices window. @@ -2608,8 +2611,9 @@ SPC: Accept word this time. (sit-for 5)) (erase-buffer))))))) +(define-obsolete-function-alias 'lookup-words 'ispell-lookup-words "24.4") -(defun lookup-words (word &optional lookup-dict) +(defun ispell-lookup-words (word &optional lookup-dict) "Look up WORD in optional word-list dictionary LOOKUP-DICT. A `*' serves as a wild card. If no wild cards, `look' is used if it exists. Otherwise the variable `ispell-grep-command' contains the command used to @@ -2643,8 +2647,12 @@ if defined." (message "Starting \"%s\" process..." (file-name-nondirectory prog)) (if look-p nil + (insert "^" word) + ;; When there are no wildcards, append one, for consistency + ;; with `look' behavior. + (unless wild-p (insert "*")) + (insert "$") ;; Convert * to .* - (insert "^" word "$") (while (search-backward "*" nil t) (insert ".")) (setq word (buffer-string)) (erase-buffer)) @@ -2929,8 +2937,7 @@ Keeps argument list for future Ispell invocations for no async support." (ispell-hunspell-fill-dictionary-entry ispell-current-dictionary))) (let* ((default-directory - (if (and (file-directory-p default-directory) - (file-readable-p default-directory)) + (if (file-accessible-directory-p default-directory) default-directory ;; Defend against bad `default-directory'. (expand-file-name "~/"))) @@ -2988,8 +2995,7 @@ Keeps argument list for future Ispell invocations for no async support." (if (or ispell-really-aspell ispell-really-hunspell ;; Protect against bad default-directory - (not (and (file-directory-p default-directory) - (file-readable-p default-directory))) + (not (file-accessible-directory-p default-directory)) ;; Ispell and per-dir personal dicts available (not (or (file-readable-p (concat default-directory ".ispell_words")) @@ -3015,7 +3021,7 @@ Keeps argument list for future Ispell invocations for no async support." (setq ispell-filter nil ispell-filter-continue nil) ;; may need to restart to select new personal dictionary. (ispell-kill-ispell t) - (message "Starting new Ispell process [%s::%s] ..." + (message "Starting new Ispell process %s with %s dictionary..." ispell-program-name (or ispell-local-dictionary ispell-dictionary "default")) (sit-for 0) @@ -3295,7 +3301,8 @@ ispell-region: Search for first region to skip after (ispell-begin-skip-region-r ispell-start ispell-end (point-at-eol) in-comment add-comment string) (if add-comment ; account for comment chars added (setq ispell-start (- ispell-start (length add-comment)) - add-comment nil)) + ;; Reset `in-comment' (and indirectly `add-comment') for new line + in-comment nil)) (setq ispell-end (point)) ; "end" tracks region retrieved. (if string ; there is something to spell check! ;; (special start end) @@ -3761,7 +3768,7 @@ Use APPEND to append the info to previous buffer if exists." ;;;###autoload (defun ispell-complete-word (&optional interior-frag) - "Try to complete the word before or under point (see `lookup-words'). + "Try to complete the word before or under point. If optional INTERIOR-FRAG is non-nil then the word may be a character sequence inside of a word. @@ -3777,11 +3784,11 @@ Standard ispell choices are then available." word (car word) possibilities (or (string= word "") ; Will give you every word - (lookup-words (concat (and interior-frag "*") word - (if (or interior-frag (null ispell-look-p)) - "*")) - (or ispell-complete-word-dict - ispell-alternate-dictionary)))) + (ispell-lookup-words + (concat (and interior-frag "*") word + (and interior-frag "*")) + (or ispell-complete-word-dict + ispell-alternate-dictionary)))) (cond ((eq possibilities t) (message "No word to complete")) ((null possibilities) @@ -4331,8 +4338,13 @@ Both should not be used to define a buffer-local dictionary." (if (fboundp 'comment-padright) ;; Try and use the proper comment marker, ;; e.g. ";;" rather than ";". - (comment-padright comment-start - (comment-add nil)) + (progn + ;; XEmacs: comment-normalize-vars + ;; (newcomment.el) only in >= 21.5 + (and (fboundp 'comment-normalize-vars) + (comment-normalize-vars)) + (comment-padright comment-start + (comment-add nil))) comment-start) " ") "")