From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#66635: 30.0.50; customize-icon State button doesn't work (never did) Date: Fri, 20 Oct 2023 21:21:34 -0300 Message-ID: <1034a4cb-217a-4e60-a474-bf07948e3dd1@gmail.com> References: <0b43fa93-0540-45ec-ab2d-b2843888c806@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33705"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: Stefan Kangas , 66635@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 21 02:23:06 2023 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 1qtzlh-0008cT-Pg for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Oct 2023 02:23:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtzlG-0007fv-QF; Fri, 20 Oct 2023 20:22:38 -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 1qtzlE-0007fZ-Is for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2023 20:22:36 -0400 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 1qtzlD-00038q-HQ for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2023 20:22:36 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qtzle-0006g1-W2 for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2023 20:23:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 00:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66635 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66635-submit@debbugs.gnu.org id=B66635.169784773825587 (code B ref 66635); Sat, 21 Oct 2023 00:23:02 +0000 Original-Received: (at 66635) by debbugs.gnu.org; 21 Oct 2023 00:22:18 +0000 Original-Received: from localhost ([127.0.0.1]:41890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtzkv-0006ed-6p for submit@debbugs.gnu.org; Fri, 20 Oct 2023 20:22:18 -0400 Original-Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:42090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtzkp-0006eL-6I for 66635@debbugs.gnu.org; Fri, 20 Oct 2023 20:22:15 -0400 Original-Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c9e95aa02dso11014005ad.0 for <66635@debbugs.gnu.org>; Fri, 20 Oct 2023 17:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697847698; x=1698452498; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=H20uKSqmZVcWjiKZkyu/fsW0YqxuWwEWCduznTXaOeM=; b=gG+bwXImbw2U0w/mVg02ZgBLJtdh1eQmPpVFXNc4L/eeUIRMUvNGN/QngsK9mQhxK0 aFJS5OxNJylkETPAXrdzssNUiFBleV4vK3fbNMpYYd35NJBcZaB22wEnVZSzV/+5hz1F da+nCBtSbDTDcdJKRb4OSMeiziBUKA1B1LmG+VQLyLmUkv6f4vLuVAKwYXJvuvdXlNSa 2LZqInwlWOumFIpXo3y/y1GVnHTd98zLAH7gAsJnZZDmdp39mAAbV+Zq+kSEbfDc08vr dtjGTrQVY5pWUCzVE6OpfguJtfPGnEIGHfpWj2rjKFPCNPUSYMZft/TOAhyuBmxLQu81 n+Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697847698; x=1698452498; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H20uKSqmZVcWjiKZkyu/fsW0YqxuWwEWCduznTXaOeM=; b=oiU7267vsetB0enYchmOlqpNZJ18eVlfdgKZfsGG5bU/5K1IZdmPaoUH13pv5slEGO FV7erletJG1Qy/XWIhyVY3N6mIUJ6y3UOuU6mMCWE4SlTDTmaYXJlqPTrQ/bg4HZT1AN Pm+W9YM90kZx23NJAMP71fU038+N0oh0WNQnUPt33/8Z1Skb3H/rl9TK+rR8YBdwk8tb 19LkelafpmVWaQxe7wzEZaB24d/BXIDdZGCvzUR93PeHBMy+njKHIinAciSln+ks1nKk GXQhSwWkmMsfcpKnwma9ydzH3tJGOr0yYqTsWq86LHNAjsMKULOvq/nU0gLCp9IMD3ut EtWQ== X-Gm-Message-State: AOJu0YzA5P2xo6kxqmJ14jkOmYGwKUBxFQryIQMOo9dtFthsdjt6iwD5 IGMIaPtCpa/rEY9oXcQTtCI= X-Google-Smtp-Source: AGHT+IHs6zQg+cYkMuvKaBHaERsuPk80oaKKt7KqmH5SH7CUiUNOctCny8k1N1JaK3SebywVNWP9JQ== X-Received: by 2002:a17:903:2447:b0:1c5:ecfc:2650 with SMTP id l7-20020a170903244700b001c5ecfc2650mr8796856pls.14.1697847697532; Fri, 20 Oct 2023 17:21:37 -0700 (PDT) Original-Received: from [192.168.0.234] ([152.168.142.156]) by smtp.gmail.com with ESMTPSA id n18-20020a170902d2d200b001c737950e4dsm2083145plc.2.2023.10.20.17.21.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Oct 2023 17:21:37 -0700 (PDT) Content-Language: en-US In-Reply-To: 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:272824 Archived-At: On 20/10/23 18:08, Stefan Kangas wrote: > Mauro Aranda writes: > >> I attach a patch to address the more important issues for now.  That is, >> at least have a working State button and rudimentary state checking. >> >> Setting and Saving icon specifications through the State button should >> work now, by adding the custom-icon-action function. > > > Thanks for working on this. > > Do you propose this patch for emacs-29?  It seems quite intrusive on the > face of it, but OTOH `customize-icon' is new in Emacs 29, so there is no > risk of regressions if this stuff never worked in the first place.  Or > is that wrong? I'm not aware of all things you and Eli have to take into account when deciding whether a patch is good for emacs-29.  I know the non-intrusive or localized, and the safe part.  This patch is certainly neither, but it's the minimum (OK, maybe not the bare minimum) to make customizing icons work for an user.  I think that's a good reason for the patch to go into emacs-29, but I won't be insisting on it, specially if it is a burden, considering 29.1.90 pretest is out. It could be made less intrusive without the change to icons--merge-spec, but I don't think it'd be wise to do that. >> From ab4fabf48665ddc142ad95a26898eb6207cd2bdc Mon Sep 17 00:00:00 2001 >> From: Mauro Aranda >> Date: Thu, 19 Oct 2023 08:46:35 -0300 >> Subject: [PATCH] Fix State button for customize-icon (Bug#66635) >> >> * lisp/cus-edit.el (custom-icon-action): New function. >> (custom-icon): Use it as the :action.  Otherwise, clicking the State >> button is a noop.  Remove irrelevant stuff from the docstring and >> comment out some copy-pasta. >> (custom-icon-extended-menu): New variable, the menu to show upon >> :action. >> (custom-icon-set): Really redraw the widget with the new settings. >> Comment out strange call to custom-variable-backup-value. >> (custom-icon-save): New function. >> >> * lisp/emacs-lisp/icons.el (icons--merge-spec): Fix call to plist-get >> and avoid infloop. >> --- >>  lisp/cus-edit.el         | 71 +++++++++++++++++++++++++++++++++------- >>  lisp/emacs-lisp/icons.el |  6 ++-- >>  2 files changed, 62 insertions(+), 15 deletions(-) >> >> diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el >> index 706e08d5657..953b8b8b80f 100644 >> --- a/lisp/cus-edit.el >> +++ b/lisp/cus-edit.el >> @@ -5366,11 +5366,6 @@ 'custom-icon >>  :hidden-states should be a list of widget states for which the >>    widget's initial contents are to be hidden. >> >> -:custom-form should be a symbol describing how to display and >> -  edit the variable---either `edit' (using edit widgets), >> -  `lisp' (as a Lisp sexp), or `mismatch' (should not happen); >> -  if nil, use the return value of `custom-variable-default-form'. >> - >>  :shown-value, if non-nil, should be a list whose `car' is the >>    variable value to display in place of the current value. >> >> @@ -5383,11 +5378,34 @@ 'custom-icon >>    :custom-category 'option >>    :custom-state nil >>    :custom-form nil >> -  :value-create 'custom-icon-value-create >> +  :value-create #'custom-icon-value-create >>    :hidden-states '(standard) >> -  :custom-set 'custom-icon-set >> -  :custom-reset-current 'custom-redraw >> -  :custom-reset-saved 'custom-variable-reset-saved) >> +  :action #'custom-icon-action >> +  :custom-set #'custom-icon-set >> +  :custom-reset-current #'custom-redraw) >> +  ;; Not implemented yet. >> +  ;; :custom-reset-saved 'custom-icon-reset-saved) >> + >> +(defvar custom-icon-extended-menu >> +  (let ((map (make-sparse-keymap))) >> +    (define-key-after map [custom-icon-set] >> +      '(menu-item "Set for Current Session" custom-icon-set >> +                  :enable (eq (widget-get custom-actioned-widget :custom-state) >> +                              'modified))) >> +    (when (or custom-file init-file-user) >> +      (define-key-after map [custom-icon-save] >> +        '(menu-item "Save for Future Sessions" custom-icon-save >> +                    :enable (memq >> +                             (widget-get custom-actioned-widget :custom-state) >> +                             '(modified set changed))))) >> +    (define-key-after map [custom-redraw] >> +      '(menu-item "Undo Edits" custom-redraw >> +                  :enable (memq >> +                           (widget-get custom-actioned-widget :custom-state) >> +                           '(modified changed)))) >> +    map) >> +  "A menu for `custom-icon' widgets. >> +Used in `custom-icon-action' to show a menu to the user.") >> >>  (defun custom-icon-value-create (widget) >>    "Here is where you edit the icon's specification." >> @@ -5517,6 +5535,24 @@ custom-icon-value-create >>        (custom-add-parent-links widget)) >>      (custom-add-see-also widget))))) >> >> +(defun custom-icon-action (widget &optional event) >> +  "Show the menu for `custom-icon' WIDGET. >> +Optional EVENT is the location for the menu." >> +  (if (eq (widget-get widget :custom-state) 'hidden) >> +      (custom-toggle-hide widget) >> +    (unless (eq (widget-get widget :custom-state) 'modified) >> +      (custom-icon-state-set widget)) >> +    (custom-redraw-magic widget) >> +    (let* ((completion-ignore-case t) >> +           (custom-actioned-widget widget) >> +           (answer (widget-choose (concat "Operation on " >> + (custom-unlispify-tag-name >> +                                           (widget-get widget :value))) >> + custom-icon-extended-menu >> +                                  event))) >> +      (when answer >> +        (funcall answer widget))))) >> + >>  (defun custom-toggle-hide-icon (visibility-widget &rest _ignore) >>    "Toggle the visibility of a `custom-icon' parent widget. >>  By default, this signals an error if the parent has unsaved >> @@ -5553,10 +5589,21 @@ custom-icon-set >>        (user-error "Cannot update hidden icon")) >> >>      (setq val (custom--icons-widget-value child)) >> -    (unless (equal val (icon-complete-spec symbol)) >> -      (custom-variable-backup-value widget)) >> +    ;; FIXME: What was the intention here? >> +    ;; (unless (equal val (icon-complete-spec symbol)) >> +    ;;   (custom-variable-backup-value widget)) > > Is there any reason to not just remove this outright? > > It'd still be there in git history, in the unlikely event that we should > need it again. I just couldn't tell what was the intention.  Maybe the intention was to make a backup just like we do for variables, for later getting the backed up value again, like custom-variable-reset-value does.  In that case, the comment may help to remind someone (and certainly me if I ever get the time) to implement something like that.  Since I'm not certain what's the intention, I had no way of justifying the removal, so I opted to comment it out.  I won't object if you prefer otherwise.