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: Fri, 08 Jan 2016 10:54:05 -0800 Message-ID: <87fuy7dhrm.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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1452279330 30011 80.91.229.3 (8 Jan 2016 18:55:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Jan 2016 18:55:30 +0000 (UTC) Cc: 17558@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 08 19:55:18 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 1aHcBv-0000n7-Fv for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Jan 2016 19:55:15 +0100 Original-Received: from localhost ([::1]:37708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHcBu-0001sI-Qr for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Jan 2016 13:55:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHcBm-0001jU-60 for bug-gnu-emacs@gnu.org; Fri, 08 Jan 2016 13:55:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHcBi-0001Uk-Ep for bug-gnu-emacs@gnu.org; Fri, 08 Jan 2016 13:55:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHcBi-0001Ug-6n for bug-gnu-emacs@gnu.org; Fri, 08 Jan 2016 13:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aHcBh-00076E-UW for bug-gnu-emacs@gnu.org; Fri, 08 Jan 2016 13:55:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Jan 2016 18:55: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.145227925827236 (code B ref 17558); Fri, 08 Jan 2016 18:55:01 +0000 Original-Received: (at 17558) by debbugs.gnu.org; 8 Jan 2016 18:54:18 +0000 Original-Received: from localhost ([127.0.0.1]:43392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHcAw-00075A-G3 for submit@debbugs.gnu.org; Fri, 08 Jan 2016 13:54:18 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:54124) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHcAr-00074z-5x for 17558@debbugs.gnu.org; Fri, 08 Jan 2016 13:54:13 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C78F120D39 for <17558@debbugs.gnu.org>; Fri, 8 Jan 2016 13:54:08 -0500 (EST) Original-Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Fri, 08 Jan 2016 13:54:08 -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=7GHXM Qy74tgXBnvmwCLTrHGf5cs=; b=Zv1+YJY8o+o/TzPIz5UtRE+5FERm9qRvKaMCr TyC71+uyIFPfP3u2hjC4h0gPNQJMhd3b4dm0moyBy8av1yGThMMZyY2LY0pJlSKm sxEMEYR5ymcGhqoD+0DH6i+6fAUhrxE0UGv6WNligIxXD0KJSA1+bsowuacjb5/I +qNPm4= 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=7GHXMQy74tgXBnvmwCLTrHGf5cs=; b=U7MPm oC/qtM6XsSghFolqh46VO21t6rPhs6iO/z1hsgwfA2+OE0alKt+NVf/p7pDYhSJL fzzbfcvCrAx1NuftXvfbQjMBeyCRXRfizShvSzH/H+SxCymD0aTodgYgWFOD8QqQ 0WWn97HCSaBuhHbF5gar43b7BL0Lhg3nW77jOE= X-Sasl-enc: uG3XVGQzyumj86SrFwxsL7/cwvfCRSc9qSSxhtqbc2Fg 1452279248 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 57991C00017; Fri, 8 Jan 2016 13:54:08 -0500 (EST) Original-Received: from localhost ([::1] helo=shorty) by shorty.local with esmtp (Exim 4.84) (envelope-from ) id 1aHcAn-00064z-AL; Fri, 08 Jan 2016 10:54:05 -0800 User-agent: mu4e 0.9.11; emacs 25.0.50.1 In-reply-to: <87wps0opcl.fsf@gnus.org> 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:111392 Archived-At: --=-=-= Content-Type: text/plain Hi. New patch attached. Notes inline Lars Ingebrigtsen writes: > I've got a couple of comments about the code... > >> (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)) >> + > > If you had a function `erc-forward-word' that did all the syntax > skipping, you could basically just say > > (upcase-region (point) (erc-forward-word)) Sure. New patch does this. >> - (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))))))))))) > > Similarly here, you could use that erc-forward-word to avoid rewriting > this code so much. It would be just > > (while (erc-forward-word) > (setq bound-stuff ...) > ) That would be nice, but no. This chunk of code was affected by subword-mode in two ways: 1. (forward-word 1) 2. (bounds-of-thing-at-point 'word) The proposed change only takes care of #1, and I don't see an obvious way to make it take care of both. I can do (while (erc-forward-word) ...), but then to get the word, I'd need to backtrack to the previous word marker, and it's not obvious to me that this would be an improvement over the existing change in the patch. The attached patch thus has no changes to this hunk. Let me know if you think of a nicer way to do this. dima --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ERC-no-longer-gets-confused-by-subword-mode.patch >From 28d49bfe6581a108b68c9b85dd57c77ecc94125c 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 | 8 +++++++- lisp/erc/erc-button.el | 30 ++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index ec45dcf..c315c47 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -474,13 +474,19 @@ 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)) + ;; 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) (erc-forward-word)) (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..653488c 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.4 --=-=-=--