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.
The Emacs Lisp manual has a section on recursive editing, which mentions a few different ways you might handle this.
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.