Skip to main content


Wrote my first non-trivial #elisp macro yesterday. Macros were the thing that scared me away from #lisp the first time I tried learning it.
#emacs

Shannon Prickett reshared this.

in reply to James Endres Howell

@James Endres Howell
I'm a little self-conscious about it as non-trivial is relative, but...
(defmacro lambdamoo-chatter-interact
    (func-name to msg docstring fmtstr &rest vals)
  "Define a function for interacting with another player"
  (let ((proc (gensym))
        (str (gensym)))
    `(defun ,func-name (,proc ,str)
       ,docstring
       (let ((,to lambdamoo-chatter)
             (,msg (substring-no-properties (lambdamoo-command-text ,str))))
         (if ,to
             (funcall lambdamoo-send-line ,proc
                      (format ,fmtstr . ,vals))
           (message "No chatter specified"))))))
in reply to Jonathan Lamothe

That's awesome. I need to hear my own advice, of course, but don't be inhibited to share something that isn't finished. It's the Fediverse! We're all anarchists! The kind sort, I mean.

Lisp macros are just so powerful.

in reply to James Endres Howell

@James Endres Howell They really are. They're a little bit of a mind bender until you really get them, but once you do they're such a game changer.
in reply to Jonathan Lamothe

Wait, how do you get the awesome code formatting? Anybody know how to configure this on fediscience.org?

AM I GOING TO HAVE TO SPIN UP MY OWN INSTANCE AGAIN

in reply to James Endres Howell

@James Endres Howell Frendica has a markdown add-on.

I just typed:

```lisp
...code...
```

Typing that however was trickier.

This website uses cookies. If you continue browsing this website, you agree to the usage of cookies.