Skip to content

Commit

Permalink
Refine displaying slide number in modeline
Browse files Browse the repository at this point in the history
  • Loading branch information
takaxp committed Feb 14, 2015
1 parent 0abef68 commit 69e8cd0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2015-02-14 Takaaki ISHIKAWA <[email protected]>

* org-tree-slide: Refine displaying slide number in modeline
- If 'lighter is specified, the slide number will be updated aggressively, then it's slow. On the other hand, 'outside is specified which will be shown quickly in the same position of 'lighter because it changes the number only if a slide is moved to the next/previous slide.

* org-tree-slide: Added two hooks
- org-tree-slide-mode-before-narrow-hook
- org-tree-slide-mode-after-narrow-hook

2015-01-12 Takaaki ISHIKAWA <[email protected]>

* org-tree-slide.el (ots-stop): Suppress an error message from org-timer
Expand Down
5 changes: 3 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#+TITLE: README for Org Tree Slide
#+AUTHOR: Takaaki Ishikawa
#+EMAIL: [email protected]
#+DATE: 2015-01-12
#+UPDATE: 19:58:48
#+DATE: 2015-02-14
#+UPDATE: 23:48:25
#+STARTUP: content

* 1. What's this?
Expand Down Expand Up @@ -219,6 +219,7 @@ see also ChangeLog
|---------+------------------+-------------------------------------------------|
| Version | Date | Description |
|---------+------------------+-------------------------------------------------|
| v2.7.4 | 2015-02-14@23:30 | Refine displaying slide number in modeline |
| v2.7.2 | 2015-01-12@19:56 | Suppress an error message from org-timer |
| v2.7.1 | 2015-01-12@18:28 | Hide skipped slides when CONTENT mode |
| v2.7.0 | 2013-07-21@05:21 | Support buffers without headings |
Expand Down
41 changes: 24 additions & 17 deletions org-tree-slide.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; org-tree-slide.el --- A presentation tool for org-mode
;;
;; Copyright (C) 2011-2014 Takaaki ISHIKAWA
;; Copyright (C) 2011-2015 Takaaki ISHIKAWA
;;
;; Author: Takaaki ISHIKAWA <takaxp at ieee dot org>
;; Maintainer: Takaaki ISHIKAWA <takaxp at ieee dot org>
Expand Down Expand Up @@ -68,7 +68,7 @@
(require 'org-timer)
(require 'org-clock) ; org-clock-in, -out, -clocking-p

(defconst org-tree-slide "2.7.1"
(defconst org-tree-slide "2.7.4"
"The version number of the org-tree-slide.el")

(defgroup org-tree-slide nil
Expand Down Expand Up @@ -149,8 +149,8 @@

(defcustom org-tree-slide-modeline-display 'outside
"Specify how to display the slide number in mode line.
'outside: shown in the mode line outside of lighter
'lighter: shown in lighter (slow)
'lighter: shown in lighter (update info actively, then it's slow)
'outside: update infomation when moving to the next/previous slide
nil: nothing to be shown"
:type 'symbol
:group 'org-tree-slide)
Expand Down Expand Up @@ -189,7 +189,10 @@
"A hook run when ots-play is evaluated to start the slide show")
(defvar org-tree-slide-mode-stop-hook nil
"A hook run when ots-stop is evaluated to stop the slide show")
(defvar display-tree-slide-string nil)
(defvar org-tree-slide-mode-before-narrow-hook nil
"A hook run before evaluating ots-display-tree-with-narrow")
(defvar org-tree-slide-mode-after-narrow-hook nil
"A hook run after evaluating ots-display-tree-with-narrow")

;;;###autoload
(define-minor-mode org-tree-slide-mode
Expand Down Expand Up @@ -237,8 +240,6 @@ Profiles:
:keymap org-tree-slide-mode-map
:group 'org-tree-slide
:require 'org
(setq display-tree-slide-string "")
(or global-mode-string (setq global-mode-string '("")))
(if org-tree-slide-mode
(ots-setup)
(ots-abort)))
Expand Down Expand Up @@ -365,7 +366,7 @@ Profiles:
(interactive)
(setq org-tree-slide-skip-done (not org-tree-slide-skip-done))
(setq ots-previous-line -1) ; to update modeline intentionally
(ots-update-modeline)
(ots-show-slide-header)
(if org-tree-slide-skip-done
(message "TODO Pursuit: ON") (message "TODO Pursuit: OFF")))

Expand All @@ -381,7 +382,8 @@ Profiles:
"Display the next slide"
(interactive)
(when (ots-active-p)
(message " Next >>")
(unless (equal org-tree-slide-modeline-display 'outside)
(message " Next >>"))
(cond
((or
(or (and (ots-before-first-heading-p) (not (org-at-heading-p)))
Expand All @@ -401,7 +403,8 @@ Profiles:
"Display the previous slide"
(interactive)
(when (ots-active-p)
(message "<< Previous")
(unless (equal org-tree-slide-modeline-display 'outside)
(message "<< Previous"))
(ots-hide-slide-header) ; for at the first heading
(widen)
(cond
Expand All @@ -420,7 +423,9 @@ Profiles:
(goto-char (point-min)))))

;;; Internal functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar ots-slide-number " TSlide")
(defvar ots-slide-number nil)
(make-variable-buffer-local 'ots-slide-number)
(setq-default ots-slide-number " TSlide")
(defvar ots-previous-line 0)

(defun ots-line-number-at-pos ()
Expand All @@ -436,17 +441,15 @@ Profiles:
(setq ots-slide-number (format " %s" (ots-count-slide (point))))
(setq ots-previous-line (ots-line-number-at-pos))
ots-slide-number)
((equal org-tree-slide-modeline-display 'outside) "")
;; just return the current ots-slide-number quickly.
((equal org-tree-slide-modeline-display 'outside) ots-slide-number)
(t " TSlide"))))

(defvar ots-header-overlay nil
"Flag to check the status of overlay for a slide header.")

(defun ots-setup ()
(when (ots-active-p)
(or (memq 'display-tree-slide-string global-mode-string)
(setq global-mode-string
(append global-mode-string '(display-tree-slide-string))))
(ots-play)))

(defun ots-abort ()
Expand Down Expand Up @@ -502,18 +505,22 @@ Profiles:

(defun ots-display-tree-with-narrow ()
"Show a tree with narrowing and also set a header at the head of slide."
(run-hooks 'org-tree-slide-mode-before-narrow-hook)
(when (equal org-tree-slide-modeline-display 'outside)
(setq ots-slide-number (format " %s" (ots-count-slide (point))))
(setq ots-previous-line (ots-line-number-at-pos)))
(goto-char (point-at-bol))
(unless (ots-before-first-heading-p)
(hide-subtree) ; support CONTENT (subtrees are shown)
(org-show-entry)
(show-children)
;; (org-cycle-hide-drawers 'all) ; disabled due to performance reduction
(org-narrow-to-subtree))
(ots-update-modeline)
(when org-tree-slide-slide-in-effect
(ots-slide-in org-tree-slide-slide-in-brank-lines))
(when org-tree-slide-header
(ots-show-slide-header)))
(ots-show-slide-header))
(run-hooks 'org-tree-slide-mode-after-narrow-hook))

(defun ots-outline-next-heading ()
(ots-outline-select-method
Expand Down

0 comments on commit 69e8cd0

Please sign in to comment.