From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Elias_M=C3=A5rtenson?= Newsgroups: gmane.emacs.devel Subject: Re: custom-set-variables considered harmful Date: Wed, 29 Nov 2017 11:36:21 +0800 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="089e082d2174df6250055f16d608" X-Trace: blaine.gmane.org 1511926634 29459 195.159.176.226 (29 Nov 2017 03:37:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 29 Nov 2017 03:37:14 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Philippe Vaucher Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 29 04:37:10 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJtBH-0006uq-My for ged-emacs-devel@m.gmane.org; Wed, 29 Nov 2017 04:37:03 +0100 Original-Received: from localhost ([::1]:41135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJtBP-0002cm-3g for ged-emacs-devel@m.gmane.org; Tue, 28 Nov 2017 22:37:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJtAe-0002b8-RE for emacs-devel@gnu.org; Tue, 28 Nov 2017 22:36:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJtAd-0001pi-PW for emacs-devel@gnu.org; Tue, 28 Nov 2017 22:36:24 -0500 Original-Received: from mail-io0-x22e.google.com ([2607:f8b0:4001:c06::22e]:38394) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eJtAd-0001pF-Im for emacs-devel@gnu.org; Tue, 28 Nov 2017 22:36:23 -0500 Original-Received: by mail-io0-x22e.google.com with SMTP id d14so2242198ioc.5 for ; Tue, 28 Nov 2017 19:36:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=R+2evIWq2kI0Ob54PQTDrvHZnJiMAiBAQinFJUryVfo=; b=o9b3XCvPxVwTmpa4PZUVbv8TgkTU7gqk4ULft/37DFhaBj1fLajJYnzYd9rPSAKMuR j+7Q2mCgWNvbTw9O1oGrf4tTvtDvI1QHnD2N7tHtwCmgrtsJDCUyHpNgy4XekcfXPAWp g1aLXTbdd9vB4ja9otxvcAPkvMCCuZeD8kzDi7c/0g6iPOESiOoTRBGabXd2DUK03zRT V+ctBw5Ty6sBOVxg5gsjbOhTknhPrVvAt6w9JD2txnzKcTY9QgU5rnbTJjQhJ02WOk3p kgkSKcRGn7PKxK9U5QfPqpttqWCpmfiligRWV8K3BDVfCoj1n33KJsB9FKvCHh4apygM kTaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=R+2evIWq2kI0Ob54PQTDrvHZnJiMAiBAQinFJUryVfo=; b=tgoA2OXxPNTAijGxCgvRGV5lmBdazMLb78cBoX/NxXVacrJmo8ivyYzffHN/WHyGbb R16MLgewf5X0/4g6KiePyvwLlfaf7dGV7l4VLtuNhXwLxGgxZajAxQnjRd4NIpSQ0+vz J17zOrgVWRl2ohA+qd3pTtxkyyF/mL42/HOJDI25asxMa/aJiEmmmLZwE3mTimARoeKf T5s0Ydfy63Bu5EJqg+4417iXTvl+irXN6cO8wf6EQmslZEKlONkakLoE7wh3ZFmJQKh6 x8AWhLHGXH4HATIT9UmX65TvPMijMZCtLx4Ta+ymtWa3gEenq1yYYT2oNlzFnQIFfe6L jWuA== X-Gm-Message-State: AJaThX4DB/vkZLKImKwWLOetAl9We1EVzZ5dFKzMwCrnJO1lEBXKeTS0 1d1kGpV6QXBWitAvDZ2SziZDypAx55jyUhacwv8= X-Google-Smtp-Source: AGs4zMaX1+gOb6df5vqGCYs5fzAZn8LMbbAarHZtod2Lu3JffEfeZHGJ/aKSpNpyphe6+pY6bqqPW4NgqbRVBGrQk6I= X-Received: by 10.107.111.20 with SMTP id k20mr1680060ioc.265.1511926582434; Tue, 28 Nov 2017 19:36:22 -0800 (PST) Original-Received: by 10.107.62.134 with HTTP; Tue, 28 Nov 2017 19:36:21 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:220515 Archived-At: --089e082d2174df6250055f16d608 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 28 November 2017 at 22:12, Philippe Vaucher wrote: > >> Note that as long as the `setq` is within the magical >> custom-autogenerated-user-settings form, it will behave correctly even >> if the variable has a setter function. The difference will only affect >> those users who take this code and then copy it elsewhere. >> >> >> But setq doesn't have any concrete benefit other than familiarity to >> people who don't understand custom. I've spent more time than I wish on >> Freenode #emacs teaching people about custom. If c-s-v was used >> consistently that effort would be made a lot easier. >> > > The problem I have with c-s-v is that I don't see its benefits for config= s > like this: > > [ lines of =E2=80=98setq=E2=80=99 invocations on ido variables ] Can you maybe enlighten me about what problem c-s-v solves that would have > me start to use it? > Your explicit =E2=80=98setq=E2=80=99 calls are perfectly fine as long as th= e variables you set do not have a setting function assigned to them. However, if they do have setter functions, then the behaviour will not be correct. It has been suggested that you manually look at the =E2=80=98defcustom=E2= =80=99 definitions of the variables so that you know which ones doesn't work with =E2=80=98setq=E2=80=99. The only reason people can get away with not doing this is because there are so few custom variables that use setter functions. Thus, if you use =E2=80=98setq=E2=80=99 instead of =E2=80=98custom-set-vari= able=E2=80=99 you need to manually check every single variable to ensure they don't have setter functions assigned. If you want to be thorough (nobody is) you also need to check them every time your modules are updated. This is not just a theoretical situation. It happened in gnu-apl-mode, a library for which I am the maintainer. In it, the variable =E2=80=98gnu-apl-mode-map-prefix=E2=80=99 got a setter function af= ter the fact. Or, you could simply use =E2=80=98custom-set-variable=E2=80=99 everywhere a= nd spare yourself the trouble. Regards, Elias --089e082d2174df6250055f16d608 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On 2= 8 November 2017 at 22:12, Philippe Vaucher <philippe.vaucher@gmai= l.com> wrote:
=

Note that as long as the `setq` i= s within the magical
custom-autogenerated-user-settings form, it will behave correctly even=
if the variable has a setter function.=C2=A0 The difference will only affec= t
those users who take this code and then copy it elsewhere.

But setq= doesn't have any concrete benefit other than familiarity to people who= don't understand custom. I've spent more time than I wish on Freen= ode #emacs teaching people about custom. If c-s-v was used consistently tha= t effort would be made a lot easier.=C2=A0
The problem I have with c-s-v is that I don't see it= s benefits for configs like this:
=C2=A0
[ lines of =E2=80=98setq=E2=80=99 inv= ocations on ido variables ]

Can you maybe enlighten me about what problem = c-s-v solves that would have me start to use it?

Your explicit =E2=80=98setq=E2=80=99 ca= lls are perfectly fine as long as the variables you set do not have a setti= ng function
assigned to them. However, if they do have setter fun= ctions, then the behaviour will not be correct.
It has been sugge= sted that you manually look at the =E2=80=98defcustom=E2=80=99 definitions = of the variables so that
you know which ones doesn't work wit= h =E2=80=98setq=E2=80=99.

The only reason peo= ple can get away with not doing this is because there are so few custom var= iables
that use setter functions.

= Thus, if you use =E2=80=98setq=E2=80=99 instead of =E2=80=98custom-set-vari= able=E2=80=99 you need to manually check every single
variable to= ensure they don't have setter functions assigned. If you want to be th= orough (nobody is)
you also need to check them every time your mo= dules are updated. This is not just a theoretical
situation. It h= appened in gnu-apl-mode, a library for which I am the maintainer. In it, th= e
variable =E2=80=98gnu-apl-mode-map-prefix=E2=80=99 got a setter= function after the fact.

Or, you could simply use= =E2=80=98custom-set-variable=E2=80=99 everywhere and spare yourself the tr= ouble.

Regards,
Elias
<= /div> --089e082d2174df6250055f16d608--