GNU bug report logs - #19363
24.4.1; Notifications can make ERC unusable

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Sat, 13 Dec 2014 06:34:02 UTC

Severity: normal

Found in version 24.4.1

Done: Kelvin White <kwhite <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 19363 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: 19363 <at> debbugs.gnu.org
Subject: Re: bug#19363: Acknowledgement (24.4.1;
 Notifications can make ERC unusable)
Date: Wed, 31 Dec 2014 00:34:28 -0800
[Message part 1 (text/plain, inline)]
Here's a patch. It works, but I don't like how un-future-proof it is. An
uncareful coder can simply use (forward-word) somewhere and get things
to break again. Is there a better way?

[0001-ERC-no-longer-gets-confused-by-subword-mode.patch (text/x-diff, inline)]
From 655e7b9b5735bd62aac104645b5a224636ab97ff Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima <at> secretsauce.net>
Date: Tue, 30 Dec 2014 23:29:21 -0800
Subject: [PATCH] ERC no longer gets confused by subword-mode

In commit 6ddc44225e743e2b2a0d5c192f50aefd7a4a915b subword-mode was
integrated into the syntax table instead of simply remapping the
interactive motion bindings as was done previously.  This had the
unintended effect of changing the behavior of lisp programs that touch
words.  In the case of ERC, it completely broke it: emacs now throws an
error when ERC is launched, making it unusable when subword-mode is
active.

This commit temporarily disables subword-mode so that ERC functions that
touch words do so the "normal" way.

Closes: #17558
---
 lisp/erc/erc-backend.el |  9 ++++++++-
 lisp/erc/erc-button.el  | 23 +++++++++++++++--------
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index bedb20f..fa95d7e 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -480,7 +480,14 @@ Currently this is called by `erc-send-input'."
   (with-temp-buffer
     (insert str)
     (goto-char (point-min))
-    (upcase-word 1)
+
+    ;; If we're in subword-mode then functions operating on words act
+    ;; differently. Here I temporarily disable subword-mode before
+    ;; touching the words
+    (let ((find-word-boundary-function-table
+           (if (boundp 'subword-empty-char-table)
+               subword-empty-char-table find-word-boundary-function-table)))
+      (upcase-word 1))
     (buffer-string)))
 
 (defun erc-server-setup-periodical-ping (buffer)
diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el
index 10e7318..8343425 100644
--- a/lisp/erc/erc-button.el
+++ b/lisp/erc/erc-button.el
@@ -300,14 +300,21 @@ specified by `erc-button-alist'."
     (when (or (eq t form)
               (eval form))
       (goto-char (point-min))
-      (while (forward-word 1)
-        (setq bounds (bounds-of-thing-at-point 'word))
-        (setq word (buffer-substring-no-properties
-                    (car bounds) (cdr bounds)))
-        (when (or (and (erc-server-buffer-p) (erc-get-server-user word))
-                  (and erc-channel-users (erc-get-channel-user word)))
-          (erc-button-add-button (car bounds) (cdr bounds)
-                                 fun t (list word)))))))
+
+      ;; If we're in subword-mode then functions operating on words
+      ;; act differently. Here I temporarily disable subword-mode
+      ;; before touching the words
+      (let ((find-word-boundary-function-table
+             (if (boundp 'subword-empty-char-table)
+                 subword-empty-char-table find-word-boundary-function-table)))
+        (while (forward-word 1)
+          (setq bounds (bounds-of-thing-at-point 'word))
+          (setq word (buffer-substring-no-properties
+                      (car bounds) (cdr bounds)))
+          (when (or (and (erc-server-buffer-p) (erc-get-server-user word))
+                    (and erc-channel-users (erc-get-channel-user word)))
+            (erc-button-add-button (car bounds) (cdr bounds)
+                                   fun t (list word))))))))
 
 (defun erc-button-add-buttons-1 (regexp entry)
   "Search through the buffer for matches to ENTRY and add buttons."
-- 
2.1.3


This bug report was last modified 10 years and 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.