From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: Using "Emacs Configure" **and** modifying .emacs Date: Sat, 12 Aug 2017 09:04:41 -0700 (PDT) Message-ID: <2d0d85f2-8ed5-4c09-bc1f-cf7f6bd897b1@default> References: <1502373086.1171866.1069247696.71F9FED4@webmail.messagingengine.com> <8660dvuzsr.fsf@zoho.com> <1502436066.2568371.1070085968.1D25E0E7@webmail.messagingengine.com> <87tw1ekxgo.fsf@127.0.0.1> <867ey9sva2.fsf@zoho.com> <86378xskth.fsf@zoho.com> <20170812073057.GB20873@tuxteam.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1502554052 32350 195.159.176.226 (12 Aug 2017 16:07:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 12 Aug 2017 16:07:32 +0000 (UTC) To: tomas@tuxteam.de, help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 12 18:07:27 2017 Return-path: Envelope-to: geh-help-gnu-emacs@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 1dgYwe-0007x7-Ru for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Aug 2017 18:07:25 +0200 Original-Received: from localhost ([::1]:36600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgYwl-0005oD-BT for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Aug 2017 12:07:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgYuB-0004EE-Va for help-gnu-emacs@gnu.org; Sat, 12 Aug 2017 12:04:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgYu7-0002vb-8p for help-gnu-emacs@gnu.org; Sat, 12 Aug 2017 12:04:51 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:19754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgYu6-0002sy-TJ for help-gnu-emacs@gnu.org; Sat, 12 Aug 2017 12:04:47 -0400 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7CG4i1Q027356 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 12 Aug 2017 16:04:44 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v7CG4hEW002036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 12 Aug 2017 16:04:44 GMT Original-Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v7CG4gRD005769; Sat, 12 Aug 2017 16:04:42 GMT In-Reply-To: <20170812073057.GB20873@tuxteam.de> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6774.5000 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114011 Archived-At: > > > And that's not hard to do: just use > > > `customize-variable' instead of `setq', for > > > user options. How hard is that? If you want > > > something shorter, define an alias... > > > > I don't think it is about being difficult, or > > long, rather what is the benefit? >=20 > I think Drew has explained that pretty well. Besides, > the "defcustom" ("15.3 Defining Customization Variables" > node in the elisp doc does a good job, too. >=20 > > What kind of function(s) get triggered? Is it > > to ensure the new value of the variable makes > > sense? That is, some variant of validating > > the input? >=20 > Yes. (The :type arg of defcustom) >=20 > > Or is it to control behavior in a wider sense, > > so that some function, that does something, is > > set to something depending on the value of > > the variable? >=20 > Yes. (Among others, :set, but also perhaps :initialize, > :set-after, etc.) >=20 > > If it is about validation, i.e. making sure the > > variable value makes sense (is within some > > range or have a certain type; is a member of > > the input domain set) then I never bothered > > with that. >=20 > Some dont want a validation to explode deep whithin > the guts of some module loaded by another module, > where the user has no clue about what the heck is > going on, but next to the place where a variable > is being set to a value it's not supposed to have. >=20 > Sometimes I can sympathize with that :-) Indeed. TL;DR: Few start out embracing `defcustom'. Some end up=20 realizing how to live with it and take advantage of it. At the risk of belaboring this (if that hasn't been done already - if it has, apologies): If you do everything you do with Emacs Lisp code only for your own use then, yes, you can take care of all places where a variable is used/set. You can find them and make them do the right thing, even in situations where dependent behavior is involved. But if you provide code that others (people or libraries) use then the situation can be a bit different. You have no real control over all of the places and ways that a=20 variable might be set. Declaring some things about the variable, its intended behavior/uses (or non-behavior/non-uses) can serve to _let others know what to expect_. It gives them a heads-up, similar to how a code comment can do that. If nothing else, you can think of `defcustom' as providing such a declaration of intent - about the types of values expected by your code, dependencies wrt value changes, etc. `defcustom' is a way of letting users (people, libraries) know stuff about _your_ uses of the variable - what your code does with it. In the context of others who use your variable, features provided by `defcustom' can be helpful. Provided, that is, that they understand that it is a variable that is helped by `defcustom', so that they use `custom-*' and `customize-*' functions to set and save it. That's really the point, I think. A library author uses `defcustom' to: 1. Let human users, especially but not only non-Lispers, use Customize to _interactively_ browse, test, set, and persistently save the variable. 2. Let other code take advantage of type-checking (`:type'); setup, updating, synchronizing, etc. trigger functions (`:set' etc.); linking to doc, download, Commentary, etc. URLS (`:link'); persistence, etc. That's all. No one is trying to make you use `custom*' functions or Customize. One point is that you will likely be interacting with=20 variables that someone has defined using `defcustom', so it behooves you to understand what that means: what=20 `defcustom' offers and how you might take advantage of that. A second point is that if you write code that might be used by others then you can take advantage of what `defcustom' offers you and your users (people & code). Not that you must; only that you can. Again, it can help you to be aware of what `defcustom' offers; that's all. The same things apply to faces and `defface'. `defface', `defcustom', and `defgroup' are your friends - or they can be, if you are interested. FWIW, many of us wrote Elisp code mainly for ourselves, to start with. And many of us didn't care about or use `defcustom'. And many of us didn't bother with Customize interactively. Later, some of us started sharing some of our code, and we eventually started using `defcustom' to easily give users a way to persist their choices. But we still didn't really care about the various features `defcustom' offers. At some point, some of us fell upon the gotcha of trying to set a user option created by someone else and not realizing there was more going on than just changing the value - e.g. a `:set' function. We've all been pretty much where you are, I think (Emmanuel), in case that helps. No one, I think, starts out as a fan of Customize. Few, I think, realize or care about the benefits of `defcustom' features, at the outset. My bet is that as you share your code more with others (people & libraries), those _users_ will help you learn the benefits of `defcustom', and little by little you will change your view: something like i-dont-need-it--i-can-do-all-i-want-in-my-own-corner will become something more like i-can-do-this-to-make-things-easier-for-myself-and-users.