Lispy: Fix lispy-quotes with #p"...".
parent
f745ec9d90
commit
1c62e98ac9
|
@ -8,4 +8,42 @@
|
||||||
(push '(sly-mrepl-mode . ("[[:space:]]" "[#`',.@]+" "#[0-9]*" "#[.,Ss+-]" "#[0-9]+[=Aa]"))
|
(push '(sly-mrepl-mode . ("[[:space:]]" "[#`',.@]+" "#[0-9]*" "#[.,Ss+-]" "#[0-9]+[=Aa]"))
|
||||||
lispy-parens-preceding-syntax-alist)
|
lispy-parens-preceding-syntax-alist)
|
||||||
|
|
||||||
|
;; REVIEW: https://github.com/abo-abo/lispy/issues/597
|
||||||
|
;; #:foo: Space should be inserted before when pressing `"`.
|
||||||
|
;; #foo: Space should NOT be inserted before when pressing `"`.
|
||||||
|
(defun lispy-quotes (arg)
|
||||||
|
"Insert a pair of quotes around the point.
|
||||||
|
|
||||||
|
When the region is active, wrap it in quotes instead.
|
||||||
|
When inside string, if ARG is nil quotes are quoted,
|
||||||
|
otherwise the whole string is unquoted."
|
||||||
|
(interactive "P")
|
||||||
|
(let (bnd)
|
||||||
|
(cond ((region-active-p)
|
||||||
|
(if arg
|
||||||
|
(lispy-unstringify)
|
||||||
|
(lispy-stringify)))
|
||||||
|
((and (setq bnd (lispy--bounds-string))
|
||||||
|
(not (= (point) (car bnd))))
|
||||||
|
(if arg
|
||||||
|
(lispy-unstringify)
|
||||||
|
(if (and lispy-close-quotes-at-end-p (looking-at "\""))
|
||||||
|
(forward-char 1)
|
||||||
|
(progn (insert "\\\"\\\""))
|
||||||
|
(backward-char 2))))
|
||||||
|
|
||||||
|
(arg
|
||||||
|
(lispy-stringify))
|
||||||
|
|
||||||
|
((lispy-after-string-p "?\\")
|
||||||
|
(self-insert-command 1))
|
||||||
|
|
||||||
|
(t
|
||||||
|
(lispy--space-unless "^\\|\\s-\\|\\s(\\|[#][^[:space:]():]*")
|
||||||
|
(insert "\"\"")
|
||||||
|
(unless (looking-at "\n\\|)\\|}\\|\\]\\|$")
|
||||||
|
(just-one-space)
|
||||||
|
(backward-char 1))
|
||||||
|
(backward-char)))))
|
||||||
|
|
||||||
(provide 'patch-lispy)
|
(provide 'patch-lispy)
|
||||||
|
|
Loading…
Reference in New Issue