Skip to content

Commit

Permalink
fixed to use common infrastructure, handle more cases, narrow/widen o…
Browse files Browse the repository at this point in the history
…n entry/exit
  • Loading branch information
BartMassey authored and Bart Massey committed Apr 18, 2008
1 parent 83514f1 commit eb3d8d2
Showing 1 changed file with 40 additions and 13 deletions.
53 changes: 40 additions & 13 deletions slide-mode.el
Expand Up @@ -13,21 +13,16 @@
(defun slide-build-mode-map ()
"Build the mode map for slide mode."
(let ((map (make-keymap)))
(define-key map "\C-n" 'next-slide)
(define-key map "\C-c\C-n" 'next-slide)
(define-key map "\C-c\C-p" 'previous-slide)
map))

;; define the mode
(define-minor-mode slide-mode
"Toggle minor mode for display of slides."
nil " Slides" (slide-build-mode-map)
t)

;; move to the next slide
(defun next-slide ()
"Go to next slide."
(interactive)
(widen)
(if (re-search-forward "^\C-l$" (point-max) t)
;; Actually display the current slide.
;; Must be widened at entry,
;; will be narrowed at exit.
(defun display-slide ()
(setq here (point))
(if (re-search-backward "^\C-l$" (point-min) t)
(beginning-of-line 2)
(goto-char (point-min)))
(setq start (point))
Expand All @@ -38,3 +33,35 @@
(goto-char (point-min))
(recenter)
(goto-char (point-max)))

;; Define the mode.
;; When mode is activated,
;; narrow on current slide.
;; When mode is deactivated,
;; widen.
(define-minor-mode slide-mode
"Toggle minor mode for display of slides."
nil " Slides" (slide-build-mode-map)
(widen)
(if slide-mode
(display-slide)))

;; move to the next slide
(defun next-slide ()
"Go to next slide."
(interactive)
(widen)
(if (re-search-forward "^\C-l$" (point-max) t)
(progn
(beginning-of-line 2)
(display-slide))))

;; move to the previous slide
(defun previous-slide ()
"Go to previous slide."
(interactive)
(widen)
(if (re-search-backward "^\C-l$" (point-min) t)
(progn
(beginning-of-line nil)
(display-slide))))

0 comments on commit eb3d8d2

Please sign in to comment.