Tidy the org-present code
This commit is contained in:
parent
94d5b27788
commit
26a1c0bf62
1 changed files with 28 additions and 43 deletions
|
@ -343,62 +343,47 @@ Used to use [[https://github.com/takaxp/org-tree-slide][org-tree-slide]] for sho
|
|||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package org-present
|
||||
:init
|
||||
:config
|
||||
(defvar ha-org-present-mode-line mode-line-format "Cache previous mode-line format state")
|
||||
|
||||
:config
|
||||
(defun org-blocks-hide-headers ()
|
||||
"Make the headers and other block metadata invisible. See `org-blocks-show-headers'."
|
||||
(add-to-invisibility-spec 'ha-org-block-headers)
|
||||
|
||||
(defun hide-this (regexp)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward regexp nil t)
|
||||
(let ((start (match-beginning 0)) (end (1+ (match-end 0))))
|
||||
(overlay-put (make-overlay start end) 'invisible 'ha-org-block-headers))))
|
||||
|
||||
(defun hide-these (patterns)
|
||||
(when patterns
|
||||
(hide-this (car patterns))
|
||||
(hide-these (cdr patterns))))
|
||||
|
||||
(defun ha-org-blocks-hide-headers ()
|
||||
"Make the headers and other block metadata invisible.
|
||||
See `ha-org-blocks-show-headers'."
|
||||
(let ((pattern (rx bol (zero-or-more space)
|
||||
(or ":" "#")
|
||||
(zero-or-more any) eol)))
|
||||
(save-excursion
|
||||
(hide-these (list (rx bol (zero-or-more space)
|
||||
"#+" (or "begin" "end") "_"
|
||||
(one-or-more any) eol)
|
||||
(rx bol (zero-or-more space)
|
||||
"#+" (or "name" "header" "results" "property" "options"
|
||||
"filetags") ":"
|
||||
(zero-or-more any) eol)
|
||||
(rx bol (zero-or-more space)
|
||||
":" (or "properties" "header-args" "end") ":"
|
||||
(zero-or-more any) eol)))))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward pattern nil t)
|
||||
(let* ((start (1+ (match-beginning 0))) (end (1+ (match-end 0)))
|
||||
(ovlay (make-overlay start end)))
|
||||
(overlay-put ovlay 'invisible t))))))
|
||||
|
||||
(defun org-blocks-show-headers ()
|
||||
(defun ha-org-blocks-show-headers ()
|
||||
"Un-invisibilize the headers and other block metadata invisible.
|
||||
In other words, this undoes what `org-blocks-hide-headers' did."
|
||||
(remove-from-invisibility-spec 'ha-org-block-headers))
|
||||
In other words, this undoes what `ha-org-blocks-hide-headers' did."
|
||||
(delete-all-overlays))
|
||||
|
||||
(defun org-present-start ()
|
||||
(defun ha-org-present-start ()
|
||||
(unless ha-org-present-mode-line
|
||||
(setq ha-org-present-mode-line mode-line-format))
|
||||
(goto-char (point-min)) (re-search-forward (rx bol "*"))
|
||||
(org-blocks-hide-headers)
|
||||
(ha-org-blocks-hide-headers)
|
||||
(org-present-big)
|
||||
(setq mode-line-format nil)
|
||||
(org-display-inline-images)
|
||||
(blink-cursor-mode -1)
|
||||
(setq cursor-type nil))
|
||||
(setq mode-line-format nil)
|
||||
(sit-for 3) ; Wait for the cursor to stop blinking
|
||||
(org-present-hide-cursor))
|
||||
|
||||
(defun org-present-end ()
|
||||
(defun ha-org-present-end ()
|
||||
(org-present-small)
|
||||
(org-blocks-show-headers)
|
||||
(ha-org-blocks-show-headers)
|
||||
(setq mode-line-format ha-org-present-mode-line)
|
||||
(setq cursor-type t)
|
||||
(blink-cursor-mode 1)
|
||||
(org-present-read-write))
|
||||
(org-present-show-cursor))
|
||||
|
||||
:hook
|
||||
(org-present-mode . org-present-start)
|
||||
(org-present-mode-quit . org-present-end))
|
||||
(org-present-mode . ha-org-present-start)
|
||||
(org-present-mode-quit . ha-org-present-end))
|
||||
#+end_src
|
||||
* Technical Artifacts :noexport:
|
||||
Note, according to [[https://www.reddit.com/r/emacs/comments/vahsao/orgmode_use_capitalized_property_keywords_or/][this discussion]] (and especially [[https://scripter.co/org-keywords-lower-case/][this essay]]), I’m switching over to lower-case version of org properties. Using this helper function:
|
||||
|
|
Loading…
Reference in a new issue