sigmoid.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A social space for people researching, working with, or just interested in AI!

Server stats:

595
active users

#elisp

3 posts3 participants0 posts today

I'm coding a little project in #elisp before I get back to bigger #Emacs things. This project has, what we could call a record, 7-8 fields. I thought, maybe I should try records or cl-defstruct. I coded them up, started to use them, and found it more painful than I hoped.

The keywords of defstruct seem like a good idea, but they percolate upwards and things get complicated.
I found myself thinking in clojurey ways which don't work so well in Elisp.

I went back to lists. A list of lists.. It feels right to me and it all just works. I can find them with some flavor of assoc, then find the attributes the same way.

What do you think? What would you do?

#elisp #emacs #lisp

has anyone seen or implemented something like common lisp's split-sequence, or partition in elisp? i.e. function that takes a predicate, and returns a list of the elements that match and another list of the elements that to do not? cl-lib doesn't seem to have it, and i can't see a way to hack it up using existing functions either. (seq-partition) from seq.el doesn't do the trick, it's a kinda false friend.

Edit: the options being
- seq-group-by
- -partition-by
- hacking cl-reduce

This cool trick (some would call it "dirty hack" 🙂) by @plantarum can be used for #dot/#graphviz, as well:

(defun my-babel-execute-maybe ()
(interactive)
(org-mode)
(org-babel-execute-maybe)
(org-display-inline-images)
(normal-mode))

E.g. imagine this comment or doc string:

/*
#+BEGIN_SRC dot :file myfunction.svg :cmdline -Kdot -Tsvg
digraph {
a -> b;
}
#+END_SRC
*/

Replied in thread

@dekks llm's ability to summarise and pattern match can absolutely be useful when exploring a new framework or library. Lowest common denominator is just another way of saying common patterns and idioms. When people report success vibe coding its usually because they are using a popular framework with lots of examples in the training data. I was just illustrating the limits of these tools. The fact #elisp is often used to create DSLs probably compounds with the paucity of training data.

My psychiatrist double-booked herself tonight so we weren't able to have our scheduled appointment.

Eff it, we ball. Time to self-medicate.

I'm writing a Python program as an elisp string to inject into the interpreter to get __doc__ strings out as association lists to jury-rig my own fuzzy-search matcher on function and method docs.

There are no rules here. Where we're going, we don't need rules.

@eduardoochs what do you think of #elisp
(cl-defmacro with-eepitch-target
((buffername) &body body)
(declare (indent 1))
(append
`(let ((old-buffername eepitch-buffer-name))
(setq eepitch-buffer-name ,buffername))
body
'((setq eepitch-buffer-name old-buffername))))

(defun eepitch-to (target line)
(with-eepitch-target
(target)
(setq line (eepitch-preprocess-line line))
(eepitch-prepare)
(eepitch-line line)))

(eepitch-to
"*slime-repl ECL*"
"(+ 2 9)")

Replied in thread

@pkw

I use both #vi (not a vim) and #Emacs. If Im doing anything very complex it's in emacs.

I've written a lot of #Elisp, actual applications not just configurations.
I created a large #Clojure project that lasted several years. That spoiled me. I love working with a REPL in emacs. I became very accustomed to doing a hybrid of TDD and REPL dev. I mostly did not work in the REPL, I would send the code I was editing to it.

I would only go to the REPL to examine or manipulate the resulting environment there.

It's a wonderful way to work, having your editor talking directly to your REPL. Evaluating your tests and functions as you go.

#Emacs question: How does one load (or include or import or however the proper terminology is) a elisp file relative to the current elisp file? I can only find load and load-file, but these seem to always load stuff relative to the load path or the CWD of Emacs itself, not the file.

Salutations from the Pacific Northwest! 🌊🏔️🌲🌧️

In a past life, I was a Web developer building Java/JavaScript webapps hosted on Linux systems.

Now I spend my time as a Cloud Security Engineer, building tooling and
microservices in AWS to keep the bad guys out (or good guys who love footguns).

When I'm not hunched over my laptop writing code or debugging,
you'll find me riding my bicycle, getting armbarred in Brazilian Jiu
Jitsu, playing D&D with my kids, or melting in a Korean sauna
(jjimjilbang) like a human dumpling.

I'm interested in connecting with people about #emacs #elisp #golang,
possibly collaborating on #foss projects.

In addition to English, I speak French (native but rusty), Spanish
(intermediate), Portuguese (beginner) and Korean (beginner).

#Emacs #Lisp ability to provide multiple forms in the else branch (implicit progn) deserves some praise. I often write recursive algorithms that have a simple base case returning a value, and a much more involved recursive else case. Whapping the else into a progn/prog1/begin/do is an annoyance, however small. So #Elisp got this thing right, at least.

I've been debating the usefulness of org-roam-dailies. Much happier since switching to one long log/journal file with datetree rather than disparate little dated files all over the place. It's easier to review/show todos in org-agenda. Some simple code for a capture template if you wanna try it out..

(setq org-roam-dailies-capture-templates
'(("d" "default" entry
"* %<%H:%M> %?"
:target (file+datetree "log.org" week))))

I'm trying to write an org-capture-template and supporting functions for it, for a blogging setup that uses individual org files within a specific directory for posts. i want this to work such that I get prompted for a title, which is used to generate the file name, the title metadata of the file, and a description, which is also used to generate another metadata variable. Based on this answer, I've come up with this:

(defun org-new-blog-post ()
(setq date (format-time-string (org-time-stamp-format :long :inactive) (org-current-time)))
(setq title (read-string "Post Title: "))
(setq fname (org-hugo-slug title))
(setq description (read-string "Description: "))
(expand-file-name (format "%s.org" fname) "~/git/personal/blog/org/blog/"))

(setq org-capture-templates
'(("n" "new post"
plain
(function org-new-blog-post)
"%(format \"#+title: %s\n#+date: %s\n#+description: %s\n\n\" title date description)")))

But this doesn't seem to work, and it just prints the output in the buffer I started with. how do I make this work?

I understand that setting global variables in a defun is bad practice but somehow using a let form doesn't allow me to reference those variables in the capture template.