# HG changeset patch # User Zachary Kanfer # Date 1528173495 14400 # Tue Jun 05 00:38:15 2018 -0400 # Node ID 55fc14b66e2ea506247a4e7dd622a9dfe5545c4b # Parent e2e34c061ff5610e99311522d7269bab8e32a1b9 Name the presentation buffer "zpresent: $SOURCE_FILE". diff --git a/zpresent.el b/zpresent.el --- a/zpresent.el +++ b/zpresent.el @@ -110,6 +110,9 @@ (defvar zpresent-default-background-color "#E0E0E0" "The default color placed over all fonts in the background.") +(defvar zpresent-buffer-name "" + "The name of the buffer used to present in.") + ;;;; Faces: (defface zpresent-whole-screen-face `((t . (:background ,zpresent-default-background-color))) "Face that should be put over the whole screen.") @@ -118,7 +121,7 @@ (defface zpresent-title-slide-title '((t . (:height 1.5 :inherit zpresent-base))) "Face for titles in a title slide." :group 'zpresent-faces) (defface zpresent-body '((t . (:height 0.66 :inherit zpresent-base))) "Face for the body." :group 'zpresent-faces) -(defvar zpresent-whole-screen-overlay (with-current-buffer (get-buffer-create "zpresentation") (make-overlay 0 0)) +(defvar zpresent-whole-screen-overlay (make-overlay 0 0) "The overlay that's put over all the text in the screen. Its purpose is to color the background color, and possibly other text properties too.") (overlay-put zpresent-whole-screen-overlay 'face 'zpresent-whole-screen-face) @@ -135,7 +138,9 @@ (setq zpresent-images (make-hash-table :test #'equal)) (zpresent--cache-images zpresent-slides) - (switch-to-buffer "zpresentation") + (setq zpresent-buffer-name (zpresent--presentation-buffer-name)) + + (switch-to-buffer zpresent-buffer-name) (font-lock-mode 0) (zpresent-mode) @@ -151,6 +156,10 @@ (zpresent--redisplay)) +(defun zpresent--presentation-buffer-name () + "Get the name of the presentation buffer." + (format "zpresentation: %s" (file-name-base (buffer-file-name)))) + (defun zpresent--format (structure-list) "Convert an STRUCTURE-LIST into a list of slides." (cl-mapcan #'zpresent--format-structure @@ -623,14 +632,15 @@ zpresent-default-background-color))))) (move-overlay zpresent-whole-screen-overlay (point-min) - (point-max)) + (point-max) + (get-buffer zpresent-buffer-name)) (goto-char (point-min))) (defun zpresent--present-normal-slide (slide) "Present SLIDE as a normal (read: non-title) slide." (interactive) - (switch-to-buffer "zpresentation") - (buffer-disable-undo "zpresentation") + (switch-to-buffer zpresent-buffer-name) + (buffer-disable-undo zpresent-buffer-name) (let ((inhibit-read-only t)) (erase-buffer) (insert "\n") @@ -641,8 +651,8 @@ (defun zpresent--present-title-slide (slide) "Present SLIDE as a title slide." - (switch-to-buffer "zpresentation") - (buffer-disable-undo "zpresentation") + (switch-to-buffer zpresent-buffer-name) + (buffer-disable-undo zpresent-buffer-name) (let ((inhibit-read-only t) (title-lines (zpresent--get-lines-for-title (gethash :title slide) (window-max-chars-per-line nil 'zpresent-title-slide-title)))) (erase-buffer) @@ -664,8 +674,8 @@ (defun zpresent--present-full-screen-image (slide) "Present SLIDE as a full screen image." - (switch-to-buffer "zpresentation") - (buffer-disable-undo "zpresentation") + (switch-to-buffer zpresent-buffer-name) + (buffer-disable-undo zpresent-buffer-name) (let ((inhibit-read-only t)) (erase-buffer) (when-let ((image-location (assoc-default "image" (gethash :properties slide) #'equal)) @@ -920,7 +930,7 @@ #s(hash-table data (title ("title manually split" "onto three" "lines (this one is pretty gosh darn long, but it shouldn't be automatically split no matter how long it is.)"))) #s(hash-table data (title "an automatically split really really really really really really really really really long title")))) - (switch-to-buffer "zpresentation") + (switch-to-buffer zpresent-buffer-name) (font-lock-mode 0) (zpresent-mode)