From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: How to customize an option to a dynamic value (computed by lisp form) Date: Thu, 25 Aug 2016 13:54:58 -0700 (PDT) Message-ID: <83832586-765e-4df4-917a-98458247d829@default> References: <87k2f69hvb.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1472158550 11856 195.159.176.226 (25 Aug 2016 20:55:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 25 Aug 2016 20:55:50 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Jorge , "Pascal J. Bourguignon" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 25 22:55:44 2016 Return-path: Envelope-to: geh-help-gnu-emacs@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 1bd1ge-0002WJ-3E for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Aug 2016 22:55:44 +0200 Original-Received: from localhost ([::1]:58023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bd1gb-0002T7-Jh for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Aug 2016 16:55:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bd1g8-0002OD-Gf for help-gnu-emacs@gnu.org; Thu, 25 Aug 2016 16:55:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bd1g4-0004PN-C1 for help-gnu-emacs@gnu.org; Thu, 25 Aug 2016 16:55:11 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:49757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bd1g4-0004MN-3h for help-gnu-emacs@gnu.org; Thu, 25 Aug 2016 16:55:08 -0400 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7PKt32C026251 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 20:55:03 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u7PKt3nt008052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 20:55:03 GMT Original-Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7PKsxJJ010891; Thu, 25 Aug 2016 20:54:59 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6753.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] 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.21 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" Xref: news.gmane.org gmane.emacs.help:111198 Archived-At: > There remain two problems: > 1. customize-set-variable does not do type checking. I have just > tested it by setting org-agenda-files to 42 (an integer). This seems like a bug. Even if it is by design, it seems like something that should be improved (aka fixed). But if you mean only interactively, then it _does_ do type-checking. > set-variable does type checking, but does not respect any custom-set > property. `set-variable' does _not_ do type-checking either. Perhaps you are thinking of the fact that _when used interactively_ it checks the type. (set-variable foo 42) does not. I filed a bug long ago to make `set-variable' respect :set etc. http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D6578 (The bug report never even got a reply, and was classed as "wishlist") > How can I elegantly combine both? And shouldn't elisp > provide a convenient command for this? Try to specify the behavior you want (more clearly). Presumably you are looking for a way, using Lisp (non-interactively), to set an option value and get all of the behavior that you get when you set it using the Customize UI (:set, :type, etc. control). > 2. If I forget that these options are changed manually (Emacs does > not warn), and configure them via customize, then the new value will > be added to the custom-set-variables form with static values. This > has two problems: > 1. It will have static values. > 2. Since org-init.el is called after the custom-set-variables > form, the values set in the form will be overwritten. Again, please specify clearly the behavior you want and the behavior you see instead. A variable value is always "static", by definition of the word "value". It's not clear (to me) just what you are looking for. BTW, you can easily check whether an option has been changed outside Customize, i.e., using something like `setq' and not something like `customize-set-variable', by invoking code such as this (taken from `customize-rogue', which lets you open Customize for all such options): (defun rogue-option-p (symbol) (let ((cval (or (get symbol 'customized-value) (get symbol 'saved-value) (get symbol 'standard-value)))) (and cval ;Declared with defcustom. (default-boundp symbol) ;Has a value. (not (equal (eval (car cval)) ;; Which does not match customize. (default-value symbol))))))