From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#17558: 24.4.50; global-subword-mode breaks ERC Date: Thu, 01 Jan 2015 11:42:56 -0500 Message-ID: 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: text/plain X-Trace: ger.gmane.org 1420130657 6471 80.91.229.3 (1 Jan 2015 16:44:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Jan 2015 16:44:17 +0000 (UTC) Cc: 17558@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 01 17:44:10 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 1Y6ir3-0008Qc-Ky for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jan 2015 17:44:09 +0100 Original-Received: from localhost ([::1]:49015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6ir2-0002i5-VB for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jan 2015 11:44:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6iqz-0002hs-Kp for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 11:44:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y6iqw-00039B-De for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 11:44:05 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53465) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6iqw-000394-Ac for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 11:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y6iqv-0005nA-Vw for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 11:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Jan 2015 16:44: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.142013058622164 (code B ref 17558); Thu, 01 Jan 2015 16:44:01 +0000 Original-Received: (at 17558) by debbugs.gnu.org; 1 Jan 2015 16:43:06 +0000 Original-Received: from localhost ([127.0.0.1]:34598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y6iq1-0005lP-DS for submit@debbugs.gnu.org; Thu, 01 Jan 2015 11:43:05 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:33345) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y6ipz-0005lH-9X for 17558@debbugs.gnu.org; Thu, 01 Jan 2015 11:43:03 -0500 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id t01GgvXn032162; Thu, 1 Jan 2015 11:42:57 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id C088AAE130; Thu, 1 Jan 2015 11:42:56 -0500 (EST) In-Reply-To: <87a924mbuk.fsf@secretsauce.net> (Dima Kogan's message of "Wed, 31 Dec 2014 01:01:35 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5173=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5173> : inlines <1719> : streams <1366504> : uri <1840837> 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:97920 Archived-At: >> Thanks for the repro. This bug is probably due to my changing how >> subword-mode works: now, forward-word will stop at subword boundaries, >> and I'm guessing ERC was relying on the old behavior. I can try to take >> a look at it if nobody who knows ERC better wants to try first. Indeed, with the new implementation of subword-mode, most of the word-operating commands should be marked as "interactive use only", since their behavior is too unreliable for use in Lisp code. > - (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). > - (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)))))))) Similarly here, we should use "word" operations at all. Maybe forward-sexp can be used instead of forward-word, or else skip-syntax-forward or skip-chars-forward. The call to (bounds-of-thing-at-point 'word) should be avoided as well (we already know the end of the bounds is (point) anyway and we can probably find the other bound at the same time as we skip-chars-forward. Stefan