[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-present 96dfce3254 28/47: Add org-present-after-naviga
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-present 96dfce3254 28/47: Add org-present-after-navigate-functions abnormal hook |
Date: |
Sat, 8 Jan 2022 13:58:30 -0500 (EST) |
branch: elpa/org-present
commit 96dfce3254d1ff78fea1072185e48578a8223d91
Author: Duncan Bayne <duncan@cogent.co>
Commit: Duncan Bayne <duncan@cogent.co>
Add org-present-after-navigate-functions abnormal hook
This adds a single abnormal hook (i.e., a hook which takes arguments)
to org-present.
The hook is called after navigating to a new heading (including the
initial heading after org-present is invoked). It takes two
parameters:
* the name of the presentation file, and
* the text of the heading.
E.g. the following code:
(add-hook 'org-present-after-navigate-functions
(lambda (title heading)
(message (concatenate 'string title " - " heading))))
... will update the minibuffer with the title and heading every time
the user navigates to a new heading.
---
org-present.el | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/org-present.el b/org-present.el
index 05e558a5be..822c017dee 100644
--- a/org-present.el
+++ b/org-present.el
@@ -101,7 +101,8 @@
(org-present-top))) ;if that was last, go back to top before narrow
;; else handle title page before first heading
(outline-next-heading))
- (org-present-narrow))
+ (org-present-narrow)
+ (org-present-run-after-navigate-functions))
(defun org-present-prev ()
"Jump to previous top-level heading."
@@ -111,7 +112,8 @@
(widen)
(org-present-top)
(org-get-last-sibling)))
- (org-present-narrow))
+ (org-present-narrow)
+ (org-present-run-after-navigate-functions))
(defun org-present-narrow ()
"Show just current page; in a heading we narrow, else show title page
(before first heading)."
@@ -129,7 +131,8 @@
(interactive)
(widen)
(beginning-of-buffer)
- (org-present-narrow))
+ (org-present-narrow)
+ (org-present-run-after-navigate-functions))
(defun org-present-end ()
"Jump to last slide of presentation."
@@ -137,7 +140,8 @@
(widen)
(end-of-buffer)
(org-present-top)
- (org-present-narrow))
+ (org-present-narrow)
+ (org-present-run-after-navigate-functions))
(defun org-present-big ()
"Make font size larger."
@@ -219,7 +223,8 @@
(setq org-present-mode t)
(org-present-add-overlays)
(org-present-narrow)
- (run-hooks 'org-present-mode-hook))
+ (run-hooks 'org-present-mode-hook)
+ (org-present-run-after-navigate-functions))
(defun org-present-quit ()
"Quit the minor-mode."
@@ -233,5 +238,22 @@
(run-hooks 'org-present-mode-quit-hook)
(setq org-present-mode nil))
+(defvar org-present-after-navigate-functions nil
+ "Abnormal hook run after org-present navigates to a new heading.")
+
+;; courtesy Xah Lee (
http://ergoemacs.org/emacs/modernization_elisp_lib_problem.html )
+(defun org-present-trim-string (string)
+ "Remove whitespace (space, tab, emacs newline (LF, ASCII 10)) in beginning
and ending of STRING."
+ (replace-regexp-in-string
+ "\\`[ \t\n]*" ""
+ (replace-regexp-in-string "[ \t\n]*\\'" "" string)))
+
+(defun org-present-run-after-navigate-functions ()
+ "Run org-present-after-navigate hook, passing the name of the presentation
buffer and the current heading."
+ (let* ((title-text (thing-at-point 'line))
+ (safe-title-text (replace-regexp-in-string "^[ \*]" "" title-text))
+ (current-heading (org-present-trim-string safe-title-text)))
+ (run-hook-with-args 'org-present-after-navigate-functions (buffer-name)
current-heading)))
+
(provide 'org-present)
;;; org-present.el ends here
- [nongnu] elpa/org-present 00679dc2b0 32/47: Merge pull request #19 from damil/master, (continued)
- [nongnu] elpa/org-present 00679dc2b0 32/47: Merge pull request #19 from damil/master, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present b2e3b19cbc 35/47: Move org-present-narrow to be called after org-present-mode-hooks to make sure images are shown inline in all slides, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 6c57386522 36/47: Fixed that read-only function erase cursor, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 236691956d 06/47: remove some debug messages, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 80eb28f2a2 10/47: Merge pull request #2 from tarsius/master, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 71486291da 12/47: Merge pull request #3 from purcell/patch-1, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 194262bdb0 09/47: provide feature, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present ef8dfc974c 16/47: Exit read-only mode before exiting the minor mode, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present c16b846434 21/47: update key list and add beginning/end, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present fca3bcdd2c 20/47: add functions to jump to beginning and end of presentation, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 96dfce3254 28/47: Add org-present-after-navigate-functions abnormal hook,
ELPA Syncer <=
- [nongnu] elpa/org-present 75ac0cab2a 44/47: Add "Version: 0.1" header, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 7e56ab02b4 47/47: Merge pull request #41 from skangas/add-version, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 9ed67fd539 30/47: while presenting, also hide verbatim markers (i.e. '~' and '=') in addition to emphasis markers, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 5010b90fd0 37/47: Merge pull request #31 from alwyn/inline-images, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 03b23602d3 26/47: document hide/show of cursor, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 14f9288674 23/47: update copyright, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 2cc76b5b2b 25/47: add hide/show for cursor, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present d13acd70ef 29/47: Merge pull request #13 from duncan-bayne/add-hooks, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 68aeae2132 31/47: fix: Needless hiding of emphasis markers already hidden by Org, ELPA Syncer, 2022/01/08
- [nongnu] elpa/org-present 9709ca2d04 34/47: Merge pull request #25 from Kazark/emphasis-markers, ELPA Syncer, 2022/01/08