From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lele Gaifax 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 19:23:35 +0100 Organization: Nautilus Entertainments Message-ID: <87twnorgig.fsf@metapensiero.it> References: <99f3716d-513e-42b5-b43b-fafca9c81f5a@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1449858261 5153 80.91.229.3 (11 Dec 2015 18:24:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Dec 2015 18:24:21 +0000 (UTC) To: 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:24:11 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 1a7SMU-00075R-2z for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Dec 2015 19:24:10 +0100 Original-Received: from localhost ([::1]:48986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7SMT-0001dF-CJ for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Dec 2015 13:24:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7SMH-0001cw-5H for help-gnu-emacs@gnu.org; Fri, 11 Dec 2015 13:23:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7SMC-0003vb-9T for help-gnu-emacs@gnu.org; Fri, 11 Dec 2015 13:23:57 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:58312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7SMC-0003vT-3r for help-gnu-emacs@gnu.org; Fri, 11 Dec 2015 13:23:52 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a7SM6-0006Ju-Dm for help-gnu-emacs@gnu.org; Fri, 11 Dec 2015 19:23:46 +0100 Original-Received: from 151.62.33.97 ([151.62.33.97]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Dec 2015 19:23:46 +0100 Original-Received: from lele by 151.62.33.97 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Dec 2015 19:23:46 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 151.62.33.97 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:CEGhGZC/VDB+tIy9SCEKSkSqIrs= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:108369 Archived-At: Drew Adams writes: > Hi Alan, > >> Thank you for the explanation. For the moment I'm sticking with >> `customize-set-variable' > > Good choice. 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... 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: (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)) While it seems working as expected, I like to hear other's opinion: do you see any problem with this approach? Thank you, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.