Isn’t it funny how sometimes you find a piece of software that you
look at, think “Ehh, I don’t really like this”, and then it comes back
several months later as a core part of your life management? I think
it is.
I tried column view in Emacs’ org-mode several months ago, and didn’t
end up liking it much. It seemed kinda pointless? Managing tags is
nice, but I can just… do that with a couple colons.
Oh boy was I wrong though, and it all changed when I figured out how
macros actually worked.
Recording the macro
I’m sure column view would be fine without this, but for my purposes
it was lacking.
So to start using a macro you have two options, you can either hit F3,
or the following sequence:
C-x (
From there you do whatever keystrokes (make sure they’re replicable
from wherever in the file you are), and then either hit F4 or
C-x )
To stop recording the macro.
For my purposes I wanted something that would move lines around a file
in a controllable way, and we’ll see why later. The lines would all
be at the top of the file, under the same heading, which has
the :ARCHIVE: tag on it so it has to be expanded with C-c TAB instead
of just TAB. Also I want it to re-enable the column view so I don’t
have to do tha tmanually every time.
The macro I ended up coming up with (shortened a bit):
C-<home> C-c C-<tab> <down> M-<up> <up> <tab> <down> M-x o r g - c o l u m n s <return>
Short description:
Go to beginning of file, expand the first heading, go to the last
sub-heading in that heading, move it to the top, close the first
heading, move to the main heading of the file, enable column view.
The shortening only removed <down> and M-<up> commands, because there
were 10 of each for 10 different views.
What does this accomplish? Multiple column views! In my personal
journal file I have around 25 properties, which would take a lot of
screen space and be annoying to parse. With this I can only view the
properties I want to see in that moment.
If I end up getting more I could theoretically make specific keybinds
for specific views either using sparse tree, or sort headings. I
don’t want to because that sounds annoying any time a new view gets
added. I guess using find could work though, especially since that
particular file is just used as a database for things like workouts.
Either way, next point:
Tag and Bag
Simple and easy:
C-x C-k n
That’s how you name it. Just type the name in. I tend to follow the
standard lower-case dash-instead-of-space approach, and just named it
‘cycle-column-view’.
From there you can use a shortcut to bind that to a key, but I’ve
disabled the Emacs UI’s ability to make permanent changes to my config
file because I hate it, so I have to do it differently.
For the GUI people, here’s how to bind it
C-x C-k b
For everyone else, open up your init.el or emacs.org file, go where
you want the macro to be, and do this:
M-x insert-kbd-macro RET
It’ll dump something like this:
(defalias 'MACRO-NAME (kmacro "C-<home> C-c C-<tab> <down> M-<up> <up> <tab> <down> M-x o r g - c o l u m n s <return>"))
From there just add this to your config file:
(keymap-global-set "C-x C-k c" 'MACRO-NAME)
Replacing MACRO-NAME with whatever you named the macro, and the
keybinding with whatever you want.
If you want to set it so that it only fires while in column view, use
this instead
(with-eval-after-load 'org (define-key org-columns-map (kbd "c") 'MACRO-NAME))
You can also bind it to a local file like this:
# Local Variables:# eval: (keymap-global-set "C-x C-k c" 'MACRO-NAME)# End:
Column-view specific:
# Local Variables:# eval: (with-eval-after-load 'org (define-key org-columns-map (kbd "c") 'MACRO-NAME))# End:
You can string those together, by the way. Just add the defalias bit
to your local variables in an eval: line and it’ll be a file specific
macro, and a file specific column-view keybind!
Setting up multiple column views
The beginning of the file looks something like this:
'* Column stuff :ARCHIVE:'** Exercise#+COLUMNS: %21ITEM(Date) %Training{X/} %Worked_standing{X/}%Steps{+} %Squats_20x3{mean} %Push-ups_10x3{mean} %Lunges_10x3){mean} %Dumbell_Rows_10x3{mean} %Plank_15x3{mean} %Jumping_Jacks_30x3{mean}
I have no idea if the ‘ at the beginning of those lines will show up
in the finished product, so if they do ignore them they’re not
supposed to be there in the finished product, but need to be there so
the source block doesn’t look weird.
You can add as many of the second and third lines as you need, and you
can set as many peoperties/variables as you want in them. Here’s the
format and some examples
%[WIDTH]PROPERTY[(TITLE)][{SUMMARY-TYPE}]%25TRAINING(Training){mean}%STEPS(Steps){+}