This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-08
Channels
- # announcements (43)
- # architecture (4)
- # beginners (115)
- # calva (6)
- # cider (4)
- # circleci (4)
- # clara (3)
- # clj-kondo (6)
- # cljs-dev (10)
- # cljsrn (1)
- # clojars (1)
- # clojure (108)
- # clojure-boston (1)
- # clojure-dev (4)
- # clojure-europe (5)
- # clojure-italy (6)
- # clojure-nl (13)
- # clojure-uk (17)
- # clojurescript (47)
- # core-async (2)
- # cursive (13)
- # data-science (1)
- # datavis (15)
- # datomic (12)
- # graphql (5)
- # juxt (10)
- # kaocha (20)
- # lumo (1)
- # off-topic (27)
- # pedestal (4)
- # reitit (2)
- # shadow-cljs (115)
- # spacemacs (4)
- # sql (74)
- # tools-deps (79)
- # vim (15)
- # xtdb (2)
Guys, I need you help regarding a snippet. What I'd like to do is to fold all the occurences of (comment ... )
in the file. I'm not so good at elisp
so could you please help me out? I know that the z r
works on the entire file and unfolds however the opposite would be nice as well.
@abhi18av my elisp is not that great sorry. Hopefully someone else can suggest something.
Are you not able to put all your commented out code in a single (comment ,,, )
block at the end of your namespace, then you can just use z c
to fold the comment
function call. This is a fairly common 'design journal' style approach.
I use the comment reader macro myself, #_
, rather than the comment
function, as it returns no value. Its very useful as a temporary comment within the code
@jr0cket, actually as of now I'm taking the following route
(def all-defs-info-final
(map info-for-a-def all-defs-in-src))
(comment
(first all-defs-info-final)
(take 10 all-defs-info-final))
This lets me keep the experimental code along with the main code itself, though it does make the file really dense. And yes #_
, is something I've also become very fond of 🙂@jr0cket, so I actually found a solution to his 🙂
(defun qyh/clojure-close-comments (arg)
"Close all top level (comment) forms. With universal arg, open all."
(interactive "P")
(save-excursion
(goto-char (point-min))
(while (search-forward-regexp "^(comment\\>" nil 'noerror)
(call-interactively
(if arg 'evil-open-fold
'evil-close-fold)))))
(evil-define-key 'normal clojure-mode-map
"zC" 'qyh/clojure-close-comments
"zO" (lambda () (interactive) (qyh/clojure-close-comments 'open)))
This was graciously shared with me on the spacemacs issues discussion. Hope it helps people here as well.@jr0cket, so I actually found a solution to his 🙂
(defun qyh/clojure-close-comments (arg)
"Close all top level (comment) forms. With universal arg, open all."
(interactive "P")
(save-excursion
(goto-char (point-min))
(while (search-forward-regexp "^(comment\\>" nil 'noerror)
(call-interactively
(if arg 'evil-open-fold
'evil-close-fold)))))
(evil-define-key 'normal clojure-mode-map
"zC" 'qyh/clojure-close-comments
"zO" (lambda () (interactive) (qyh/clojure-close-comments 'open)))
This was graciously shared with me on the spacemacs issues discussion. Hope it helps people here as well.