Emacs Ergonomics

Hi - new TidalCycles student here. Loved how easy it was to get up and running on MacOS! I'm working my way through the Learning TidalCycles course and really enjoying it.

Are people using the default keybindings in tidal-mode? I ended up remapping tidal-run-d1 and friends to F1..F9 and tidal-stop-d1 etc. to C-F1..C-F9. I also ended up writing a tidal-hush function and mapping it to F10.

If this is naive, my apologies. I'd love to know how people find it easiest to interact with Tidal using Emacs. If this is useful for anyone, I'd be glad to post my config here or submit a PR.

Welcome @jkdufair! It's hard to know, but I don't think the emacs keybindings are well known / well used. PRs are welome, but maybe on some platforms the F1 keys are already taken? I'd be happy to try it out under Linux. TBH I've used emacs for a couple of decades but have barely scratched the surface in terms of customising it!

Thank you. I figure I'll develop a bit more acumen and see what itches and what might be nice and shiny. I've watched a number of your live performances & demos, @yaxu (really enjoying your style). Are you using Emacs in those? I like how you have the superDirt channel in like a left gutter.

I sometimes use emacs for performances but that'll be feedforward with the meters

1 Like

Hello! Emacs user here. According to the major mode help, the tidal-run-d1 commands are already bound to C-c C-1 etc. The F1 to F5 keys are already taken by emacs, so I would advise against using them.
As for the tidal-stop-d1 functions, I think it's a good idea to bind those, it would save time compared to having to type d1 $ silence or invoke the emacs command.
Given Emacs shortcuts conventions, C-Fn doesn't look very natural for that purpose. To follow conventions, such a command should be of the form C-c C-something, possibly followed by something again. C-c C-m 1 would have been nice to use, but C-c C-m is already taken by the Haskell major mode.

1 Like

@th4 Thanks for your reply. I did see the default bindings. There are some for the stop functions too (C-v C-1 etc)

My thinking was that I won't be using, i.e. help nor macros when I'm in tidal-mode and live coding and single-key access to starting/stopping SuperDirt channels would be worth overriding conventions for that mode alone. I just modified the tidal-mode-map. I suppose overriding Fx keys in tidal-mode might make some old graybeards like me uncomfortable, so I can just keep them in my config.

Here's my config so far if it's useful to anyone:

(use-package tidal
  :config
  (defun tidal-hush ()
    "send d1-d9 $ silence as a single line"
    (interactive)
    (tidal-send-string ":{")
    (tidal-send-string " mapM_ ($ silence) [d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16]")
    (tidal-send-string ":}"))

  (let ((map tidal-mode-map))
    (define-key map (kbd "<f1>") 'tidal-run-d1)
    (define-key map (kbd "<f2>") 'tidal-run-d2)
    (define-key map (kbd "<f3>") 'tidal-run-d3)
    (define-key map (kbd "<f4>") 'tidal-run-d4)
    (define-key map (kbd "<f5>") 'tidal-run-d5)
    (define-key map (kbd "<f6>") 'tidal-run-d6)
    (define-key map (kbd "<f7>") 'tidal-run-d7)
    (define-key map (kbd "<f8>") 'tidal-run-d8)
    (define-key map (kbd "<f9>") 'tidal-run-d9)
    (define-key map (kbd "C-<f1>") 'tidal-stop-d1)
    (define-key map (kbd "C-<f2>") 'tidal-stop-d2)
    (define-key map (kbd "C-<f3>") 'tidal-stop-d3)
    (define-key map (kbd "C-<f4>") 'tidal-stop-d4)
    (define-key map (kbd "C-<f5>") 'tidal-stop-d5)
    (define-key map (kbd "C-<f6>") 'tidal-stop-d6)
    (define-key map (kbd "C-<f7>") 'tidal-stop-d7)
    (define-key map (kbd "C-<f8>") 'tidal-stop-d8)
    (define-key map (kbd "C-<f9>") 'tidal-stop-d9)
    (define-key map (kbd "<f10>") 'tidal-hush)))
3 Likes

Thanks @th4, agreed we should stick to the conventions.

Thanks for sharing that!

I could be wrong, but I think there is a TidalCycles key binding that overrides the emacs C-v command (move page down), which I find very annoying :sweat_smile:

Does anyone else have this problem? I'm a very new Emacs user, so I'm not entirely sure how remap C-v so it moves the buffer down...

1 Like

You could edit your tidal.el file, more specifically the part with lines like this: (define-key map [?\C-v ?\C-1] 'tidal-stop-d1).
You could either comment these lines if you don't intend on using these functions with shortcuts, or edit the bindings if you still want to have them available this way (you could for example replace them with (define-key map [?\C-c ?\C-v ?\C-1] 'tidal-stop-d1)).
Don't hesitate to ask if you have more questions!

2 Likes

tidal.el is just what I didn't know I was looking for! :nerd_face:

Thanks @th4

1 Like

@jkdufair and @th4 if you are using use-package it's possible to add key bindings in your emacs init file (and probably a better idea than editing tidal.el directly)

for example, add Control-F1 to start and Meta-F1 to stop d1, and F2 to start d2

(use-package tidal
  :mode ("\\.tidal\\’" . tidal-mode)
  :config (setq tidal-interpreter "~/.ghcup/bin/ghci"
                haskell-process-type 'auto
                ;; boot script from https://github.com/tidalcycles/Tidal/blob/main/BootTidal.hs
                tidal-boot-script-path "~/.config/tidal/BootTidal.hs")
  :bind (:map tidal-mode-map
              ("C-<f1>" . tidal-run-d1)
              ("M-<f1>" . tidal-stop-d1)
              ("<f2>" . tidal-run-d2)))