From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 10 03:01:52 2013 Received: (at submit) by debbugs.gnu.org; 10 Oct 2013 07:01:52 +0000 Received: from localhost ([127.0.0.1]:39523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUAFp-0003I2-HB for submit@debbugs.gnu.org; Thu, 10 Oct 2013 03:01:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38813) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VUAFl-0003Hs-8c for submit@debbugs.gnu.org; Thu, 10 Oct 2013 03:01:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUAFe-00055f-E1 for submit@debbugs.gnu.org; Thu, 10 Oct 2013 03:01:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUAFe-00055a-B0 for submit@debbugs.gnu.org; Thu, 10 Oct 2013 03:01:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUAFY-0003tC-9m for bug-gnu-emacs@gnu.org; Thu, 10 Oct 2013 03:01:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUAFS-00051m-Kg for bug-gnu-emacs@gnu.org; Thu, 10 Oct 2013 03:01:32 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:44312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUAFS-00051P-DV for bug-gnu-emacs@gnu.org; Thu, 10 Oct 2013 03:01:26 -0400 Received: from compute6.internal (compute6.nyi.mail.srv.osa [10.202.2.46]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 3F42321090 for ; Thu, 10 Oct 2013 03:01:24 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Thu, 10 Oct 2013 03:01:24 -0400 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=pD/1Ar/Cyf4c+7eJI8LY+8h0bD0=; b=HFLximDjuiyabidyM9irf NgxtnT2SDaL5WhC3jEx9eQ9idpuXNCiwpDDa4+XVdmpti0d4fOoN7UW+ly4YKG8n 1A20vSZMT6VkJkT+wbBnoFcFfak+lQgff1r42+wN55OAMU4hQQ06E96hbrvQhamn ZWXCMuFsr5znH/LXjYP5EU= 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=pD/1Ar/Cyf4c+7eJI8LY+8 h0bD0=; b=hAvOFZ1maesORmKMeWcoQBCIdDUqYDMppCUVyRSMwBa1eXJTKDDWMC q0Li2q/4mopKnDb6h3nqJ0gFOfeYgpeAjsizatCMkuKPPfEwFMagsxPz9fotbzit oM7DYfI2cpKa79U2z8D8wOThp7x42n4l81yO0zl6KiUs36jGZb07Y= X-Sasl-enc: aawMODI7ziUo4YyYqBb/TV7p/OZ5piFZsZqtkjTN5OrC 1381388483 Received: from shorty.local (unknown [76.169.247.77]) by mail.messagingengine.com (Postfix) with ESMTPA id EE31DC00E84 for ; Thu, 10 Oct 2013 03:01:23 -0400 (EDT) Received: from dima by shorty.local with local (Exim 4.80) (envelope-from ) id 1VUAFO-00037y-A3 for bug-gnu-emacs@gnu.org; Thu, 10 Oct 2013 00:01:22 -0700 From: Dima Kogan To: bug-gnu-emacs@gnu.org Subject: [PATCH] 24.3.50; subword-capitalize at the end of a buffer jumps to the beginning Date: Thu, 10 Oct 2013 00:01:22 -0700 Message-ID: <87y561obi5.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Content-Type: text/plain Hi. I'm observing subword-capitalize get confused when called near the end of a buffer. Instead of doing nothing like capitalize-word does, subword-capitalize jumps to around the beginning of the buffer and capitalizes something there. The cause is simple. subword-capitalize does (re-search-forward "[[:alpha:]]" ....) and uses the results of this search even if it failed. The attached patch explicitly checks for search failure and exits the function in that case. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-subword-capitalize-now-fails-gracefully-at-end-of-bu.patch >From 3329a22e633ce345d727ebceb81d3183bd74372f Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Wed, 9 Oct 2013 23:57:25 -0700 Subject: [PATCH] subword-capitalize now fails gracefully at end-of-buffer --- lisp/progmodes/subword.el | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index 8cf4feb..1866ad9 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el @@ -260,21 +260,25 @@ Optional argument ARG is the same as for `capitalize-word'." (let ((count (abs arg)) (start (point)) (advance (if (< arg 0) nil t))) - (dotimes (i count) - (if advance - (progn (re-search-forward - (concat "[[:alpha:]]") - nil t) - (goto-char (match-beginning 0))) - (subword-backward)) - (let* ((p (point)) - (pp (1+ p)) - (np (subword-forward))) - (upcase-region p pp) - (downcase-region pp np) - (goto-char (if advance np p)))) - (unless advance - (goto-char start)))) + + (catch 'search-failed + (dotimes (i count) + (if advance + (progn + (when (not (re-search-forward + (concat "[[:alpha:]]") + nil t)) + (throw 'search-failed "search failed")) + (goto-char (match-beginning 0))) + (subword-backward)) + (let* ((p (point)) + (pp (1+ p)) + (np (subword-forward))) + (upcase-region p pp) + (downcase-region pp np) + (goto-char (if advance np p)))) + (unless advance + (goto-char start))))) -- 1.8.3.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 15 08:34:23 2013 Received: (at 15580-done) by debbugs.gnu.org; 15 Oct 2013 12:34:23 +0000 Received: from localhost ([127.0.0.1]:50597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VW3pP-0004KW-9c for submit@debbugs.gnu.org; Tue, 15 Oct 2013 08:34:23 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:36960) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VW3pI-0004Jv-8H for 15580-done@debbugs.gnu.org; Tue, 15 Oct 2013 08:34:21 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id r9FCYFUk017977; Tue, 15 Oct 2013 08:34:15 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 0D28266162; Mon, 14 Oct 2013 15:25:17 -0400 (EDT) From: Stefan Monnier To: Dima Kogan Subject: Re: bug#15580: [PATCH] 24.3.50; subword-capitalize at the end of a buffer jumps to the beginning Message-ID: References: <87y561obi5.fsf@secretsauce.net> Date: Mon, 14 Oct 2013 15:25:17 -0400 In-Reply-To: <87y561obi5.fsf@secretsauce.net> (Dima Kogan's message of "Thu, 10 Oct 2013 00:01:22 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.5 X-NAI-Spam-Rules: 2 Rules triggered DATE_IN_PAST_12_24=0.5, RV4732=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4732> : inlines <145> : streams <1056272> : uri <1565975> X-NAI-Spam-Level: X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 15580-done Cc: 15580-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) > and uses the results of this search even if it failed. The attached > patch explicitly checks for search failure and exits the function in > that case. Thanks. I slightly simplified your patch (since re-search-forward already signal search-failed if the 3rd arg is nil) and installed it. Stefan PS: This is at least the second "tiny" patch you contributed, so you're on course to hit the limit of what we can accept without copyright paperwork. If you'd like to sign this paperwork already to avoid future delays, I can send you the needed forms. From unknown Sat Aug 16 21:12:26 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: Did not alter fixed versions and reopened. Date: Tue, 15 Oct 2013 19:00:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # Did not alter fixed versions and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 15 15:04:04 2013 Received: (at 15580) by debbugs.gnu.org; 15 Oct 2013 19:04:04 +0000 Received: from localhost ([127.0.0.1]:52101 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VW9uW-00063H-2P for submit@debbugs.gnu.org; Tue, 15 Oct 2013 15:04:04 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:39297) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VW9uU-00062x-6M for 15580@debbugs.gnu.org; Tue, 15 Oct 2013 15:04:02 -0400 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id D746B237C8 for <15580@debbugs.gnu.org>; Tue, 15 Oct 2013 15:03:59 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Tue, 15 Oct 2013 15:04:00 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:references:in-reply-to:date:message-id :mime-version:content-type; s=mesmtp; bh=xeJ0VEg3lsp04TXWHlVAFFs 736w=; b=dNyJRRyRYlHxC73qV9mmuXtYT7cG/pagHb6s9/qf2Egt9HfAmCpKh86 gmx3pRNhdpyZbr32m1aPIGyzrQ+sNzMw8wnqKuuvsk3lF5m3N+cSpj5NRHVpCJCh 4UFi6bpp/4jHd5m+Z6QgWgy4Y0gaHITdHjIgL+ZXJLyWxP41NM9k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:references:in-reply-to :date:message-id:mime-version:content-type; s=smtpout; bh=xeJ0VE g3lsp04TXWHlVAFFs736w=; b=OFsDeD1njuXyjzddXUqfQTbxp7Hd+01R833ML7 CRXhW0N3GwtSpsHQ6utwA2FoiyZpn8coQLDfpNdaRqAqizwpX3KTUM4Xor16IV8P GGluOI+SQ6nOabo/F3Gi7VsUiFu5raDd0goUrgUepEeJ9v0qW1l2VSvSSRxMkcTq FzG18= X-Sasl-enc: 2td25EIwPZ0KkeAUSMWbtRyM5vXuTNu28jRzSJJIz/vs 1381863839 Received: from shorty.local (unknown [76.169.247.77]) by mail.messagingengine.com (Postfix) with ESMTPA id A09DFC00E81 for <15580@debbugs.gnu.org>; Tue, 15 Oct 2013 15:03:59 -0400 (EDT) Received: from dima by shorty.local with local (Exim 4.80) (envelope-from ) id 1VW9uQ-0006QY-IG for 15580@debbugs.gnu.org; Tue, 15 Oct 2013 12:03:58 -0700 From: Dima Kogan To: 15580@debbugs.gnu.org Subject: Re: bug#15580: [PATCH] 24.3.50; subword-capitalize at the end of a buffer jumps to the beginning References: <87y561obi5.fsf@secretsauce.net> User-agent: mu4e 0.9.9.5; emacs 24.3.50.1 In-reply-to: Date: Tue, 15 Oct 2013 12:03:58 -0700 Message-ID: <87y55u2w69.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 15580 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain Stefan Monnier writes: > Thanks. I slightly simplified your patch (since re-search-forward > already signal search-failed if the 3rd arg is nil) and installed it. Hi. Thanks for looking at this. I tried the fix you made in the repo, and it has two issues: 1. search-failed is raised with (signal) not (throw), so it needs to be caught differently 2. You changed (re-search-forward) to (search-forward), however we still are searching for a regex, so it must remain re-search-forward. I'm attaching a patch to fix these two issues dima --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Correction-to-the-recent-subword-capitalize-fix.patch >From b3d45ce893aa51f9fd7175a70003dca5571be9d2 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Tue, 15 Oct 2013 11:54:56 -0700 Subject: [PATCH] Correction to the recent subword-capitalize fix This applies to emacs bug 15580 --- lisp/progmodes/subword.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index 1232588..0d754d5 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el @@ -257,7 +257,7 @@ Optional argument ARG is the same as for `upcase-word'." See the command `subword-mode' for a description of subwords. Optional argument ARG is the same as for `capitalize-word'." (interactive "p") - (catch 'search-failed + (condition-case nil (let ((count (abs arg)) (start (point)) (advance (>= arg 0))) @@ -265,7 +265,7 @@ Optional argument ARG is the same as for `capitalize-word'." (dotimes (i count) (if advance (progn - (search-forward "[[:alpha:]]") + (re-search-forward "[[:alpha:]]") (goto-char (match-beginning 0))) (subword-backward)) (let* ((p (point)) @@ -275,7 +275,8 @@ Optional argument ARG is the same as for `capitalize-word'." (downcase-region pp np) (goto-char (if advance np p)))) (unless advance - (goto-char start))))) + (goto-char start))) + (search-failed nil))) -- 1.8.3.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 15 23:03:16 2013 Received: (at 15580-done) by debbugs.gnu.org; 16 Oct 2013 03:03:16 +0000 Received: from localhost ([127.0.0.1]:53341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWHOG-0002Ww-BJ for submit@debbugs.gnu.org; Tue, 15 Oct 2013 23:03:16 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:53895) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWHOE-0002Wo-Mw for 15580-done@debbugs.gnu.org; Tue, 15 Oct 2013 23:03:14 -0400 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id r9G33DBu020617; Tue, 15 Oct 2013 23:03:13 -0400 Received: by pastel.home (Postfix, from userid 20848) id D329F62EBC; Tue, 15 Oct 2013 23:03:11 -0400 (EDT) From: Stefan Monnier To: Dima Kogan Subject: Re: bug#15580: [PATCH] 24.3.50; subword-capitalize at the end of a buffer jumps to the beginning Message-ID: References: <87y561obi5.fsf@secretsauce.net> <87y55u2w69.fsf@secretsauce.net> Date: Tue, 15 Oct 2013 23:03:11 -0400 In-Reply-To: <87y55u2w69.fsf@secretsauce.net> (Dima Kogan's message of "Tue, 15 Oct 2013 12:03:58 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4732=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4732> : inlines <150> : streams <1056602> : uri <1566601> X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 15580-done Cc: 15580-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) > Thanks for looking at this. I tried the fix you made in the repo, and it > has two issues: Duh! > I'm attaching a patch to fix these two issues Thank you very much. Installed as-is for fear of messing up again, Stefan From unknown Sat Aug 16 21:12:26 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 13 Nov 2013 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator