this post was submitted on 18 Nov 2023
2 points (100.0% liked)

Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I have a number of edits I need to do to yaml files. I'd like to drive emacs in the following way: mapcar over a list calling a function that opens a file, searches for a match, switches to interactive mode so I can adjust point, inserts some pre-formatted data specific to the match, allows me to edit the insertion to fix the inevitable typos that exist and, when I'm ready, saves the file and moves to the next element. I'm automating the file and buffer navigation as well as the content insertion but doing precise placement and editing by hand. Sadly, I did this once previously years ago but I don't remember how.

Relevant rant: this stupidity's only necessary because yaml's flexibility for too many ways to do the same thing so reading the yaml in, adjusting the data structures and writing it back out make pull requests horrific as minute semantic changes can have massive syntactic ones.

you are viewing a single comment's thread
view the rest of the comments
[–] fragbot2@alien.top 1 points 1 year ago

My general thought:

(defun zzz (elt)
   (let ((file (car elt))
            (repo (cadr elt))
             (st (caddr elt))
             (is (cadddr elt))
       (progn (find-file file)
         (search-forward repo)
         (switch-me-to-interactive-node-until-i hit-a-hotkey st is)
         (save-buffer)
         (kill-buffer))))

It's the switch-me function that I'm not sure how to approach.