unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60954: 29.0.60; ERC 5.4.1: loading ERC clobbers customizations to erc-mode-hook
@ 2023-01-20  5:34 J.P.
  0 siblings, 0 replies; 11+ messages in thread
From: J.P. @ 2023-01-20  5:34 UTC (permalink / raw)
  To: 60954; +Cc: emacs-erc

[-- Attachment #1: Type: text/plain, Size: 5874 bytes --]

Tags: patch

To reproduce:

  1. Put the following in /tmp/test/init.el
  
       (custom-set-variables
        '(erc-mode-hook '(erc-imenu-setup visual-line-mode)))

     which is exactly what you'd get by doing

       M-x customize-group RET erc-hooks RET

     and adding a `visual-line-mode' item to `erc-mode-hook'.

  2. Run

       emacs --no-site-file --init-directory=/tmp/test

  3. If you do a

       C-h v erc-mode-hook RET

     which loads `erc' behind the scenes, the hook's value will be

       (erc-imenu-setup)

     Note the missing `visual-line-mode'.


Superficially, this is a regression stemming from 

  bug#56340: 29.0.50; [PATCH] Don't ask people to order requires.

which became

   commit c2d657e7c4fd9685591f2120007eabf78745919d
   Author: Dick R. Chiang <dick.r.chiang@gmail.com>
   Date:   Fri Jul 1 11:06:51 2022 -0400

   Move ERC's core dependencies to separate file

But amid all that rearranging, a subtle and pernicious headache long ago
swept under the rug happened to resurface [1].

I see two basic avenues of attack here. The first is a pretty safe
stopgap and the second a slightly riskier comprehensive approach that
should have been on the books the moment that bug was closed:

  hack: partially revert a tiny hunk from the commit above

  fix:  don't require goodies at all and instead update the module
        mapping data and add all necessary autoloads and forward
        declarations

Implementations of both are attached. (I didn't bother updating the
required Compat version in the second patch, but that'd also need to
accompany the change set.) For now, I propose we take the shorter route
but with an eye toward revisiting the issue soon after the next (ERC)
release. If anyone has an opinion here, now would be the time to speak
up.

Thanks.

P.S. This bug owes its existence to Libera user jrm, who kindly brought
it to our attention earlier today.


[1] Some related background. For ages, `erc-goodies' was `require'd by
    erc.el at the very end of that file, likely in order to sidestep the
    manual module-to-feature mapping needed by `erc-update-modules' for
    outliers whose names don't match their features (arguably justified
    for smaller, miscellaneous modules). A secondary benefit and
    possible motivating factor was that various commands from goodies
    could feature in `erc-mode-map' without being autoloaded. However,
    additional liberties were eventually taken until erc-goodies.el
    became a de facto addendum to erc.el.



In GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.35, cairo version 1.17.6) of 2023-01-19 built on localhost
Repository revision: 7b7b2b95138e691f1b155060b91a8998e3905651
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 36 (Workstation Edition)

Configured using:
 'configure --enable-check-lisp-object-type --enable-checking=yes,glyphs
 'CFLAGS=-O0 -g3'
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util text-property-search mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils erc iso8601 time-date
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map thingatpt pp format-spec cl-loaddefs cl-lib erc-backend erc-goodies
erc-networks byte-opt gv bytecomp byte-compile erc-common erc-compat
erc-loaddefs rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty
make-network-process emacs)

Memory information:
((conses 16 64464 6515)
 (symbols 48 8616 0)
 (strings 32 23657 2042)
 (string-bytes 1 685680)
 (vectors 16 15232)
 (vector-slots 8 209553 7914)
 (floats 8 24 23)
 (intervals 56 228 0)
 (buffers 976 10))

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-load-erc-goodies-atop-erc.el.patch --]
[-- Type: text/x-patch, Size: 1228 bytes --]

From a20ae7ac78abbb1d200a6e264dbc0ede39d56dd1 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Thu, 19 Jan 2023 20:19:40 -0800
Subject: [PATCH 1/3] Don't load erc-goodies atop erc.el

* lisp/erc/erc.el: Commit c2d657e7c4fd9685591f2120007eabf78745919d
"Move ERC's core dependencies to a separate file" ironed out ERC's
interwoven dependencies for the better but didn't cleanly sidestep the
goodies interdependency, specifically with regard to custom options.
This reverts the tiny portion impacting this aspect by once again
requiring `erc-goodies' at the very end of ERC's main library. Special
thanks to Libera.Chat user jrm for reporting this bug.
---
 lisp/erc/erc.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 7f51b7bfb2e..ff1820cfaf2 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -61,7 +61,6 @@
 (load "erc-loaddefs" 'noerror 'nomessage)
 
 (require 'erc-networks)
-(require 'erc-goodies)
 (require 'erc-backend)
 (require 'cl-lib)
 (require 'format-spec)
@@ -7386,4 +7385,6 @@ erc-handle-irc-url
 
 (provide 'erc)
 
+;; FIXME this is a temporary stopgap for Emacs 29.
+(require 'erc-goodies)
 ;;; erc.el ends here
-- 
2.38.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-5.6-Copy-over-upstream-Compat-macros-to-erc-compat.patch --]
[-- Type: text/x-patch, Size: 3995 bytes --]

From 9604e304bb025a620abdec86c75d2c4074b87d88 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Thu, 19 Jan 2023 20:52:47 -0800
Subject: [PATCH 2/3] [5.6] Copy over upstream Compat macros to erc-compat

* lisp/erc/erc-backend: (erc--get-isupport-entry): Replace call to
`erc-compat--with-memoization' with the built-in `with-memoization'.
* lisp/erc/erc-compat.el: (erc-compat-function, erc-compat-call): Add
new macros from Compat 29.1.2.0.
(erc-compat--with-memoization): Remove because it's now provided by
Compat.
---
 lisp/erc/erc-backend.el |  2 +-
 lisp/erc/erc-compat.el  | 49 +++++++++++++++++++++++++++++++++--------
 2 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 1da701aebc4..f00c8b2841a 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -1878,7 +1878,7 @@ erc--get-isupport-entry
 primitive value."
   (if-let* ((table (or erc--isupport-params
                        (erc-with-server-buffer erc--isupport-params)))
-            (value (erc-compat--with-memoization (gethash key table)
+            (value (with-memoization (gethash key table)
                      (when-let ((v (assoc (symbol-name key)
                                           erc-server-parameters)))
                        (if (cdr v)
diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el
index 5601ede27a5..fb354a1d3f7 100644
--- a/lisp/erc/erc-compat.el
+++ b/lisp/erc/erc-compat.el
@@ -34,6 +34,46 @@
 (require 'compat nil 'noerror)
 (eval-when-compile (require 'cl-lib) (require 'url-parse))
 
+;; Except for the "erc-" namespacing, these two definitions should be
+;; continuously updated to match the latest upstream ones verbatim.
+;; Although they're pretty simple, it's likely not worth checking for
+;; and possibly deferring to the non-prefixed versions.
+;;
+;; BEGIN Compat macros
+
+;;;; Macros for explicit compatibility function calls
+
+(defmacro erc-compat-function (fun)
+  "Return compatibility function symbol for FUN.
+
+If the Emacs version provides a sufficiently recent version of
+FUN, the symbol FUN is returned itself.  Otherwise the macro
+returns the symbol of a compatibility function which supports the
+behavior and calling convention of the current stable Emacs
+version.  For example Compat 29.1 will provide compatibility
+functions which implement the behavior and calling convention of
+Emacs 29.1.
+
+An example is the function `plist-get' which got an additional
+predicate argument in Emacs 29.  The compatibility function,
+which supports this additional argument can be obtained
+via (compat-function plist-get) and called with the additional
+predicate argument via (compat-call plist-get plist prop
+predicate).  It is not possible to directly call (plist-get plist
+prop predicate), since the function does not yet support the
+predicate argument on older Emacs versions and the Compat library
+does not override existing functions."
+  (let ((compat (intern (format "compat--%s" fun))))
+    `#',(if (fboundp compat) compat fun)))
+
+(defmacro erc-compat-call (fun &rest args)
+  "Call compatibility function or macro FUN with ARGS.
+See `compat-function' for details."
+  (let ((compat (intern (format "compat--%s" fun))))
+    `(,(if (fboundp compat) compat fun) ,@args)))
+
+;; END Compat macros
+
 ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat")
 (define-obsolete-function-alias 'erc-define-minor-mode
   #'define-minor-mode "28.1")
@@ -368,15 +408,6 @@ erc-compat--29-sasl-scram--client-final-message
 
 ;;;; Misc 29.1
 
-(defmacro erc-compat--with-memoization (table &rest forms)
-  (declare (indent defun))
-  (cond
-   ((fboundp 'with-memoization)
-    `(with-memoization ,table ,@forms)) ; 29.1
-   ((fboundp 'cl--generic-with-memoization)
-    `(cl--generic-with-memoization ,table ,@forms))
-   (t `(progn ,@forms))))
-
 (defvar url-irc-function)
 
 (defun erc-compat--29-browse-url-irc (string &rest _)
-- 
2.38.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-5.6-Don-t-require-erc-goodies-in-erc.el.patch --]
[-- Type: text/x-patch, Size: 4945 bytes --]

From 8cd02bc9c0b54cb0812aebac137ed1828e395a31 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Thu, 19 Jan 2023 21:07:27 -0800
Subject: [PATCH 3/3] [5.6] Don't require erc-goodies in erc.el

* lisp/erc/erc-common.el: (erc--features-to-modules): Add mappings
from erc-goodies.
* lisp/erc/erc-goodies.el: Sort `defvar' forward declarations for
maintainability.
(erc-irccontrols-mode, erc-enable-irccontrols,
erc-disable-irccontrols): Add and remove key for
`erc-toggle-interpret-controls' to `erc-mode-map'.
* lisp/erc/erc.el: Add some forward declarations from `erc-goodies'
and remove the `require' call for `erc-goodies' at the end of the
file.
(erc-mode-map): Remove C-c C-c binding for
`erc-toggle-interpret-controls'.
(erc-update-mode-line-buffer): Only strip control chars when
`erc-irccontrols-mode' is active.  This is arguably a minor breaking
change perhaps deserving of a NEWS entry.
---
 lisp/erc/erc-common.el  | 10 +++++++++-
 lisp/erc/erc-goodies.el | 11 +++++++----
 lisp/erc/erc.el         | 10 ++++++----
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el
index 994555acecf..e567a108191 100644
--- a/lisp/erc/erc-common.el
+++ b/lisp/erc/erc-common.el
@@ -96,7 +96,15 @@ erc--features-to-modules
     (erc-page page ctcp-page)
     (erc-sound sound ctcp-sound)
     (erc-stamp stamp timestamp)
-    (erc-services services nickserv))
+    (erc-services services nickserv)
+    (erc-goodies scrolltobottom)
+    (erc-goodies readonly)
+    (erc-goodies move-to-prompt)
+    (erc-goodies keep-place)
+    (erc-goodies noncommands)
+    (erc-goodies irccontrols)
+    (erc-goodies smiley)
+    (erc-goodies unmorse))
   "Migration alist mapping a library feature to module names.
 Keys need not be unique: a library may define more than one
 module.  Sometimes a module's downcased alias will be its
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 05a21019042..0bf4bb9537c 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -38,9 +38,10 @@ erc-controls-highlight-regexp
 (defvar erc-controls-remove-regexp)
 (defvar erc-input-marker)
 (defvar erc-insert-marker)
-(defvar erc-server-process)
-(defvar erc-modules)
 (defvar erc-log-p)
+(defvar erc-mode-map)
+(defvar erc-modules)
+(defvar erc-server-process)
 
 (declare-function erc-buffer-list "erc" (&optional predicate proc))
 (declare-function erc-error "erc" (&rest args))
@@ -384,9 +385,11 @@ erc-get-fg-color-face
 (define-erc-module irccontrols nil
   "This mode enables the interpretation of IRC control chars."
   ((add-hook 'erc-insert-modify-hook #'erc-controls-highlight)
-   (add-hook 'erc-send-modify-hook #'erc-controls-highlight))
+   (add-hook 'erc-send-modify-hook #'erc-controls-highlight)
+   (define-key erc-mode-map "\C-c\C-c" #'erc-toggle-interpret-controls))
   ((remove-hook 'erc-insert-modify-hook #'erc-controls-highlight)
-   (remove-hook 'erc-send-modify-hook #'erc-controls-highlight)))
+   (remove-hook 'erc-send-modify-hook #'erc-controls-highlight)
+   (erc-compat-call define-key erc-mode-map "\C-c\C-c" nil t)))
 
 (defun erc-controls-interpret (str)
    "Return a copy of STR after dealing with IRC control characters.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index ff1820cfaf2..007f70b8671 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -134,11 +134,14 @@ erc-scripts
 
 ;; Forward declarations
 (defvar erc-message-parsed)
+(defvar erc-irccontrols-mode)
 
 (defvar tabbar--local-hlf)
 (defvar motif-version-string)
 (defvar gtk-version-string)
 
+(declare-function erc-controls-strip "erc-goodies" (str))
+
 ;; tunable connection and authentication parameters
 
 (defcustom erc-server nil
@@ -1188,7 +1191,6 @@ erc-mode-map
     (define-key map [home] #'erc-bol)
     (define-key map "\C-c\C-a" #'erc-bol)
     (define-key map "\C-c\C-b" #'erc-switch-to-buffer)
-    (define-key map "\C-c\C-c" #'erc-toggle-interpret-controls)
     (define-key map "\C-c\C-d" #'erc-input-action)
     (define-key map "\C-c\C-e" #'erc-toggle-ctcp-autoresponse)
     (define-key map "\C-c\C-f" #'erc-toggle-flood-control)
@@ -6847,7 +6849,9 @@ erc-update-mode-line-buffer
                   (?m . ,(erc-format-channel-modes))
                   (?n . ,(or (erc-current-nick) ""))
                   (?N . ,(erc-format-network))
-                  (?o . ,(or (erc-controls-strip erc-channel-topic) ""))
+                  (?o . ,(or (and erc-irccontrols-mode
+                                  (erc-controls-strip erc-channel-topic))
+                             ""))
                   (?p . ,(erc-port-to-string erc-session-port))
                   (?s . ,(erc-format-target-and/or-server))
                   (?S . ,(erc-format-target-and/or-network))
@@ -7385,6 +7389,4 @@ erc-handle-irc-url
 
 (provide 'erc)
 
-;; FIXME this is a temporary stopgap for Emacs 29.
-(require 'erc-goodies)
 ;;; erc.el ends here
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-03-15 14:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87pmb9wyz6.fsf@neverwas.me>
2023-01-20  7:16 ` bug#60954: 29.0.60; ERC 5.4.1: loading ERC clobbers customizations to erc-mode-hook Eli Zaretskii
     [not found] ` <83cz79oeu7.fsf@gnu.org>
2023-01-20 14:14   ` J.P.
2023-01-20 14:15 ` J.P.
2023-01-21 15:03 ` bug#60954: 30.0.50; ERC >5.5: Stop requiring erc-goodies in erc.el J.P.
2023-01-31 15:27 ` J.P.
2023-02-07 15:22 ` J.P.
2023-02-19 15:07 ` J.P.
2023-03-09 14:43 ` J.P.
2023-03-14 13:32 ` J.P.
2023-03-15 14:04 ` J.P.
2023-01-20  5:34 bug#60954: 29.0.60; ERC 5.4.1: loading ERC clobbers customizations to erc-mode-hook J.P.

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).