💾 Archived View for sergio-101.mywire.org › posts › new-emacs-lisp-project.gmi captured on 2022-06-03 at 22:51:21. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

                               "                  mmm     mmmm  mmm
  mmm    mmm    m mm   mmmm  mmm     mmm            #    m"  "m   #
 #   "  #"  #   #"  " #" "#    #    #" "#           #    #  m #   #
  """m  #""""   #     #   #    #    #   #   """     #    #    #   #
 "mmm"  "#mm"   #     "#m"#  mm#mm  "#m#"         mm#mm   #mm#  mm#mm
                       m  #
                        ""

A new emacs lisp tiny project

Last updated: 2022-05-14

For the most part, every software project I work on is massive, and it's for someone else. I really have fun working on small projects that solve a problem for me specifically. This is what I want to do next. Unfortunately, I am not an emacs list (elisp) pro. I will stumble through this, and it will be very un-lispy. I hope I'll gain a better understanding of lisp doing this.

I have written a few elisp programs in the past, but so much time passes between opportunities, it feels like I have alot of relearning to do. Perhaps I'll go through the elisp tutorial directly in emacs.

Perhaps I'll fail, and run to [@cwebber@octodon.social] for help.

@cwebber@octodon.social

The specific problem

I use emacs [org-mode] to create documents for my [weekly radio show]. I can go into specifics on this if anyone is interested, but in the end, I end up with:

The playlists evolve every week as we add new artists, venues, etc to the show.

To make this information more useful, I like to have anything mentioned linked (urls). Doing this by hand is a huge amount of work. I'd like to be able to create something that:

That's it! Super easy. But, I want to do this in elisp so I can create an interactive function and do this to any buffer.

org-mode

weekly radio show

email newsletter

The implementation

I think I can use an [association list] to create something like Tuple in another language. I could create a list of text/url substitutions to do something like:

((link one . http://link.one.com)
 (link two . http://link.two.com))

I think it would be cleaner to maintain that list in some sort of text file, and suck it in as an association list, but I'll handle that as a second issue.

Next, I would just need to use the emacs `replace-string` function to replace all occurrences of the key string with value of the item in the string (I am sure I am using the wrong term for the item)

"link one" => [[http://link.one.com][link one]]

The one gotcha is that once we should be able to run this function any number of times, and get an acceptable outcome. In our case, running it again would update the "link one" inside the [org mode hyper link], and we would get a nested result rather than what we want.

So, I'll have to figure out how to use the `replace-regex` command in elisp to replace ONLY target text that is not already surrounded by "[" or "]".

association list

org mode hyper link

Testing

I hate writing software by writing, running, and checking to see if I got what I was hoping for. I need to see if elisp has a test framework so I can write my expections first. Then, run them until everything passes.

I'll let everyone know how this progresses. I can't imagine it will take more than half an hour, but finding that half hour is the tricky part. I will probably spend about the amount of time to solve this problem in writing this blog post, but I really like the idea of playing with and working on GeminiSpace content.

A new emacs lisp tiny project was published on 2022-05-14

Go to home page