From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Artur Malabarba <bruce.connor.am@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Customizable modes and package.el
Date: Sun, 29 Mar 2015 20:41:50 -0400 [thread overview]
Message-ID: <jwvzj6vgvwj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAAdUY-LiQCQam1=YuR2UrV+YDcN7m1QPL8Oj-HhudPDB6+CvSQ@mail.gmail.com> (Artur Malabarba's message of "Sun, 29 Mar 2015 15:48:35 +0100")
> The only thing I'm totally sure on is the `now' parameter. I think
> it's not a problem, because it's meant to indicate "set the value
> wihout waiting for the defcustom" and not "set the value immediately",
> but I don't know its real use-case, so it's hard to say for sure.
Hmm... I thought the idea was to add "(package-initialize)" to the
~/.emacs
Stefan
> diff --git a/lisp/custom.el b/lisp/custom.el
> index e5fe0eb..d07f0c0 100644
> --- a/lisp/custom.el
> +++ b/lisp/custom.el
> @@ -933,6 +933,37 @@ handle SYMBOL properly.
> COMMENT is a comment string about SYMBOL."
> (apply 'custom-theme-set-variables 'user args))
> +(defun custom--load-entry (entry &optional requests)
> + "Load custom ENTRY, after requiring all features in REQUESTS.
> +Signal a meaningful error if any of the features are absent."
> + ;; Now set the variable.
> + (let* ((now (nth 2 entry))
> + (comment (nth 4 entry))
> + (symbol (indirect-variable (nth 0 entry)))
> + (value (nth 1 entry))
> + set)
> + (dolist (f requests)
> + (unless (require f nil t)
> + (error "Cannot find load file `%s', required by `%s' inside your `%s'"
> + f symbol 'custom-set-variables)))
> + (setq set (or (get symbol 'custom-set) 'custom-set-default))
> + (put symbol 'saved-value (list value))
> + (put symbol 'saved-variable-comment comment)
> + ;; Allow for errors in the case where the setter has
> + ;; changed between versions, say, but let the user know.
> + (condition-case data
> + (cond (now
> + ;; Rogue variable, set it now.
> + (put symbol 'force-value t)
> + (funcall set symbol (eval value)))
> + ((default-boundp symbol)
> + ;; Something already set this, overwrite it.
> + (funcall set symbol (eval value))))
> + (error
> + (message "Error setting %s: %s" symbol data)))
> + (and (or now (default-boundp symbol))
> + (put symbol 'variable-comment comment))))
> +
> (defun custom-theme-set-variables (theme &rest args)
> "Initialize variables for theme THEME according to settings in ARGS.
> Each of the arguments in ARGS should be a list of this form:
> @@ -972,31 +1003,16 @@ COMMENT is a comment string about SYMBOL."
> (value (nth 1 entry)))
> (custom-push-theme 'theme-value symbol theme 'set value)
> (unless custom--inhibit-theme-enable
> - ;; Now set the variable.
> - (let* ((now (nth 2 entry))
> - (requests (nth 3 entry))
> - (comment (nth 4 entry))
> - set)
> - (when requests
> - (put symbol 'custom-requests requests)
> - (mapc 'require requests))
> - (setq set (or (get symbol 'custom-set) 'custom-set-default))
> - (put symbol 'saved-value (list value))
> - (put symbol 'saved-variable-comment comment)
> - ;; Allow for errors in the case where the setter has
> - ;; changed between versions, say, but let the user know.
> - (condition-case data
> - (cond (now
> - ;; Rogue variable, set it now.
> - (put symbol 'force-value t)
> - (funcall set symbol (eval value)))
> - ((default-boundp symbol)
> - ;; Something already set this, overwrite it.
> - (funcall set symbol (eval value))))
> - (error
> - (message "Error setting %s: %s" symbol data)))
> - (and (or now (default-boundp symbol))
> - (put symbol 'variable-comment comment)))))))
> + (let* ((requests (nth 3 entry)))
> + (when requests
> + (put symbol 'custom-requests requests))
> + ;; If a symbol has requirements, we don't even try to load
> + ;; them now, because we might accidentally load an old
> + ;; built-in instead of a newer installed version.
> + (if requests
> + (add-hook 'after-init-hook
> + (apply-partially #'custom--load-entry entry requests))
> + (custom--load-entry entry)))))))
> (defvar custom--sort-vars-table)
> (defvar custom--sort-vars-result)
next prev parent reply other threads:[~2015-03-30 0:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-28 8:58 Customizable modes and package.el Sebastian Wiesner
2015-03-28 9:30 ` Philipp Stephani
2015-03-28 12:26 ` Stefan Monnier
2015-03-28 14:59 ` Sebastian Wiesner
2015-03-28 17:55 ` Artur Malabarba
2015-03-28 20:42 ` Stefan Monnier
2015-03-29 14:48 ` Artur Malabarba
2015-03-30 0:41 ` Stefan Monnier [this message]
2015-03-30 7:05 ` Artur Malabarba
2015-03-30 13:39 ` Stefan Monnier
2015-03-30 14:31 ` Artur Malabarba
2015-03-30 14:55 ` Robert Pluim
2015-03-30 16:07 ` Artur Malabarba
2015-03-30 17:09 ` Drew Adams
2015-03-30 17:28 ` Stefan Monnier
2015-11-08 3:26 ` David Reitter
2015-11-08 3:43 ` Kaushal Modi
2015-11-08 4:33 ` Drew Adams
2015-11-08 10:48 ` Artur Malabarba
2015-11-08 10:50 ` Artur Malabarba
2015-03-30 17:45 ` Achim Gratz
2015-04-18 1:52 ` Ted Zlatanov
2015-04-18 4:30 ` Stefan Monnier
2015-04-18 4:46 ` Artur Malabarba
2015-03-30 19:06 ` Artur Malabarba
2015-03-30 20:36 ` Stefan Monnier
2015-03-31 20:14 ` João Távora
-- strict thread matches above, loose matches on Subject: below --
2015-04-18 8:36 Richard Y. Kim
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=jwvzj6vgvwj.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=bruce.connor.am@gmail.com \
--cc=emacs-devel@gnu.org \
/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).