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#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer Date: Tue, 19 Feb 2013 02:21:49 -0800 Message-ID: <8738wspps2.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1361269398 23220 80.91.229.3 (19 Feb 2013 10:23:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 Feb 2013 10:23:18 +0000 (UTC) To: 13758@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 19 11:23:39 2013 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 1U7kML-0007P4-MR for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Feb 2013 11:23:37 +0100 Original-Received: from localhost ([::1]:34956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7kM1-000114-ED for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Feb 2013 05:23:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7kLq-0000zh-2z for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 05:23:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7kLi-0003q9-EU for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 05:23:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7kLi-0003q5-Af for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 05:22:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1U7kMk-0004j7-Ap for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 05:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Feb 2013 10:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13758 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136126939718116 (code B ref -1); Tue, 19 Feb 2013 10:24:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Feb 2013 10:23:17 +0000 Original-Received: from localhost ([127.0.0.1]:36044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U7kM1-0004i9-78 for submit@debbugs.gnu.org; Tue, 19 Feb 2013 05:23:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:53479) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U7kLy-0004i2-KJ for submit@debbugs.gnu.org; Tue, 19 Feb 2013 05:23:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7kKm-0003hO-OS for submit@debbugs.gnu.org; Tue, 19 Feb 2013 05:22:10 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:44507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7kKm-0003hJ-Kv for submit@debbugs.gnu.org; Tue, 19 Feb 2013 05:22:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7kKj-0000o9-DC for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 05:22:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7kKg-0003fo-5S for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 05:21:57 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7kKg-0003fU-1H for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 05:21:54 -0500 Original-Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id F27DE20904 for ; Tue, 19 Feb 2013 05:21:51 -0500 (EST) Original-Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute3.internal (MEProxy); Tue, 19 Feb 2013 05:21:51 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:date:message-id:mime-version:content-type; s= mesmtp; bh=grHZzM89coKYMLYNZ22sQN7vfJQ=; b=PvlQYZfVMUH5uxNxlmTIy bMKiNhOGgRR2o28eT8Vx6/7Sn8FJaLNQrsk50wNYztkVCmh9dahFcuRIB5HeG2hi j1QfHL/RSGnApLMQb2lB2mFpIl31cQlpkkytX/rL03nJFeU+Bpx53Z8KKp8s+LzP aaS7JkEwXo42KBBtd24wSc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :mime-version:content-type; s=smtpout; bh=grHZzM89coKYMLYNZ22sQN 7vfJQ=; b=d9Gs6ZH4dCc6aiM2JknM8XvPtm9iahwWklUUbkZxcX6gpMvCRvUbVF 3htijMXsCzZrPDphbD2YlSKKPivFuxs57Id6GnMGJy6jkWSoVaea70rOaoC/zwiF tR5cN2kluApud9hfHkLBVkh4ZC8FYZkt4RXLtDG/tePaLJV7wUsnQ= X-Sasl-enc: r5IZt/nLpDJgQCCSLqKco8b1NxYnuL2xgUGNsF3+zm6k 1361269311 Original-Received: from shorty.local (unknown [76.169.247.77]) by mail.messagingengine.com (Postfix) with ESMTPA id A3EE1482775 for ; Tue, 19 Feb 2013 05:21:51 -0500 (EST) Original-Received: from dima by shorty.local with local (Exim 4.80) (envelope-from ) id 1U7kKc-0003GX-4h for bug-gnu-emacs@gnu.org; Tue, 19 Feb 2013 02:21:50 -0800 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.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:71514 Archived-At: --=-=-= Content-Type: text/plain I'm attaching a patch to fix an edge case of (subword-forward). To reproduce the issue: 1. create a buffer that has an all-caps string such as 'ASDF' at the end of the buffer. There must not be a newline at the end; the 'F' should be the last character 2. Go to the start of the buffer, and do (subword-forward). Observe that the point ends up at the 'F', but it should end up one character ahead of there. To see more clearly that this is wrong, do (subword-downcase 1) instead of (subword-forward). This should make all the characters lowercase, but it misses the last one. This is happening because (subword-forward) is trying to match the character after the start of the new subword, but at the end of the buffer, this character doesn't exist. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-subword-forward-no-longer-gets-confused-by-the-end-o.patch Content-Description: patch >From c248e56c86d96dac8990880b44b983fd4883b1d9 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Tue, 19 Feb 2013 02:14:26 -0800 Subject: [PATCH] (subword-forward) no longer gets confused by the end of the buffer This fixes an edge case of (subword-forward). If the point is at the start of an all-caps word at the end of the buffer, (subword-forward) would end up at the last character of the word, NOT past the word, as it should. This was happening because (subword-forward) was trying to match the character after the start of the new subword, but at the end of the buffer, this character didn't exist --- lisp/progmodes/subword.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index 80e632c..a86a29b 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el @@ -87,7 +87,7 @@ "Function to call for backward subword movement.") (defvar subword-forward-regexp - "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" + "\\W*\\(\\([[:upper:]]*\\(\\W?\\)\\)[[:lower:][:digit:]]*\\)" "Regexp used by `subword-forward-internal'.") (defvar subword-backward-regexp @@ -268,7 +268,16 @@ Optional argument ARG is the same as for `capitalize-word'." (goto-char (cond ((< 1 (- (match-end 2) (match-beginning 2))) - (1- (match-end 2))) + ;; if we saw start of subword (capital letters or + ;; whitespace)... + (if (and (= (match-end 2) (point-max)) + (= (match-end 2) (match-beginning 3))) + ;; ... and we have all-caps at the end of the buffer, the + ;; next subword starts at end of buffer... + (match-end 2) + ;; ... if we're not at the end, we have the position of the + ;; 2nd character in the subword, so go back one + (1- (match-end 2)))) (t (match-end 0)))) (forward-word 1))) -- 1.7.10.4 --=-=-=--