Rewrite extras-write library
This commit is contained in:
parent
d4c035df15
commit
44f4593132
1 changed files with 28 additions and 12 deletions
|
@ -8,16 +8,31 @@
|
|||
|
||||
;; Write-mode settings
|
||||
(defconst write-mode nil)
|
||||
(defconst write-mode-font (font-spec :family "Hack" :size 14))
|
||||
(defconst write-mode-biblio-dir "~/Dropbox/docs/biblio")
|
||||
(defconst write-mode-theme 'narf-light)
|
||||
(defconst write-mode-font (font-spec :family "Hack" :size 12))
|
||||
|
||||
(defconst write-mode--last-mode-line mode-line-format)
|
||||
(defconst write-mode--last-line-spacing line-spacing)
|
||||
|
||||
(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 everytime an org-mode buffer is visited/created while `write-mode' is
|
||||
active.")
|
||||
"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
|
||||
|
@ -25,21 +40,22 @@ 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)))
|
||||
;; (scroll-bar-mode on-off)
|
||||
(narf/load-theme (if mode-p 'narf-dark write-mode-theme) t)
|
||||
(narf/load-font (if mode-p narf-default-font write-mode-font))
|
||||
(if write-mode
|
||||
(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 (eq major-mode 'org-mode)
|
||||
(unless write-mode
|
||||
;; (font-lock-remove-keywords nil write-mode-org-font-lock-keywords)
|
||||
(write-mode|org-hook))
|
||||
(org-bullets-mode on-off))))
|
||||
(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))))
|
||||
(narf/get-buffers-in-modes '(org-mode markdown-mode)))
|
||||
(setq write-mode (not write-mode))))
|
||||
(setq write-mode (not mode-p))))
|
||||
|
||||
(when (> emacs-major-version 24)
|
||||
;; From <https://github.com/joostkremers/visual-fill-column/pull/6>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue