This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-10
Channels
- # aws (45)
- # bangalore-clj (16)
- # beginners (109)
- # boot (137)
- # cider (7)
- # cljs-dev (54)
- # cljsrn (22)
- # clojure (77)
- # clojure-conj (1)
- # clojure-greece (2)
- # clojure-nl (5)
- # clojure-russia (36)
- # clojure-spec (15)
- # clojure-uk (54)
- # clojurescript (118)
- # cursive (7)
- # datomic (25)
- # emacs (33)
- # hoplon (276)
- # klipse (38)
- # lein-figwheel (1)
- # leiningen (9)
- # melbourne (1)
- # off-topic (18)
- # om (98)
- # onyx (6)
- # pedestal (1)
- # perun (24)
- # re-frame (46)
- # reagent (6)
- # ring-swagger (3)
- # spacemacs (67)
- # specter (15)
- # untangled (33)
- # vim (6)
There may be a more standard way, but I highlight it in visual mode and then do s ]
or s }
or...you can use the left-bracket equivalents, but that'll add a space.
I know I can get o
to get a symbol; I’m just not used to thinking of the exact thing I’m selecting
Agreed -- but since they're less important in non-clj lisps, maybe the authors didn't think about them? Purely guessing there.
Oh, one handy tip -- there's a way to get SM to recognize that, eg foo-bar-baz
is a single word in lisp-land. I can dig that up if you'd like to add it.
;; Use clojure-based definition of words
(with-eval-after-load 'clojure-mode
(dolist (c (string-to-list ":_-?!#*"))
(modify-syntax-entry c "w" clojure-mode-syntax-table )))
That's a variation on the lisp one because of minor differences -- if you use other lisps you may want that one too (but I don't have it)
I know this doesn’t directly solve your problem, but for the exact purpose of wrapping stuff easier is why I installed the evil-cleverparans layer and haven’t looked back. Now to wrap I just use M-(
to wrap a single sexp or 2 M-(
to wrap 2 sexps etc. This also works with M-[
and M-{
I also like the other keybindings too.
Ooooh, didn't know about that one -- @malch no problems/conflicts with SM's built-in layer? (smartparens IIRC)
evil-cleverparens supports most of the paredit functionality (same about smartparens, I guess)
@eggsyntax I haven’t disabled any smartparens settings and I haven’t had any issues.
I use this for wrapping:
;; make wrapping friendly to Clojure/Pixie/Hy
(with-eval-after-load "evil-lisp-state"
;; undef SPC k w so we can generalize it
(evil-leader/set-key "kw" nil)
;; wrap using SPC k w ([{
(evil-leader/set-key "kw("
(lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "(")))
(evil-leader/set-key "kw["
(lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "[")))
(evil-leader/set-key "kw{"
(lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "{")))
(evil-leader/set-key "kw\""
(lambda (&optional arg) (interactive "P") (sp-wrap-with-pair "\""))))
I also define SPC m e o
as a generic eval operator and SPC m s o
as a generic send operator and then hook into the mode-specific eval-region
(cider's is cider-eval-region
). This lets me eval motions. Then I redefined all of the SPC m s
and SPC m e
eval and send stuff in terms of the generic eval and send so that they are consistent across emacs lisp, python, and clojure
it's a bit verbose, but for one-off evals it's much easier to SPC m e o %
on an opening or closing paren, while keeping the ability to eval a buffer, a line, etc and not think about shortcuts, just the normal evil building blocks
I think it's a bit crazy that every spacemacs language layer has a slightly different set of eval/send functionality and at different keybindings
then you get to say stuff like
;; Enable highlighting of the area to be eval'd
(define-eval-sexp-fu-flash-command emidln//generic-eval-region
(eval-sexp-fu-flash (cons beg end)))
re: evil-cleverparens
which is so cool it makes my jaw drop (because of course the way to handle sexps for vimmers is to make them ordinary text objects), there's a pre-existing spacemacs layer for it:
https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Bvim/evil-cleverparens
(For anyone to whom that isn't immediately clear, I suggest https://yanpritzker.com/learn-to-speak-vim-verbs-nouns-and-modifiers-d7bfed1f6b2d )
@eggsyntax is your dot spacemacs posted anywhere?
@jasonjckn Not at the moment -- it's a mess for sure, & includes some stuff that I haven't been able to get to work. I'm still a semi-noob at emacs & emacs lisp. But I'd be happy to share it with you if you'd like.
(with-eval-after-load 'clojure-mode
(dolist (c (string-to-list ":_-?!#*"))
(modify-syntax-entry c "w" clojure-mode-syntax-table )))
seems to not work quite right, when I hold "w" in normal mode the cursor sometimes gets stuck at a closing parens and makes no more forward movements.Looks like I stole it from here: https://timothypratley.blogspot.com/2014/08/clojure-friendly-word-definitions-in.html (note the 1st comment)
@jasonjckn here's my .spacemacs -- for anyone who looks at it, please be aware that a) it's a mess, b) there's broken stuff in there, and c) I'm still an emacs & emacs lisp noob. But it's at least commented.
thanks @eggsyntax
@eggsyntax many great hacks in there thatkns
@eggsyntax i'm also dvorakian 😉
@jasonjckn if it’s obvious to you why any of the broken things are broken, let me know 🙂