From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.devel Subject: Re: Customizable modes and package.el Date: Mon, 30 Mar 2015 08:05:58 +0100 Message-ID: References: Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c3234c32811805127c1d52 X-Trace: ger.gmane.org 1427699172 16699 80.91.229.3 (30 Mar 2015 07:06:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Mar 2015 07:06:12 +0000 (UTC) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 30 09:06:11 2015 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 1YcTlu-0000AJ-IT for ged-emacs-devel@m.gmane.org; Mon, 30 Mar 2015 09:06:06 +0200 Original-Received: from localhost ([::1]:59742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcTlt-0004lt-PS for ged-emacs-devel@m.gmane.org; Mon, 30 Mar 2015 03:06:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcTlo-0004fp-RQ for emacs-devel@gnu.org; Mon, 30 Mar 2015 03:06:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcTln-0006Gr-7a for emacs-devel@gnu.org; Mon, 30 Mar 2015 03:06:00 -0400 Original-Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:33920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcTln-0006Gi-0n for emacs-devel@gnu.org; Mon, 30 Mar 2015 03:05:59 -0400 Original-Received: by oigz129 with SMTP id z129so75369487oig.1 for ; Mon, 30 Mar 2015 00:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=NBRJTJmranYNkE1dlsPUOG/XujtGpl8oAtMknr95cuY=; b=UqwOcazM8I62/1S+1wIAEn9/Qvn3xoJRQw8j+MfRrJe1HmUbDUhMTEUAsTiPjvCMJD BwU9iQ4x8kbaMF/CrZmg6mkLPFFQIi8wtz2lMj2MEaoukotGHdMYDNaLnQt3Eg6YeMOY ZVuGdX7R/dk5Qqr9MO5YCxk2rfghOsvGGKMWGMCrtWj7y26Et8uYx50dadv5v6a3gLL+ viMJcCJWcjzT3Hr6LfccRGVCFY7afRltz8D4nj/VBHjSlvDLmnoASAu+RhC7whT+fh/d nAjFeNUYnDwvXLDPoszqcq+sDCrrn2bUHn/Y9wGyJ508mVC4GHNwz/DUma6cCUKln43z peDQ== X-Received: by 10.182.213.102 with SMTP id nr6mr25005489obc.5.1427699158645; Mon, 30 Mar 2015 00:05:58 -0700 (PDT) Original-Received: by 10.182.45.234 with HTTP; Mon, 30 Mar 2015 00:05:58 -0700 (PDT) Original-Received: by 10.182.45.234 with HTTP; Mon, 30 Mar 2015 00:05:58 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: 6scYJY-ORYdjQ3nDMP0fKg7Qzwk X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::234 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:184536 Archived-At: --001a11c3234c32811805127c1d52 Content-Type: text/plain; charset=UTF-8 If that's the path we're taking, I'd rather simply have package-initialize be called before loading the init file, instead of after. I understand the reasoning behind the easy it is now, but it's done way more harm than good. The amount of people we see manually adding Elpa packages to their load-path is appalling. On Mar 30, 2015 1:41 AM, "Stefan Monnier" wrote: > > 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) > --001a11c3234c32811805127c1d52 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

If that's the path we're taking, I'd rather simp= ly have package-initialize be called before loading the init file, instead = of after.
I understand the reasoning behind the easy it is now, but it's done way= more harm than good. The amount of people we see manually adding Elpa pack= ages to their load-path is appalling.

On Mar 30, 2015 1:41 AM, "Stefan Monnier&qu= ot; <monnier@iro.umontreal.c= a> wrote:
>= ; The only thing I'm totally sure on is the `now' parameter. I thin= k
> it's not a problem, because it's meant to indicate "set t= he value
> wihout waiting for the defcustom" and not "set the value imm= ediately",
> but I don't know its real use-case, so it's hard to say for su= re.

Hmm... I thought the idea was to add "(package-initialize)" to th= e
~/.emacs


=C2=A0 =C2=A0 =C2=A0 =C2=A0 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.
>=C2=A0 COMMENT is a comment string about SYMBOL."
>=C2=A0 =C2=A0 (apply 'custom-theme-set-variables 'user args))
> +(defun custom--load-entry (entry &optional requests)
> +=C2=A0 "Load custom ENTRY, after requiring all features in REQUE= STS.
> +Signal a meaningful error if any of the features are absent." > +=C2=A0 ;; Now set the variable.
> +=C2=A0 (let* ((now (nth 2 entry))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(comment (nth 4 entry))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(symbol (indirect-variable (nth 0 e= ntry)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(value (nth 1 entry))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0set)
> +=C2=A0 =C2=A0 (dolist (f requests)
> +=C2=A0 =C2=A0 =C2=A0 (unless (require f nil t)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Cannot find load file `%s= 9;, required by `%s' inside your `%s'"
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0f symbol '= custom-set-variables)))
> +=C2=A0 =C2=A0 (setq set (or (get symbol 'custom-set) 'custom-= set-default))
> +=C2=A0 =C2=A0 (put symbol 'saved-value (list value))
> +=C2=A0 =C2=A0 (put symbol 'saved-variable-comment comment)
> +=C2=A0 =C2=A0 ;; Allow for errors in the case where the setter has > +=C2=A0 =C2=A0 ;; changed between versions, say, but let the user know= .
> +=C2=A0 =C2=A0 (condition-case data
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (cond (now
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Rogue varia= ble, set it now.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put symbol &#= 39;force-value t)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(funcall set s= ymbol (eval value)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((default-boundp sym= bol)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Something a= lready set this, overwrite it.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(funcall set s= ymbol (eval value))))
> +=C2=A0 =C2=A0 =C2=A0 (error
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message "Error setting %s: %= s" symbol data)))
> +=C2=A0 =C2=A0 (and (or now (default-boundp symbol))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put symbol 'variable-comment c= omment))))
> +
>=C2=A0 (defun custom-theme-set-variables (theme &rest args)
>=C2=A0 =C2=A0 "Initialize variables for theme THEME according to s= ettings in ARGS.
>=C2=A0 Each of the arguments in ARGS should be a list of this form:
> @@ -972,31 +1003,16 @@ COMMENT is a comment string about SYMBOL."=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(value (nth 1 entry)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 (custom-push-theme 'theme-value symbol = theme 'set value)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless custom--inhibit-theme-enable
> -=C2=A0 =C2=A0 ;; Now set the variable.
> -=C2=A0 =C2=A0 (let* ((now (nth 2 entry))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(requests (nth 3 entry))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(comment (nth 4 entry))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0set)
> -=C2=A0 =C2=A0 =C2=A0 (when requests
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 (put symbol 'custom-requests requests= )
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 (mapc 'require requests))
> -=C2=A0 =C2=A0 =C2=A0 (setq set (or (get symbol 'custom-set) '= custom-set-default))
> -=C2=A0 =C2=A0 =C2=A0 (put symbol 'saved-value (list value))
> -=C2=A0 =C2=A0 =C2=A0 (put symbol 'saved-variable-comment comment)=
> -=C2=A0 =C2=A0 =C2=A0 ;; Allow for errors in the case where the setter= has
> -=C2=A0 =C2=A0 =C2=A0 ;; changed between versions, say, but let the us= er know.
> -=C2=A0 =C2=A0 =C2=A0 (condition-case data
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cond (now
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Rogue variable, se= t it now.
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put symbol 'forc= e-value t)
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(funcall set symbol (= eval value)))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((default-boundp symbol) > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Something already = set this, overwrite it.
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(funcall set symbol (= eval value))))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 (error
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "Error setting %s: %s= " symbol data)))
> -=C2=A0 =C2=A0 =C2=A0 (and (or now (default-boundp symbol))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put symbol 'variable-co= mment comment)))))))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (let* ((requests (nth 3 entry)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when requests
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (put symbol 'custom-req= uests requests))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; If a symbol has requirements, w= e don't even try to load
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; them now, because we might acci= dentally load an old
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; built-in instead of a newer ins= talled version.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if requests
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (add-hook 'after= -init-hook
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (apply-partially #'custom--load-entry entry requests)) > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (custom--load-entry entry))= )))))

>=C2=A0 (defvar custom--sort-vars-table)
>=C2=A0 (defvar custom--sort-vars-result)
--001a11c3234c32811805127c1d52--