From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#66635: 30.0.50; customize-icon State button doesn't work (never did) Date: Fri, 20 Oct 2023 14:08:05 -0700 Message-ID: References: <0b43fa93-0540-45ec-ab2d-b2843888c806@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25179"; mail-complaints-to="usenet@ciao.gmane.io" To: Mauro Aranda , 66635@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 20 23:08:52 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 1qtwjj-0006OA-I4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 20 Oct 2023 23:08:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtwjV-0005X3-RV; Fri, 20 Oct 2023 17:08:37 -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 1qtwjT-0005WD-T2 for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2023 17:08:35 -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 1qtwjT-0005bC-H8 for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2023 17:08:35 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qtwju-0006AZ-9R for bug-gnu-emacs@gnu.org; Fri, 20 Oct 2023 17:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Oct 2023 21:09: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.169783612523690 (code B ref 66635); Fri, 20 Oct 2023 21:09:02 +0000 Original-Received: (at 66635) by debbugs.gnu.org; 20 Oct 2023 21:08:45 +0000 Original-Received: from localhost ([127.0.0.1]:41752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtwjc-0006A0-DQ for submit@debbugs.gnu.org; Fri, 20 Oct 2023 17:08:44 -0400 Original-Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]:52456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtwjX-00069l-N1 for 66635@debbugs.gnu.org; Fri, 20 Oct 2023 17:08:42 -0400 Original-Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c523ac38fbso18880881fa.0 for <66635@debbugs.gnu.org>; Fri, 20 Oct 2023 14:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697836086; x=1698440886; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:references:in-reply-to:from :from:to:cc:subject:date:message-id:reply-to; bh=TyfXXNwaeKy/k+nI9NrpsLZB0ns7KxFwgY7mX3KMfX0=; b=ZpZoQeSCUGM7gKiPj+fTZlwDlLRKNCAdGdhUxhHn6Vj497cGlNEpRQtpXqYZo+r76u 0Wqdf3ELEXuiPFZv/pChLxSgbOGC3ZeraeX6BPaFzyxc6XKbU0x+tGZb2mUuDSdLbA17 foHGTHDy8TfBsiFIOIThCiHLNWP0nyU6YXJjWfGkF065rYpBsmr9rTDagpIeK4aHwdDW 4cRI4j5CInRBQjepvYRUDcWXQNQQwg4MFO/+K2N73Gxdp88Scvfvbx3sTgSSjem83n1X 1hlYOkYowZQpD8mSYwSCf/dEXyivFc7mkgf2GxqNoz4z87RezdZ5S4dojYozt/TU0A6d uJ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697836086; x=1698440886; h=to:subject:message-id:date:mime-version:references:in-reply-to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TyfXXNwaeKy/k+nI9NrpsLZB0ns7KxFwgY7mX3KMfX0=; b=qNhHX3BG5VlRSiTQmrSRnPbjk65ZcpbeQ7UgU2M4T4k6aGoOwPw5txx7HRRgZHvYQ/ eTSXYyFEh/UZin6knv5q2P8D/qymwg6L4H0Gv0Q8cMxp6Cg4U2nIY06Zl3RexgHFlaMR fobgh6ueXTDs0E5nE0ueYodIDjYe28Q1OYul/C2XiWBT8p93b5t8hL4mJv08ufvzHMio mbC5EJqpWsMznX/znrI1MoOQPTpyiEYDxIF3IUgAN3iEpqR2LEUO7A4wSh8a2GGPcZsc 7DPlEoRKSt8JgNyHD1an7onfKNFIPtubNwoS/WgUZ/q3hnazQDBW+wj57M//keVY5ig6 v/GA== X-Gm-Message-State: AOJu0YwOSlAG6GA6GWQrJ4YHU3dDDZN73fji7b6O6qomHK8X1TGMNrLY tt8O/zvb5k0mzgz7rV7mThfOs6SRltobapBcoOg= X-Google-Smtp-Source: AGHT+IFTePhU68HsUjWVcQePIOs9/Y0fttp31/qZ0+ip7v3oFLsQeeDsNtRljAWXHxve/cWaGrmF4OZEsRla6v5LpQU= X-Received: by 2002:a2e:7004:0:b0:2c4:ff4c:64b0 with SMTP id l4-20020a2e7004000000b002c4ff4c64b0mr2056476ljc.50.1697836085667; Fri, 20 Oct 2023 14:08:05 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 20 Oct 2023 14:08:05 -0700 In-Reply-To: <0b43fa93-0540-45ec-ab2d-b2843888c806@gmail.com> 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:272819 Archived-At: 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? > 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. > (custom-push-theme 'theme-icon symbol 'user 'set val) > - (custom-redraw-magic widget))) > + (custom-redraw widget))) > + > +(defun custom-icon-save (widget) > + "Save value of icon edited by widget WIDGET." > + (custom-set-icons (cons (widget-value widget) > + (list > + (custom--icons-widget-value > + (car (widget-get widget :children)))))) > + (custom-save-all) > + (custom-icon-state-set widget) > + (custom-redraw-magic widget)) > > ;;;###autoload > (defun customize-icon (icon) > diff --git a/lisp/emacs-lisp/icons.el b/lisp/emacs-lisp/icons.el > index cb08c1a6b81..9a6d26243c7 100644 > --- a/lisp/emacs-lisp/icons.el > +++ b/lisp/emacs-lisp/icons.el > @@ -181,9 +181,9 @@ icons--merge-spec > (let ((parent-keywords (icon-spec-keywords elem)) > (current-keywords (icon-spec-keywords current))) > (while parent-keywords > - (unless (plist-get (car parent-keywords) current-keywords) > - (nconc current (take 2 parent-keywords)) > - (setq parent-keywords (cddr parent-keywords)))))))) > + (unless (plist-get current-keywords (car parent-keywords)) > + (nconc current (take 2 parent-keywords))) > + (setq parent-keywords (cddr parent-keywords))))))) > merged) > > (cl-defmethod icons--create ((_type (eql 'image)) icon keywords) > -- > 2.34.1