From d60de45141b414b54aecabb7b1c87841ef72a5a2 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Tue, 5 Nov 2024 12:07:27 -0800 Subject: [PATCH] Better hiding of Org header lines --- ha-demos.org | 87 ++++++++++++++++++++++++--------------------- ha-org-mermaid.png | Bin 0 -> 5743 bytes 2 files changed, 47 insertions(+), 40 deletions(-) create mode 100644 ha-org-mermaid.png diff --git a/ha-demos.org b/ha-demos.org index 07adde7..6257738 100644 --- a/ha-demos.org +++ b/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-" . org-tree-slide-skip-done-toggle) - :map org-tree-slide-mode-map + (:map org-tree-slide-mode-map ("" . org-tree-slide-move-next-tree) ("S-" . org-tree-slide-move-previous-tree) ("M-" . 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: diff --git a/ha-org-mermaid.png b/ha-org-mermaid.png new file mode 100644 index 0000000000000000000000000000000000000000..c448cf8a49a3b24ccc4bd712fee310ad4c7f2a32 GIT binary patch literal 5743 zcmcgwXIN9)wgnp~#YzWJ3?c$j1ks419$ElFsu0@2&?8L}N+6)9aFCK?5R|TfA|*je zD4`yaAT3D1gcgc)LNy>g+~xcG?)QGZd-u1qviDy5n|sc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