From a24b996116895c3bc8c78842ba014711fad4839c Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Tue, 15 Oct 2013 23:02:40 -0400 Subject: [PATCH] * lisp/progmodes/subword.el (subword-capitalize): Fix Stefan's mess. Fixes: debbugs:15580 --- lisp/ChangeLog | 5 +++++ lisp/progmodes/subword.el | 39 ++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f51947ffac..134219a16d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-10-16 Dima Kogan (tiny change) + + * progmodes/subword.el (subword-capitalize): Fix Stefan's mess + (bug#15580). + 2013-10-16 Glenn Morris * ansi-color.el (ansi-color-drop-regexp): diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index 1232588ca3..15535ba4f5 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el @@ -257,25 +257,26 @@ 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 - (let ((count (abs arg)) - (start (point)) - (advance (>= arg 0))) - - (dotimes (i count) - (if advance - (progn - (search-forward "[[:alpha:]]") - (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))))) + (condition-case nil + (let ((count (abs arg)) + (start (point)) + (advance (>= arg 0))) + + (dotimes (i count) + (if advance + (progn + (re-search-forward "[[:alpha:]]") + (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))) + (search-failed nil))) -- 2.20.1