From 7f233420c8ce97ba79bf82f47c4f0138087301e1 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 30 Jun 2021 11:22:09 -0700 Subject: [oni-org] Add functions to remove and toggle inlineimages --- oni-org/oni-org.el | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index 12c4c32..9b9605e 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2021.0630.111102 +;; Version: 2021.0630.112155 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons org-journal) ;; This program is free software; you can redistribute it and/or modify @@ -71,6 +71,36 @@ (goto-char (1- header-end)) (insert "#+STARTUP: inlineimages\n"))))) + (defun oni-org-document-remove-inline-images-startup () + "Remove a line to the current org buffer that will make it load images inline." + (interactive) + (unless (derived-mode-p 'org-mode) + (error "Not currently in an org-mode buffer")) + (save-excursion + (goto-char (point-min)) + (let ((header-end (or (search-forward "\n\n" nil t) + (point-max))) + (case-fold-search t)) + (goto-char (point-min)) + (when (search-forward "#+startup: inlineimages" header-end t) + (kill-whole-line))))) + +(defun oni-org-document-toggle-inline-images-startup () + "Add or remove a line to the current org buffer that will make it load images inline." + (interactive) + (unless (derived-mode-p 'org-mode) + (error "Not currently in an org-mode buffer")) + (save-excursion + (goto-char (point-min)) + (let ((header-end (or (search-forward "\n\n" nil t) + (point-max))) + (case-fold-search t)) + (goto-char (point-min)) + (if (search-forward "#+startup: inlineimages" header-end t) + (kill-whole-line) + (goto-char (1- header-end)) + (insert "#+STARTUP: inlineimages\n"))))) + (defun oni-org-expand-to-home (file-name) "Expand FILE-NAME to the base directory for that system. The base for all org files on Windows is u:/, but on my linux -- cgit v1.2.3-54-g00ecf