From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#21563: 24.5; discourage load-hook variables Date: Thu, 16 Jan 2020 21:30:44 +0100 Message-ID: <877e1r400b.fsf@marxist.se> References: <39185.7955.374134.22021@gargle.gargle.HOWL> <87tv4w1poj.fsf@marxist.se> <87muaoz2qu.fsf@marxist.se> <320a9fa6-6419-420e-ac97-9dcbe54a04a6@default> <87h80wz0dm.fsf@marxist.se> <80b979c0-0fdf-4b84-bf1b-cde0a596f8bb@default> <87tv4vy19c.fsf@marxist.se> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="113022"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Roland Winkler , 21563@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 16 21:31:18 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1isBnS-000TLN-24 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Jan 2020 21:31:18 +0100 Original-Received: from localhost ([::1]:48100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isBnR-0008Mc-4Q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Jan 2020 15:31:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56582) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isBnF-0008Ah-Gh for bug-gnu-emacs@gnu.org; Thu, 16 Jan 2020 15:31:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isBnD-0003Uw-QG for bug-gnu-emacs@gnu.org; Thu, 16 Jan 2020 15:31:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60669) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1isBnD-0003Tw-L2 for bug-gnu-emacs@gnu.org; Thu, 16 Jan 2020 15:31:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1isBnC-0007PF-G8 for bug-gnu-emacs@gnu.org; Thu, 16 Jan 2020 15:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Jan 2020 20:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21563 X-GNU-PR-Package: emacs Original-Received: via spool by 21563-submit@debbugs.gnu.org id=B21563.157920665428455 (code B ref 21563); Thu, 16 Jan 2020 20:31:02 +0000 Original-Received: (at 21563) by debbugs.gnu.org; 16 Jan 2020 20:30:54 +0000 Original-Received: from localhost ([127.0.0.1]:38409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1isBn3-0007Ot-Qm for submit@debbugs.gnu.org; Thu, 16 Jan 2020 15:30:54 -0500 Original-Received: from ted.gofardesign.uk ([67.225.143.91]:51910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1isBn2-0007OX-Fs for 21563@debbugs.gnu.org; Thu, 16 Jan 2020 15:30:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FNNA4jcH81jek64WKuN2WHySUnCUAT6y0NsFqt1ZBx0=; b=pXwNKE+sLrt3bc8dR2sjPpx4C2 QvPTFM4g8PIcsz54bkkLYtIY4dB2SdiS3ocpoNtHvw530jxfeL+N1MP1s7tQxPrAC8B+PBRQpEEfQ P6J97FtsgMtsu+/aLq/qri2i4MlkLSlkxXHQa267OCHYB9UCyXHndvz0JvMoOf4fcnTJvQzVYjhex rXEHvngcnA9RwGNoOs2mMHccBFVoYkEcatRBpCEsOIdXq8GEE2gjSesLP+hZYUo+94p1SA4S9RuXg 4eyyPZHMSwXZjtx22ZoA5Pqk/YgiYAwVlNDTA5QWARVubsNVkULQgVNifTlzdv16hQ0f/XR7Y867D u8rMuzCQ==; Original-Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:49942 helo=localhost) by ted.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1isBmw-001e34-JH; Thu, 16 Jan 2020 15:30:46 -0500 In-Reply-To: (Drew Adams's message of "Thu, 16 Jan 2020 08:15:58 -0800 (PST)") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ted.gofardesign.uk X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - marxist.se X-Get-Message-Sender-Via: ted.gofardesign.uk: authenticated_id: stefan@marxist.se X-Authenticated-Sender: ted.gofardesign.uk: stefan@marxist.se X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:174740 Archived-At: --=-=-= Content-Type: text/plain Drew Adams writes: >> To summarize what has come up in this thread so far, the load-hook >> convention has the following problems: >> >> 1. They are never called if set by a user after a library is loaded. >> 2. They can lead to issues like Bug#24491. >> 3. They require every package (that wants to use them) to add boiler >> plate code. >> >> They are also redundant since we have eval-after-load and >> with-eval-after-load, which do not have any of the above problems. > > Here's what I'd suggest, if you are bent on removing > all load hooks and deprecating them: > > 1. Try removing all of them from the vanilla > (distributed) Elisp code. > > 2. Run with that for a major release or two. If no > problems, then deprecate (declare obsolete). I'm not sure I understand the proposal. What is the "vanilla (distributed) Elisp code"? What does "removing all of them" mean, and how is removing them more cautious than adding a deprecation warning to the variables? Or, are we perhaps talking about different things? IIUC, load-hooks is just a convention to: a) (defvar foo-load-hook nil) ;; or defcustom spanning several lines, or ;; indeed no declaration at all b) (run-hooks 'foo-load-hook) ;; added just before the provide statement Third party packages are free to continue doing that. AFAICT, we have no way to stop them -- and I wouldn't advocate for that. Am I missing something here? I'm not sure if this was clear, but the course of action suggested by Glenn was to add deprecation warnings to the load-hook variables in GNU Emacs. Please see the attached patches for an example. Best regards, Stefan Kangas --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Obsolete-viper-load-hook-in-favor-of-eval-after-load.patch >From a47b2cb213af71978e8a16d596934fa318847971 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 16 Jan 2020 01:07:20 +0100 Subject: [PATCH 1/3] Obsolete viper-load-hook in favor of eval-after-load * lisp/emulation/viper-init.el (viper-load-hook): Make obsolete. * doc/misc/viper.texi (Rudimentary Changes): Doc fix - no longer mention viper-load-hook. --- doc/misc/viper.texi | 5 +---- lisp/emulation/viper-init.el | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/misc/viper.texi b/doc/misc/viper.texi index 9ce809e7d4..087eb2701d 100644 --- a/doc/misc/viper.texi +++ b/doc/misc/viper.texi @@ -1755,7 +1755,7 @@ Rudimentary Changes Insert state, or Emacs state. This heuristics works well in virtually all cases. @code{nil} means you either has to invoke @code{viper-mode} manually for each buffer (or you can add @code{viper-mode} to the appropriate major mode -hooks using @code{viper-load-hook}). +hooks). This option must be set in your Viper customization file. @item viper-custom-file-name "~/.emacs.d/viper" @@ -1903,9 +1903,6 @@ Rudimentary Changes @item viper-emacs-state-hook nil List of (parameterless) functions called just after switching from Vi state to Emacs state. -@item viper-load-hook nil -List of (parameterless) functions called just after loading Viper. This is -the last chance to do customization before Viper is up and running. @end table @noindent You can reset some of these constants in Viper with the Ex command @kbd{:set} diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el index 511c68f24a..09fa0ba7f6 100644 --- a/lisp/emulation/viper-init.el +++ b/lisp/emulation/viper-init.el @@ -923,6 +923,9 @@ viper-load-hook :type 'hook :group 'viper-hooks) +(make-obsolete-variable 'viper-load-hook + "use `with-eval-after-load' instead." "28.1") + (defun viper-restore-cursor-type () (condition-case nil (setq cursor-type (default-value 'cursor-type)) -- 2.20.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Obsolete-reftex-load-hook-in-favor-of-eval-after-loa.patch >From c225cd8059607eeef0d65b57db31122e36b0471c Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 16 Jan 2020 01:23:46 +0100 Subject: [PATCH 2/3] Obsolete reftex-load-hook in favor of eval-after-load * lisp/textmodes/reftex-vars.el (reftex-load-hook): Make obsolete. * doc/misc/reftex.texi (Key Bindings, Keymaps and Hooks): No longer mention reftex-load-hook. (Bug#21563) --- doc/misc/reftex.texi | 9 ++------- lisp/textmodes/reftex-vars.el | 3 +++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/misc/reftex.texi b/doc/misc/reftex.texi index 013c5639a1..0dab524151 100644 --- a/doc/misc/reftex.texi +++ b/doc/misc/reftex.texi @@ -2896,9 +2896,8 @@ Key Bindings Note that this variable has to be set before @RefTeX{} is loaded to have an effect. -@vindex reftex-load-hook -Changing and adding to @RefTeX{}'s key bindings is best done in the hook -@code{reftex-load-hook}. For information on the keymaps +Changing and adding to @RefTeX{}'s key bindings is best done using +@code{with-eval-after-load}. For information on the keymaps which should be used to add keys, see @ref{Keymaps and Hooks}. @node Faces @@ -5320,10 +5319,6 @@ Keymaps and Hooks The keymap for @RefTeX{} mode. @end deffn -@deffn {Normal Hook} reftex-load-hook -Normal hook which is being run when loading @file{reftex.el}. -@end deffn - @deffn {Normal Hook} reftex-mode-hook Normal hook which is being run when turning on @RefTeX{} mode. @end deffn diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index ca92541331..d2324dd4ae 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -2101,6 +2101,9 @@ reftex-load-hook :group 'reftex-miscellaneous-configurations :type 'hook) +(make-obsolete-variable 'reftex-load-hook + "use `with-eval-after-load' instead." "28.1") + (defcustom reftex-mode-hook nil "Hook which is being run when turning on RefTeX mode." :group 'reftex-miscellaneous-configurations -- 2.20.1 --=-=-=--