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: Re: Ispell: Skipping part of text in texinfo-mode Date: Fri, 30 Aug 2024 10:13:59 +0200 Message-ID: References: <8634mnfcag.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21908"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Aug 30 10:14:51 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 1sjwmQ-0005XY-Rz for ged-emacs-devel@m.gmane-mx.org; Fri, 30 Aug 2024 10:14:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjwlk-0007WF-NX; Fri, 30 Aug 2024 04:14: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 1sjwlh-0007Vm-JM for emacs-devel@gnu.org; Fri, 30 Aug 2024 04:14:05 -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 1sjwlh-00038g-9y for emacs-devel@gnu.org; Fri, 30 Aug 2024 04:14:05 -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:References:In-Reply-To:Subject:To: From; bh=dYIL602d27Ud4GnaRA/c1tyQ/KLW6ADrhnruHbkgOko=; b=MKO3vRn1DG0YP3bpDzJI IGdX/9fzcGwK1wPWhElByX2CTugEj8pCXCWHX+85MQ7EqVjdv4++0xKMHNmIXURVnqXvcEiN7MZTj MYENwZZ8aGw8xEdeFmfwnYzd14L0yJB0Y77kSdmi89hd7iQXhTsw9X0Dd3tfol+qjL4D/9nU2FVQ1 VFjN+fGQHDG2WlNEixPiL7bmF2XrxYbMXAJhC1hC3SKVe5yDnw66mky2cirFca4iScgTFZOqxsd9q bu4n/hmBwt8cPJlyFVK/V3PkuHFzw8ZjoJdK37yehxWQ8JgZ2cTRNQqTeVUAfISDUbifARSppd2hx uWVF4IaIQ84Iqw==; In-Reply-To: <8634mnfcag.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 29 Aug 2024 20:51:03 +0300") 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:323194 Archived-At: Eli Zaretskii writes: > Thanks. But there be dragons... I thought so, and I was hoping that someone could guide me through that unknown water :-) > There are many more, no? @samp, @sc, @item, @itemx, to mention just a > few. > [...] > Likewise here: @defmac, @defspec, and many others (see the Texinfo > manual). Yes, at some point, I have to go through the @-Command List section in the Texinfo manual. > What about @kbd in general? and @key? See below, the first regexp approach was fragile anyway, I think I have a better solution now. > Why "entirely"? They frequently include comments, not just code. I think the environments contain more code to be ignored than comments to check, but that's only me. > Very simple: press 'a' once on each directive you never want to look > at, and leave the rest for judgment calls. Thanks, this was also my approach until now, but I didn't find it satisfactory. > To some degree, I guess. I think we should take only the bare > minimum, the ones that we want _never_ to be marked as mis-spellings, > and leave the rest to the users. We can discuss which macros to include and which to drop once the code is working. I'm currently facing the issue that when I open a .texi file, eval (setq ispell-parser 'texinfo) and do M-x ispell RET, also comments in the file are checked, the value of `ispell-check-comments' is nil, though. Do you have an idea what's going wrong? I don't get this in a .tex buffer. Here the latest patch: --8<---------------cut here---------------start------------->8--- diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 99f9e10a5a8..8da5681af1c 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -1744,6 +1744,37 @@ 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" "kbd" "key" "option" "samp" + "url" "var") + "@\\(?:")) + (skip-line (regexp-opt '("deffn" "deffnx" "defmac" "defun" + "defopt" "defspec" "defvar" + "findex" "vindex" "kindex" "cindex" + "end " + "ifclear" "ifset" "include" + "item" "itemx" + "setfilename") + "^@\\(?:"))) + `(;; Macros with a single arg + (,single-arg ispell-texinfo-arg-end) + ;; 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 +1830,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 +3308,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 +3374,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 @@ -3360,6 +3396,30 @@ ispell-tex-arg-end (beep) (sit-for 2)))) +(defvar ispell--texinfo-arg-end-syntax-table + (let ((table (make-syntax-table)) + (chars '((?\f . ">") (?\n . ">") + (?\" . " ") (?\@ . "/") + (?\( . " ") (?\) . " ") + (?\[ . " ") (?\] . " ") + (?\< . " ") (?\> . " ") + (?\\ . " ") + (?\{ . "(}") (?\} . "){")))) + (dolist (elt chars) + (modify-syntax-entry (car elt) (cdr elt) table)) + table)) + +(defun ispell-texinfo-arg-end (&optional arg) + "Skip across ARG number of braces." + (condition-case nil + (with-syntax-table ispell--texinfo-arg-end-syntax-table + (unless (= (following-char) ?\{) + (skip-chars-forward "^{")) + (forward-sexp (or arg 1))) + (error + (message "Error skipping s-expressions at point %d." (point)) + (beep) + (sit-for 2)))) (defun ispell-ignore-fcc (start end) "Query whether to delete Fcc header due to attachment between START and END. --8<---------------cut here---------------end--------------->8---