From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: custom: how do I augment an option? Date: Thu, 06 Sep 2012 14:20:18 -0400 Organization: disorganization Message-ID: <871uifhv31.fsf@gnu.org> References: <87zk5473qz.fsf@gnu.org> Reply-To: emacs-devel@gnu.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1346955635 10604 80.91.229.3 (6 Sep 2012 18:20:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Sep 2012 18:20:35 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 06 20:20:35 2012 Return-path: Envelope-to: ged-emacs-devel@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 1T9ggs-0006g1-H5 for ged-emacs-devel@m.gmane.org; Thu, 06 Sep 2012 20:20:34 +0200 Original-Received: from localhost ([::1]:59172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9ggp-0006m3-9c for ged-emacs-devel@m.gmane.org; Thu, 06 Sep 2012 14:20:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9ggm-0006lm-8K for emacs-devel@gnu.org; Thu, 06 Sep 2012 14:20:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9ggh-0007n9-Mb for emacs-devel@gnu.org; Thu, 06 Sep 2012 14:20:28 -0400 Original-Received: from mail-pb0-f41.google.com ([209.85.160.41]:64115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9ggh-0007mW-Fx for emacs-devel@gnu.org; Thu, 06 Sep 2012 14:20:23 -0400 Original-Received: by pbbro12 with SMTP id ro12so3217738pbb.0 for ; Thu, 06 Sep 2012 11:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:organization:references:user-agent :return-receipt-to:reply-to:x-attribution:x-disclaimer:date :in-reply-to:message-id:mime-version:content-type; bh=Qbyr5k42v6xm2L35ex00wRTl2tvOjcH9ExromL2ybJ0=; b=tbc4ObtVsBej+ibnCrSiyqEHMPDfFPEnC9OX/uhcWjBg0bN5frh2CIx2PoQYQxdCMx SrRNakvDApbzRFI9g/pWjayL5U9zJGTwpAhIR/9nmol8NABY+c4huYDFxOQfMwHzjJAF JwtVIINbCwS5xw+bChQimPE04cRxok/HAzFtQBRDeNpZ0vvorpLVjLPfTpn+RMTzRHwM tR5xwDM6YrlRE75GK1e0jAEW+RJViCNGqIr3rgh2Wp4iqsY0P9otE2o8IM3l3X0w4Rb1 IPk2eelSEVFRkSsHQd+sUY0kj0ymFJ5M9u8+WnL1hwmywmu77tCa/p0JeClDlBu0eNeQ zyRQ== Original-Received: by 10.68.134.230 with SMTP id pn6mr5776793pbb.44.1346955622342; Thu, 06 Sep 2012 11:20:22 -0700 (PDT) Original-Received: from t520sds ([74.113.160.197]) by mx.google.com with ESMTPS id vd4sm1722675pbc.41.2012.09.06.11.20.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 11:20:21 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. In-Reply-To: (Stefan Monnier's message of "Thu, 06 Sep 2012 09:14:55 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:153125 Archived-At: This was originally discussed on gnu-emacs-help, but it appears that the further discussion should take place on emacs-devel. I said: If I want to _modify_ a custom variable, I have to resort to something like --8<---------------cut here---------------start------------->8--- (add-hook 'message-load-hook (lambda () (add-to-list 'message-syntax-checks '(long-lines . disabled)))) --8<---------------cut here---------------end--------------->8--- which will break if `message-syntax-checks' ever acquires a setter or --8<---------------cut here---------------start------------->8--- (custom-set-variables '(message-syntax-checks (cl-adjoin '(long-lines . disabled) (eval (car (get 'message-syntax-checks 'standard-value))) :test 'equal))) --8<---------------cut here---------------end--------------->8--- which uses a CL function _and_ also eval. > * Stefan Monnier [2012-09-06 09:14:55 -0400]: > >> So, what is the official method? > > There are 3 official methods: > 1- forget about flexibility and just set the var to a constant value > that does not depend on the default value. That can be done from the GUI. this sucks as it ignores the changes in the default value, as discussed on gnu-emacs-help. > 2- if you want to use actual code (instead of a mere constant), then > don't use Customize, and use something like the add-hook code you showed. this sucks in case the custom variable in question ever acquires a setter, as mentioned above. > 3- submit a patch for Customize which lets the user specify not just > a new value but a change (like a "diff") to the default value. > For lists representing sets, a way for the user to specify elements > to add and elements to remove would be great. For lists where order > matters, the user should additionally have some control over where to > add elements. > Point 3 would be *really* welcome. How about changing `custom-set-variables' to accept (SYMBOL EXP [NOW [REQUEST [COMMENT [SETTER]]]]) instead of (SYMBOL EXP [NOW [REQUEST [COMMENT]]]) where SETTER would be a function acceptable as the :set argument to defcustom. (Actually, I would prefer to replace the positional optional arguments with keywords, like in `defcustom', but that would be an incompatible change) Also, semi-independently, I propose a function (defun custom-standard-value (symbol) "Return the standard value of the customizable option." (eval (car (get symbol 'standard-value)))) A cheap ad-hoc fix for `message-syntax-checks' (and other set variables) would be to give it a setter which would accept lists like (add ...) or (delete ...). -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://dhimmi.com http://honestreporting.com http://jihadwatch.org http://www.PetitionOnline.com/tap12009/ When you talk to God, it's prayer; when He talks to you, it's schizophrenia.