|
182 | 182 | :group 'bindings
|
183 | 183 | :prefix "lispy-")
|
184 | 184 |
|
185 |
| -(defvar lispy-left "[([{]" |
| 185 | +(defvar lispy-left (rx (or (any "([{") symbol-start)) |
186 | 186 | "Opening delimiter.")
|
187 | 187 |
|
188 |
| -(defvar lispy-right "[])}]" |
| 188 | +(defvar lispy-right (rx (or (any "])}") symbol-end)) |
189 | 189 | "Closing delimiter.")
|
190 | 190 |
|
191 | 191 | (defvar lispy-outline "^;;\\(?:;[^#]\\|\\*+\\)"
|
@@ -7286,6 +7286,12 @@ See https://clojure.org/guides/weird_characters#_character_literal.")
|
7286 | 7286 | (match-string subexp)))
|
7287 | 7287 | t t nil subexp)))))
|
7288 | 7288 |
|
| 7289 | +(defconst lispy--symbol-safe-chars-regexp |
| 7290 | + (rx (any alnum ?+ ?- ?* ?/ ?: ?=)) |
| 7291 | + "Regexp for \"safe\" characters. |
| 7292 | +Safe characters are those which are suitable for a symbol and |
| 7293 | +have no special reader syntax.") |
| 7294 | + |
7289 | 7295 | ;; TODO: Make the read test pass on string with semi-colon
|
7290 | 7296 | (defun lispy--read (str)
|
7291 | 7297 | "Read STR including comments and newlines."
|
@@ -7524,11 +7530,13 @@ See https://clojure.org/guides/weird_characters#_character_literal.")
|
7524 | 7530 | (unless (lispy--in-string-or-comment-p)
|
7525 | 7531 | (replace-match (format "(ly-raw racket-option %s)"
|
7526 | 7532 | (match-string 1)))))
|
7527 |
| - ;; Clojure # in a symbol |
| 7533 | + ;; Protect symbols containing unsafe characters |
7528 | 7534 | (goto-char (point-min))
|
7529 | 7535 | (while (re-search-forward "\\_<\\(?:\\sw\\|\\s_\\)+\\_>" nil t)
|
7530 | 7536 | (unless (lispy--in-string-p)
|
7531 |
| - (when (cl-position ?# (match-string 0)) |
| 7537 | + (unless (string-match |
| 7538 | + lispy--symbol-safe-chars-regexp |
| 7539 | + (match-string 0)) |
7532 | 7540 | (let* ((bnd (lispy--bounds-dwim))
|
7533 | 7541 | (str (lispy--string-dwim bnd)))
|
7534 | 7542 | (delete-region (car bnd) (cdr bnd))
|
|
0 commit comments