Fork me on GitHub
#emacs
<
2024-03-06
>
karlis12:03:58

Is it possible to extend logic of what imenu considers function definitions? I'd like to jump between re-frame subscription and event handlers (for example, re-frame.core/reg-sub :foobar ) via imenu as well.

lassemaatta14:03:56

This is just a guess, but perhaps you could try defining your own matchers in https://www.gnu.org/software/emacs/manual/html_node/elisp/Imenu.html#index-imenu_002dgeneric_002dexpression?

👀 1
lassemaatta14:03:52

no idea how that works if you also use something like lsp-mode at the same time which also populates the imenu :man-shrugging:

ag18:03:41

> I'd like to jump between re-frame subscription and event handlers

(defun add-reframe-regs-to-imenu ()
      (add-to-list
       'imenu-generic-expression
       '("re-frame" "^(*reg-\\(event-db\\|sub\\|sub-raw\\|fx\\|event-fx\\|event-ctx\\|cofx\\)[ \n]+\\([^\t \n]+\\)" 2)
       t)))

(add-hook 'clojurescript-mode #'add-reframe-regs-to-imenu)
    

nice 4
karlis18:03:58

Nice! Thanks, @U0G75ARHC

1
otfrom13:03:56

I love being able to automate a complex series of commands in emacs as a keyboard macro and then do C-u 10 f4 to just do them again and again and again (put in whatever number you want for 10)

emacs-spin 7
Ed14:03:48

I like that if you put M-0 C-x e it will repeat until it get's an error (like from isearch-forward or whatever)

1
😲 1
practicalli-johnny14:03:10

10 @ a for Evil assuming q a ,,, q was used to create the macro

Ed14:03:35

It works well in combination with narrowing if you want to restrict it to part of a buffer.

❤️ 1
practicalli-johnny14:03:05

Narrowing for the win... best feature of Emacs ❤️

Ed14:03:48

I think one of the things that gets missed when comparing editing in things like vi(m)/emacs to things like vs code is the composability of the editing and movement commands into things like macros in a convenient way. It's one of the reasons I couldn't get on with when trying eclipse / intelij / etc ...

otfrom15:03:23

does vim let you record macros? That start record, do it, stop record, try using it, do it again is pretty essential to me

Ed15:03:17

well ... in vim, you enter / exit command mode which you could consider as record a macro and then there's a key-press which is do the last thing again

Ed15:03:53

I couldn't get on with the modal editing thing, so I use vanilla emacs shortcuts (which are generally supported by things like readline - so all command line tools like mysql or pgsql, or you can use rlwrap) ... so my preference is to start recording and save it ... but sometimes I wish that I'd started recording a while ago and have to view-lossage and copy and paste it into edit-last-kbd-macro ... instead of just starting again 😉

Ed15:03:26

Good link on keyboard macros ... I hadn't spotted C-x C-k l before ... that's less copy/pasta error prone 😉

Ed15:03:28

and C-x C-k SPC sounds like a winner 😉

Ed15:03:32

every day's a school day 😉

Ellis15:03:10

Yeah vim and evil both support macros

practicalli-johnny15:03:03

@U0525KG62 yes, in Evil normal mode, q followed by another character starts recording, e.g. q a to capture all the key presses until q is presses again in normal mode. Then @ to replay a keyboard macro, so @ a will replay the macro once, 10 @ a to replay the macro 10 times. They keyboard macro supports more than the . dot repeat feature of Evil.

adham18:03:55

I love doing macros with s-expression movements sometimes, like a case statement or sometimes just to align keys and values I also love taking things out into snippets, for example here's my basic snippet to write a defn with a Malli schema

# -*- mode: snippet -*-
# name: malli defn
# key: mdefn
# --

(defn $1
  "$2"
  {:malli/schema [:=>
                 [:cat $3]
                 $4]}
  [$5]
  $6)