Insert a link to an Org Mode heading from an org-refile prompt

| emacs, embark, org

I often want to link to an Org heading from somewhere in my org-refile-targets, which includes my agenda files and other things. I don't want to think about where the heading is, I just want to link to it. I could use C-u C-c C-w (org-refile) to go to the heading, use C-c l (my shortcut for org-store-link), head back with org-mark-ring-goto, and then insert it with C-c C-l (org-insert-link).

Or I can use this code to make an Embark command that hooks into minibuffer prompts that include "goto" or "refile", so I can link to something with C-. i right from a refile or goto query.

(defun my-embark-org-insert-link-from-path (path)
  (interactive (list (car (org-refile-get-location))))
  (let* ((extra (if org-refile-use-outline-path "/" ""))
         (tbl (mapcar
               (lambda (x)
                 (if (and (not (member org-refile-use-outline-path
                                       '(file full-file-path title)))
                          (not (equal filename (file-truename (nth 1 x)))))
                     (cons (concat (car x) extra " ("
                                   (file-name-nondirectory (nth 1 x)) ")")
                           (cdr x))
                   (cons (concat (car x) extra) (cdr x))))
               org-refile-target-table))
         link)
    (insert (save-window-excursion
              (save-excursion
                (org-goto-marker-or-bmk
                 (elt
                  (org-refile--get-location path tbl)
                  3))
                (org-store-link nil))))))
(defvar-keymap my-org-path-map
  :doc "Shortcuts for working with Org paths from `org-refile'."
  "i" #'my-embark-org-insert-link-from-path)
(with-eval-after-load 'marginalia
  (add-to-list 'marginalia-prompt-categories '("Goto\\|Refile" . my-org-path)))
(with-eval-after-load 'embark
  (add-to-list 'embark-keymap-alist '(my-org-path . my-org-path-map)))
2024-10-24_10-34-21.png
Figure 1: Screenshot of Embark menu invoked with "C-.", showing the new "i" shortcut for inserting a link

There are more Embark shortcuts in my Embark configuration.

This is part of my Emacs configuration.
View org source for this post

Wednesday weblog: Toots ending 2024-10-16

| review, weblog
  • Emacs:
  • Other:
    • Reading books; Atomic Habits - 2024-10-22T13:44:31.682Z

      All right, I'm slowly getting back into reading and sketching books, now that I've discovered that
      Libby lets me export my highlights. =) Here's my #sketchnote of Atomic Habits:
      https://sachachua.com/blog/2024/10/2024-10-21-05-atomic-habits-visual-book-notes-productivity-personal-development/

      Text from the sketch:

      ```
      Atomic Habits - James Clear (2022) - Notes by Sacha Chua 2024-10-21-05

      - time vs results: valley of disappointment: (we expect linear progress)
      - Achieving a Goal only changes your life for the moment.
      - In order to improve for good, solve problems at the system level.
      - Fall in love with process rather than product.
      - Not "what do you want to achieve?", who do you want to become?
      - prove it with small wins
      - habits
      - Problem phase
      - Cue: Make it obvious.
      - point & call: raise level of awareness
      - common cues: time, location, other habits
      - Manage your environment
      - Craving: Make it attractive.
      - Temptation bundling
      - anticipation, dopamine, action
      - Social groups
      - Reframe
      - Solution phase
      - Response: Make it easy.
      - Make it easier to do the right things
      - Motion != action
      - Repetitions, automaticity: habit line
      - Make your habits so easy that you'll do them even when you don't feel like it
      - 2 minutes
      - Reward: Make it satisfying.
      - Immediate
      - Visuals: paper clip strategy, tracker
      - Habits can be easier to change in a new environment. (old cues gone)
      - You have to fall in love with boredom
      - Habit stacking
      - My take aways:
      - Processes, not products
      - Analyze & redesign:
      - habits I have
      - habits I want
      - be thoughtful about helping the kiddo learn
      ```

      (Also, how do I format this text more nicely? I want to preserve indentation, and fencing it with three backticks doesn't seem to be working.)

    • From audio braindumping to a post - 2024-10-16T15:08:13.172Z

      I'm slowly getting the hang of this sketch+audio braindumping thing. I managed to write a fairly long post on #pkm:

      Thinking about 12 aspects of personal information/knowledge management
      https://sachachua.com/blog/2024/10/thinking-about-12-aspects-of-personal-information-knowledge-management/

      Looking forward to exploring more as I dive into reading and conversations!

    • My time data - 2024-10-18T02:39:23.402Z

      I got curious and did a scholar.google.com search for "Sacha Chua." The most amusing thing I found was:

      Joscha Cueppers and Jilles Vreeken. Just Wait For It... Mining Sequential Patterns with Reliable Prediction Delays. In: IEEE International Conference on Data Mining (ICDM). 2020

      which (among other things) had apparently analyzed the time tracking records that I'd intentionally made public:

      "Next we consider Lifelog, which is based on the life of Sacha Chua who logs and publishes all her daily activities. We considered the data over 2017, removing any activities with have the same start and stop timestamp. As this dataset provides many events that are potentially interesting, we consider every e ∈ Ω as target, and have 40 target sequences with Y [i] = 1 iff X[i] = e. In addition, we consider a Y where we marked all business related activities as interesting.
      Over all these datasets, SCIS discovers on average 695 patterns, many of which are redundant and not all make intuitive sense. While SQS only discovers 3 predictive patterns, these do make sense: Cook, Dinner→Clean the Kitchen
      and Subway, Social→Subway. OMEN takes between 6.1 and 37 seconds per dataset, and overall discovers 24 patterns.
      Many of these, such as Sleep→Childcare, Cook→Dinner, Dinner→Clean the Kitchen, predict the next action, i.e. a time delay distribution with a peak at 1. A more interesting pattern is Subway→Subway which has its peak at δ = 2, and for which a natural interpretation is that Sacha takes the subway, logs on average one activity, and then takes the subway back."

      https://publications.cispa.de/articles/conference_contribution/Just_Wait_For_It_Mining_Sequential_Patterns_with_Reliable_Prediction_Delays/24613377?file=43247712

      2017! Bwahaha... I had a one-year-old child and was trying to stay sane by squeezing in some consulting here and there while dealing with sleep deprivation and all sorts of other new-parent challenges. :) I still don't have the time to do lots of different things on one errand, although it's nice that I'm now biking around a lot more than I use the subway. Maybe analyzing 2012-2016 might have been more interesting for their data mining, since that covered a little bit of corporate work time and the transition to self-directed learning in my semi-retirement experiment.

      Cool, cool, very fun, I'm tickled pink that someone else found the data nifty. I recently made quantifiedawesome.com more private, but maybe I should open that part up again.

View org source for this post

Added a gallery and slideshow view for my visual book notes

| 11ty, blogging

I customized my visual book notes - all view to show the thumbnails of the images, and I added You can get to it by going to the visual-book-notes category from a post and then choosing "All". I like the new "View slideshow" and "Shuffle slideshow" buttons I added.

2024-10-23_14-09-26.png
Figure 1: Screenshot of my visual book notes gallery

I also fixed some of the broken images in older posts, so there should be 43 posts with images now.

Someday I want to add a way to go from the sketch in the slideshow to the post, but it might require upgrading the version of Photoswipe I have. I'm currently on 4.x, which hasn't been updated in years.

View org source for this post

A git post-commit hook for tagging my subed.el release version

| git, emacs, subed

Debian uses Git repository tags to notice when to update packages. I kept forgetting to tag subed's versions, so now I made a git post-commit hook which I think will do the trick. I based it on https://gist.github.com/ajmirsky/1245103, just updated for Python 3 and tweaked to work with how I do versions in subed.el. I've also added it to my README.org.

#!/usr/bin/python

# place in .git/hooks/post-commit
# Based on https://gist.github.com/ajmirsky/1245103

import subprocess
import re

print("checking for version change...",)

output = subprocess.check_output(['git', 'diff', 'HEAD^', 'HEAD', '-U0']).decode("utf-8")

version_info = None
for d in output.split("\n"):
    rg = re.compile(r'\+(?:;;\s+)?Version:\s+(?P<major>[0-9]+)\.(?P<minor>[0-9]+)\.(?P<rev>[0-9]+)')
    m = rg.search(d)
    if m:
        version_info = m.groupdict()
        break

if version_info:
    tag = "v%s.%s.%s" % (version_info['major'], version_info['minor'], version_info['rev'])
    existing = subprocess.check_output(['git', 'tag']).decode("utf-8").split("\n")
    if tag in existing:
        print("%s is already tagged, not updating" % tag)
    else:
        result = subprocess.run(['git', 'tag', '-f', tag])
        if result.returncode:
            raise Exception('tagging not successful: %s %s' % (result.stdout, result.returncode))
        print("tagged revision: %s" % tag)
else:
    print("none found.")
View org source for this post

Visual book notes: Atomic Habits

| visual-book-notes, productivity

Text from sketch

Atomic Habits - James Clear (2022) - Notes by Sacha Chua 2024-10-21-05

  • time vs results: valley of disappointment: (we expect linear progress)
  • Achieving a Goal only changes your life for the moment.
  • In order to improve for good, solve problems at the system level.
  • Fall in love with process rather than product.
  • Not "what do you want to achieve?", who do you want to become?
    • prove it with small wins
      • habits
  • Problem phase
    • Cue: Make it obvious.
      • point & call: raise level of awareness
      • common cues: time, location, other habits
      • Manage your environment
    • Craving: Make it attractive.
      • Temptation bundling
        • anticipation, dopamine, action
      • Social groups
      • Reframe
  • Solution phase
    • Response: Make it easy.
      • Make it easier to do the right things
      • Motion != action
      • Repetitions, automaticity: habit line
      • Make your habits so easy that you'll do them even when you don't feel like it
      • 2 minutes
    • Reward: Make it satisfying.
      • Immediate
      • Visuals: paper clip strategy, tracker
  • Habits can be easier to change in a new environment. (old cues gone)
  • You have to fall in love with boredom
  • Habit stacking
  • My take aways:
    • Processes, not products
    • Analyze & redesign:
      • habits I have
      • habits I want
    • be thoughtful about helping the kiddo learn

In my life

Habits I'm tinkering with:

  • Tidying and listening: When the kiddo watches videos in the afternoon, I'll get dinner started (unless W- has taken care of it already), and then I'll listen to a podcast while tidying.
  • Reading: It turns out I can export my highlights from Libby, even from a returned book. That means I can do a little reading at night or when I have a spare moment on my phone, then look at the highlights when doing a sketchnote. This makes it easier and allows me to feel like I can squeeze it in whenever..
  • Shuffling my to-do list: I'm experimenting with shuffling my unscheduled tasks to add some variable rewards to my someday/maybe list, increasing its attractiveness.

I like the focus on process rather than product. I was briefly enamoured with Big Hairy Audacious Goals but it turned out that wasn't really that motivating for me. These days, I'm more curious about enjoying life, making sense of things, and making incremental improvements to my processes.

I don't quite agree with the thought that you have to fall in love with boredom. I think part of continuous improvement is being able to find more things to be curious about, even with the basics, and to enjoy your progress and consistency. Maybe "fall in love with boredom" isn't quite the right wording for me. I think the author meant that you've got to be able to keep doing the routine stuff, which makes sense, but I hope I can still occasionally find interesting things in it. My brain probably just doesn't like the idea of boredom very much and has a bit of a visceral reaction to the word.

I am also iffy about streaks (they're not that motivating for me), commitment contracts and punishment (definitely not the way my brain likes to work), and never missing twice. My approach of being curious and gentle with myself might be suboptimal, but that's okay with me.

Parenting

When it comes to parenting and helping the kiddo learn habits, the approach I'm gradually coming to feels a little different from the bonus chapter he posted on his website.

I like explicitly talking about figuring out how to work with our particular brains and bodies, including habit mechanisms and dopamine. The kiddo is eight and quite capable of co-experimenting. She likes to alternate homework with snuggles, Minecraft, or Youtube videos. Sometimes I feel a little twitchy about alternating, like, two minutes of homework with twenty minutes of videos, but she's managed to get all her work done so far.

That also means I talk about how I'm figuring out my brain. When I forget something, I talk about how I'm going to change the cues for it so that I remember.

I want to develop intrinsic motivation and pride more than using praise, since I don't want her to rely too much on other people's evaluation of her. I try to focus my verbal feedback on enthusiastically observing what she's doing and how she's feeling. ("You worked on your homework and got that part done, and it's not even 9 AM! Does that feel so satisfying?") Now she occasionally talks about wanting to do certain things (ex: walk home instead of riding in my cargo bike) because of the satisfaction she'll feel, so I think it's working.

Identity and pride are helpful for habit formation, but it can be easy to develop a fixed mindset ("I'm smart") instead of a growth mindset. It's also easy to focus on results that might not always be within her control. I want to focus her attention more on what she does and how she does it. It's like not focusing on "being a good student" or "getting good grades", but on figuring out how to work with her brain. Assigments and grades are part of the feedback mechanism, but they're not the most important thing.

Links:

View org source for this post

2024-10-21 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Mastodon #emacs, Hacker News, lobste.rs, programming.dev, lemmy.world, lemmy.ml, communick.news, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, and emacs-devel. Thanks to Andrés Ramírez for emacs-devel links. Do you have an Emacs-related link or announcement? Please e-mail me at sacha@sachachua.com. Thank you!

View org source for this post

Shuffling my Org Mode unscheduled tasks

| emacs, org

I enjoyed listening to Podcast #1,029: Treat Your To-Do List Like a River, and Other Mindset Shifts for Making Better Use of Your Time | The Art of Manliness (thanks @ctietze@mastodon.social for the recommendation) and checking out the Autofocus method (main website with translations) for reviewing your TODO list without worrying too much about prioritization. I also had an opportunity to reflect on similar topics in a conversation with John Wiegley and Adam Porter about personal information management (which I'll be blogging about once John has a chance to review the draft).

This nudged me to experiment with randomizing my unscheduled task list. I'm not trying to finish everything on my list, I'm just mixing it up so that I enjoy keeping things on my radar and picking something to do. org-ql lets me create randomly-sorted views, so I wrote some code to show me a shuffled list of my unscheduled TODO tasks and SOMEDAY tasks.

(defun my-org-ql-shuffle-todo ()
  (interactive)
  (org-ql-search (org-agenda-files)
    '(and
      (todo "TODO" "STARTED")
      (not (done))
      (not (scheduled))
      (not (deadline))
      (not (ts-active))
      (not (tags "cooking")))
    :sort 'random))

(defun my-org-ql-shuffle-someday ()
  (interactive)
  (org-ql-search (org-agenda-files)
    '(and
      (todo "SOMEDAY")
      (not (done))
      (not (scheduled))
      (not (deadline))
      (not (ts-active))
      (not (tags "cooking")))
    :sort 'random))

I can't make it part of my org-agenda-custom-commands yet because of an open issue, but having separate commands is a starting point. It's surprisingly fun. I used org-agenda-follow-mode to quickly flip through the tasks while looking at the agenda. I've already noticed some tasks to cancel and picked some tasks to do. Could be neat!

This is part of my Emacs configuration.
View org source for this post