Last active
December 4, 2023 08:38
-
-
Save whhone/e8960bc2d22c1168499d9393a2d58e7d to your computer and use it in GitHub Desktop.
Emacs lisp function to jump to random org heading. Useful for getting a random note from a giant org file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/org-random-heading () | |
"Jump to a random org heading in the current org file." | |
(interactive) | |
(goto-char (point-min)) | |
(let ((headings '())) | |
(while (re-search-forward "^\\*+ " nil t) | |
(push (point) headings)) | |
(when headings | |
(goto-char (nth (random (length headings)) headings)) | |
(org-reveal)))) | |
(with-eval-after-load "org" | |
(define-key org-mode-map (kbd "C-c n R") #'my/org-random-heading)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is also M-x org-random-todo-goto-new from https://github.com/unhammer/org-random-todo :)