summaryrefslogtreecommitdiff
path: root/lisp/progmodes/subword.el
diff options
context:
space:
mode:
authorDima Kogan <dima@secretsauce.net>2013-10-14 15:20:29 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-10-14 15:20:29 -0400
commitc2de5588b4c8799f9b5a545bbace588f2454640e (patch)
tree5d2702d8c317c5f8a722b8f4b697ec1a88ad72f0 /lisp/progmodes/subword.el
parent279066b2b3a56e94c4a5dc994e0349db03a52c09 (diff)
downloademacs-c2de5588b4c8799f9b5a545bbace588f2454640e.tar.gz
* lisp/progmodes/subword.el (subword-capitalize): Be careful when
the search for [[:alpha:]] fails. Fixes: debbugs:15580
Diffstat (limited to 'lisp/progmodes/subword.el')
-rw-r--r--lisp/progmodes/subword.el37
1 files changed, 19 insertions, 18 deletions
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el
index 8cf4feb62cb..1232588ca32 100644
--- a/lisp/progmodes/subword.el
+++ b/lisp/progmodes/subword.el
@@ -257,24 +257,25 @@ 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")
- (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
+ (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)))))