This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-05
Channels
- # announcements (1)
- # babashka (7)
- # beginners (60)
- # biff (7)
- # cider (2)
- # clj-kondo (1)
- # clojure (15)
- # clojure-france (1)
- # clojure-norway (1)
- # clojurescript (7)
- # datascript (7)
- # emacs (4)
- # etaoin (1)
- # honeysql (7)
- # interceptors (8)
- # introduce-yourself (3)
- # kaocha (1)
- # off-topic (16)
- # pathom (2)
- # reagent (15)
- # reitit (11)
- # releases (1)
- # slack-help (3)
- # vim (36)
At the bottom of many namespaces I tend to have a "rich comment", one of the first forms in this comment is a do
form pulling state out of the integrant repl system. I usually mark the end of this sexp with a ;; rcf
comment. I'd like to bind a key in emacs/cider that jumps to that form, evals it, then puts the point back where i was editing.
I've no idea how to go about this in elisp. Any pointers or prior work here?
Something like this?
(defun eval-rcf ()
(interactive) ;; you have to do this to be able to bind it to a key or M-x it
(save-excursion ;; this is what returns the point to where you started
(goto-char (point-max)) ;; go to end of buffer
(if (re-search-backward " *;; rcf" nil t) ;; search backward, don't throw an error
(cider-eval-last-sexp) ;; the cider fn which evals the last form
(message "No rcf found!")))) ;; if the search fails, show a message in the echo area
(define-key cider-mode-map (kbd "<f8>") #'eval-rcf)
you may have to adjust the regexp to find the exact point where you want to execute the eval, and of course the keybinding to your liking❤️ 1