From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74511: 31.0.50; `dictionary-search-interface' overrides the user's customization of `dictionary-read-word-function' Date: Mon, 25 Nov 2024 19:17:04 +0100 Message-ID: References: <878qt8pik7.fsf@stebalien.com> <86sergihd5.fsf@gnu.org> <875xocpdxr.fsf@stebalien.com> <86plmjiko0.fsf@gnu.org> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7616"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Steven Allen , 74511@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 25 19:18:33 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1tFdfL-0001oA-4U for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 19:18:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFdf1-0005Ek-1J; Mon, 25 Nov 2024 13:18:12 -0500 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 1tFdet-0005DO-Oy for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2024 13:18:06 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFdet-0005qY-GD for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2024 13:18:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=oM+59xlbZGZ/yKMFQ7XME7O+2wsWU5f7aXr4UM7ZJpU=; b=I9NgEhb5G/YfzgYUQov6UHhgmXK7prbUdjIgZIJFbWRft3q8BRYPbjItR6kKzhDd1hLGjbB5vi7XUuHfFJeXznrwZKomZvImINN9f87XLmeR5a19kf60cfpn+9eh9iTdhUJ1UeWSDrrxfxKbX96t5r0z2XhI2nxWi6FYf94Tvc6Iuu9ZWyD5HWfL/d8cq1YdiDwPzEz7bIb3OEbafS1T5T9re4EiyyN4NyiDSJYmVUwcKAQN19FvhFaDXS6Do9sjFSexdRn5sDOKG1NyHP0/WWBhsB3i/jwJX0ONDQxtRPlWv0w+Y3rsAQPKgnVJNoDNZ1GWQPm+EB0SSbmQPBVMMw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tFdes-00056e-TR for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2024 13:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Nov 2024 18:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74511 X-GNU-PR-Package: emacs Original-Received: via spool by 74511-submit@debbugs.gnu.org id=B74511.173255863019499 (code B ref 74511); Mon, 25 Nov 2024 18:18:02 +0000 Original-Received: (at 74511) by debbugs.gnu.org; 25 Nov 2024 18:17:10 +0000 Original-Received: from localhost ([127.0.0.1]:40491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tFde2-00054Q-4L for submit@debbugs.gnu.org; Mon, 25 Nov 2024 13:17:10 -0500 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:37762 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tFddz-00054E-3g for 74511@debbugs.gnu.org; Mon, 25 Nov 2024 13:17:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1732558626; bh=u7APQbfW7Fld1HKpqYyAtDgCdMzbsdw+OqFaepVZecs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=gI9ZmgY/mF0DLrwb1G1tlt1FQ41uS/5++7SMefPwW0puNg1j70EXPgLfdoMXYqpND s7eSnKbb5sj/GnEbeDumbqz9juPz56c6o5/WsRPRwMDAMVPqqernqsWToVbPUHvhCB AuprQ0PrXeDd0zz/WXpYrJLt7zJ30MV9R8POTLhxGJSh6ROhXeiQOfnhxtE5U/8pqy 1lksWZX5+xO/jNCjUeOGN4maWptV2+h3UFapeRC4ZbwUYAbrbghSdtLPlyiIPonnTX J+EgfZ/K0sjNpCNhJb7f1VttMivRIpxgzc51tDZeiIjGuDWn52RHpIVnYBH7xBntuq 6KfA21B/OEb+w== In-Reply-To: <86plmjiko0.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 25 Nov 2024 14:04:47 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295950 Archived-At: Hi, Eli Zaretskii writes: >> From: Steven Allen >> Cc: 74511@debbugs.gnu.org >> Date: Sun, 24 Nov 2024 12:36:00 -0800 >> >> Eli Zaretskii writes: >> >> >> Date: Sun, 24 Nov 2024 10:56:08 -0800 >> >> From: Steven Allen via "Bug reports for GNU Emacs, >> >> the Swiss army knife of text editors" >> >> >> >> >> >> If the user customizes `dictionary-read-word-function' then loads the >> >> dictionary package, the value of `dictionary-read-word-function' will be >> >> overridden when `dictionary-search-interface' is loaded. To reproduce: >> >> >> >> 1. Run emacs with `emacs -Q`. >> >> 2. Open a scratch buffer and evaluate the following: >> >> >> >> (setopt dictionary-read-word-function 'dictionary-completing-read-word) >> >> (require 'dictionary) >> >> (message "%S" dictionary-read-word-function) >> >> >> >> I'd expect `dictionary-read-word-function' to be >> >> `dictionary-completing-read-word' but instead it gets reset back to the >> >> default, `dictionary-read-dictionary-default'. I can work around this by >> >> calling `setopt' after loading the `dictionary' package, but ideally >> >> that wouldn't be necessary. >> > >> > You are supposed to customize dictionary-search-interface if you want >> > this mode of operation. >> >> In addition to dictionary-search-interface, there are three separately >> customizable variables: >> >> - dictionary-display-definition-function >> - dictionary-read-word-function >> - dictionary-read-dictionary-function >> >> I'd expect dictionary-search-interface to override the defaults for >> these variables, but I wouldn't expect it to completely clobber any user >> customizations of said variables. >> >> If these variables cannot be customized, I'd expect them to be "defvar" >> not "defcustom". Although that would be rather unfortunate because, >> while I want to enable minibuffer completion for words/dictionaries, I'd >> also like to use the real dictionary mode (not the help buffer). >> >> Adding ":initialize 'custom-initialize-changed" to >> dictionary-search-interface would make it possible to specify either >> dictionary-search-interface or any of the other variables (but not both >> at the same time). > > Eshel, would you please look into this? IMO, we should at least > improve the documentation to clarify these subtleties. Bonus points > for allowing users to customize the other options without clobbering > them when the package is loaded or dictionary-search-interface is > customized. Thank you Steven, for reporting this issue, and Eli, for pinging me. The patch below tries to do both: - it adds a few words to the docstring of dictionary-search-interface which explain that this option can only be meaningfully set after loading dictionary.el, and - it avoids clobbering existing settings for the other options during initialization. It still overrides existing settings for the other options if you set dictionary-search-interface after dictionary.el, because that's the intended behavior when customizing this option. WDYT? diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index 58c2e9771ba..0f9daa2d07d 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -301,21 +301,30 @@ dictionary-search-interface When set to `help', `dictionary-search' displays definitions in a *Help* buffer, and provides completion for word selection based on dictionary matches. -Otherwise, `dictionary-search' displays definitions in a *Dictionary* buffer." +Otherwise, `dictionary-search' displays definitions in a *Dictionary* buffer. + +This option only takes affect when you customize it after loading the +`dictionary' library, so you may want to use `with-eval-after-load' to +set it in your Emacs initialization file." :type '(choice (const :tag "Dictionary buffer" nil) (const :tag "Help buffer" help)) :set (lambda (symbol value) - (let ((vals (pcase value - ('help '(dictionary-display-definition-in-help-buffer - dictionary-completing-read-word - dictionary-completing-read-dictionary)) - (_ '(nil - dictionary-read-word-default - dictionary-read-dictionary-default))))) - (seq-setq (dictionary-display-definition-function - dictionary-read-word-function - dictionary-read-dictionary-function) - vals)) + ;; If the symbol of this option is not bound, then we are + ;; initializing it, and the user hasn't set it in init.el. + ;; Avoid overriding individual customization of other options + ;; in this case. + (when (boundp symbol) + (let ((vals (pcase value + ('help '(dictionary-display-definition-in-help-buffer + dictionary-completing-read-word + dictionary-completing-read-dictionary)) + (_ '(nil + dictionary-read-word-default + dictionary-read-dictionary-default))))) + (seq-setq (dictionary-display-definition-function + dictionary-read-word-function + dictionary-read-dictionary-function) + vals))) (set-default-toplevel-value symbol value)) :version "30.1")