Skip to content

Instantly share code, notes, and snippets.

@cadadr
Created June 12, 2022 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cadadr/66c5d0b486c2e4069daae372ffcd1494 to your computer and use it in GitHub Desktop.
Save cadadr/66c5d0b486c2e4069daae372ffcd1494 to your computer and use it in GitHub Desktop.
Capture template for annotated research photographs with Emacs and Org mode

Code snippet to accompany the fediverse post: https://scholar.social/@cadxdr/108464579108516573

This is a simple system based on Emacs, Org mode, and it's Capture feature to annotate images. Or any other file really, but I'm making this workflow to annotate images, as an alternative to using Tropy.

Tropy is nice but for my purposes, for whom pictures aren't the centre of my research, it is a bit too much. I need to know about stuff, like Dublin Core, or specific metadata practices, which likely won't come up in my work. So I don't want that barrier to get in my way when I'm organising and annotating photographs.

The below snippet assumes there's a file at the path ~/Notes/Photos.org and that you have used org-store-link to collect links for the file or the files you would like to annotate. The template creates a toplevel entry in the file, prompts you for information, and then you're presented with something like below in the capture template:

* 
| author     | Some Body                   |
| place      | Some Where, Some Place, ... |
| date&time  | [an inactive org timestamp] |

- Link 1
- Link 2 (if applicable)
- ....


The cursor will be on the first line, right after * where you can insert a title. Then, optionally, you can go to the bottom of the entry and add freeform comments.

Of course that's just how I plan to use it. Feel free to turn this into whatever works for you. FWIW, I make the code available under Creative Commons 0 Public Domain licence.

P.S.: This is adapted from my configuration, see here for the original version.

(defun gk-org-capture-annotated-photograph ()
"Generate capture template for Photos.org
Template generation relies on links being stored using ‘org-store’.
After completion removes used links from ‘org-stored-links’."
(let ((template-head
(concat "* %?\n"
"| author | %^{Author|own work} |\n"
"| place | %^{Place} |\n"
"| date&time | %^{Date (and optionally time):}U |\n"))
(selected-links
(cl-remove-if-not
(lambda (link) (y-or-n-p (format "Include %s" (car link))))
org-stored-links)))
;; Remove links selected for inclusion in the template from
;; ‘org-stored-links’.
(setf org-stored-links (seq-difference org-stored-links selected-links))
(concat template-head
"\n"
(mapconcat (lambda (link)
(concat "- [["
(car link)
"]["
(cadr link)
"]]"))
selected-links
"\n")
"\n\n")))
;; Capture template (for ‘org-capture-templates’):
("F"
"Annotated photograph(s) [store links to the photos first!]"
entry
(file "~/Notes/Photos.org")
(function 'gk-org-capture-annotated-photograph)
:prepend nil
:empty-lines-before 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment