From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#17558: 24.4.50; global-subword-mode breaks ERC Date: Thu, 01 Jan 2015 13:47:41 -0800 Message-ID: <871tnemasq.fsf@secretsauce.net> References: <87ppj4ette.fsf@secretsauce.net> <537FB4C8.3080809@dancol.org> <87a924mbuk.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1420149018 6711 80.91.229.3 (1 Jan 2015 21:50:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Jan 2015 21:50:18 +0000 (UTC) To: 17558@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 01 22:50:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1Y6ndD-00010T-AS for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jan 2015 22:50:11 +0100 Original-Received: from localhost ([::1]:49691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6ndC-0007zB-I4 for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jan 2015 16:50:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6nd8-0007xE-F0 for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 16:50:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y6nd5-0001Tz-8f for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 16:50:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6nd4-0001TN-VR for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 16:50:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y6nd4-0004lY-3J for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 16:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Jan 2015 21:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17558 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17558-submit@debbugs.gnu.org id=B17558.142014896118263 (code B ref 17558); Thu, 01 Jan 2015 21:50:01 +0000 Original-Received: (at 17558) by debbugs.gnu.org; 1 Jan 2015 21:49:21 +0000 Original-Received: from localhost ([127.0.0.1]:34713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y6ncO-0004kV-PN for submit@debbugs.gnu.org; Thu, 01 Jan 2015 16:49:21 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:57123) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y6ncK-0004kK-5f for 17558@debbugs.gnu.org; Thu, 01 Jan 2015 16:49:17 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id A9EAF207B6 for <17558@debbugs.gnu.org>; Thu, 1 Jan 2015 16:49:15 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Thu, 01 Jan 2015 16:49:15 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=x-sasl-enc:references:from:to:subject:date:in-reply-to :message-id:mime-version:content-type; s=mesmtp; bh=EOqzPXDtUl6I 2XD0tfd/ANOCu3s=; b=I4NU80wfNHC7zja/7E1QIAHGrjpO0VhnInHquxe9R2te cfgppc8Y1vxb/oeHbNXJZFNnqUdYd+1j0s2KMYydASi+OraGVeviu/LzLl8zIADF vhdnOqQmJSkoVUCoTpPMt197BzHgB2FbPsZVs9qaSZf6Wql4nPLhVteSTRmwiOk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:references:from:to:subject :date:in-reply-to:message-id:mime-version:content-type; s= smtpout; bh=EOqzPXDtUl6I2XD0tfd/ANOCu3s=; b=UPTT7z3ilXeyLCLZrI5b eC0aYT38jgLrtKmP/JUMEjA1DaEVYyLYJuRJQiBkVD6vD5qcgmk6D7CpHzP4xfXk NIBYCfPpjyDUB9OjDcV3FpTzWqU0p2rIM6UMxmDu7VPV1PpvNn3A7waZKetPSSk1 vFUdqTpe34i3IuKL8vPB4xk= X-Sasl-enc: TBsU8fuq5BXTYcbOt1FOtDVghUtBsybceJ/KE+7VvmcC 1420148955 Original-Received: from shorty.local (unknown [174.28.80.18]) by mail.messagingengine.com (Postfix) with ESMTPA id 042A5680107 for <17558@debbugs.gnu.org>; Thu, 1 Jan 2015 16:49:15 -0500 (EST) Original-Received: from dima by shorty.local with local (Exim 4.84) (envelope-from ) id 1Y6ncD-0006yA-Vf for 17558@debbugs.gnu.org; Thu, 01 Jan 2015 13:49:09 -0800 In-reply-to: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97929 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> - (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)) > > Yuck. I suggest you use upcase-region instead (and probably something > like skip-char-forward to find the word's boundaries). OK. New patch attached. It's a bit less ugly, maybe; still pretty verbose. Marking the -word functions as interactive-only would be a great thing to do. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ERC-no-longer-gets-confused-by-subword-mode.patch >From 3017aba1093c8f57d3a3b7193692d62a56b68d3b Mon Sep 17 00:00:00 2001 From: Dima Kogan 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 replaces the word-oriented calls with ones that navigate the buffer using syntax classes Closes: #17558 --- lisp/erc/erc-backend.el | 11 ++++++++++- lisp/erc/erc-button.el | 30 ++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 1ef494c..0e80438 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -480,7 +480,16 @@ Currently this is called by `erc-send-input'." (with-temp-buffer (insert str) (goto-char (point-min)) - (upcase-word 1) + + ;; this is (upcase-word 1), but working even with subword-mode + ;; active + (skip-syntax-forward "^w") + (let* + ((word-start (point)) + (word-end + (progn (skip-syntax-forward "w") (point)))) + (upcase-region word-start word-end)) + (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..d194627 100644 --- a/lisp/erc/erc-button.el +++ b/lisp/erc/erc-button.el @@ -300,14 +300,28 @@ 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))))))) + + (while + (progn + + ;; I move forward a word (independent of subword-mode) ... + (skip-syntax-forward "^w") + (let* + ((word-start (point)) + (word-end + (progn (skip-syntax-forward "w") (point)))) + + ;; ... if the word was empty we're at the end of buffer ... + (and (/= word-start word-end) + + ;; ... otherwise, we do stuff with this word + (progn + (setq word (buffer-substring-no-properties + word-start word-end)) + (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 word-start word-end + 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 --=-=-=--