diff options
| author | Stefan Monnier | 2010-09-20 13:53:42 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-09-20 13:53:42 +0200 |
| commit | 94eb3112c5eb822c2fe5968924f80fd0bc5e716b (patch) | |
| tree | f43b2c4b64b9921e7d11fd1ec012aa0df5adda0e | |
| parent | a953c1e3df1015056523747595b2ca324cdbe871 (diff) | |
| download | emacs-94eb3112c5eb822c2fe5968924f80fd0bc5e716b.tar.gz emacs-94eb3112c5eb822c2fe5968924f80fd0bc5e716b.zip | |
* lisp/textmodes/ispell.el: Fix commenting convention.
(ispell-parse-output): Simplify, use push.
(ispell-region): Use match-string-no-properties.
(ispell-begin-skip-region-regexp): Use mapconcat to simplify.
(ispell-minor-mode): Use define-minor-mode.
(ispell-message): Remove unused var `skip-regexp'.
(ispell-add-per-file-word-list): Use dynamic let-binding.
Try and use the proper comment marker.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 139 |
2 files changed, 63 insertions, 85 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ae4064bc04a..eb85c0dc262 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2010-09-20 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2010-09-20 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * textmodes/ispell.el: Fix commenting convention. | ||
| 4 | (ispell-parse-output): Simplify, use push. | ||
| 5 | (ispell-region): Use match-string-no-properties. | ||
| 6 | (ispell-begin-skip-region-regexp): Use mapconcat to simplify. | ||
| 7 | (ispell-minor-mode): Use define-minor-mode. | ||
| 8 | (ispell-message): Remove unused var `skip-regexp'. | ||
| 9 | (ispell-add-per-file-word-list): Use dynamic let-binding. | ||
| 10 | Try and use the proper comment marker. | ||
| 11 | |||
| 3 | * mail/sendmail.el: Fix commenting convention. | 12 | * mail/sendmail.el: Fix commenting convention. |
| 4 | (sendmail-send-it): Use line-beginning-position. | 13 | (sendmail-send-it): Use line-beginning-position. |
| 5 | 14 | ||
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index ad2838adaa9..8fe42b320c6 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -770,8 +770,8 @@ here just for backwards compatibility.") | |||
| 770 | 770 | ||
| 771 | 771 | ||
| 772 | 772 | ||
| 773 | ;;; The version must be 3.1 or greater for this version of ispell.el | 773 | ;; The version must be 3.1 or greater for this version of ispell.el |
| 774 | ;;; There is an incompatibility between version 3.1.12 and lower versions. | 774 | ;; There is an incompatibility between version 3.1.12 and lower versions. |
| 775 | (defconst ispell-required-version '(3 1 12) | 775 | (defconst ispell-required-version '(3 1 12) |
| 776 | "Ispell versions with which this version of ispell.el is known to work.") | 776 | "Ispell versions with which this version of ispell.el is known to work.") |
| 777 | (defvar ispell-offset -1 | 777 | (defvar ispell-offset -1 |
| @@ -1106,7 +1106,7 @@ aspell is used along with Emacs).") | |||
| 1106 | 1106 | ||
| 1107 | 1107 | ||
| 1108 | (defun ispell-valid-dictionary-list () | 1108 | (defun ispell-valid-dictionary-list () |
| 1109 | "Returns a list of valid dictionaries. | 1109 | "Return a list of valid dictionaries. |
| 1110 | The variable `ispell-library-directory' defines the library location." | 1110 | The variable `ispell-library-directory' defines the library location." |
| 1111 | ;; Initialize variables and dictionaries alists for desired spellchecker. | 1111 | ;; Initialize variables and dictionaries alists for desired spellchecker. |
| 1112 | ;; Make sure ispell.el is loaded to avoid some autoload loops in XEmacs | 1112 | ;; Make sure ispell.el is loaded to avoid some autoload loops in XEmacs |
| @@ -1269,9 +1269,6 @@ The variable `ispell-library-directory' defines the library location." | |||
| 1269 | 1269 | ||
| 1270 | ;;; ********************************************************************** | 1270 | ;;; ********************************************************************** |
| 1271 | 1271 | ||
| 1272 | |||
| 1273 | ;;; This variable contains the current dictionary being used if the ispell | ||
| 1274 | ;;; process is running. | ||
| 1275 | (defvar ispell-current-dictionary nil | 1272 | (defvar ispell-current-dictionary nil |
| 1276 | "The name of the current dictionary, or nil for the default. | 1273 | "The name of the current dictionary, or nil for the default. |
| 1277 | This is passed to the ispell process using the `-d' switch and is | 1274 | This is passed to the ispell process using the `-d' switch and is |
| @@ -1296,6 +1293,7 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs." | |||
| 1296 | 1293 | ||
| 1297 | ;; Return a string decoded from Nth element of the current dictionary. | 1294 | ;; Return a string decoded from Nth element of the current dictionary. |
| 1298 | (defun ispell-get-decoded-string (n) | 1295 | (defun ispell-get-decoded-string (n) |
| 1296 | "Get the decoded string in slot N of the descriptor of the current dict." | ||
| 1299 | (let* ((slot (or | 1297 | (let* ((slot (or |
| 1300 | (assoc ispell-current-dictionary ispell-local-dictionary-alist) | 1298 | (assoc ispell-current-dictionary ispell-local-dictionary-alist) |
| 1301 | (assoc ispell-current-dictionary ispell-dictionary-alist) | 1299 | (assoc ispell-current-dictionary ispell-dictionary-alist) |
| @@ -2151,7 +2149,7 @@ Global `ispell-quit' set to start location to continue spell session." | |||
| 2151 | (if (and ispell-use-framepop-p (fboundp 'framepop-display-buffer)) | 2149 | (if (and ispell-use-framepop-p (fboundp 'framepop-display-buffer)) |
| 2152 | (progn | 2150 | (progn |
| 2153 | (framepop-display-buffer (get-buffer ispell-choices-buffer)) | 2151 | (framepop-display-buffer (get-buffer ispell-choices-buffer)) |
| 2154 | ;;; (get-buffer-window ispell-choices-buffer t) | 2152 | ;; (get-buffer-window ispell-choices-buffer t) |
| 2155 | (select-window (previous-window))) ; *Choices* window | 2153 | (select-window (previous-window))) ; *Choices* window |
| 2156 | ;; standard selection by splitting a small buffer out of this window. | 2154 | ;; standard selection by splitting a small buffer out of this window. |
| 2157 | (let ((choices-window (get-buffer-window ispell-choices-buffer))) | 2155 | (let ((choices-window (get-buffer-window ispell-choices-buffer))) |
| @@ -2546,18 +2544,18 @@ Optional third arg SHIFT is an offset to apply based on previous corrections." | |||
| 2546 | (setq count (string-to-number output) ; get number of misses. | 2544 | (setq count (string-to-number output) ; get number of misses. |
| 2547 | output (substring output (1+ (string-match " " output 1))))) | 2545 | output (substring output (1+ (string-match " " output 1))))) |
| 2548 | (setq offset (string-to-number output)) | 2546 | (setq offset (string-to-number output)) |
| 2549 | (if (eq type ?#) ; No miss or guess list. | 2547 | (setq output (if (eq type ?#) ; No miss or guess list. |
| 2550 | (setq output nil) | 2548 | nil |
| 2551 | (setq output (substring output (1+ (string-match " " output 1))))) | 2549 | (substring output (1+ (string-match " " output 1))))) |
| 2552 | (while output | 2550 | (while output |
| 2553 | (let ((end (string-match ", \\|\\($\\)" output))) ; end of miss/guess. | 2551 | (let ((end (string-match ", \\|\\($\\)" output))) ; end of miss/guess. |
| 2554 | (setq cur-count (1+ cur-count)) | 2552 | (setq cur-count (1+ cur-count)) |
| 2555 | (if (> cur-count count) | 2553 | (if (> cur-count count) |
| 2556 | (setq guess-list (cons (substring output 0 end) guess-list)) | 2554 | (push (substring output 0 end) guess-list) |
| 2557 | (setq miss-list (cons (substring output 0 end) miss-list))) | 2555 | (push (substring output 0 end) miss-list)) |
| 2558 | (if (match-end 1) ; True only when at end of line. | 2556 | (setq output (if (match-end 1) ; True only when at end of line. |
| 2559 | (setq output nil) ; no more misses or guesses | 2557 | nil ; No more misses or guesses. |
| 2560 | (setq output (substring output (+ end 2)))))) | 2558 | (substring output (+ end 2)))))) |
| 2561 | ;; return results. Accept word if it was already accepted. | 2559 | ;; return results. Accept word if it was already accepted. |
| 2562 | ;; adjust offset. | 2560 | ;; adjust offset. |
| 2563 | (if (member original-word accept-list) | 2561 | (if (member original-word accept-list) |
| @@ -2849,8 +2847,7 @@ Return nil if spell session is quit, | |||
| 2849 | (message "searching for regions to skip")) | 2847 | (message "searching for regions to skip")) |
| 2850 | (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t) | 2848 | (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t) |
| 2851 | (progn | 2849 | (progn |
| 2852 | (setq key (buffer-substring-no-properties | 2850 | (setq key (match-string-no-properties 0)) |
| 2853 | (match-beginning 0) (match-end 0))) | ||
| 2854 | (set-marker skip-region-start (- (point) (length key))) | 2851 | (set-marker skip-region-start (- (point) (length key))) |
| 2855 | (goto-char reg-start))) | 2852 | (goto-char reg-start))) |
| 2856 | (let (message-log-max) | 2853 | (let (message-log-max) |
| @@ -2944,42 +2941,30 @@ Return nil if spell session is quit, | |||
| 2944 | "Return a regexp of the search keys for region skipping. | 2941 | "Return a regexp of the search keys for region skipping. |
| 2945 | Includes `ispell-skip-region-alist' plus tex, tib, html, and comment keys. | 2942 | Includes `ispell-skip-region-alist' plus tex, tib, html, and comment keys. |
| 2946 | Must call after `ispell-buffer-local-parsing' due to dependence on mode." | 2943 | Must call after `ispell-buffer-local-parsing' due to dependence on mode." |
| 2947 | ;; start with regions generic to all buffers | 2944 | (mapconcat |
| 2948 | (let ((skip-regexp (ispell-begin-skip-region ispell-skip-region-alist))) | 2945 | 'identity |
| 2949 | ;; Comments | 2946 | (delq nil |
| 2950 | (if (and (null ispell-check-comments) comment-start) | 2947 | (list |
| 2951 | (setq skip-regexp (concat (regexp-quote comment-start) "\\|" | 2948 | ;; messages |
| 2952 | skip-regexp))) | 2949 | (if (and ispell-checking-message |
| 2953 | (if (and (eq 'exclusive ispell-check-comments) comment-start) | 2950 | (not (eq t ispell-checking-message))) |
| 2954 | ;; search from end of current comment to start of next comment. | 2951 | (mapconcat #'car ispell-checking-message "\\|")) |
| 2955 | (setq skip-regexp (concat (if (string= "" comment-end) "^" | 2952 | ;; tex |
| 2956 | (regexp-quote comment-end)) | 2953 | (if (eq ispell-parser 'tex) |
| 2957 | "\\|" skip-regexp))) | 2954 | (ispell-begin-tex-skip-regexp)) |
| 2958 | ;; tib | 2955 | ;; html stuff |
| 2959 | (if ispell-skip-tib | 2956 | (if ispell-skip-html |
| 2960 | (setq skip-regexp (concat ispell-tib-ref-beginning "\\|" skip-regexp))) | 2957 | (ispell-begin-skip-region ispell-html-skip-alists)) |
| 2961 | ;; html stuff | 2958 | ;; tib |
| 2962 | (if ispell-skip-html | 2959 | (if ispell-skip-tib ispell-tib-ref-beginning) |
| 2963 | (setq skip-regexp (concat | 2960 | ;; Comments |
| 2964 | (ispell-begin-skip-region ispell-html-skip-alists) | 2961 | (if (and (eq 'exclusive ispell-check-comments) comment-start) |
| 2965 | "\\|" | 2962 | ;; search from end of current comment to start of next comment. |
| 2966 | skip-regexp))) | 2963 | (if (string= "" comment-end) "^" (regexp-quote comment-end))) |
| 2967 | ;; tex | 2964 | (if (and (null ispell-check-comments) comment-start) |
| 2968 | (if (eq ispell-parser 'tex) | 2965 | (regexp-quote comment-start)) |
| 2969 | (setq skip-regexp (concat (ispell-begin-tex-skip-regexp) "\\|" | 2966 | (ispell-begin-skip-region ispell-skip-region-alist))) |
| 2970 | skip-regexp))) | 2967 | "\\|")) |
| 2971 | ;; messages | ||
| 2972 | (if (and ispell-checking-message | ||
| 2973 | (not (eq t ispell-checking-message))) | ||
| 2974 | (setq skip-regexp (concat | ||
| 2975 | (mapconcat (lambda (lst) (car lst)) | ||
| 2976 | ispell-checking-message | ||
| 2977 | "\\|") | ||
| 2978 | "\\|" | ||
| 2979 | skip-regexp))) | ||
| 2980 | |||
| 2981 | ;; return new regexp | ||
| 2982 | skip-regexp)) | ||
| 2983 | 2968 | ||
| 2984 | 2969 | ||
| 2985 | (defun ispell-begin-skip-region (skip-alist) | 2970 | (defun ispell-begin-skip-region (skip-alist) |
| @@ -3456,15 +3441,6 @@ available on the net." | |||
| 3456 | ;;; Ispell Minor Mode | 3441 | ;;; Ispell Minor Mode |
| 3457 | ;;; ********************************************************************** | 3442 | ;;; ********************************************************************** |
| 3458 | 3443 | ||
| 3459 | (defvar ispell-minor-mode nil | ||
| 3460 | "Non-nil if Ispell minor mode is enabled.") | ||
| 3461 | ;; Variable indicating that ispell minor mode is active. | ||
| 3462 | (make-variable-buffer-local 'ispell-minor-mode) | ||
| 3463 | |||
| 3464 | (or (assq 'ispell-minor-mode minor-mode-alist) | ||
| 3465 | (setq minor-mode-alist | ||
| 3466 | (cons '(ispell-minor-mode " Spell") minor-mode-alist))) | ||
| 3467 | |||
| 3468 | (defvar ispell-minor-keymap | 3444 | (defvar ispell-minor-keymap |
| 3469 | (let ((map (make-sparse-keymap))) | 3445 | (let ((map (make-sparse-keymap))) |
| 3470 | (define-key map " " 'ispell-minor-check) | 3446 | (define-key map " " 'ispell-minor-check) |
| @@ -3472,14 +3448,8 @@ available on the net." | |||
| 3472 | map) | 3448 | map) |
| 3473 | "Keymap used for Ispell minor mode.") | 3449 | "Keymap used for Ispell minor mode.") |
| 3474 | 3450 | ||
| 3475 | (or (not (boundp 'minor-mode-map-alist)) | ||
| 3476 | (assoc 'ispell-minor-mode minor-mode-map-alist) | ||
| 3477 | (setq minor-mode-map-alist | ||
| 3478 | (cons (cons 'ispell-minor-mode ispell-minor-keymap) | ||
| 3479 | minor-mode-map-alist))) | ||
| 3480 | |||
| 3481 | ;;;###autoload | 3451 | ;;;###autoload |
| 3482 | (defun ispell-minor-mode (&optional arg) | 3452 | (define-minor-mode ispell-minor-mode |
| 3483 | "Toggle Ispell minor mode. | 3453 | "Toggle Ispell minor mode. |
| 3484 | With prefix argument ARG, turn Ispell minor mode on if ARG is positive, | 3454 | With prefix argument ARG, turn Ispell minor mode on if ARG is positive, |
| 3485 | otherwise turn it off. | 3455 | otherwise turn it off. |
| @@ -3489,11 +3459,7 @@ warns you if the previous word is incorrectly spelled. | |||
| 3489 | 3459 | ||
| 3490 | All the buffer-local variables and dictionaries are ignored -- to read | 3460 | All the buffer-local variables and dictionaries are ignored -- to read |
| 3491 | them into the running ispell process, type \\[ispell-word] SPC." | 3461 | them into the running ispell process, type \\[ispell-word] SPC." |
| 3492 | (interactive "P") | 3462 | nil " Spell" ispell-minor-keymap) |
| 3493 | (setq ispell-minor-mode | ||
| 3494 | (not (or (and (null arg) ispell-minor-mode) | ||
| 3495 | (<= (prefix-numeric-value arg) 0)))) | ||
| 3496 | (force-mode-line-update)) | ||
| 3497 | 3463 | ||
| 3498 | (defun ispell-minor-check () | 3464 | (defun ispell-minor-check () |
| 3499 | "Check previous word then continue with the normal binding of this key. | 3465 | "Check previous word then continue with the normal binding of this key. |
| @@ -3759,15 +3725,14 @@ You can bind this to the key C-c i in GNUS or mail by adding to | |||
| 3759 | (goto-char (point-min)) | 3725 | (goto-char (point-min)) |
| 3760 | ;; Select type or skip checking if this is a non-multipart message | 3726 | ;; Select type or skip checking if this is a non-multipart message |
| 3761 | ;; Point moved to end of buffer if region is encoded. | 3727 | ;; Point moved to end of buffer if region is encoded. |
| 3762 | (if (and mimep (not boundary)) | 3728 | (when (and mimep (not boundary)) |
| 3763 | (let (skip-regexp) ; protect from `ispell-mime-skip-part' | ||
| 3764 | (goto-char (point-min)) | 3729 | (goto-char (point-min)) |
| 3765 | (re-search-forward "Content-[^ \t]*:" end-of-headers t) | 3730 | (re-search-forward "Content-[^ \t]*:" end-of-headers t) |
| 3766 | (forward-line -1) ; following fn starts one line above | 3731 | (forward-line -1) ; following fn starts one line above |
| 3767 | (ispell-mime-skip-part nil) | 3732 | (ispell-mime-skip-part nil) |
| 3768 | ;; if message-text-end region, limit may be less than point. | 3733 | ;; if message-text-end region, limit may be less than point. |
| 3769 | (if (> (point) limit) | 3734 | (if (> (point) limit) |
| 3770 | (set-marker limit (point))))) | 3735 | (set-marker limit (point)))) |
| 3771 | (goto-char (max end-of-headers (point))) | 3736 | (goto-char (max end-of-headers (point))) |
| 3772 | (forward-line 1) | 3737 | (forward-line 1) |
| 3773 | (setq case-fold-search old-case-fold-search) | 3738 | (setq case-fold-search old-case-fold-search) |
| @@ -3850,7 +3815,7 @@ Includes Latex/Nroff modes and extended character mode." | |||
| 3850 | (sit-for 2)))))))) | 3815 | (sit-for 2)))))))) |
| 3851 | 3816 | ||
| 3852 | 3817 | ||
| 3853 | ;;; Can kill the current ispell process | 3818 | ;; Can kill the current ispell process |
| 3854 | 3819 | ||
| 3855 | (defun ispell-buffer-local-dict (&optional no-reload) | 3820 | (defun ispell-buffer-local-dict (&optional no-reload) |
| 3856 | "Initializes local dictionary and local personal dictionary. | 3821 | "Initializes local dictionary and local personal dictionary. |
| @@ -3923,16 +3888,14 @@ Both should not be used to define a buffer-local dictionary." | |||
| 3923 | (setq ispell-buffer-local-name (buffer-name))) | 3888 | (setq ispell-buffer-local-name (buffer-name))) |
| 3924 | (save-excursion | 3889 | (save-excursion |
| 3925 | (goto-char (point-min)) | 3890 | (goto-char (point-min)) |
| 3926 | (let ((old-case-fold-search case-fold-search) | 3891 | (let (line-okay search done found) |
| 3927 | line-okay search done found) | ||
| 3928 | (while (not done) | 3892 | (while (not done) |
| 3929 | (setq case-fold-search nil | 3893 | (let ((case-fold-search nil)) |
| 3930 | search (search-forward ispell-words-keyword nil 'move) | 3894 | (setq search (search-forward ispell-words-keyword nil 'move) |
| 3931 | found (or found search) | 3895 | found (or found search) |
| 3932 | line-okay (< (+ (length word) 1 ; 1 for space after word.. | 3896 | line-okay (< (+ (length word) 1 ; 1 for space after word.. |
| 3933 | (progn (end-of-line) (current-column))) | 3897 | (progn (end-of-line) (current-column))) |
| 3934 | 80) | 3898 | fill-column))) |
| 3935 | case-fold-search old-case-fold-search) | ||
| 3936 | (if (or (and search line-okay) | 3899 | (if (or (and search line-okay) |
| 3937 | (null search)) | 3900 | (null search)) |
| 3938 | (progn | 3901 | (progn |
| @@ -3941,7 +3904,13 @@ Both should not be used to define a buffer-local dictionary." | |||
| 3941 | (progn | 3904 | (progn |
| 3942 | (open-line 1) | 3905 | (open-line 1) |
| 3943 | (unless found (newline)) | 3906 | (unless found (newline)) |
| 3944 | (insert (concat comment-start " " ispell-words-keyword)) | 3907 | (insert (if (fboundp 'comment-padright) |
| 3908 | ;; Try and use the proper comment marker, | ||
| 3909 | ;; e.g. ";;" rather than ";". | ||
| 3910 | (comment-padright comment-start | ||
| 3911 | (comment-add nil)) | ||
| 3912 | comment-start) | ||
| 3913 | " " ispell-words-keyword) | ||
| 3945 | (if (> (length comment-end) 0) | 3914 | (if (> (length comment-end) 0) |
| 3946 | (save-excursion | 3915 | (save-excursion |
| 3947 | (newline) | 3916 | (newline) |