2017-06-08 11:47:56 +02:00
|
|
|
;;; app/present/autoload.el -*- lexical-binding: t; -*-
|
2017-04-07 20:05:21 -04:00
|
|
|
|
2017-04-11 09:24:20 -04:00
|
|
|
;; --- impatient-mode -------------------------------------------------------------
|
|
|
|
|
2017-04-07 20:05:21 -04:00
|
|
|
;;;###autoload
|
2017-04-11 09:24:20 -04:00
|
|
|
(defun +present/impatient-mode ()
|
2017-04-07 20:05:21 -04:00
|
|
|
(interactive)
|
|
|
|
(require 'simple-httpd)
|
|
|
|
(unless (process-status "httpd")
|
|
|
|
(httpd-start))
|
2017-04-11 09:24:20 -04:00
|
|
|
(impatient-mode)
|
|
|
|
(if impatient-mode
|
|
|
|
(add-hook 'kill-buffer-hook '+present--cleanup-impatient-mode)
|
|
|
|
(+present--cleanup-impatient-mode)))
|
|
|
|
|
|
|
|
(defun +present--cleanup-impatient-mode ()
|
2017-06-08 11:47:56 +02:00
|
|
|
(unless (cl-loop for buf in (doom-buffer-list)
|
|
|
|
if (buffer-local-value 'impatient-mode buf)
|
|
|
|
return t)
|
2017-04-11 09:24:20 -04:00
|
|
|
(httpd-stop)
|
|
|
|
(remove-hook 'kill-buffer-hook '+present--cleanup-impatient-mode)))
|
|
|
|
|
|
|
|
|
|
|
|
;; --- org tree slides ------------------------------------------------------------
|
|
|
|
|
|
|
|
(defvar +present--overlays-list nil)
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +present/org-tree-slides ()
|
|
|
|
(interactive)
|
|
|
|
(unless (derived-mode-p 'org-mode)
|
|
|
|
(error "Not in an org buffer"))
|
|
|
|
(call-interactively 'org-tree-slide-mode)
|
|
|
|
(add-hook 'kill-buffer-hook '+present--cleanup-org-tree-slides-mode))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +present|add-overlays ()
|
|
|
|
(add-to-invisibility-spec '(+present))
|
|
|
|
(save-excursion
|
|
|
|
;; hide org-mode options starting with #+
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "^[[:space:]]*\\(#\\+\\)\\(\\(?:BEGIN\\|END\\|ATTR\\)[^[:space:]]+\\).*" nil t)
|
|
|
|
(+present--make-invisible
|
|
|
|
(match-beginning 1)
|
|
|
|
(match-end 0)))
|
|
|
|
;; hide stars in headings
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "^\\(\\*+\\s-\\)" nil t)
|
|
|
|
(+present--make-invisible (match-beginning 1) (match-end 1)))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +present|remove-overlays ()
|
2017-04-17 02:17:10 -04:00
|
|
|
(mapc #'delete-overlay +present--overlays-list)
|
2017-04-11 09:24:20 -04:00
|
|
|
(remove-from-invisibility-spec '(+present)))
|
|
|
|
|
2017-04-11 18:47:22 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defun +present|detect-slide ()
|
|
|
|
(outline-show-all)
|
|
|
|
(if (member "title" (org-get-tags-at))
|
|
|
|
(text-scale-set 10)
|
|
|
|
(text-scale-set +present-scale)))
|
|
|
|
|
2017-04-11 09:24:20 -04:00
|
|
|
(defun +present--cleanup-org-tree-slides-mode ()
|
2017-06-08 11:47:56 +02:00
|
|
|
(unless (cl-loop for buf in (doom-buffers-in-mode 'org-mode)
|
|
|
|
if (buffer-local-value 'org-tree-slide-mode buf)
|
|
|
|
return t)
|
2017-04-11 09:24:20 -04:00
|
|
|
(org-tree-slide-mode -1)
|
2017-04-17 02:17:10 -04:00
|
|
|
(remove-hook 'kill-buffer-hook #'+present--cleanup-org-tree-slides-mode)))
|
2017-04-11 09:24:20 -04:00
|
|
|
|
|
|
|
(defun +present--make-invisible (beg end)
|
|
|
|
(let ((overlay (make-overlay beg end)))
|
|
|
|
(push overlay +present--overlays-list)
|
|
|
|
(overlay-put overlay 'invisible '+present)))
|
|
|
|
|
2017-04-11 18:47:22 -04:00
|
|
|
|
2017-04-11 09:24:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
;; --- misc -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
(defvar +present--original-font +doom-font)
|
2017-04-07 20:05:21 -04:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(define-minor-mode +present/big-mode
|
2017-04-17 02:20:07 -04:00
|
|
|
"A global mode that resizes the font, for streams, screen-sharing and
|
|
|
|
presentations."
|
2017-04-07 20:05:21 -04:00
|
|
|
:init-value nil
|
|
|
|
:lighter " BIG"
|
|
|
|
:global t
|
2017-04-11 09:24:20 -04:00
|
|
|
(if +present/big-mode
|
2017-04-07 20:05:21 -04:00
|
|
|
(set-frame-font +present-big-font t t)
|
2017-04-11 09:24:20 -04:00
|
|
|
(set-frame-font +present--original-font t t)))
|
2017-04-07 20:05:21 -04:00
|
|
|
|
|
|
|
;;;###autoload
|
2017-04-11 09:24:20 -04:00
|
|
|
(defun +present/resize-frame-for-stream ()
|
2017-04-07 20:05:21 -04:00
|
|
|
"Resize the frame pixelwise, so that it fits directly into my livecoding.tv
|
|
|
|
streaming layout."
|
|
|
|
(interactive)
|
|
|
|
(set-frame-width (selected-frame) 1325 nil t)
|
|
|
|
(set-frame-height (selected-frame) 1080 nil t))
|