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: Sat, 09 Jan 2016 10:14:51 -0800 Message-ID: <87twmmhb6s.fsf@secretsauce.net> References: <87ppj4ette.fsf@secretsauce.net> <537FB4C8.3080809@dancol.org> <87a924mbuk.fsf@secretsauce.net> <8rvbghcp9y.fsf@fencepost.gnu.org> <553EB8A7.7070103@dancol.org> <55404294.40908@dancol.org> <87y4iiw0p3.fsf@secretsauce.net> <87wps0opcl.fsf@gnus.org> <87fuy7dhrm.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1452363328 32379 80.91.229.3 (9 Jan 2016 18:15:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Jan 2016 18:15:28 +0000 (UTC) Cc: 17558@debbugs.gnu.org To: Lars Magne Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 09 19:15:15 2016 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 1aHy2k-0004L7-Hk for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Jan 2016 19:15:14 +0100 Original-Received: from localhost ([::1]:41993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHy2j-0006aP-LV for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Jan 2016 13:15:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHy2c-0006Wo-DB for bug-gnu-emacs@gnu.org; Sat, 09 Jan 2016 13:15:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHy2Y-0000Vm-Kv for bug-gnu-emacs@gnu.org; Sat, 09 Jan 2016 13:15:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56389) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHy2Y-0000Vg-DJ for bug-gnu-emacs@gnu.org; Sat, 09 Jan 2016 13:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aHy2Y-00065Y-93 for bug-gnu-emacs@gnu.org; Sat, 09 Jan 2016 13:15: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: Sat, 09 Jan 2016 18:15:02 +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.145236330123382 (code B ref 17558); Sat, 09 Jan 2016 18:15:02 +0000 Original-Received: (at 17558) by debbugs.gnu.org; 9 Jan 2016 18:15:01 +0000 Original-Received: from localhost ([127.0.0.1]:44609 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHy2T-000651-Sl for submit@debbugs.gnu.org; Sat, 09 Jan 2016 13:15:01 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:35480) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHy2P-00064q-CF for 17558@debbugs.gnu.org; Sat, 09 Jan 2016 13:14:57 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id D731E20676 for <17558@debbugs.gnu.org>; Sat, 9 Jan 2016 13:14:52 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Sat, 09 Jan 2016 13:14:52 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=YclvB tkfQlzIAKaXWqh5jV0BArM=; b=ssNPgGZC1oIBG41aGcvbkzEfoaq3Ac/plBsjm 6mS/Y101Dvto2dmIBFGSfSl6i7aXtFNNk6b2RNOqvA+TCoUhKsCMObe3/FVRrMTE S9jXbumYenn9bxhMdjWJ2Oc357kEhZz0PFOEyal2NoAahqkfx/Df2jAE2FCeX1LF CNk//4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=YclvBtkfQlzIAKaXWqh5jV0BArM=; b=SRRGH toa8auEzeeohJ8yOTmz5ccdJzfl/II3fIw+Ld7wzWLR2TjO3DqqnjBugPFZ7sku4 v/EEakMF+hEDsHToWLRwpshAxVkEN6/65DaMWVDPNAu0heMexBZh5ToZj0Xh25Vg s1ajLy2zITST0Sl2UiqDLdhZKO64uux50p7lH4= X-Sasl-enc: lY8j2GNDLgoFL1z5g88m374S220iQbpMc/xjnK8mqeA0 1452363292 Original-Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com [50.1.153.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 7633168011F; Sat, 9 Jan 2016 13:14:52 -0500 (EST) Original-Received: from localhost ([::1] helo=shorty) by shorty.local with esmtp (Exim 4.84) (envelope-from ) id 1aHy2N-0005FR-9a; Sat, 09 Jan 2016 10:14:51 -0800 User-agent: mu4e 0.9.11; emacs 25.0.50.1 In-reply-to: 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: 208.118.235.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:111435 Archived-At: --=-=-= Content-Type: text/plain Lars Magne Ingebrigtsen writes: >> The attached patch thus has no changes to this hunk. Let me know if you >> think of a nicer way to do this. > > This still seems very difficult to understand. The old version has a > clear loop condition > >> - (while (forward-word 1) > > while in the new version everything is inside a progn, making it kinda > difficult to follow. Aaah, I see the complaint now. New patch attached. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ERC-no-longer-gets-confused-by-subword-mode.patch >From ba2f53e864cc36a3a9296104975407274b59b601 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 | 28 +++++++++++++++++++++++++++- lisp/erc/erc-button.el | 16 ++++++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index ec45dcf..4925c96 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -474,13 +474,39 @@ Currently this is called by `erc-send-input'." nil t)) (split-string (buffer-string) "\n")))) +(defun erc-forward-word () + "Moves forward one word, ignoring any subword settings. If no +subword-mode is active, then this is (forward-word)." + (skip-syntax-forward "^w") + (> (skip-syntax-forward "w") 0)) + +(defun erc-word-at-arg-p (pos) + "Reports whether the char after a given POS has word syntax. +If POS is out of range, the value is nil." + (let ((c (char-after pos))) + (if c + (eq ?w (char-syntax c)) + nil))) + +(defun erc-bounds-of-word-at-point () + "Returns the bounds of a word at point, or nil if we're not at +a word. If no subword-mode is active, then this +is (bounds-of-thing-at-point 'word)." + (if (or (erc-word-at-arg-p (point)) + (erc-word-at-arg-p (1- (point)))) + (save-excursion + (let* ((start (progn (skip-syntax-backward "w") (point))) + (end (progn (skip-syntax-forward "w") (point)))) + (cons start end))) + nil)) + ;; Used by CTCP functions (defun erc-upcase-first-word (str) "Upcase the first word in STR." (with-temp-buffer (insert str) (goto-char (point-min)) - (upcase-word 1) + (upcase-region (point) (progn (erc-forward-word) (point))) (buffer-string))) (defun erc-server-setup-periodical-ping (buffer) diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el index 0e4c709..a59ad22 100644 --- a/lisp/erc/erc-button.el +++ b/lisp/erc/erc-button.el @@ -300,14 +300,14 @@ 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 (erc-forward-word) + (when (setq bounds (erc-bounds-of-word-at-point)) + (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.4 --=-=-=--