1
0
Fork 0

[oni-org] Add functions to remove and toggle inlineimages

This commit is contained in:
Tom Willemse 2021-06-30 11:22:09 -07:00
parent 9d74d0341d
commit 7f233420c8

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; 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