smartparens
smartparens copied to clipboard
Clojure tagged elements should be treated as a single sexp
Expected behavior
Tagged elements in Clojure/EDN, such as #uuid "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
, should be treated as a single sexp.
This is what clojure-forward-logical-sexp
does in clojure-mode
. clojure-forward-logical-sexp
also takes into account hints (e.g. ^:private foo
is treated as a single sexp).
Actual behavior
#uuid "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
is treated as two sexps:
-
#uuid
-
"f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
Steps to reproduce the problem
- In
clojure-mode
, callsp-forward-sexp
with point at:|#uuid "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
Backtraces if necessary (M-x toggle-debug-on-error
)
N/A
Environment & version information
-
smartparens
version:smartparens-20170129.956
- Emacs version (
M-x emacs-version
):Emacs 25.1.50.1
- OS:
Darwin C02RW05YFVH6 15.6.0
@Fuco1 I'll try to implement this if you'll give me some pointers.
My current idea is to simply use set sp-{forward, backward}-sexp
to use clojure-{forward, backward}-logical-sexp
in smartparens-clojure.el
, though I'm not sure how best to do that (advising seems hackish).
I think it should be possible to do this with the prefix functionality in SP. If this #uuid
tag can only be applied to strings, you can add a :prefix
property to the "
pair.
From the docs:
PREFIX is a regular expression matching an optional prefix for
this pair in the specified major modes. If not specified, the
characters of expression prefix syntax class are automatically
considered instead. This can be used to attach custom prefixes
to pairs, such as prefix \"\\function\" in \\function{arg} in
`LaTeX-mode'.
So the regexp would be something like #uuid
(with space at the end). Or if there are more variants you can construct the regexp to match them all.
If any expression can have these tags, you can use the variable sp-sexp-prefix
to configure it (that is a setting for everything in given major mode). Check its docstring.