extra => custom

This commit is contained in:
Henrik Lissner 2016-06-08 03:10:27 -04:00
parent ba011b6ffe
commit 4057c56e4c
7 changed files with 120 additions and 147 deletions

10
init.el
View file

@ -83,11 +83,11 @@
module-eshell ; for inferior OSes *cough*windows
module-org ; for organized fearless leader
;;; Extra libraries
extra-demo ; allow me to demonstrate...
extra-tags ; if you liked it you should've generated a tag for it
extra-tmux ; close the rift between GUI & terminal
extra-write ; Emacs as a word processor
;;; Custom modules
custom-demo ; allow me to demonstrate...
custom-tags ; if you liked it you should've generated a tag for it
custom-tmux ; close the rift between GUI & terminal
custom-write ; Emacs as a word processor
;;; Personal
my-commands

55
modules/custom-demo.el Normal file
View file

@ -0,0 +1,55 @@
;;; custom-demo.el --- -*- no-byte-compile: t; -*-
(defvar powerline-height)
;; This library offers:
;; + impatient-mode: for broadcasting my emacs session
;; + big-mode: for enlarged text while screencasting
;; + TODO integration with reveal.js for presentations
;; + TODO peer programming collab
;; Big-mode settings
(defconst big-mode-font (font-spec :family "Inconsolata" :size 16))
(defconst big-mode-line-spacing 0)
(defconst big-mode-modeline-height 35)
;;
(use-package impatient-mode
:commands impatient-mode
:config (httpd-start))
(defvar big-mode--old-line-spacing line-spacing)
(defvar big-mode--old-modeline-height powerline-height)
(define-minor-mode big-mode
:init-value nil
:lighter " BIG"
:global t
(when big-mode-font
(doom/load-font (if big-mode big-mode-font doom-default-font)))
(if big-mode
(setq-default
powerline-height big-mode-modeline-height
line-spacing big-mode-line-spacing)
(setq-default
powerline-height big-mode--old-modeline-height
line-spacing big-mode--old-line-spacing)))
(evil-define-command doom:big (&optional size)
"Use to enable large text mode."
(interactive "<a>")
(if size
(let ((big-mode-font big-mode-font))
(big-mode -1)
(font-put big-mode-font :size (string-to-int size))
(big-mode +1))
(big-mode (if big-mode -1 +1))))
(defun doom/resize-for-stream ()
"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))
(provide 'custom-demo)
;;; custom-demo.el ends here

View file

@ -1,4 +1,4 @@
;;; extra-tags.el
;;; custom-tags.el
;; WIP
@ -27,6 +27,7 @@
;;;###autoload
(defun doom/find-def ()
"Find definition using tags, falling back to dumb-jump otherwise."
(interactive)
(let ((orig-pt (point))
(orig-file (buffer-file-name)))
@ -44,5 +45,5 @@
(let ((path (expand-file-name ".tags" (doom/project-root))))
(and (f-exists? path) path)))
(provide 'extra-tags)
;;; extra-tags.el ends here
(provide 'custom-tags)
;;; custom-tags.el ends here

View file

@ -1,4 +1,4 @@
;;; extra-tmux.el
;;; custom-tmux.el
;; This library offers:
;; + A way of communicating with a tmux instance
@ -24,7 +24,7 @@
:ex-arg shell
(list (when (evil-ex-p) (evil-ex-file-arg))))
;;;###autoload (autoload 'doom:tmux-cd "extra-tmux" nil t)
;;;###autoload (autoload 'doom:tmux-cd "custom-tmux" nil t)
(evil-define-command doom:tmux-cd (&optional bang)
(interactive "<!>")
(if bang
@ -32,7 +32,7 @@
(doom/tmux-cd-to-here)))
(defvar doom-tmux-last-command nil "The last command sent to tmux")
;;;###autoload (autoload 'doom:tmux "extra-tmux" nil t)
;;;###autoload (autoload 'doom:tmux "custom-tmux" nil t)
(evil-define-operator doom:tmux (&optional command bang)
"Sends input to tmux. Use `bang' to append to tmux"
:type inclusive
@ -56,5 +56,5 @@
(interactive)
(doom/tmux-cd-to-here (doom/project-root)))
(provide 'extra-tmux)
;;; extra-tmux.el ends here
(provide 'custom-tmux)
;;; custom-tmux.el ends here

51
modules/custom-write.el Normal file
View file

@ -0,0 +1,51 @@
;; custom-write.el
;; This library offers the following:
;; + Write-mode: a mode that turns Emacs into an app for writing notes,
;; papers, or fiction: it adds eye-candy to org-mode, switches to a light
;; color theme and to a more readable font.
;; + Bibtex integration
;; Write-mode settings
(defconst write-mode-theme 'doom-one)
(defconst write-mode-font (font-spec :family "Source Sans Pro" :size 14))
(defconst write-mode--last-mode-line mode-line-format)
(defconst write-mode--last-theme doom-current-theme)
(defconst write-mode--last-line-spacing line-spacing)
(after! spaceline
(spaceline-compile
'write
'(((*macro-recording *anzu *iedit *evil-substitute *flycheck)
:skip-alternate t
:tight t)
*buffer-path
*buffer-modified)
'((*selection-info :when active)
*buffer-encoding-abbrev
(global :when active)
*buffer-position
*pad)))
(defvar write-mode nil)
(defun doom/write-mode ()
"A mode that turns Emacs into an app for writing notes, papers, or fiction: it
adds eye-candy to org-mode, switches to a light color theme and to a more
readable font."
(interactive)
(setq write-mode (not write-mode))
(when write-mode-theme
(doom/load-theme (if write-mode write-mode-theme write-mode--last-theme) t))
(when write-mode-font
(doom/load-font (if write-mode write-mode-font doom-default-font)))
(mapc (lambda (b)
(with-current-buffer b
(setq line-spacing (if write-mode write-mode--last-line-spacing '2))
(when (featurep 'spaceline)
(let ((doom-hide-mode-line-format '("%e" (:eval (spaceline-ml-write)))))
(doom-hide-mode-line-mode (if write-mode +1 -1))))))
(doom/get-buffers-in-modes '(org-mode markdown-mode))))
(provide 'custom-write)
;;; custom-write.el ends here

View file

@ -1,51 +0,0 @@
;;; extra-demo.el --- -*- no-byte-compile: t; -*-
(defvar powerline-height)
;; This library offers:
;; + impatient-mode: for broadcasting my emacs session
;; + big-mode: for enlarged text while screencasting
;; + TODO integration with reveal.js for presentations
;; + TODO peer programming collab
;; Big-mode settings
(defconst big-mode-font (font-spec :family "Inconsolata" :size 16))
(defconst big-mode-line-spacing 0)
(defconst big-mode-modeline-height 35)
;;
(use-package impatient-mode
:commands impatient-mode
:config (httpd-start))
(defvar big-mode--line-spacing line-spacing)
(defvar big-mode--powerline-height powerline-height)
(define-minor-mode big-mode
:init-value nil
:lighter " BIG"
:global t
(doom/load-font (if big-mode big-mode-font doom-default-font))
(setq-default
powerline-height
(if big-mode big-mode-modeline-height big-mode--powerline-height)
line-spacing
(if big-mode big-mode-line-spacing big-mode--line-spacing))
(if big-mode
(progn
(setq neo-window-width 25)
(add-hook 'neo-after-create-hook 'doom|text-scale-1))
(setq neo-window-width 28)
(remove-hook 'neo-after-create-hook 'doom|text-scale-1)))
(defun doom|text-scale-1 (&rest _)
(text-scale-set -1) (setq line-spacing 0))
(evil-define-command doom:big-mode (&optional size)
(interactive "<a>")
(let ((big-mode-font big-mode-font))
(when (and size (not big-mode))
(font-put big-mode-font :size (string-to-int size)))
(big-mode (if big-mode -1 +1))))
(provide 'extra-demo)
;;; extra-demo.el ends here

View file

@ -1,83 +0,0 @@
;; extra-write.el
;; This library offers the following:
;; + TODO Write-mode: a mode that turns Emacs into an app for writing notes, papers, or
;; fiction: it adds eye-candy to org-mode, switches to a light color theme and to a
;; more readable font.
;; + Bibtex integration
;; Write-mode settings
(defconst write-mode nil)
(defconst write-mode-theme 'doom-light)
(defconst write-mode-font (font-spec :family "Hack" :size 12))
(defconst write-mode--last-mode-line mode-line-format)
(defconst write-mode--last-theme doom-current-theme)
(defconst write-mode--last-line-spacing line-spacing)
(after! spaceline
(spaceline-compile
'write
'(((*macro-recording *anzu *iedit *evil-substitute *flycheck)
:skip-alternate t
:tight t)
*buffer-path
*buffer-modified)
'((*selection-info :when active)
*buffer-encoding-abbrev
(global :when active)
*buffer-position
*pad)))
;;
(defun write-mode|org-hook ()
"A hook that runs in org-mode buffers when `write-mode' is active."
(when write-mode
(setq header-line-format '("%e" (:eval (spaceline-ml-write)))
mode-line-format nil)))
(defun write-mode-toggle ()
"Enable write-mode, this is not a [global] minor mode because it mixes some frame-local
functionality with buffer-local ones, which can be buggy in a minor-mode."
(interactive)
(let* ((mode-p write-mode)
(on-off (if mode-p -1 +1)))
(doom/load-theme (if mode-p write-mode--last-theme write-mode-theme) t)
(doom/load-font (if mode-p doom-default-font write-mode-font))
(if mode-p
(remove-hook 'org-mode-hook 'write-mode|org-hook)
(add-hook 'org-mode-hook 'write-mode|org-hook))
(mapc (lambda (b)
(with-current-buffer b
(setq line-spacing (if mode-p write-mode--last-line-spacing '2))
(when (and (eq major-mode 'org-mode)
(not mode-p))
(write-mode|org-hook))
(unless mode-p
(setq mode-line-format write-mode--last-mode-line
header-line-format nil))))
(doom/get-buffers-in-modes '(org-mode markdown-mode)))
(setq write-mode (not mode-p))))
(when (> emacs-major-version 24)
;; From <https://github.com/joostkremers/visual-fill-column/pull/6>
;; Splitting windows while visual-fill-column makes Emacs go crazy. This prevents that
;; by simply disabled VFC before splitting.
(after! visual-fill-column
(advice-add 'split-window :around #'visual-fill-column--disable-on-split-window))
(defun visual-fill-column--disable-on-split-window (fn window &rest args)
"Undo the effects of `visual-fill-column-mode' for splitting window."
(if (and (or (not window) (window-live-p window))
(buffer-local-value 'visual-fill-column-mode
(window-buffer (or window (selected-window)))))
(let ((inhibit-redisplay t))
(set-window-fringes (or window (selected-window)) nil)
(set-window-margins (or window (selected-window)) 0 0)
(unwind-protect (apply fn window args)
(save-selected-window
(when window (select-window window 'norecord))
(visual-fill-column--adjust-window))))
(apply fn window args))))
(provide 'extra-write)
;;; extra-write.el ends here