Skip to content

Instantly share code, notes, and snippets.

@yuhan0
Created December 31, 2018 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuhan0/838afa0582f4d59fe6680961e67cd5f6 to your computer and use it in GitHub Desktop.
Save yuhan0/838afa0582f4d59fe6680961e67cd5f6 to your computer and use it in GitHub Desktop.
Excerpt from WIP Spacemacs outshine layer
;;; Outshine
(defun outshine/init-outshine ()
(use-package outshine
:defer t
:commands (outshine-reveal-context outshine-mode)
:init
(progn
;; Enable outshine-mode for *all* programming buffers.
;; note - this enables outline-minor-mode at the same time.
(add-hook 'prog-mode-hook 'outshine-mode)
(setq outshine-preserve-delimiter-whitespace t ;; Haskell mode behaves oddly without this
outshine-startup-folded 'content
outshine-use-speed-commands nil ;; does not play well with evil mode
outshine-org-style-global-cycling-at-bob-p t))
:config
(progn
;; subtree evil text object under "ir" / "ar"
(add-hook 'outshine-mode-hook 'spacemacs/setup-outshine-text-objects)
(add-hook 'outline-insert-heading-hook #'evil-insert-state)
;; make sure pretty bullets are managed by font lock
(add-hook 'outshine-mode-hook
(lambda ()
(make-local-variable 'font-lock-extra-managed-props)
(add-to-list 'font-lock-extra-managed-props 'composition)
;; (add-to-list 'font-lock-extra-managed-props 'display)
))
;; make sure adjust-parens doesn't override TAB bindings
(with-eval-after-load 'adjust-parens
(when-let ((x (assq 'outshine-mode minor-mode-map-alist)))
(setq minor-mode-map-alist (cons x (delq 'outshine-mode minor-mode-map-alist)))))
(spacemacs|diminish outline-minor-mode "")
(spacemacs|diminish outshine-mode "Ⓞ"))))
;;; Outorg
(defun outshine/init-outorg ()
(use-package outorg
:defer t
:init
(progn
;; TODO move elsewher
(defun outorg-edit-buffer ()
"Simulates C-u universal arg on outorg edit command, making it act on entire buffer"
(interactive)
(outorg-edit-as-org '(4)))
(evil-define-key '(normal insert) outshine-mode-map
(kbd "M-#") #'outorg-edit-buffer
(kbd "C-#") #'outorg-edit-as-org))
:config
(progn
;; use ~,c~ convention for confirming action.
;; TODO what does abort ~,k~ correspond to?
(spacemacs/set-leader-keys-for-minor-mode 'outorg-edit-minor-mode
"c" 'outorg-copy-edits-and-exit))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment