From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: which one to use: custom-set-variables, customize-set-variable, or customize-set-value? Date: Mon, 30 Nov 2015 07:20:27 -0800 (PST) Message-ID: <99f3716d-513e-42b5-b43b-fafca9c81f5a@default> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1448896867 919 80.91.229.3 (30 Nov 2015 15:21:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Nov 2015 15:21:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Alan Schmitt Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 30 16:20:54 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a3QG4-00064D-Hd for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Nov 2015 16:20:52 +0100 Original-Received: from localhost ([::1]:41522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3QG3-0003pP-5v for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Nov 2015 10:20:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3QFn-0003lt-QT for help-gnu-emacs@gnu.org; Mon, 30 Nov 2015 10:20:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3QFk-0001ga-9o for help-gnu-emacs@gnu.org; Mon, 30 Nov 2015 10:20:35 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:41334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3QFk-0001gB-2X for help-gnu-emacs@gnu.org; Mon, 30 Nov 2015 10:20:32 -0500 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tAUFKTMm011662 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 30 Nov 2015 15:20:30 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id tAUFKSA0027226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 30 Nov 2015 15:20:29 GMT Original-Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id tAUFKSUo025674; Mon, 30 Nov 2015 15:20:28 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108259 Archived-At: Hi Alan, > Thank you for the explanation. For the moment I'm sticking with > `customize-set-variable' Good choice. > and I'll see if I get in trouble. I don't think you can get in trouble that way. > > I agree that the doc is not very clear. Recently I forgot > > that `customize-set-value' does not use the defcustom's :set > > function, and I was bitten by the fact that it does not. >=20 > I'm curious about this: what is the scenario where this can be > a problem? Situations where setting the variable is more complex than just changing its value, that is, where other changes to the state of Emacs need to be associated with the change in the variable value. If you look at the doc (Elisp manual, node Variable Definitions), have a look at not only :set but also :initialize, to get an idea of what can be involved. You will see, for example, that there are multiple initialization functions that are predefined, and they act differently with respect to :set and setting the value during initialization. This might give you an idea of different :set scenarios. Here is one example of a :set function (from character-fold+.el) that does something more than just change the value: (defcustom char-fold-symmetric nil "Non-nil means char-fold searching treats equivalent chars the same. That is, use of any of a set of char-fold equivalent chars in a search string finds any of them in the text being searched. If nil then only the \"base\" or \"canonical\" char of the set matches any of them. The others match only themselves, even when char-folding is turned on." :set (lambda (sym defs) (custom-set-default sym defs) (update-char-fold-table)) :type 'boolean :group 'isearch) Standard function `custom-set-default' is the usual way to change the variable's (default) value, so this :set function firt calls that. Then it calls a function that changes some other state, taking the new variable value into account. HTH.