Better hiding of Org header lines
This commit is contained in:
parent
029a714bd7
commit
d60de45141
2 changed files with 47 additions and 40 deletions
87
ha-demos.org
87
ha-demos.org
|
@ -2,7 +2,7 @@
|
|||
#+author: Howard X. Abrams
|
||||
#+date: 2024-10-18
|
||||
#+filetags: emacs hamacs
|
||||
#+lastmod: [2024-10-30 Wed]
|
||||
#+lastmod: [2024-11-05 Tue]
|
||||
|
||||
A literate programming file for creating and running demonstrations
|
||||
|
||||
|
@ -58,6 +58,29 @@ But I feel I should replace it, and this project encapsulates the following goal
|
|||
|
||||
* Presentations with Org
|
||||
A demonstration begins with an Org file where the screen shows a /single heading/ with a larger font. Not much more. I have two projects that I like to use.
|
||||
** Hiding Blocks
|
||||
When showing a presentation, I never want the =#+business= to lines to completely disappear. First attempt turned the foreground color to the background color, but that still leaves a blank, but occupied line. Using the invisible overlays removes them completely:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun ha-org-blocks-hide-headers ()
|
||||
"Make the headers and other block metadata invisible.
|
||||
See `ha-org-blocks-show-headers' to return their appearance."
|
||||
(let ((pattern (rx bol (zero-or-more space)
|
||||
(or ":" "#")
|
||||
(zero-or-more any) eol)))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward pattern nil t)
|
||||
(let* ((start (match-beginning 0)) (end (1+ (match-end 0)))
|
||||
(ovlay (make-overlay start end)))
|
||||
(overlay-put ovlay 'invisible t))))))
|
||||
|
||||
(defun ha-org-blocks-show-headers ()
|
||||
"Un-invisibilize the headers and other block metadata invisible.
|
||||
In other words, this undoes what `ha-org-blocks-hide-headers' did."
|
||||
(delete-all-overlays))
|
||||
#+END_SRC
|
||||
|
||||
** Org Present
|
||||
Converted to use [[https://github.com/rlister/org-present][org-present]]. I love the /hooks/ as that makes it easier to handle. My problem with =org-present= is that it doesn’t always display images.
|
||||
|
||||
|
@ -67,24 +90,6 @@ Converted to use [[https://github.com/rlister/org-present][org-present]]. I love
|
|||
(defvar ha-org-present-mode-line mode-line-format
|
||||
"Cache previous mode-line format state")
|
||||
|
||||
(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
|
||||
(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 ha-org-blocks-show-headers ()
|
||||
"Un-invisibilize the headers and other block metadata invisible.
|
||||
In other words, this undoes what `ha-org-blocks-hide-headers' did."
|
||||
(delete-all-overlays))
|
||||
|
||||
(defun ha-org-present-start ()
|
||||
"Hook to run when starting a presentation.
|
||||
This happens _after_ `org-present' has started."
|
||||
|
@ -158,33 +163,32 @@ I’ve used [[https://github.com/takaxp/org-tree-slide][org-tree-slide]] for yea
|
|||
"Configure the presentation display.
|
||||
See `ha-org-tree-slide-stop' that undoes this."
|
||||
(setq org-hide-emphasis-markers t)
|
||||
(set-face-attribute 'org-quote nil
|
||||
:inherit 'variable-pitch :slant 'italic)
|
||||
(ha-org-blocks-hide-headers)
|
||||
(ha-demo-hide-cursor)
|
||||
(ha-demo-presentation-frame)
|
||||
(demo-it--presentation-display-set)
|
||||
(ha-demo-hide-mode-line)
|
||||
(git-gutter-mode -1)
|
||||
(ha-demo-presentation-frame)
|
||||
;; (demo-it--presentation-display-set)
|
||||
(text-scale-set 4)
|
||||
(git-gutter-mode -1)
|
||||
(flycheck-mode -1)
|
||||
(jinx-mode -1))
|
||||
|
||||
(defun ha-org-tree-slide-stop ()
|
||||
"Reset the display after a presentation.
|
||||
See `ha-org-tree-slide-start' for what's set."
|
||||
(demo-it--presentation-display-restore) ; Restore previous changes
|
||||
(setq org-hide-emphasis-markers t)
|
||||
(ha-demo-show-mode-line)
|
||||
(ha-org-blocks-show-headers)
|
||||
(ha-demo-show-cursor)
|
||||
(ha-demo-show-mode-line)
|
||||
(ha-demo-normalize-frame)
|
||||
(git-gutter-mode)
|
||||
;; (demo-it--presentation-display-restore) ; Restore previous changes
|
||||
(text-scale-set 0)
|
||||
(git-gutter-mode)
|
||||
(flycheck-mode)
|
||||
(jinx-mode))
|
||||
|
||||
:bind
|
||||
(("S-<f6>" . org-tree-slide-skip-done-toggle)
|
||||
:map org-tree-slide-mode-map
|
||||
(:map org-tree-slide-mode-map
|
||||
("<f5>" . org-tree-slide-move-next-tree)
|
||||
("S-<f5>" . org-tree-slide-move-previous-tree)
|
||||
("M-<f5>" . org-tree-slide-content)
|
||||
|
@ -192,12 +196,9 @@ I’ve used [[https://github.com/takaxp/org-tree-slide][org-tree-slide]] for yea
|
|||
|
||||
:general
|
||||
(:states 'normal :keymaps 'org-tree-slide-mode-map
|
||||
"c" #'ha-demo-hide-cursor
|
||||
"C" #'ha-demo-show-cursor
|
||||
"C" #'ha-demo-toggle-cursor
|
||||
"n" #'org-tree-slide-move-next-tree
|
||||
"j" #'org-tree-slide-move-next-tree
|
||||
"k" #'org-tree-slide-move-previous-tree
|
||||
"p" #'org-tree-slide-move-previous-tree
|
||||
"N" #'org-tree-slide-move-previous-tree
|
||||
"Q" (lambda () (interactive) (org-slide-tree-mode -1)))
|
||||
|
||||
:hook
|
||||
|
@ -389,6 +390,13 @@ The typical presentation software has an issue for hiding the cursor when workin
|
|||
(set-frame-parameter (selected-frame)
|
||||
'cursor-type (nth 5 ha-demo-cursor))
|
||||
(setq ha-demo-cursor nil)))
|
||||
|
||||
(defun ha-demo-toggle-cursor ()
|
||||
"Toggles the display of the cursor."
|
||||
(interactive)
|
||||
(if ha-demo-cursor
|
||||
(ha-demo-show-cursor)
|
||||
(ha-demo-hide-cursor)))
|
||||
#+END_SRC
|
||||
|
||||
** Hide and Show the Modeline
|
||||
|
@ -469,10 +477,12 @@ All options? Should I use Common Lisp’s =cl-defun= for the keyword parameters?
|
|||
|
||||
;; Step 1: Create a window
|
||||
(pcase position
|
||||
('full )
|
||||
('above (progn (split-window-vertically)))
|
||||
('up (progn (split-window-vertically)))
|
||||
('left (progn (split-window-horizontally)))
|
||||
('right (progn (split-window-horizontally) (other-window 1)))
|
||||
('above (progn (split-window-vertically) (other-window 1)))
|
||||
('below (progn (split-window-vertically) (other-window 1))))
|
||||
;; We could do :left and :top by not doing the other window bit...
|
||||
|
||||
;; Step 2: Load the file or switch to the buffer:
|
||||
(if (file-exists-p filename)
|
||||
|
@ -506,10 +516,7 @@ All options? Should I use Common Lisp’s =cl-defun= for the keyword parameters?
|
|||
(unless modeline
|
||||
(setq-local mode-line-format nil))
|
||||
|
||||
(when commands (funcall commands))
|
||||
)
|
||||
|
||||
(funcall (lambda () (message "Hello")))
|
||||
(when commands (funcall commands)))
|
||||
#+END_SRC
|
||||
|
||||
Let try it all together:
|
||||
|
|
BIN
ha-org-mermaid.png
Normal file
BIN
ha-org-mermaid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Loading…
Reference in a new issue