Categories: geek

RSS - Atom - Subscribe via email

Yay Emacs 7: Rewriting and copying custom Org Mode links

| yay-emacs, emacs, org

I use org-link-set-parameters to define a lot of custom links in Org Mode for things like my blog or my Emacs config. Then I can code how I want to complete, open, and export those links. These links don't make sense to other people, of course. I want to be able to quickly copy or replace my custom links with regular web links, like the ones I use when I export to HTML.

My shortcut for this is C-. u to copy the exported URL and C-. r to rewrite a link. These stand for my-embark-org-copy-exported-url and my-embark-replace-link-with-exported-url respectively.

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

View org source for this post

Thinking about how I can use large language models

| ai, geek

I wanted to follow up on my post on large language models and me from January and do some more thinking/learning out loud.

Data

I have >= 8000 posts in my blog, almost 4000 sketches (mostly public, many with OCR results), and lots of text notes in my Org Mode files, many of which are in a hierarchy and many of which are just a random list of entries.

There's also the episodic memory aspect of things, trying to remember using different cues. Might be fun to figure out what I can do with >= 16,000 text journal entries (usually a sentence, sometimes longer).

Vector/approximate search

I like the idea of being able to search my notes with both exact and approximate matches. Semantic Search for Org roam | lgmoneda might be a good starting point. Khoj has a free self-hosted option that can be configured to use offline models and some support for Org Mode, but it might be too big for me to wrap my head around at this point. I'll probably write my own thing so that I can understand it and so that I can tailor it to the structure (or lack thereof) of what I've got.

I don't mind starting with just the retrieval aspect, since text generation is still a little iffy. I'd rather be able to flip through the titles and jump to the source information for now.

I'm partly looking for the modern equivalent of the Remembrance Agent, which I enjoyed using in Emacs before. It used a bag-of-words approach to look at a few hundred words around your cursor and suggest files/emails/etc. that were relevant in another window.

Episodic search

Slightly more far-off: it might be nice to be able to find something based on more retrieval cues and episodic memory, and to enrich memory.

Someday it would be pretty cool to have something help me remember where I left something. Video (SpotEM, Episodic Memory Question Answering) might be excessive, but maybe I could get into the habit of audio notes?

Transcript correction

It would be good to have more conveniences for fixing commonly-misrecognized words, although that might also be handled with simple regex-based replacements (maybe like mbork's mrr-replace-mode).

Topic identification and segmentation

It would be nice to automatically break up transcripts of braindumps or web conferences into topics. I currently do a bit of light structuring via keywords in my audio braindumps, but topic segmentation is a well-established area, so I should be able to figure this out once I set aside time for it.

Question-answering: not so much yet

I thought it was a little interesting how Dan Shipper used 10 years of journal data for retrieval-augmented text generation and question-answering (source) and how AI can make analyzing your thoughts and actions feel more like a conversation, but I don't think this is quite useful for me yet.

Question-asking might be more useful

When I'm writing, my challenge is usually resisting going down the rabbit hole of more tweaks and instead reining things in so that I can finish the post. But if I do find myself wanting to write more, I think it might potentially be interesting to ask what kinds of follow-up questions people might ask about something, and then add links or more explanations.

View org source for this post

2024-10-28 Emacs news

| emacs, emacs-news

UPDATE: I'm moving Emacs News to the info-gnu-emacs mailing list instead of emacs-tangents. If you're subscribed to Emacs News through emacs-tangents, you may want to switch your subscriptions. Emacs News will also continue to be available on the web and through RSS. I'll post to both info-gnu-emacs and emacs-tangents for a little while.

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

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