From 72088b763efbcc6d3e2f4c724917cd6a66754535 Mon Sep 17 00:00:00 2001 From: shoshin Date: Mon, 4 Jul 2022 15:12:28 -0500 Subject: Add: my-org-top-level-heading command --- shoshin-config.el | 5 +++++ shoshin-config.org | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/shoshin-config.el b/shoshin-config.el index 8bd307e..6fecaed 100644 --- a/shoshin-config.el +++ b/shoshin-config.el @@ -70,6 +70,11 @@ (package-install 'markdown-mode) +(defun my-org-top-level-heading () + (interactive) + (let ((moo 1)) + (while moo (setq moo (org-up-heading-safe))))) + (package-install 'htmlize) (recentf-mode) diff --git a/shoshin-config.org b/shoshin-config.org index e9accc2..b67f689 100644 --- a/shoshin-config.org +++ b/shoshin-config.org @@ -397,6 +397,23 @@ config might get what i want with vanilla built ins. #+end_src ** org mode +*** jump to top level parent heading + +a friend was wanting this functionality, so i dug around in the org functions +to find one i could build a command out of: + +#+begin_src emacs-lisp + (defun my-org-top-level-heading () + (interactive) + (let ((moo 1)) + (while moo (setq moo (org-up-heading-safe))))) +#+end_src + +~org-up-heading-safe~ is designed not to throw an error and returns the level +of the headline found (as it goes up) or nil if no higher level is found. +this just uses a dumb while loop to call it until it returns nil, which should +get us where we are looking to go 😃 + *** exporting #+begin_src (require 'ox-md) -- cgit v1.2.3