aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorDima Kogan2013-10-14 15:20:29 -0400
committerStefan Monnier2013-10-14 15:20:29 -0400
commitc2de5588b4c8799f9b5a545bbace588f2454640e (patch)
tree5d2702d8c317c5f8a722b8f4b697ec1a88ad72f0 /lisp/progmodes
parent279066b2b3a56e94c4a5dc994e0349db03a52c09 (diff)
downloademacs-c2de5588b4c8799f9b5a545bbace588f2454640e.tar.gz
emacs-c2de5588b4c8799f9b5a545bbace588f2454640e.zip
* lisp/progmodes/subword.el (subword-capitalize): Be careful when
the search for [[:alpha:]] fails. Fixes: debbugs:15580
Diffstat (limited to 'lisp/progmodes')
-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'."
257See the command `subword-mode' for a description of subwords. 257See the command `subword-mode' for a description of subwords.
258Optional argument ARG is the same as for `capitalize-word'." 258Optional argument ARG is the same as for `capitalize-word'."
259 (interactive "p") 259 (interactive "p")
260 (let ((count (abs arg)) 260 (catch 'search-failed
261 (start (point)) 261 (let ((count (abs arg))
262 (advance (if (< arg 0) nil t))) 262 (start (point))
263 (dotimes (i count) 263 (advance (>= arg 0)))
264 (if advance 264
265 (progn (re-search-forward 265 (dotimes (i count)
266 (concat "[[:alpha:]]") 266 (if advance
267 nil t) 267 (progn
268 (goto-char (match-beginning 0))) 268 (search-forward "[[:alpha:]]")
269 (subword-backward)) 269 (goto-char (match-beginning 0)))
270 (let* ((p (point)) 270 (subword-backward))
271 (pp (1+ p)) 271 (let* ((p (point))
272 (np (subword-forward))) 272 (pp (1+ p))
273 (upcase-region p pp) 273 (np (subword-forward)))
274 (downcase-region pp np) 274 (upcase-region p pp)
275 (goto-char (if advance np p)))) 275 (downcase-region pp np)
276 (unless advance 276 (goto-char (if advance np p))))
277 (goto-char start)))) 277 (unless advance
278 (goto-char start)))))
278 279
279 280
280 281