Categories: geek » emacs

View topic page - RSS - Atom - Subscribe via email

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

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

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

Yay Emacs 6: Inserting links with consult-omni

| yay-emacs, emacs

I want to quickly look up and add links. consult-omni lets me search within Emacs instead of switching to a web interface. After I set up consult-omni-google with a Google custom search engine and a JSON API key, I can call it with my shortcut: M-g w. Using M-n for future history pulls in the word at point. Then I can select a site and use Embark to insert with C-. i or copy with C-. w.

My config: https://sachachua.com/dotemacs#consult-omni

You can watch this on YouTube, download the video, or download the audio.

View org source for this post

Thinking about 12 aspects of personal information/knowledge management

| pkm, org

Here is a totally rough list of aspects that I came up with to start thinking about how I do personal information/knowledge management and how I want to explore other people's systems.

(text from sketch duplicated as headings below)

Use: What do you want to use it for, and how?

I mostly work on code, so I need to keep things like TODOs and setup instructions.

I also want to organize resources and refer people to them.

It's important to me to get things out of my head because unfinished thoughts in my head are intrusive (Ovsiankina effect). They get in the way of being able to enjoy time with the kiddo. I need to be able to get them out into a system that I can trust, so that I can stop thinking about it until it's time to think about it again. I don't have a lot of computer time, so I want to be able to pick things up quickly when I do.

Capture: How do you get stuff in?

Most of the time, I add quick questions or ideas using Orgzly Revived on my phone because I'm not close to a computer. Sometimes I look up web pages that relate to something, and then I can share that with Orgzly using the Android share menu. If I'm close to a computer, then I can use org-capture.

I also use my Supernote to sketch/write ideas.

I use my phone for audio braindumps.

Challenge: I want to write down more context because I occasionally come across notes that don't make sense to me.

Retrieval: How do you get stuff out?

I usually tend to work on things that I've recently thought about, so I'm working out of my inbox or out of a few active projects. Either the relevant items I've captured are still there in my inbox or in the project's tree, or I can quickly organize them before I dive into my work.

Sometimes I need to retrieve something that's a lot older, such as when I want to recommend something I remember seeing a year or two ago. This is challenging because I often don't remember the exact words that will bring it up. I can help that a little bit by adding my own words when I create the note, but I don't feel like that's a solid solution yet. I think that this is a challenge that's going to get worse as my brain gets fuzzier. Finding things using approximate matches could be interesting. Most of the time, I end up relying on an Internet search, because then I can take advantage of the variety of words used in other people's descriptions of the thing.

Blog posts (and funneling my toots and sketches into blog posts) makes things slightly more findable. I've come across things I've completely forgotten writing about.

Challenge: When I'm trying to move too quickly instead of writing things down, then there's nothing to retrieve years later when I'm picking a project back up again. For example, when I finally dusted off my time-tracking project so that I could upgrade the Rails version, I had to do a lot of figuring out. That tells me I need to write more notes. As I run into things that I didn't write down well enough (or as I bump into things I could've sworn I wrote about but I just can't find my notes), I try to write down what I've figured out, where I looked, and what words I used in order to look for it. Maybe that will make it more findable in the future.

Priorities: How do you get the right stuff out?

I tend to work on a few recent thoughts, so I can generally schedule them for the day that I think I'll be able to work on them. Then I can use my Org Mode agenda to get a short list of the things that I want to work on. When that's done, I can then go through the more general things–still biased towards what's recent, what's in my inbox, what I've been thinking about lately. It takes extra time to context shift back into older things.

My life generally doesn't have a lot of urgent commitments, so it's mostly a matter of thinking: What do I feel like working on? What's the most annoying thing I need to work around? What am I curious about? Then I can go to that project or thought.

Sometimes I'll use the TODO status to distinguish between things that I want to do someday versus things that I could do sooner. Pushing things off to SOMEDAY is especially handy for ideas that are not very fleshed out yet. My newly created tasks default to SOMEDAY so that it takes me an active effort to say, okay, this stuff is on my list of things to focus on.

Sometimes I use the [#A] and [#C] priority marker in Org Mode to move things to the top or bottom of my list.

In general, I don't worry too much about making sure that I'm working on the absolute best thing at the time, because that stuff takes planning, too.

Time: How do you deal with dates/times/conditions?

Scheduling something on a particular day is how I pick a short list of things that I want to do. These things don't always happen. Sometimes I end up procrastinating something for another few weeks out or a month out. If I do that too often, I usually end up cancelling it, because clearly there are other things I want to do.

There are also the things I've got to schedule once in a while that I don't actively think about until the reminder pops up, like renewing my passport. The Org agenda takes care of that.

I like to keep journal entries so that I can look back and see the progress I've made.

Revision: How do you add to or refine things?

I might start off with just a quick question or idea. Depending on what I have time for, I might flush out that idea in an audio braindump or a sketch. I can convert either of those things into text and dump them into my note for editing, or I can sit down and flesh out the idea further by writing it, with the eventual goal of turning it into either a toot or a post. Maybe some of them will get turned into videos. So that's how I gradually refine things.

I would like to get better at this. Maybe I can keep track of which thoughts could benefit from sketching or doing a brain dump, or refining those sketches or brain dumps into posts. Which posts are almost there and just need a little bit more work? Which ones do I want to turn into a video?

Since the sketching and the braindumping can happen in parallel, it's probably more about tags rather than TODO states.

One improvement could be showing me where these ideas are in the pipeline so that if I'm at my computer and I want to get something out the door, I can make a list of posts that are almost there. If I'm heading out for a walk to the store, then I can make a list of the things to think about out loud. Then I can have my system do the transcript and stick it back into the pipeline so I can edit it.

How do I take those fragments of thoughts, put them together, and turn them into a finished chunk?

When it comes to refining sketches, I can just flip open my supernote and I add more stuff to it. It's very easy to pick up and put down again. I like that.

Audio is harder to work with in terms of refining an idea, but maybe I'll figure out the workflow for that someday. The draft for this post came from a sketch and an audio braindump.

There's also this idea of refining a project. When I do my first pass through my inbox, I'm just basically throwing things in the rough direction of where I'm probably going to want them. I'll refile things very roughly into Consulting or EmacsConf or whatever else. Refining in that context would be collecting several resources and putting them under one subtree, or making sense of something, mapping out the resources for a topic, or summarizing.

If I've saved a web page, it becomes a lot easier to learn from and find again if I use my own words to describe what I'm learning from it. That's another area that I could definitely do better in.

Refining is easier to do when I'm on my computer, but when I'm on my computer, I tend to want to make stuff rather than edit stuff. If I'm refining something with the goal of making it a post, that sometimes happens. But if I want to review a page whose link I saved, sometimes that ends up very low on my priority list. I'm throwing all these things into my SOMEDAY list and not actually getting around to them yet. Maybe someday!

Connection: How do you link things together?

Most of the time, I refile things so they're roughly close to where other things I need are. I can just scroll to find connected items.

I don't have many things that need to be in multiple places in my In my outline. When I do, I tend to use links to connect the ideas. I like linking between blog posts and sketches.

I don't have a good facility for backlinks yet. I should make this easier for myself, either by just opening the blog post that I'm referring to so that I can quickly add a link to it going the other way–a manual backlink that lets me provide the context–or maybe adding some backlink support to my static site generator.

Anyhow, at least the forward links are fine. I've got some completion to help me with that. Web searches are helpful just in case my completion doesn't work, as right now my completion only works with title searches. If I am a little fuzzier about what I've called something, then I will search the Internet, grab the URL, and pop in the link.

Most of the linking happens in my blog posts because the blog posts live outside my outline. They are just roughly organized by date and category. So if I want to build on another thought, I've got to link to it. Fortunately, I've got the URL, so it's easy to link to things.

I can link to things within Org Mode. I probably should more often, and it will probably involve getting the hang of Org IDs. It hasn't been as big a need for me for now because I try to push things into blog posts as much as possible.

Sometimes it makes sense to have a URL or a link that works for both the exported version and my own internal notes. I want some things to open up in Emacs instead. Then I might have a custom link type to make that easier.

Externals: How do you refer to things outside your system?

There are a lot of things that I want to think about or refer to that aren't within my Org Mode files. Fortunately, Org Mode makes it super easy to link to the things, so that part is fairly solid.

There are some kinds of things that I don't have an easy way of thinking about or working with yet, like audio.

Work ideas are harder for me to link to now that I can't access the company's WebEx chat on my personal phone, so I just write down a couple of keywords to remind myself what to think about or search for. I also tend to read my e-mail on my phone, so I don't have Org Mode's fancy linking. I write down or copy a few keywords and tag the note with "email" to help me remember where to look. Life would be much easier if I could do all of these things within Emacs so that I could just create a task and it would automatically be annotated with the link to the original stuff, but we've got to work with what we've got.

Sharing: How do you share with others?

I've been gradually refining my workflow for turning my notes ito blog posts. Org Mode is fantastic for this. I can have source blocks, I can export to various formats, it's all good. I'm also exploring the idea of turning some things into richer text–adding diagrams or sketches, or narrating it, or turning it into a video.

My main thing is I want to get thoughts, ideas, and questions from my notes into some kind of public chunk. Toots are nice because I can get smaller thoughts out instead of waiting until I've fleshed them out further. Blog posts are ideal.

I want to experiment with this by using audio braindumps and sketches to explore ideas faster and use non-computer time to help with writing.

Maintenance: How do you tidy or trim?

Part of maintenance is figuring out what's out of date and what I can archive to make it easier for me to just see the current stuff. I periodically go through my inbox and archive things or refile things into projects. I am slowly getting the hang of archiving things instead of deleting things, since disk space is cheap. Once in a while, I'll go through my Org file to archive inactive projects and neaten things up.

On the public side, I could probably do automated things like link-checking, but it's been pretty low priority. Most of the time, I end up updating posts when I look up them up in order to link to them or when people ask me about them. I have a snippet that makes it a little easier to note an update, but I should probably improve it to handle adding an update to a post that's already been updated before.

I don't have a list of recently modified but not newly posted posts, which might be a good idea for exposing that to blog readers.

I also want to create more evergreen pages that organize resources, kind of like my blog outline but more granular. I still want to have the last modified date as text in the page itself, but it doesn't have to be part of the permalink.

Discovery: How do you stumble upon things?

I have a lot in my notes that I've completely forgotten about. One of the benefits of keeping most of my notes online is that when people come across those notes, their links or comments help me find them again.

I've also added a random blog post button on my blog, and I'm trying to shift some doom-scrolling to use that instead.

For my personal notes, I don't bump into things as much because org-refile is very efficient for getting to just the thing I want to look at. For the most part, things get hidden away under their sub-trees until I feel like working on that particular area, so it might be years before I touch something again, if at all.

I could probably add some kind of randomness thing, but I don't really struggle with finding things to work on when I'm on my computer. There's usually something else more pressing that I want to work on, so it hasn't been an issue.

I do want to add a random sketch thing, though. I think it could be fun to cycle my background through the files in my public sketches on my desktop or my phone lockscreen.

Longevity: How do you keep it around?

Using plain text and free and open source software is really important to me because I want it to be easy to back up and I want to be able to trust that it's going to be around. Having seen many things get bought up or taken down… Yeah, I want to have my own notes. I feel reasonably confident, based on other people's experiences, that if I want to keep using my notes in another 20 years or more, it'll probably still be there as long as I don't do anything silly with the data.

For my sketches, I put titles and tags in the filenames. I've been using Google Cloud Vision to do handwriting recognition so that I have some kind of text that presumably I could search, although I haven't built that part yet.

Audio is a bit more ephemeral, but it might still be interesting to hear archived audio.

One of these days, I should make an organized backup of the things that I've shared on YouTube and other places. Videos take much more space.

Another thing that I'm thinking of long-term, once in a while, is how to keep going into this, how to keep it easy for me to access, use, add to, and share as I get older. I hear menopause might really do a number on my brain. People report having a hard time remembering words and thinking thoughts. It would be nice to have approximate search in place by then so that I can still find things, or at least have shared as much as possible.

My long-term plan (in case stuff happens) is to have whatever notes might be helpful be publicly available already so that theoretically someone could use the Internet Archive or a static mirror or to get back to it. Even in the case where I die and my hosting stops being paid for, the core things about it, I think, have been well-demonstrated and can be easily picked up by somebody else if they want to.

Planet Emacslife is a blog aggregator. The idea of Emacs News is fairly straightforward and somebody else could step into it easily. The ideas are not dependent on me, whic his nice.

My posts and code are out there too. They're not immortal, and they don't have to do be. If they're useful in the moment, that's already enough. If somebody comes across them months or years later and finds them useful, that's a bonus. I use them to think through something, so that's already a win.

Wrapping up

I'd love to hear about your personal information/knowledge management systems, whether you want to think about it using these aspects or your own framework. Let's share notes!

View org source for this post

Change Org Mode TODO keyword color based on the state and the current Modus theme

| emacs, org

I use modus-theme-toggle to switch between modus-vivendi-tinted and modus-operandi-tinted depending on whether I want a dark background or a light one. I also customize my org-todo-keyword-faces to visually distinguish TODO, DONE, WAITING, and SOMEDAY. This is how to colour them based on the current Modus theme.

(defun my-org-todo-set-keyword-faces ()
  (setq org-todo-keyword-faces
        `(("TODO" . (:foreground ,(modus-themes-get-color-value 'blue-warmer) :weight bold))
          ("DONE" . (:foreground ,(modus-themes-get-color-value 'green-warmer) :weight bold))
          ("WAITING" . (:foreground ,(modus-themes-get-color-value 'red-warmer) :weight bold))
          ("SOMEDAY" . (:foreground ,(modus-themes-get-color-value 'fg-dim) :weight bold))))
  (when (derived-mode-p 'org-mode)
    (font-lock-fontify-buffer)))
(with-eval-after-load 'modus-themes
  (add-hook 'modus-themes-after-load-theme-hook #'my-org-todo-set-keyword-faces))
2024-10-14-17-21-48.svg
Figure 1: Light background
2024-10-14-17-22-31.svg
Figure 2: Dark background
This is part of my Emacs configuration.
View org source for this post