branch: elpa/clojure-mode
commit 4bccd24fc680238f8d29fee1629401f620d50ca6
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Use skip-chars-backward and bobp in toggle-keyword-string
Replace manual while/backward-char loop with skip-chars-backward and
hardcoded position 1 with bobp, fixing potential misbehavior in
narrowed buffers.
---
clojure-mode.el | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/clojure-mode.el b/clojure-mode.el
index 903cf92ad1..27347286b9 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -2034,12 +2034,12 @@ nil."
"Convert the string or keyword at point to keyword or string."
(interactive)
(let ((original-point (point)))
- (while (and (> (point) 1)
- (not (eq ?\" (char-after)))
- (not (eq ?: (char-after))))
- (backward-char))
+ (unless (memq (char-after) '(?\" ?:))
+ (skip-chars-backward "^:\"")
+ (unless (bobp)
+ (backward-char)))
(cond
- ((= 1 (point))
+ ((bobp)
(error "Beginning of file reached, this was probably a mistake"))
((eq ?\" (char-after))
(insert ":" (substring (clojure-delete-and-extract-sexp) 1 -1)))