unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6411: Ispell string or comment
@ 2010-06-12 17:57 Lennart Borgman
  2010-06-22 15:00 ` Agustin Martin
  2019-08-21 14:07 ` Stefan Kangas
  0 siblings, 2 replies; 15+ messages in thread
From: Lennart Borgman @ 2010-06-12 17:57 UTC (permalink / raw)
  To: 6411

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]

Here is a suggestion for a function ispell-comment-or-string for spell
checking of current comment or string, see attachement.

[-- Attachment #2: ispell-comment-0.diff --]
[-- Type: text/x-patch, Size: 1537 bytes --]

=== modified file 'lisp/textmodes/ispell.el'
--- trunk/lisp/textmodes/ispell.el	2010-05-13 10:36:03 +0000
+++ patched/lisp/textmodes/ispell.el	2010-06-12 17:53:38 +0000
@@ -3266,11 +3266,21 @@
 
 
 ;;;###autoload
-(defun ispell-comments-and-strings ()
+(defun ispell-comments-and-strings (only-current)
   "Check comments and strings in the current buffer for spelling errors."
-  (interactive)
+  (interactive (list nil))
+  (let (state done)
+    (if (not only-current)
   (goto-char (point-min))
-  (let (state done)
+      (let* ((here (point))
+             (state (parse-partial-sexp (point-min) (point)))
+             (inside (or (nth 3 state) (nth 4 state)))
+             (start (when inside (nth 8 state))))
+        (if start
+            (goto-char start)
+          (setq done t)
+          (goto-char here)
+          (message "Not inside a string or comment"))))
     (while (not done)
       (setq done t)
       (setq state (parse-partial-sexp (point) (point-max)
@@ -3282,8 +3292,14 @@
 	    (if (or (nth 3 state) (nth 4 state))
 		(error "Unterminated string or comment"))
 	    (save-excursion
-	      (setq done (not (ispell-region start (point))))))))))
+	      (setq done (not (ispell-region start (point)))))))
+      (when only-current (setq done t)))))
 
+;;;###autoload
+(defun ispell-comment-or-string ()
+  "Check comments or strings at point for spelling errors."
+  (interactive)
+  (ispell-comments-and-strings t))
 
 ;;;###autoload
 (defun ispell-buffer ()


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-08-26 11:27 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-12 17:57 bug#6411: Ispell string or comment Lennart Borgman
2010-06-22 15:00 ` Agustin Martin
2019-08-21 14:07 ` Stefan Kangas
2019-08-21 17:08   ` Eli Zaretskii
2019-08-21 20:57     ` Stefan Kangas
2020-04-08 19:23     ` bug#6411: Ispell string or comment, " Štěpán Němec
2020-04-09  6:21       ` Eli Zaretskii
2020-04-09 14:48         ` Štěpán Němec
2020-04-09 17:06           ` Eli Zaretskii
2020-04-09 17:11             ` Eli Zaretskii
2020-04-09 18:44             ` Štěpán Němec
2020-04-09 19:01               ` Eli Zaretskii
2020-04-09 19:56                 ` Štěpán Němec
2020-04-10  6:22                   ` Eli Zaretskii
2020-08-26 11:27         ` Štěpán Němec

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).