#+TITLE: New emacs install, lisp hooks for moo #+author: screwlisp * New emacs install Since I had a new emacs environment, I thought I would grab my config orgfiles from my phlog. But my new emacs was emacs 28, and I guess keyboard macros changed a bit. So I just used elisp instead of a keyboard macro example to postpend source blocks in the config files. I'll clobber the old config. * Lisp and hooks I tooted on the mastodon that deferred commitment was the key lisp style. Talking to mdhughes, I think that the use of hooks and also immediately-useful programs, without defining some end goal are examples. ** Inferior lisp rmoo You should go visit my updated interactive config, but the gist is I added this in config-back.org : #+begin_src elisp (defvar *cattle-rustling* nil) (defvar *herd-captured* (list)) (defun my-capture-moo (string) (when *cattle-rustling* (push string *herd-captured*))) #+end_src Okay, it's a bit simple-minded, but I just wanted to sometimes capture rmoo's output. Oh right, and this hook enabled interactively: #+begin_src elisp (add-hook 'rmoo-handle-text-hooks (lambda () (my-capture-moo (buffer-substring-no-properties (point-min) (point-max))))) #+end_src Clearly I can turn on and off capturing passing rmoo lines. ** Inferior lisp (common-lisp) package *** rmoo.asd #+begin_src lisp (defsystem "rmoo" :class :package-inferred-system :depends-on (:rmoo/all)) #+end_src *** all.lisp Five very manual functions for driving rmoo from inferior lisp. #+begin_src lisp (uiop:Define-package :rmoo/all (:import-from :swank) (:export #:take-capture #:blank-capture #:call-verb #:start-capturing #:stop-capturing) (:nicknames :rmoo)) (in-package :rmoo/all) (defvar *buffer* "*LambdaMOO*") (defun call-verb (moo-verb) (swank:eval-in-emacs `(progn (with-current-buffer ,*buffer* (end-of-buffer) (insert ,moo-verb) (rmoo-send))))) (Defun start-capturing () (swank:eval-in-emacs '(setq *cattle-rustling* t))) (defun stop-capturing () (swank:eval-in-emacs '(setq *cattle-rustling* nil))) (defun blank-capture () (swank:eval-in-emacs '(setq *herd-captured* (list)))) (defun take-capture () (reverse (swank:eval-in-emacs '*herd-captured*))) #+end_src *** Eg. #+begin_src lisp (rmoo:blank-capture) (rmoo:Start-capturing) (rmoo:call-verb "@mail") #+end_src #+RESULTS: : NIL **** Results Rather than attempt a timeout mechanism, I left it interactive as to when to follow up on a verb. Obviously, *LambdaMOO* could be inspected. #+begin_src lisp (rmoo:stop-capturing) (rmoo:take-capture) #+end_src #+RESULTS: | 4 messages: | | 1: Apr 5 05:00 Employment Office (#5198) Pay Stub | | 2: Apr 6 23:27 Slak (#125276) FYI New Job. I've created a new job called Dead DJ. T | | 3: Apr 12 05:00 Employment Office (#5198) Pay Stub | | >>>4: Apr 14 20:02 Slak (#125276) FYI. Did i mention you can type sloggers to see who ha | |------------------------------------------------------------------------------------------------------| * Final thoughts. I'm pretty happy, but the rmoo-handle-text-hooks doesn't pass the lines as strings, it leaves you in a buffer where (point-min) and (point-max) are the beginning and end of the line (and it's asyncronous). * PS Thanks Slak for everything you MOO! * PPS Thanks to yduJ for resetting my password when I lost a drive. * PPPS Thanks everyone else, especially those who make Zhen House and the lispy gopher climate great! * swank:eval-in-emacs Clearly I had M-x customize-variable slime-enable-evaluate-in-emacs set true.