#elisp
I wrote this #elisp index generator a while ago. It's probably not the best way to do this, but there's something really neat about this little hack :p


I wrote about implementing a custom Tramp Method in Emacs.
Scraping the shell command output was the way to go - perhaps a little slower, but far more reliable.
So thankful for dash.el's -->
macro. Makes me feel like I'm programming in bash again (in a good way). Must use it more. #elisp
Elisp problem: given a list l and a thing, create (l[1] thing "-or" l[2] thing "-or" ...). Emacs Lisp supports this for a simple string, but I wanted a list of strings.
Solution: (cdr (mapcan (lambda (x) ("-or" x thing)) l))
Don't try to be clever about when to put in the separator, just put in an extra one at the front and take it out at the end. (Dropping the first element of a list is easier than dropping the last one, and idiomatic in Lisp.)
015 / #100daystooffload #CommonLisp #Programming #clim #demo #lisp themed.
In which I start #swank using #elisp #eshell in #emacs #orgmode (using this text file).
#gopher
gopher://tilde.club/0/~screwtape/synthember-100days-tooffload/015-clim-in-emacs.org
proxy
https://gopher.tildeverse.org/tilde.club/0/~screwtape/synthember-100days-tooffload/015-clim-in-emacs.org
@jackdaniel what do you do to start swank here? I forgot where the note on doing this was when I was jamming this org doc.
https://gopher.tildeverse.org/tilde.club/1/~screwtape/synthember-100days-tooffload/
gopher://tilde.club/1/~screwtape/synthember-100days-tooffload/
Keynote: Delimited Continuations, Demystified by Alexis King | Lambda Da...
#scheme has been very prompt on adopting research work
Apparently it just didnt care about those adoptions being adopted
I mean the first thing I stumbled at after learning about curry Howard correspondence upon googling long long ago , was haskell monads and a terrible book #lyah , also i wasnt very serious about #learntocode thing , before i could figure out the economic incubation of my own labor , didnt start lime that.
That aside , despite trying #emacs in a whim to get away from browser in 2014 ( long after that ) first thing i stumbled at was #pubshell
again no #functionalprogramming , while ema s started to replace nearly everything i used till then , for a long time i saw #elisp as an easy to use config lang with a huge relative value preposition some functions, some calls and a compile env (based on gcc? ( as it was a program?) and a bit of #git ( again no orgit till then .. i was using org-publish though , but without #cd , again not into devops and yes broken org-emacs was an issue then, besides reproducility issues 1 and i present eve now, which helped in seeing #nix primarily as a config language with types, functions and options . It took me a year till i focused on creating my own serious symlinks with home.file . which took me to focus on flakes , modules and nix the language, till then it was more a config language for #nixos (I was not alone and nor fully wrong 2 which fascinated me with its build options also at that time i started to dabble into #ohw and was trying to free myself of commercial stuff since 2014
, then it was time to care about my representation on #socialmedia and integrity of the ab\use of my identity thanks to #cambridgeanalytica and #netflix , as it neared the real life experiences , thanks to the local socio economics and i saw nix as to #selfhost my infra. Dabbling into #typetheory #prooftheory bits of #haskell and #agda is still on ..lets see , where it all goes ( if anywhere at all).
Summary = i ve been more a plt guy than a pl guy per se.
Upside As, I write this I am working to get my emacs config to load some of my nix paths. :meta #introduction post, this also changes , how is see #nixpkgs sets
what next[experimental ] also try to to do it with dotfiles instead of dotconfig dir 3 , although i prefer home.file and I guess , I ll for my own reasons notes - * src = builtins.filterSource(path: type: type != "directory" || baseNameOf path != ".svn")./source-dir;Thus, the first argument e1 must be a predicate function that is called for each regular file, directory or symlink in the source tree e2. If the function returns true, the file is copied to the Nix store, otherwise it is omitted. The function is called with two arguments. The first is the full path of the file. The second is a string that identifies the type of the file, which is either "regular", "directory", "symlink" or "unknown" (for other kinds of files such as device nodes or fifos — but note that those cannot be copied to the Nix store, so if the predicate returns true for them, the copy will fail). If you exclude a directory, the entire corresponding subtree of e2 will be excluded.4When an interpolated string evaluates to a path, the path is first copied into the Nix store and the resulting string is the store path of the newly created store object.
For instance, evaluating "${./foo.txt}" will cause foo.txt in the current directory to be copied into the Nix store and result in the string "/nix/store/-foo.txt".
Note that the Nix language assumes that all input files will remain unchanged while evaluating a Nix expression. For example, assume you used a file path in an interpolated string during a nix repl session. Later in the same session, after having changed the file contents, evaluating the interpolated string with the file path again might not return a new store path, since Nix might not re-read the file contents. 5
criticism , feedback, hat tips welcome
We are starting using org Life In Plain Text for our phlogs. My stab at an orgmode+elisp entrypoint.
#elpher #emacs #elisp #lisp it works but I leave a useless buffer in the background.
#gopher #orgmode
#100daystooffload 011/100
gopher:
gopher://tilde.club/0/~screwtape/synthember-100days-tooffload/011-orgmode-phloging.org
proxy:
https://gopher.tildeverse.org/tilde.club/0/~screwtape/synthember-100days-tooffload/011-orgmode-phloging.org
@matto @dekkzz76 @pkw @louis @82mhz @darkstar
https://orgmode.org
#phloggersgarage on #liberachat
I still don't understand what I'm doing with #elisp and macros, but this works to use a macro in a dolist:
(dolist (x list-of-things) (eval `(make-function-macro ,x)))
This also lets me byte-compile this file, while the version that uses a function-making function blows up. (Well, maybe it wouldn't if I used eval, but a direct call goes boom.)
This is with lexical binding for my .el file, which is not the default but is recommended.
Found in: https://stackoverflow.com/questions/38579435/expanding-macros-inside-dolist
#emacs #emacslisp
Current status: discovering that I actually want an Emacs elisp function that defines functions, not a macro that defines functions, because you cannot put macros in (dolist ...) and similar things, and of course I have a whole collection of functions to make and do things with, which I would like not to do by hand in lines after lines of elisp.
Not only is symex.el a useful package now I'm starting to remember its keybindings, but also it dares challenge the orthodoxy of calling a symbolic expression a "sexp"
@abcdw @goku12 For the past 20+ years I've maintained a bibliography (now at ~13 000 entries) using nothing but #Emacs #auctex & #bibtex mode on what's basically just a text (.bib) file. A short #elisp function also allows me to immediately open the document (say, pdf or djvu) corresponding to the entry, simply by entering F9 anywhere on the entry. This system has several advantages:
Emacs's regexp-search together with reftex-citation allow for incredibly powerful and flexible searches through the database
Any other interaction niceties more or less easily implementable through elisp code. For instance, I have a custom function that abbreviates a selected piece of text according to ISO 4 standard
It's basically just a text file, so in particular situations one can search or modify with any text editor
Automatically integrated with Emacs & AUCTeX when writing TeX files (in Emacs of course :) )
Of course it's a purely subjective choice, I'm not saying it's objectively better than any other. But worth considering and trying!
Revisited my torrent client project (using #elisp of course) and checked a bunch of torrent test files whether they can be processed without any extensions. To my surprise, the #Archlinux ISO torrent relies on the WebSeed extension, meaning that the torrent merely points at a list of HTTP/FTP URLs. So, unless another peer discovery mechanism like DHT is used, you'd be better off directly downloading from a HTTP/FTP mirror...
@holgerschurig @nnungest Yeah that use of `rgrep` might be a good excuse for a small #elisp wrapper around `shell-command` (see the dwim project, https://github.com/xenodium/dwim-shell-command).
You might also take advantage of `ripgrep` or the silver searcher to make the results a little nicer.
#elisp format, a list of lists like
;; -*- coding: utf-8 -*
https://www.reddit.com/r/emacs/comments/h9calt/newsticker_vs_elfeed_a_small_informal_comparison/
Bloody well written ..
https://nyxt.atlas.engineer/article/elisp-vs-common-lisp.org
@louis @galdor @a13cui To be honest, I'm skeptical about defining "superiority" on the set of isomorphic representations of reasonable code.
Of course, there's the space of bad code, e.g. long hard-to-understand poorly-documented (take any) functions, spaghetti code, WET, unreadable constructs such as nested ternaries, etc., etc... And better programmers sample that space less, but it's substantial, even in more minimal languages.
I.e. I doubt you can write "better" code, you can write the code that is less bad perhaps.
Conversely, I'm in love with #elisp, so I know I can write the same iteration construct with mapcar & co, cl-loop, threading macros, seq-*, dash functions, dolist, cl-do, cl-reduce & the rest of cl-*, hmm, what else... And I don't feel like I've grown much because of that 🙂
By the way, it's kinda the same with the aforementioned darkness.js, with its countless _.chain(libraries) besides the built-in loop expressions, .map / .reduce / whatever, .forEach... A Scheme with C syntax indeed.
And next to the above, there's the space of memory/compute inefficient code... From my work with students, I often find it harder to explain that this code is O(n!) while it should be O(n^2).
Besides, there are principles of single responsibility, separation of concerns, which are mostly language-independent. And architectural decisions.
...maybe I'll change something in this stream of consciousness if I manage to work in the field for the next 20 years 🤷
The small #elisp linked below demonstrates how to limit the completion of certain commands to a specific major mode in #emacs E.g. to make `ledger-occur` only available when you're in a buffer with ledger-mode.
Packages which define (interactive) commands may handle this themselves. See the MODES argument in the (interactive) help text. However, it's not a common practice, so you can achieve this from your own configuration with a few lines of elisp.
Why do this? I maintain my ledger in an #orgmode file with ledger source blocks in between. `ledger-occur` does not behave well when used in a different mode, and it resulted in data loss when executed in an Org buffer. To prevent accidentally selecting `ledger-occur` in other contexts, I put a restriction in place:
(my/restrict-symbol 'ledger-mode '(ledger-copy-transaction-at-point ledger-occur))
Now, I can't accidentally invoke `ledger-occur` or `ledger-copy-transaction-at-point` outside `ledger-mode`.
The restriction only affects the completion options in the command list invoked by M-x. Therefore, if you bind a restricted command to a key, it would still be invokable.
I've been doing some VS Code extension hacking recently (something cool coming soon, possibly!) and I have to say...
It is really a testament to LISP and to the Emacs contributors that docstrings are:
1. a core part of the language
2. are available on nearly every function and command
The best way to even find out if a command _exists_ in VS Code is to open the "keyboard shortcuts" window. And then just guess the args…
#vscode #vscodeExtension #emacs #elisp #lisp #docstring #documentation
In #commonlisp and #elisp , can you give me an example on when you would use the intern function?
As far as I understand, this is used to turn a string into it's corresponding keyword symbol. When is this useful?
All of this bringeth me to this proposal: a single file #elisp library that provides the basic framework for abstracting these inconsistencies away.
2 problems:
- what to name it
- where should it go on the system?
#emacs #elisp #scripting
This is also a runtime challenge. When I invoke a long-running function in Emacs with an interactive progress display, it had better be asynchronous. But when you call async-shell-command from a noninteractive session, it just exits.
#emacs #elisp #scripting
... The next problem, which is async.
#elpaca is the best elisp package manager, and I want to be able to use it everywhere. But unlike straight, elpaca (seems to) requires an interactive session. Maybe there's a solution in having both straight.el and elpaca available and symlink some/all of their caches together? Then interactive operations can use elpaca but a script can fall back to straight without double downloads.
Whoops, I made a minor edit with thread editing on and thought I was making a new post afterwards. Suffice to say we can do something like
(if noninteractive
(call-interactively #'name--main)
(provide' name))
For the footer
#emacs #elisp #scripting
(numbers are hard)/?
My #ADHD secret to sticking with #Emacs and #elisp: I felt as though I was MAKING PROGRESS and LEARNING A TON at. EVERY. STEP.
Just start at “This, this right here, is good enough.” If you truly experience “Wow, today is better than yesterday!” almost every day, you can sustain the years of ‘effort’(?) it takes to reach goals that appear MAGICAL at the beginning.
This technique also works for switching to #Linux, #grapheneOS, #selfhosting, #degoogling, etc etc etc
@stranded_output DUDE! YES! THIS IS MY STRUGGLE!
THIS IS WHY #Emacs and #elisp were perfect for me! Ironic? I guess. I can definitely see how to many newcomers its learning curve resembles a sheer cliff.
But I just made a list of things I wanted, and worried away at the list one teeny tiny atomic feature at a time. It took years, but (HERE IS THE SECRET) I felt as though I was MAKING PROGRESS and LEARNING A TON at. EVERY. STEP.
I have quite a lot more followers than I did when I first wrote my introduction, so it’s only fair that I’m writing a new one, bump up the major version.
#introduction #intro #introductions
Hi! o/
I am Ștefan (ș as sh, I also accept Stephan or the equivalent in your language). I’m 21 years old, ♑, he/him, proud #leftist and soon to graduate CS @ UVABc. Sort of proudly living in #romania. My native language is Romanian, fairly proficient at English, slowly learning #finnish (and #italian).
Tried a lot of programming languages in my childhood up until now, a non-chronological list of ones that stuck with me for one reason or another being: VB6 (that’s what I started on at 8 years old), #pascal (+ #freepascal and #delphi), #perl (+ #raku), #tcl #tcltk, #lisp (usually #scheme, on a good day #elisp #emacslisp and #commonlisp), #elixir, #php, #forth, #lua, #oberon, #modula-2, #cpp #c++, #ocaml, #fsharp, #smalltalk (+ #squeak #pharo #self), #ada, #powershell, #dart, #matlab, #rlang, #zig, #nim, #cobol and #julia. I don’t claim full proficiency in all of these, but I’m familiar enough with these (+ some others not mentioned here) that I could get along just fine with 2 weeks at most of studying and looking through cookbooks and examples). I’m flexible in learning new languages and technologies if needed.
I also do #sudoku and #math for fun (especially functional equations and number theory problems, sometimes calculus and geometric algebra). I am interested in #linguists, #conlangs (#lojban and #esperanto) and #nlp, contemporary (post-‘45, usually post-‘89 for me) history, #balkan history, lower-level stuff (I like to learn about how tools around me work, I’m most interested in #compilers, #emulators and #microcontrollers), #typography and #latex, #linux + #bsd, #msdos, #amiga, #oberon, #plan9, #philosophy, #astronomy (especially in a worldbuilding context) and #philosophy, along with other less notable interests.
I engage in #politics relatively often irl, although I’m not inserting it in absolutely every scenario in my life. As I mentioned, I’m a #leftist and #progressive (or… um… #woke) (Nazis and fascists can have a merry fuck off, DNI with me). I am also a spiritual person, a #deist (if you really want to put it that way, an agnostic, although it’s not quite true) and I find #astrology and #tarot interesting (I’ll let you guess my moon and ascendant, let’s see how close you are).
With that being said, I hope I’m welcome here, you can pick your subset of things that interest you from this list, you have plenty of options. :P Quite a bit longer than last time, but oh well…
Dr. Howell's SUMMER 2023 NERD PROJECTS
✅ Learn enough #Emacs #lisp #emacslisp #elisp to write my own boutique major-mode and minor-modes
✅ Get back on Mastodon and post some rants
✅ Migrate to #GrapheneOS and take the final step out of Apple's #walledgarden
__ Set up one of the laptops with #Guix #GuixOS and see how free a nerd can breathe
Thanks to "An Introduction to Programming in Emacs Lisp", "Mastering Emacs" and similar resources, I feel comfortable in writing little snippets of #Elisp for convenient small functions in #Emacs (like this https://dindi.garjola.net/emms-random-album.html). I understand how to write a minor/major mode. However, I am not able to write something like a game (snake, tetris) or an "application" using several windows to provide a UI (like Gnus' article/summary windows). Looking at the code of those packages feels like a big wall to me. Are there tutorials showing how to build these kinds of things, with step by step guidance?
I just discovered this novel #emacs #emacslisp #elisp feature:
As part of their definitions, functions can be declared as being pure and side-effect free. This shows up in *Help* buffers and is also used by the compiler for optimisation. These types of declarations are associated with the symbol as opposed to the function value(https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Properties.html), just like #clojure metadata(https://clojure.org/reference/metadata).
I know #dlang has a similar feature where functions can be marked as being pure (https://tour.dlang.org/tour/en/gems/functional-programming), but I haven't seen it anywhere else. I suppose #rust immutable references are kind of similar too, although that's stretching it.
Are there any there any other cool or novel features in elisp?
This piece #elisp of makes #emacs execute certain code when opening a file with a particular name. This is useful for files that have no clear extension or mode setting.
I use it to enter `yaml-mode` whenever I open a .clang-format file (which I don't want to pollute with -*- magic).
The original code was inspired by this StackExchange post, but I found the implementation quite cumbersome so I rewrote it to make it more condense.
When @spritelyinst closes in on their work on #Guile's wasm compiler (maybe later this year?!), it'll certainly become the easiest way to target optimized #wasm. Tree-IL has gotta be the simplest intermediate language to compile to, and you get all the optimizations Guile offers for free.
Considering Robin Templeton, the author of Guile's #elisp compiler, is one of the engineers behind it, I can't help but speculate that this will put #emacs in the browser within reach. If I can handle my org-agenda online by 2025, I will cry.
It's called #Scheme because it allows just a few friends to plot a CONSpiracy to build amazing things.
@chris_spackman Yes, for sure. I was the same with #emacs--using the arrow keys, the delete key, etc. Then I learned a bunch of the readline() shortcuts and I use them all over the place.
For a while I dabbled with write #elisp for various helpers, but it isn't worth it when you sit at different computers logged in as different users all the time.
Multiple ramps to multiple plateaus.
(let ((host "toot.love"))
(with-temp-buffer
(open-network-stream host (current-buffer) host 443 :type 'tls)))
why does it hang? #elisp
https://github.com/mooseyboots/mastodon.el/issues/149#issuecomment-368320107
cc @rougier
test toot from emacs
never use lambdas in the update-function because it causes trouble
why?
#elisp
https://codeberg.org/martianh/mastodon.el/issues/317#issuecomment-695522
Sprinkling your code with logs for debugging
One #elisp tip for profiling non-interactively when using #emacs --batch:
(require 'profiler)
(profiler-start 'cpu)
;; ...
(profiler-stop)
(let ((filename (format "%d.profile" (truncate (float-time)))))
(profiler-write-profile (profiler-cpu-profile) filename))
You can then use M-x profiler-find-profile on the file.
I've moved some of the request objects outside the drawing loop and resorted to reusing one object per type of request, then mutating the fields as necessary before sending the request. Now the performance hotspots left seem to be inside the data marshalling code. I can't do much about it unless I were to rewrite it to avoid creating/walking objects in the first place.
Using xcb.el I managed to recreate a X11 drawing demo with #elisp. This may or may not pave the way forward to faster graphics rendering programs in #Emacs...
https://www.x.org/releases/current/doc/libxcb/tutorial/index.html#drawingprim
Yup, learning #elisp . In hindsight, I should have done this ages ago. Previously I was just mimicking existing code for my init.el whereas now I'm actually writing it from scratch. It's really not that hard of a language to understand and learn. Makes you feel like a wizard when you can hook and extend your IDE and work environment with such ease.
But the most important part for me is that it's the first time I'm learning a new language and using all the assistance of a fully-fledged IDE from the beginning... it's amazing. Having docs, completion, repl, .... all within one environment is sooooo much of a productivity boost.
I barely scratched this when I started learning #rust a few years back. Had I started learning it with this environment I would have learnt (a bit) faster.
So yes, this is the confession of an old fart realizing late (but not too late) that fully-fledged IDE are the way to program (and debug, learn programming,...).
@daviwil Thank you for that very interesting stream today. It was great watching you do some deep dive into #Elisp data structures and functional libraries.
In my opinion #Emacs Lisp is a bright light in the otherwise dim #Lisp ecosystem when it comes to discoverability, documentation and user experience. 🚀
@hl @engtao you probably noticed the long list of links on the wiki page, https://www.emacswiki.org/emacs/LearnEmacsLisp for learning #elisp , but if I had to do it all over again, that might start with the Land of Lisp, http://landoflisp.com/ and try to do the examples in #emacs itself; noticing the differences between common and #emacslisp.
The `named-let` macro came in quite handy to solve #adventofcode day 6 in #elisp. It allows you to express your solution with a recursive call, while under the hood it translates to a loop. Which is, of course, also known as tail call optimization.
(spoiler alert in the link below if you're even slower than me going through the AoC)
🔴 On today's #SystemCrafters stream, we'll experiment with Emacs' built-in debuggers, `debug` and `edebug`.
Let's see if we can discover some good debugging strategies for when your configuration or a package you use starts to break!
Join us LIVE at 4PM UTC on YouTube or Twitch:
- https://youtu.be/LfwSc-lfFxM
- https://twitch.tv/SystemCrafters
#EmacsTip: If you are writing #Emacs #Lisp macros, #Macrostep might be of interest. It allows to expand macros interactively.
@cwebber I have been using #emacs as an editor for many years and very gradually picked up some #elisp from setting parameters in my config. In the last year or so I have also been learning #CommonLisp through #OrgMode babel because of an interest in reproducible research, and because the support for the language in Org babel was good. I had originally decided to use #python for these calculations in documents, but found myself using more and more lisp as time went by because it's convenient in that environment. Lisp is fun to learn, but not having a computer science background can make some of the ideas (lambda functions and macros, for example) difficult to understand. I enjoy reading here about what other people are doing.
@cwebber A long time ago, in a terminal far away, I was programming in vim when a friend recommended #emacs. I switched and never looked back.
My responsibilities at work outgrew my tooling, and I found #org-mode and began writing #elisp to help me out. It was awesome so I picked up #common-lisp (now my favorite).
Found #Guix; Nix ideas with Lisp? Yes.
Now I solve problems with various lisps while people tell me those problems can't be solved.
Quick tip: you can write standalone #Elisp scripts with the following header lines:
```
#!/usr/bin/env sh
":"; exec emacs --quick --script "$0" "$@" # -*- mode: emacs-lisp -*-
```
This is used by #DoomEmacs' helper scripts, but it's great whenever you need the convenience of a #ShellScript but the power of Lisp. It even supports Emacs' buffer-manipulation capabilities!
Do note that using `(message ...)` will print to stderr and cannot be used in pipes. Instead just return the values.
Since I did the same on my old functional.cafe instance, thought I should have an intro here as well, it’s mostly stolen from there
[insert #introduction #intro #introductions since it seems those hashtags are popular or something]
My name is Ștefan (ș being sh or s if you’re English), 20 y.o., ♑, he/him, leftist and all that. I’m sadly living in Romania, I’m an undergrad in computer science and I’ve tried waaaay too many programming languages.
My usual speciality is programming, I prefer functional programming (and Lisps such as #scheme, #commonlisp and #elisp sometimes), math (mostly real analysis, calculus, number theory and geometric algebra).
I am also interested in #linguistics (and NLP), post-WWII history (especially post-‘89), #compilers and #emulators (and generally low-level stuff), #typography and #latex, #linux and #bsd (and #dos stuff) and #philosophy, #astronomy and #astrology (don’t @ me) among many other things. I hope I’ll be welcomed here!
Hello! #introductions #introduction
I am finishing grad student in #numericalrelativity (#generalrelativity, #astrodon) at #UArizona. I study #blackholes and #gravitationalwaves. I work a lot with #HPC and #Python. I am strong advocate for #OpenSource and #OpenScience.
My computer boots directly into #Emacs. I am involved with #vterm and other #elisp packages.
I am a massive fan of #nationalparks and enjoy #hiking and #cycling. I like to read about #history.