From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: custom-set-variables considered harmful Date: Sat, 04 Nov 2017 13:10:11 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1509815432 6945 195.159.176.226 (4 Nov 2017 17:10:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Nov 2017 17:10:32 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 04 18:10:21 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 1eB1xb-0000vL-3c for ged-emacs-devel@m.gmane.org; Sat, 04 Nov 2017 18:10:19 +0100 Original-Received: from localhost ([::1]:41706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eB1xi-0008AA-J8 for ged-emacs-devel@m.gmane.org; Sat, 04 Nov 2017 13:10:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eB1xc-00089t-Ah for emacs-devel@gnu.org; Sat, 04 Nov 2017 13:10:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eB1xX-0001KC-Tt for emacs-devel@gnu.org; Sat, 04 Nov 2017 13:10:19 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:53723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eB1xX-0001Ji-MT for emacs-devel@gnu.org; Sat, 04 Nov 2017 13:10:15 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id vA4HABqT012027; Sat, 4 Nov 2017 13:10:12 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id BFD38AE0C3; Sat, 4 Nov 2017 13:10:11 -0400 (EDT) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6151=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6151> : inlines <6156> : streams <1769336> : uri <2528114> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 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:219924 Archived-At: I keep seeing people copy and pasting part of calls to custom-set-variables, and getting all confused about it. I think we should stop using it. Here's a proposal for that. When writing customizations, instead of writing (custom-set-variables ;; Big ugly warning which doesn't help enough. '(VAR1 VAL1) '(VAR2 VAL2 nil '(REQUEST) COMMENT) '(VAR3 VAL3) ...) we write (autogenerated-custom-settings ;; Big warning, still, but less important. (setq VAR1 VAL1) (require 'REQUEST) (customize-set-variable VAR2 VAL2 COMMENT) (customize-set-variable VAR3 VAL3) ...) where `autogenerated-custom-settings` is a macro which turns that call back into the form expected by custom-set-variables. The idea is basically to use a syntax which happens to look close to what you'd write by hand if you weren't using Customize, so that users who copy&paste snippets of code end up copying more or less valid code, instead of copying "code" like '(toto 2) and then be surprised that it doesn't do anything. [ The difference between VAR1 and VAR3 is that VAR1 doesn't have a setter. I guess in some cases we should emit `(setq-default VAR VAL)` also. ] One question, tho: could someone explain to me what the NOW is used for, really? I've read the docstrings, comments, and the code that seems related to it, and I have some idea of what it supposedly does, but I don't have a clear idea of a scenario where it's used. Stefan