Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion org-tree-slide-compt.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; These functions shall be loaded for Emacs 25.1 or earlier.
;; These functions shall be loaded for Emacs 25.1 or earlier. -*- lexical-binding: t; -*-
;; outline-show-children <- show-children
;; outline-show-subtree <- show-subtree
;; outline-hide-subtree <- hide-subtree
Expand Down Expand Up @@ -48,3 +48,23 @@ If non-nil, EVENT should be a mouse event."
(when (mouse-event-p event)
(mouse-set-point event))
(outline-flag-subtree t)))


;;; Rusi Additions
;;; --- compat for Emacs / Org versions ---

;; --- Emacs: pos-bol ---
(unless (fboundp 'pos-bol)
(if (fboundp 'line-beginning-position)
(defalias 'pos-bol #'line-beginning-position)
(defalias 'pos-bol #'point-at-bol))) ;; very old Emacs

;; --- Org: org-fold-show-siblings ---
(unless (fboundp 'org-fold-show-siblings)
(defalias 'org-fold-show-siblings #'org-show-siblings))

;; --- Org: org-fold-show-entry ---
(unless (fboundp 'org-fold-show-entry)
(defalias 'org-fold-show-entry #'org-show-entry))

(provide 'org-tree-slide-compt)
68 changes: 33 additions & 35 deletions org-tree-slide.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; org-tree-slide.el --- A presentation tool for org-mode
;;; org-tree-slide.el --- A presentation tool for org-mode -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2011-2023 Takaaki ISHIKAWA
;;
Expand Down Expand Up @@ -76,6 +76,7 @@
;;; Code:

(require 'org)
;; (require 'org-tree-style-compt) ;; If you need to use on older emacsen
(require 'org-timer)
(require 'face-remap)

Expand Down Expand Up @@ -210,35 +211,33 @@ If you want to show anything, just specify nil."
map)
"The keymap for `org-tree-slide'.")

(defcustom org-tree-slide-heading-level-1
'(outline-1 :height 1.5 bold)
"Level 1."
:type 'list
;; Canonical heading-level faces
(defface org-tree-slide-heading-level-1
'((t (:inherit outline-1 :height 1.5 :weight bold)))
"Face for level 1 headings in org-tree-slide."
:group 'org-tree-slide)

(defcustom org-tree-slide-heading-level-2
'(outline-2 :height 1.4 bold)
"Level 2."
:type 'list
(defface org-tree-slide-heading-level-2
'((t (:inherit outline-2 :height 1.4 :weight bold)))
"Face for level 2 headings in org-tree-slide."
:group 'org-tree-slide)

(defcustom org-tree-slide-heading-level-3
'(outline-3 :height 1.3 bold)
"Level 3."
:type 'list
(defface org-tree-slide-heading-level-3
'((t (:inherit outline-3 :height 1.3 :weight bold)))
"Face for level 3 headings in org-tree-slide."
:group 'org-tree-slide)

(defcustom org-tree-slide-heading-level-4
'(outline-4 :height 1.2 bold)
"Level 4."
:type 'list
(defface org-tree-slide-heading-level-4
'((t (:inherit outline-4 :height 1.2 :weight bold)))
"Face for level 4 headings in org-tree-slide."
:group 'org-tree-slide)

(defvar-local org-tree-slide-heading-level-1-cookie nil)
(defvar-local org-tree-slide-heading-level-2-cookie nil)
(defvar-local org-tree-slide-heading-level-3-cookie nil)
(defvar-local org-tree-slide-heading-level-4-cookie nil)

(defvar org-tree-slide--skip-comments-mode nil)
(defvar org-tree-slide-mode nil)
(defvar org-tree-slide-play-hook nil
"A hook run when `org-tree-slide--play' is evaluated to start the slideshow.")
Expand All @@ -254,6 +253,12 @@ If you want to show anything, just specify nil."
"A hook run before moving to the previous slide.")
(defvar org-tree-slide-before-content-view-hook nil
"A hook run before showing the content.")
(defvar org-tree-slide--slide-number nil)
(make-variable-buffer-local 'org-tree-slide--slide-number)

(defvar org-tree-slide--lighter " TSlide"
"Lighter for `org-tree-slide'.
This is displayed by default if `org-tree-slide-modeline-display' is nil.")

;;;###autoload
(define-minor-mode org-tree-slide-mode
Expand Down Expand Up @@ -374,7 +379,7 @@ Profiles:
((or
(or (and (org-tree-slide--before-first-heading-p)
(not (org-at-heading-p)))
(and (= (point-at-bol) 1) (not (buffer-narrowed-p))))
(and (= (line-beginning-position) 1) (not (buffer-narrowed-p))))
(or (org-tree-slide--first-heading-with-narrow-p)
(not (org-at-heading-p))))
(run-hooks 'org-tree-slide-before-move-next-hook)
Expand Down Expand Up @@ -538,12 +543,6 @@ See also `org-tree-slide-skip-comments'."
(format " %s" (org-tree-slide--count-slide (point))))))

;;; Internal functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar org-tree-slide--slide-number nil)
(make-variable-buffer-local 'org-tree-slide--slide-number)

(defvar org-tree-slide--lighter " TSlide"
"Lighter for `org-tree-slide'.
This is displayed by default if `org-tree-slide-modeline-display' is nil.")

(defun org-tree-slide--line-number-at-pos ()
"Return the line number when widen."
Expand Down Expand Up @@ -571,7 +570,6 @@ This is displayed by default if `org-tree-slide-modeline-display' is nil.")
"Flag to check the status of overlay for a slide header.")

(defvar org-tree-slide--header-face-autoconfig nil)
(defvar org-tree-slide--skip-comments-mode nil)
(defun org-tree-slide--setup ()
"Setup."
(when (org-tree-slide--active-p)
Expand Down Expand Up @@ -603,12 +601,13 @@ This is displayed by default if `org-tree-slide-modeline-display' is nil.")
(message "%s" org-tree-slide-activate-message))))

(defvar org-tree-slide-startup "overview"
"If you have \"#+startup:\" line in your org buffer, the org buffer will be shown with corresponding status \(content, showall, overview:default\).")
"If you have \"#+startup:\" line in your org buffer, the org buffer will be
shown with corresponding status \(content, showall, overview:default\).")

(defun org-tree-slide--stop ()
"Stop the slide view, and redraw the orgmode buffer with #+STARTUP:."
(widen)
(org-show-siblings)
(org-fold-show-siblings)
(when (or org-tree-slide-cursor-init (org-tree-slide--before-first-heading-p))
(goto-char (point-min))
(org-overview)
Expand All @@ -635,10 +634,10 @@ This is displayed by default if `org-tree-slide-modeline-display' is nil.")
(setq org-tree-slide--slide-number
(format " %s" (org-tree-slide--count-slide (point))))
(setq org-tree-slide--previous-line (org-tree-slide--line-number-at-pos)))
(goto-char (point-at-bol))
(goto-char (line-beginning-position))
(unless (org-tree-slide--before-first-heading-p)
(outline-hide-subtree) ; support CONTENT (subtrees are shown)
(org-show-entry)
(org-fold-show-entry)
;; If this is the last level to be displayed, show the full content
(if (and (not org-tree-slide-fold-subtrees-skipped)
(org-tree-slide--heading-level-skip-p (1+ (org-outline-level))))
Expand Down Expand Up @@ -900,13 +899,13 @@ Otherwise, return the point. This doesn't check whether skipping or not."
(status
(setq
org-tree-slide-heading-level-1-cookie
(face-remap-add-relative 'org-level-1 org-tree-slide-heading-level-1)
(face-remap-add-relative 'org-level-1 'org-tree-slide-heading-level-1)
org-tree-slide-heading-level-2-cookie
(face-remap-add-relative 'org-level-2 org-tree-slide-heading-level-2)
(face-remap-add-relative 'org-level-2 'org-tree-slide-heading-level-2)
org-tree-slide-heading-level-3-cookie
(face-remap-add-relative 'org-level-3 org-tree-slide-heading-level-3)
(face-remap-add-relative 'org-level-3 'org-tree-slide-heading-level-3)
org-tree-slide-heading-level-4-cookie
(face-remap-add-relative 'org-level-4 org-tree-slide-heading-level-4)))
(face-remap-add-relative 'org-level-4 'org-tree-slide-heading-level-4)))
(t
(face-remap-remove-relative org-tree-slide-heading-level-1-cookie)
(face-remap-remove-relative org-tree-slide-heading-level-2-cookie)
Expand Down Expand Up @@ -980,7 +979,7 @@ If the cursor exist before first heading, do nothing."
*** second ; nil
hoge ; nil
*** third ; nil"
(and (buffer-narrowed-p) (= (point-at-bol) (point-min))))
(and (buffer-narrowed-p) (= (line-beginning-position) (point-min))))

(defun org-tree-slide--all-skip-p ()
"Check the buffer has at least one slide to be shown."
Expand All @@ -1003,7 +1002,6 @@ If every heading is specified as skip, return nil.
(goto-char target)
(org-tree-slide--beginning-of-tree)
(let ((p (point))
(v (goto-char (1+ (buffer-size))))
(l (org-tree-slide--last-point-at-bot)))
(if l
(= p l)
Expand Down