macro power: removing weekends from repeating event
Table of Contents
- Updated: comment clarifying “macros”
Intro
Time to make a new daily event for the next 90 days, but it shouldn’t have weekends. Most of these steps become muscle memory after getting used to emacs macro power in orgmode files, sql dumps, dired find-and-replace, text formatting, YAML/XML/HTML/JSON/EDN tailoring, etc. It’s the speed and flexibility of this method that shines, allowing for solutions to very specific problems, or just nice custom orgmode agenda entries in this case.
Easy Steps
-
Make the initial entry, including TODO, effort estimates, and deadline/schedule/timestamp.
-
Orgmode,
org-clone-subtree-with-time-shift
(C-c C-x c
) so it allows note-taking for specific entries, and is granular so I can change individual instances easily -
I don’t want weekends, make a regexp search
isearch-forward-regexp
(C-M-s
) that finds included Sat or Sun entriesS[au]
-
Start recording macro
f3
-
repeat search to next result
C-M-s C-M-s
-
Go to the heading of the thing I found, using
C-c C-p
(org-previous-visible-heading
) -
Collapse heading and cut that one entry
-
End macro recording then repeat until done (f4 end recording,
C-99 <f4>
to repeat it 99 times or until bell rings)
Comments, Resources
Improvements to this workflow are welcome. I might make this into a function if I didn’t find it a fun exercise to do it manually to keep my macro-skills sharp.
- Reddit user 00-11 pointed out that we should clarify here: this refers to keyboard macros (recorded sequences of keys), not lisp macros (a meta-programming technique for code generation). Thanks! https://www.reddit.com/r/emacs/comments/r69w7i/comment/hmtbjfj/?utm_source=share&utm_medium=web2x&context=3