unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Sam Steingold <sds@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: custom: how do I augment an option?
Date: Thu, 06 Sep 2012 14:20:18 -0400	[thread overview]
Message-ID: <871uifhv31.fsf@gnu.org> (raw)
In-Reply-To: <jwv8vcnuwl5.fsf-monnier+gnu.emacs.help@gnu.org> (Stefan Monnier's message of "Thu, 06 Sep 2012 09:14:55 -0400")

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 <zbaavre@veb.hzbagerny.pn> [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.



       reply	other threads:[~2012-09-06 18:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87zk5473qz.fsf@gnu.org>
     [not found] ` <mailman.8164.1346872698.855.help-gnu-emacs@gnu.org>
     [not found]   ` <jwv8vcnuwl5.fsf-monnier+gnu.emacs.help@gnu.org>
2012-09-06 18:20     ` Sam Steingold [this message]
2012-10-26 18:21       ` custom: how do I augment an option? Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871uifhv31.fsf@gnu.org \
    --to=sds@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).