Skip to content

Commit 4bccd24

Browse files
committed
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.
1 parent 75fa633 commit 4bccd24

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

clojure-mode.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,12 +2034,12 @@ nil."
20342034
"Convert the string or keyword at point to keyword or string."
20352035
(interactive)
20362036
(let ((original-point (point)))
2037-
(while (and (> (point) 1)
2038-
(not (eq ?\" (char-after)))
2039-
(not (eq ?: (char-after))))
2040-
(backward-char))
2037+
(unless (memq (char-after) '(?\" ?:))
2038+
(skip-chars-backward "^:\"")
2039+
(unless (bobp)
2040+
(backward-char)))
20412041
(cond
2042-
((= 1 (point))
2042+
((bobp)
20432043
(error "Beginning of file reached, this was probably a mistake"))
20442044
((eq ?\" (char-after))
20452045
(insert ":" (substring (clojure-delete-and-extract-sexp) 1 -1)))

0 commit comments

Comments
 (0)