From unknown Thu Jun 19 14:03:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52743: 29.0.50; Ispell completion-at-point function Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 Dec 2021 23:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52743 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 52743@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164021551331652 (code B ref -1); Wed, 22 Dec 2021 23:26:01 +0000 Received: (at submit) by debbugs.gnu.org; 22 Dec 2021 23:25:13 +0000 Received: from localhost ([127.0.0.1]:60000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0Ayv-0008ES-8O for submit@debbugs.gnu.org; Wed, 22 Dec 2021 18:25:13 -0500 Received: from lists.gnu.org ([209.51.188.17]:60594) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0Ays-0008EI-On for submit@debbugs.gnu.org; Wed, 22 Dec 2021 18:25:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Ays-0005fO-GH for bug-gnu-emacs@gnu.org; Wed, 22 Dec 2021 18:25:10 -0500 Received: from mail.ericabrahamsen.net ([52.70.2.18]:36400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Aym-00024n-Gr for bug-gnu-emacs@gnu.org; Wed, 22 Dec 2021 18:25:10 -0500 Received: from localhost (c-71-197-232-41.hsd1.wa.comcast.net [71.197.232.41]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id C7979FA093 for ; Wed, 22 Dec 2021 23:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1640215497; bh=vMklkQtEsaGV2+SmlMgKdpndfZl3hV2UmQSviVlaDak=; h=From:To:Subject:Date:From; b=UrhB8SUSJP41wIOxMRpZo9PVE2bFDxAkdJHAgyLG9uDvbzw2LZZlbp/daTMCytQZY v0CVI7rXEbI+ewtlT6sw7QAnbEu7WUozY1skcZXPqJsPNiK5G2BQTjqwWP80l037Iy OkNz+uDx2SNhH27xlsHpgsMtFOkcxwUxWBElBzsY= From: Eric Abrahamsen Date: Wed, 22 Dec 2021 15:24:55 -0800 Message-ID: <877dbw8bp4.fsf@ericabrahamsen.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@ericabrahamsen.net; helo=mail.ericabrahamsen.net X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Ispell doesn't currently come with a function suitable for use in `completion-at-point-functions' -- there's a FIXME comment to that effect on `ispell-complete-word'. I really don't think that `flyspell-mode' should be clobbering C-M-i by default, and replacing it with `flyspell-auto-correct-word': this essentially bypasses the entire capf machinery, and means you can't combine dictionary-based completion with any other completion. I've taken a stab at writing an `ispell-completion-at-point' function, to be added to `completion-at-point-functions'. Perhaps `flyspell-use-meta-tab' could be extended to accept the symbol 'capf, in which case `ispell-completion-at-point' would be added to `c-a-p-functions', and M-TAB/C-M-i would be left alone. The function currently doesn't work very well. I don't know what the `ispell-filter' is, or why it raises an error with "Ispell and its process have different character maps", but I'm sure I can figure that out. I wanted to raise this here first, to get some feedback. I know capf prefers its functions to simply return a table, but that seems unwieldy when we're talking about a completion dictionary with potentially hundreds of thousands of entries. The function below tries two things: - ispell-lookup-words, which uses the ispell process against `ispell-complete-word-dict' and `ispell-alternate-dictionary' to find completions. - ispell--run-on-word, which does a full spell-check on the word, and returns a list of potential corrections. This function and its return value are more complicated than I fully understand now, but I can spend some time figuring them out. So both options involve invoking the ispell process, and the function does the filtering itself. I know this isn't optimal, and I could also do a version that reads ispell-complete-word-dict or ispell-alternate-dictionary and returns the whole contents, with caching. (defun ispell-completion-at-point () (condition-case nil (progn (ispell-set-spellchecker-params) (ispell-accept-buffer-local-defs) (pcase-let* ((`(,word ,start ,end) (ispell-get-word nil)) (table (or (ignore-errors (ispell-lookup-words word)) (let ((run-return (ispell--run-on-word word))) (when (and (listp run-return) (> (length run-return) 0)) run-return))))) (list start end table))) ;; `user-error' is signaled when ispell fails to find a word to ;; work on, in which case we want to silently return nil. (user-error nil))) Anyway, please comment! Eric From unknown Thu Jun 19 14:03:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52743: Acknowledgement (29.0.50; Ispell completion-at-point function) Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Dec 2021 01:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52743 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 52743@debbugs.gnu.org Cc: monnier@iro.umontreal.ca X-Debbugs-Original-Xcc: monnier@iro.umontreal.ca Received: via spool by 52743-submit@debbugs.gnu.org id=B52743.16403107165192 (code B ref 52743); Fri, 24 Dec 2021 01:52:02 +0000 Received: (at 52743) by debbugs.gnu.org; 24 Dec 2021 01:51:56 +0000 Received: from localhost ([127.0.0.1]:35321 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0ZkS-0001Lg-Af for submit@debbugs.gnu.org; Thu, 23 Dec 2021 20:51:56 -0500 Received: from mail.ericabrahamsen.net ([52.70.2.18]:50704) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0ZkQ-0001LT-C8 for 52743@debbugs.gnu.org; Thu, 23 Dec 2021 20:51:55 -0500 Received: from localhost (c-71-197-232-41.hsd1.wa.comcast.net [71.197.232.41]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 6E1C4FA02D for <52743@debbugs.gnu.org>; Fri, 24 Dec 2021 01:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1640310708; bh=svD+uG1Dub2X/P3iS7Cz5SniTeylJNgGWJaD06Ld0AM=; h=From:To:Subject:References:Date:In-Reply-To:From; b=eoM/utkO4rGyfDyetgseUMXsp8c7kXAeQTCXp8Q+jwO46hpKOVaATKqXsX3wyw8VO UX71hPi0OX+i+Og+reGvxdC4lcVpBNiOCDFisiYYokMV+E9rbWpZitYNVhkksc+xuZ pq8lRjTTqAuynYCwXxblIWgqiOaLnFo7OKA1sjGQ= From: Eric Abrahamsen References: <877dbw8bp4.fsf@ericabrahamsen.net> Date: Thu, 23 Dec 2021 17:51:46 -0800 In-Reply-To: (GNU bug Tracking System's message of "Wed, 22 Dec 2021 23:26:01 +0000") Message-ID: <87fsqiepn1.fsf@ericabrahamsen.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Politely cc'ing Stefan, who is probably the only person who cares about this...