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: Fri, 11 Dec 2015 10:53:30 -0800 (PST) Message-ID: <63e721db-3901-4017-a254-a679a4d8d04e@default> References: <99f3716d-513e-42b5-b43b-fafca9c81f5a@default> <87twnorgig.fsf@metapensiero.it> 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 1449860050 2134 80.91.229.3 (11 Dec 2015 18:54:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Dec 2015 18:54:10 +0000 (UTC) To: Lele Gaifax , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 11 19:53: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 1a7SpF-0008GE-Ck for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Dec 2015 19:53:53 +0100 Original-Received: from localhost ([::1]:49132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7SpE-0004Ll-OD for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Dec 2015 13:53:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7Sp2-0004KO-Uk for help-gnu-emacs@gnu.org; Fri, 11 Dec 2015 13:53:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7Sox-000445-Tr for help-gnu-emacs@gnu.org; Fri, 11 Dec 2015 13:53:40 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:24869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7Sox-00043s-Mf for help-gnu-emacs@gnu.org; Fri, 11 Dec 2015 13:53:35 -0500 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 tBBIrVDf008326 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Dec 2015 18:53:32 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id tBBIrVej026269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 11 Dec 2015 18:53:31 GMT Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id tBBIrV4Z030164; Fri, 11 Dec 2015 18:53:31 GMT In-Reply-To: <87twnorgig.fsf@metapensiero.it> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.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] 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:108371 Archived-At: > After reading this thread, as well as the referenced > http://permalink.gmane.org/gmane.emacs.bugs/107690, I tried to see if I > should > rectify some settings in my own init file. Indeed, I was using `setq' on = a > bunch of customizable options... >=20 > Given that checking each variable documentation to see the right way to > set its value is error prone, I wrote the following macro and used it in > almost all cases, replacing `setq' and `set-default' in my configuration: >=20 > (defmacro csetq (variable value) > "Macro to set the value of a variable, possibly a custom user > option." > `(funcall (or (get ',variable 'custom-set) > (and (plist-member (symbol-plist ',variable) > 'standard-value) 'set-default) > 'set) > ',variable ,value)) >=20 > While it seems working as expected, I like to hear other's opinion: do yo= u > see any problem with this approach? You can do that. But I would advise just using `customize-set-variable' for a user option, and using `setq' or `setq-default' etc. for non-options. That is much more readable in your code, IMO. And no, you do not ever need to "check each variable documentation to see the right way to set its value". (And you should anyway not rely on a variable's documentation for that.)