Skip to content

Commit

Permalink
Allow choosing heading level to use as frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
punchagan committed Jun 20, 2011
1 parent 386fd46 commit f4b4a86
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
38 changes: 32 additions & 6 deletions epresent.el
Expand Up @@ -78,6 +78,9 @@
(defvar epresent-hide-tags t)
(defvar epresent-hide-properties t)

(defvar epresent-frame-level 1)
(make-variable-frame-local 'epresent-frame-local) ;; Obsolete function?

(defvar epresent-mode-line nil
"Set the mode-line format. Hides it when nil")

Expand All @@ -99,13 +102,25 @@
epresent--frame)

;; functions
(defun epresent-get-frame-level ()
"Get the heading level to show as different frames."
(interactive)
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(if (re-search-forward
"^#\\+EPRESENT_FRAME_LEVEL:[ \t]*\\(.*?\\)[ \t]*$" nil t)
(string-to-number (match-string 1))
1))))

(defun epresent-goto-top-level ()
"Go to the current top level heading containing point."
(interactive)
(unless (org-at-heading-p) (outline-previous-heading))
(let ((level (org-current-level)))
(when (and level (> level 1))
(outline-up-heading (- level 1)))))
(let ((level (ignore-errors (org-reduced-level (org-current-level)))))
(when (and level (> level epresent-frame-level))
(org-up-heading-all (- level epresent-frame-level)))))

(defun epresent-current-page ()
"Present the current outline heading."
Expand All @@ -114,7 +129,10 @@
(progn
(epresent-goto-top-level)
(org-show-subtree)
(org-narrow-to-subtree))
(org-narrow-to-subtree)
(when (< (org-reduced-level (org-current-level))
epresent-frame-level)
(org-cycle '(16)))) ;; this doesn't seem to be working
;; before first headline -- fold up subtrees as TOC
(org-cycle '(4))))

Expand All @@ -130,15 +148,22 @@
(interactive)
(epresent-goto-top-level)
(widen)
(org-get-next-sibling)
(if (< (or (ignore-errors (org-reduced-level (org-current-level))) 0)
epresent-frame-level)
(outline-next-heading)
(org-get-next-sibling))
(epresent-current-page))

(defun epresent-previous-page ()
"Present the previous outline heading."
(interactive)
(epresent-goto-top-level)
(widen)
(or (org-get-last-sibling) (goto-char (point-min)))
(org-content)
(if (< (or (ignore-errors (org-reduced-level (org-current-level))) 0)
epresent-frame-level)
(outline-previous-heading)
(org-get-last-sibling))
(epresent-current-page))

(defun epresent-clean-overlays ()
Expand Down Expand Up @@ -283,6 +308,7 @@
(interactive)
(unless (eq major-mode 'org-mode)
(error "EPresent can only be used from Org Mode"))
(setq epresent-frame-level (epresent-get-frame-level))
(setq epresent--org-buffer (current-buffer))
(epresent--get-frame)
(epresent-mode)
Expand Down
2 changes: 1 addition & 1 deletion present.org
@@ -1,6 +1,6 @@
#+Title: Example Presentation
#+Author: Eric Schulte

#+EPRESENT_FRAME_LEVEL: 1
* TODO One -- intro :hello:world:
:PROPERTIES:
:ARCHIVE: hello
Expand Down

0 comments on commit f4b4a86

Please sign in to comment.