From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arash Esbati Newsgroups: gmane.emacs.devel Subject: Ispell: Skipping part of text in texinfo-mode Date: Thu, 29 Aug 2024 18:25:02 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5476"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: "emacs-devel" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Aug 29 18:25:50 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sjhy2-0001FF-7o for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Aug 2024 18:25:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjhxM-0004C0-JR; Thu, 29 Aug 2024 12:25:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sjhxL-0004Bq-2p for emacs-devel@gnu.org; Thu, 29 Aug 2024 12:25:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sjhxK-0006AW-Ov for emacs-devel@gnu.org; Thu, 29 Aug 2024 12:25:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=TRPjTzZr3HyJDQLfjKr1dATdcrtShEPs68ziMQ9iukk=; b=rMXfz2bsVnmFJ4 mMQmi9VQNuh0+61hq9JCDPMgur91dYQxPzGREz5jbF9zeAAB5EQ7GJUjt9gMai65aqphcFb27weRM MOO7w3iFyE2lLYDGh1rVDz0yRRzlCjxl9EUL5UTCIVJEyQXV5uPKg5r/06nqWaotNbgWEC3fHchtV 4NUV30XQ0VK0eAFaXo/XDQclc5Cjf7iigQ0D36Q8MUUthlTm3CB2v3MoGDzDa/033QSKhy9eyM48v xpns0oT3ydS3wHmLzxmrzwtp4XQft6YFYdyXchxMkB7QmonHcz+fATAS3d0hUmdRBR0MpqAjn8R0Z lZBZdJ33PeVRAejTjzKg==; X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:323181 Archived-At: Hi all, I wanted to spellcheck a .texi file with 'M-x ispell RET' (running hunspell) and it occurred to me that skipping part of text like in .tex files isn't available OOTB. In my experiment, ispell didn't ignore anything and checked every Texinfo macro. Having no clue about ispell.el, I managed to ease the pain with this change: --8<---------------cut here---------------start------------->8--- diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 99f9e10a5a8..af12c99ce0a 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -1744,6 +1744,36 @@ ispell-html-skip-alists (e.g. \"<[tT][tT]/\" and \"<[^ \\t\\n>]\").") (put 'ispell-html-skip-alists 'risky-local-variable t) +;;;###autoload +(defvar ispell-texinfo-skip-alists + (let ((single-arg (regexp-opt '("acronym" "cite" "code" "command" "env" + "file" "key" "option" "url" "var") + "@\\(?:")) + (skip-line (regexp-opt '("deffn" "defun" "defopt" "defvar" + "findex" "vindex" "kindex" "cindex" + "end " + "ifclear" "ifset" "include" + "setfilename" ) + "^@\\(?:"))) + `(;; Macros with a single arg + (,single-arg ispell-tex-arg-end) + ;; Special arrangement for things like @kbd{C-(} + ("@\\(?:kbd\\|samp\\){" . "[^@]}") + ;; Envs to skip entirely + ("^@\\(?:\\(?:small\\)?example\\|lisp\\|verbatim\\)" . + "^@end \\(?:\\(?:small\\)?example\\|lisp\\|verbatim\\)") + ;; macros w/o arg + (,skip-line forward-line) + ;; This is for the first line: + ("\\\\input" forward-line) + ;; All other macros + ("@[a-zA-Z]+"))) + "Lists of start and end keys to skip in texinfo buffers. +Same format as `ispell-skip-region-alist'. +Note - Match for general texinfo macros like @foo must come last, e.g.: + (\"@[a-zA-Z]+\").") +(put 'ispell-texinfo-skip-alists 'risky-local-variable t) + (defvar-local ispell-local-pdict ispell-personal-dictionary "A buffer local variable containing the current personal dictionary. If non-nil, the value must be a string, which is a file name. @@ -1799,11 +1829,11 @@ ispell-accept-output and pass it the output of the last Ispell invocation." (if ispell-async-processp (if (process-live-p ispell-process) - (let ((timeout (if timeout-msecs - (+ (or timeout-secs 0) (/ timeout-msecs 1000.0)) - timeout-secs))) - (accept-process-output ispell-process timeout)) - (error "No Ispell process to read output from!")) + (let ((timeout (if timeout-msecs + (+ (or timeout-secs 0) (/ timeout-msecs 1000.0)) + timeout-secs))) + (accept-process-output ispell-process timeout)) + (error "No Ispell process to read output from!")) (if (null ispell-process) (error "No Ispell process to read output from!") (let ((buf ispell-output-buffer) @@ -3277,6 +3307,8 @@ ispell-begin-skip-region-regexp ;; tex (if (eq ispell-parser 'tex) (ispell-begin-tex-skip-regexp)) + (if (eq ispell-parser 'texinfo) + (ispell-begin-skip-region ispell-texinfo-skip-alists)) ;; html stuff (if ispell-skip-html (ispell-begin-skip-region ispell-html-skip-alists)) @@ -3341,6 +3373,9 @@ ispell-skip-region-list skip-alist (append (car ispell-tex-skip-alists) (car (cdr ispell-tex-skip-alists)) skip-alist))) + (if (eq ispell-parser 'texinfo) + (setq case-fold-search nil + skip-alist (append ispell-texinfo-skip-alists skip-alist))) (if ispell-skip-html (setq skip-alist (append ispell-html-skip-alists skip-alist))) (if (and ispell-checking-message --8<---------------cut here---------------end--------------->8--- I presume there are some .texi writers here and I'd like to know how others handle this. Is the change above useful for ispell.el? Otherwise I can put it in my init file and add it locally to `ispell-skip-region-alist' in `texinfo-mode'. Best, Arash