unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RFC: omit some variables from custom-save-variables
@ 2020-06-19 18:41 Ted Zlatanov
  2020-06-19 20:14 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Zlatanov @ 2020-06-19 18:41 UTC (permalink / raw)
  To: Emacs Development, John Wiegley

Hello!

I am proposing a simple way for Emacs packages to use the customize
machinery without forcing the variables to be saved.

A good use case is to let use-package :custom coexist with
cus-edit.el:custom-save-variables. It bothered me yesterday because I
like use-package :custom a lot so I thought I'd propose something :)

Specific example. On the use-package side, something like this:

  (use-package python-mode
    :custom
    (python-indent-offset 4))

creates python-indent-offset in my custom.el file *and* in the code
above, creating duplication and possible problems if I remove it from
the use-package invocation.

The proposal is for use-package to apply the save-exemptions symbol
property behind the scenes. This is a new symbol property. 

This change has no effect on existing code or customizations so it's a
gentle upgrade. For users with older Emacs versions, there is no
difference.

There is no provision in this proposal for channeling Customize UI
interactions into use-package :custom or other places. Users will have
to manually migrate customized variables from the custom.el file, just
like they do now.

Ted

#+BEGIN_SRC diff
diff --git i/lisp/cus-edit.el w/lisp/cus-edit.el
index 1ec2708550..308bb9fa0a 100644
--- i/lisp/cus-edit.el
+++ w/lisp/cus-edit.el
@@ -4600,6 +4600,8 @@ custom-save-variables
       (mapatoms
        (lambda (symbol)
         (if (and (get symbol 'saved-value)
+                 ;; Drop explicitly ignored customizations.
+                 (null (get symbol 'save-exemptions))
                  ;; ignore theme values
                  (or (null (get symbol 'theme-value))
                      (eq 'user (caar (get symbol 'theme-value)))))
#+END_SRC



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: RFC: omit some variables from custom-save-variables
  2020-06-19 18:41 RFC: omit some variables from custom-save-variables Ted Zlatanov
@ 2020-06-19 20:14 ` Stefan Monnier
  2020-06-19 20:24   ` Ted Zlatanov
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2020-06-19 20:14 UTC (permalink / raw)
  To: Emacs Development; +Cc: John Wiegley

> The proposal is for use-package to apply the save-exemptions symbol
> property behind the scenes. This is a new symbol property. 

Hmm... my reflex would have been to make use-package use something like

    (funcall (or (get variable 'custom-set) #'set-default) variable value)

instead of whichever other way it currently uses to set the variable.

Could you describe what would be the advantage of introducing a new
symbol property?

[ BTW: whichever way we end up going, I think that it would be better if
  use-package didn't use custom's symbol properties, so we should
  introduce a new function (I suggest to name it
  `customize-set-variable-external` to get the bikeshedding
  rolling ;-). ]


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFC: omit some variables from custom-save-variables
  2020-06-19 20:14 ` Stefan Monnier
@ 2020-06-19 20:24   ` Ted Zlatanov
  2020-06-19 21:26     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Zlatanov @ 2020-06-19 20:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: John Wiegley, Emacs Development

On Fri, 19 Jun 2020 16:14:01 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> The proposal is for use-package to apply the save-exemptions symbol
>> property behind the scenes. This is a new symbol property. 

SM> Hmm... my reflex would have been to make use-package use something like

SM>     (funcall (or (get variable 'custom-set) #'set-default) variable value)

SM> instead of whichever other way it currently uses to set the variable.

Does that omit the variable from the custom.el file? The problem is the
double persistence, both in code and in custom.el.

SM> Could you describe what would be the advantage of introducing a new
SM> symbol property?

Soft migration, no unexpected behavior, everything works like it does today.

SM> [ BTW: whichever way we end up going, I think that it would be better if
SM>   use-package didn't use custom's symbol properties, so we should
SM>   introduce a new function (I suggest to name it
SM>   `customize-set-variable-external` to get the bikeshedding
SM>   rolling ;-). ]

Sure, an API instead of a direct setting. I like the approach and the name.

Ted



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFC: omit some variables from custom-save-variables
  2020-06-19 20:24   ` Ted Zlatanov
@ 2020-06-19 21:26     ` Stefan Monnier
  2020-06-22 18:22       ` Ted Zlatanov
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2020-06-19 21:26 UTC (permalink / raw)
  To: Emacs Development; +Cc: John Wiegley

>>> The proposal is for use-package to apply the save-exemptions symbol
>>> property behind the scenes. This is a new symbol property. 
> SM> Hmm... my reflex would have been to make use-package use something like
> SM>     (funcall (or (get variable 'custom-set) #'set-default) variable value)
> SM> instead of whichever other way it currently uses to set the variable.
> Does that omit the variable from the custom.el file?

Yes, as should be obvious at least in the case where it falls back on `set-default`.

> SM> Could you describe what would be the advantage of introducing a new
> SM> symbol property?
> Soft migration, no unexpected behavior, everything works like it does today.

I was thinking compared to the approach I showed.
I'm not favoring either of them, I'm just trying to better understand
the trade-offs.


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFC: omit some variables from custom-save-variables
  2020-06-19 21:26     ` Stefan Monnier
@ 2020-06-22 18:22       ` Ted Zlatanov
  0 siblings, 0 replies; 5+ messages in thread
From: Ted Zlatanov @ 2020-06-22 18:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: John Wiegley, Emacs Development

On Fri, 19 Jun 2020 17:26:06 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 
SM> Hmm... my reflex would have been to make use-package use something like
SM> (funcall (or (get variable 'custom-set) #'set-default) variable value)
SM> instead of whichever other way it currently uses to set the variable.
>> Does that omit the variable from the custom.el file?

SM> Yes, as should be obvious at least in the case where it falls back on `set-default`.

OK, it sounds like a better approach if it requires no core changes. I
proposed the change in https://github.com/jwiegley/use-package/pull/850
and in my testing it behaved correctly.

Ted



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-22 18:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19 18:41 RFC: omit some variables from custom-save-variables Ted Zlatanov
2020-06-19 20:14 ` Stefan Monnier
2020-06-19 20:24   ` Ted Zlatanov
2020-06-19 21:26     ` Stefan Monnier
2020-06-22 18:22       ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).