]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/ispell.el
Doc fix in Commentary section.
[gnu-emacs] / lisp / textmodes / ispell.el
index 727a3653f10bff73ff4ece4aa90f215ad109a577..60cf46da30d006f03f2f79671f6f876419c30006 100644 (file)
@@ -80,6 +80,7 @@
 ;;   ispell-region
 ;;   ispell-buffer
 ;;   ispell-message
+;;   ispell-comments-and-strings
 ;;   ispell-continue
 ;;   ispell-complete-word
 ;;   ispell-complete-word-interior-frag
@@ -455,7 +456,8 @@ The function must take one string argument and return a string."
   "*File name of your personal spelling dictionary, or nil.
 If nil, the default personal dictionary, \"~/.ispell_DICTNAME\" is used,
 where DICTNAME is the name of your default dictionary."
-  :type 'file
+  :type '(choice file
+                (const :tag "default" nil))
   :group 'ispell)
 
 (defcustom ispell-silently-savep nil
@@ -992,7 +994,7 @@ Word syntax described by `ispell-dictionary-alist' (which see)."
        (error "No word found to check!"))
     (setq start (match-beginning 0)
          end (point)
-         word (buffer-substring start end))
+         word (buffer-substring-no-properties start end))
     (list word start end)))
 
 
@@ -1707,7 +1709,7 @@ With prefix argument, set the default directory."
                   (setq ispell-dictionary dict))
               (if (null arg)           ; set local dictionary
                   (setq ispell-local-dictionary dict)))
-          (error "Illegal dictionary: %s" dict))
+          (error "Invalid Ispell dictionary: %s" dict))
         (ispell-kill-ispell t)
         (message "(Next %sIspell command will use %s dictionary)"
                  (cond ((equal ispell-local-dictionary ispell-dictionary)
@@ -1980,6 +1982,25 @@ With prefix argument, set the default directory."
       (message "Spell-checking done"))))
 
 
+;;;###autoload
+(defun ispell-comments-and-strings ()
+  "Check comments and strings in the current buffer for spelling errors."
+  (interactive)
+  (goto-char (point-min))
+  (let (state done)
+    (while (not done)
+      (setq done t)
+      (setq state (parse-partial-sexp (point) (point-max)
+                                     nil nil state 'syntax-table))
+      (when (or (nth 3 state) (nth 4 state))
+       (let ((start (point)))
+         (setq state (parse-partial-sexp start (point-max)
+                                         nil nil state 'syntax-table))
+         (when (or (nth 3 state) (nth 4 state))
+           (error "Unterminated string or comment."))
+         (save-excursion
+           (setq done (not (ispell-region start (point))))))))))
+
 
 ;;;###autoload
 (defun ispell-buffer ()
@@ -2359,7 +2380,7 @@ Includes latex/nroff modes and extended character mode."
                 (process-send-string ispell-process "-\n~nroff"))
                ((string-match "~" string) ; Set extended character mode.
                 (process-send-string ispell-process (concat string "\n")))
-               (t (message "Illegal Ispell Parsing argument!")
+               (t (message "Invalid Ispell Parsing argument!")
                   (sit-for 2))))))))
 
 
@@ -2380,13 +2401,15 @@ Both should not be used to define a buffer-local dictionary."
        (setq end (save-excursion (end-of-line) (point)))
        (if (re-search-forward " *\\([^ \"]+\\)" end t)
            (setq ispell-local-dictionary
-                 (buffer-substring (match-beginning 1) (match-end 1)))))
+                 (buffer-substring-no-properties (match-beginning 1)
+                                                 (match-end 1)))))
       (goto-char (point-min))
       (while (search-forward ispell-pdict-keyword nil t)
        (setq end (save-excursion (end-of-line) (point)))
        (if (re-search-forward " *\\([^ \"]+\\)" end t)
            (setq ispell-local-pdict
-                 (buffer-substring (match-beginning 1) (match-end 1)))))))
+                 (buffer-substring-no-properties (match-beginning 1)
+                                                 (match-end 1)))))))
   ;; Reload if new personal dictionary defined.
   (if (and ispell-local-pdict
           (not (equal ispell-local-pdict ispell-personal-dictionary)))