diff options
author | Dima Kogan <dima@secretsauce.net> | 2013-10-14 15:20:29 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-10-14 15:20:29 -0400 |
commit | c2de5588b4c8799f9b5a545bbace588f2454640e (patch) | |
tree | 5d2702d8c317c5f8a722b8f4b697ec1a88ad72f0 /lisp/progmodes/subword.el | |
parent | 279066b2b3a56e94c4a5dc994e0349db03a52c09 (diff) | |
download | emacs-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.el | 37 |
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))))) |