├── layers ├── common-lisp │ ├── img │ │ └── slime.png │ ├── config.el │ ├── packages.el │ └── README.org ├── ivy-tweaks │ ├── funcs.el │ └── packages.el ├── nameless │ └── packages.el ├── window-tweaks │ ├── README.org │ └── packages.el ├── spaceline-tweaks │ └── packages.el └── window-purpose │ ├── README.org │ ├── packages.el │ └── local │ └── purpose-popwin │ └── purpose-popwin.el ├── README.org ├── .gitignore ├── purpose-layouts ├── edit-help.window-layout ├── sicp.window-layout ├── two-edit.window-layout ├── edit-terminal.window-layout ├── python.window-layout ├── big-repl.window-layout └── code.window-layout └── init.el /layers/common-lisp/img/slime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmag/spacemacs-config/HEAD/layers/common-lisp/img/slime.png -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | My personal configuration for Spacemacs. The configuration follows Spacemcs' 2 | develop branch. To install, clone the directory to =~/.spacemacs.d=. If you have 3 | a =~.spacemacs= file, move it out of the way. 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled 2 | *.elc 3 | 4 | # Packaging 5 | .cask 6 | 7 | # Temporary 8 | *~ 9 | 10 | # shared packages 11 | mycustom.el 12 | rollback 13 | # cache directories 14 | machines/linux/cache/ 15 | machines/windows/cache/ 16 | # binaries for windows 17 | machines/windows/bin/ -------------------------------------------------------------------------------- /purpose-layouts/edit-help.window-layout: -------------------------------------------------------------------------------- 1 | (nil (0 0 152 37) (:purpose edit :purpose-dedicated t :width 0.6375838926174496 :height 1.0 :edges (0.0 0.0 0.6375838926174496 1.0)) (:purpose general :purpose-dedicated nil :width 0.3825503355704698 :height 1.0 :edges (0.6375838926174496 0.0 1.0201342281879195 1.0))) -------------------------------------------------------------------------------- /purpose-layouts/sicp.window-layout: -------------------------------------------------------------------------------- 1 | (t (0 0 152 37) (:purpose py :purpose-dedicated t :width 1.0201342281879195 :height 0.7837837837837838 :edges (0.0 0.0 1.0201342281879195 0.7837837837837838)) (:purpose repl :purpose-dedicated t :width 1.0201342281879195 :height 0.21621621621621623 :edges (0.0 0.7837837837837838 1.0201342281879195 1.0))) -------------------------------------------------------------------------------- /layers/ivy-tweaks/funcs.el: -------------------------------------------------------------------------------- 1 | (defun ivy-tweaks/copy-actions (from to) 2 | "Copy Ivy actions between two commands. 3 | Override TO's actions with FROM's actions." 4 | (ivy-set-actions to (plist-get ivy--actions-list from))) 5 | 6 | (defun ivy-tweaks/ivy-insert-current () 7 | (interactive) 8 | (with-ivy-window 9 | (insert ivy--current))) 10 | -------------------------------------------------------------------------------- /purpose-layouts/two-edit.window-layout: -------------------------------------------------------------------------------- 1 | (nil (0 0 240 56) (:purpose edit :purpose-dedicated nil :width 0.5042016806722689 :height 0.9824561403508771 :edges (0.0 0.0 0.5042016806722689 0.9824561403508771)) (:purpose edit :purpose-dedicated nil :width 0.5042016806722689 :height 0.9824561403508771 :edges (0.5042016806722689 0.0 1.0084033613445378 0.9824561403508771))) -------------------------------------------------------------------------------- /purpose-layouts/edit-terminal.window-layout: -------------------------------------------------------------------------------- 1 | (t (0 0 107 38) (:purpose edit :purpose-dedicated t :width 1.0288461538461537 :height 0.6410256410256411 :edges (0.0 0.0 1.0288461538461537 0.6410256410256411)) (:purpose terminal :purpose-dedicated nil :width 1.0288461538461537 :height 0.3333333333333333 :edges (0.0 0.6410256410256411 1.0288461538461537 0.9743589743589743))) -------------------------------------------------------------------------------- /purpose-layouts/python.window-layout: -------------------------------------------------------------------------------- 1 | (nil (0 0 213 55) (:purpose py :purpose-dedicated t :width 0.6398104265402843 :height 1.0 :edges (0.0 0.0 0.6398104265402843 1.0)) (t (135 0 213 55) (:purpose terminal :purpose-dedicated t :width 0.3696682464454976 :height 0.4 :edges (0.6398104265402843 0.0 1.009478672985782 0.4)) (:purpose org :purpose-dedicated nil :width 0.3696682464454976 :height 0.6 :edges (0.6398104265402843 0.4 1.009478672985782 1.0)))) -------------------------------------------------------------------------------- /layers/common-lisp/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- Common Lisp Layer Configuration File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: Sylvain Benner 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; variables 13 | 14 | (spacemacs|defvar-company-backends lisp-mode) 15 | -------------------------------------------------------------------------------- /purpose-layouts/big-repl.window-layout: -------------------------------------------------------------------------------- 1 | (nil (0 0 171 43) (t (0 0 86 43) (:purpose edit :purpose-dedicated t :width 0.5119047619047619 :height 0.7674418604651163 :edges (0.0 0.0 0.5119047619047619 0.7674418604651163)) (:purpose HELP :purpose-dedicated t :width 0.5119047619047619 :height 0.23255813953488372 :edges (0.0 0.7674418604651163 0.5119047619047619 1.0))) (:purpose REPL :purpose-dedicated t :width 0.5059523809523809 :height 1.0 :edges (0.5119047619047619 0.0 1.0178571428571428 1.0))) -------------------------------------------------------------------------------- /layers/ivy-tweaks/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- ivy-tweaks layer packages file for Spacemacs. 2 | ;;; Commentary: 3 | ;;; Code: 4 | 5 | (defconst ivy-tweaks-packages 6 | '(ivy) 7 | ) 8 | 9 | (defun ivy-tweaks/post-init-ivy () 10 | (with-eval-after-load 'ivy 11 | (with-eval-after-load 'projectile 12 | (ivy-tweaks/copy-actions 'ivy-recentf 'projectile-recentf)) 13 | (define-key ivy-minibuffer-map (kbd "C-c ") #'ivy-tweaks/ivy-insert-current))) 14 | 15 | 16 | ;;; packages.el ends here 17 | -------------------------------------------------------------------------------- /purpose-layouts/code.window-layout: -------------------------------------------------------------------------------- 1 | (nil (0 0 232 61) (:purpose edit :purpose-dedicated t :width 0.5065502183406113 :height 0.9838709677419355 :edges (0.0 0.0 0.5065502183406113 0.9838709677419355)) (t (116 0 232 61) (:purpose terminal :purpose-dedicated t :width 0.5065502183406113 :height 0.6129032258064516 :edges (0.5065502183406113 0.0 1.0131004366812226 0.6129032258064516)) (:purpose general :purpose-dedicated nil :width 0.5065502183406113 :height 0.3709677419354839 :edges (0.5065502183406113 0.6129032258064516 1.0131004366812226 0.9838709677419355)))) -------------------------------------------------------------------------------- /layers/nameless/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- nameless layer packages file for Spacemacs. 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: Bar 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;; Commentary: 13 | 14 | ;;; Code: 15 | 16 | (defconst nameless-packages '(nameless)) 17 | 18 | (defun nameless/init-nameless () 19 | (use-package nameless 20 | :defer t 21 | :init 22 | (add-hook 'emacs-lisp-mode-hook #'nameless-mode-from-hook) 23 | :config 24 | (define-key nameless-mode-map (kbd "C-;") #'nameless-insert-name))) 25 | 26 | ;;; packages.el ends here 27 | -------------------------------------------------------------------------------- /layers/window-tweaks/README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: window-tweaks layer 2 | 3 | 4 | # TOC links should be GitHub style anchors. 5 | * Table of Contents :TOC_4_gh:noexport: 6 | - [[#description][Description]] 7 | - [[#install][Install]] 8 | - [[#key-bindings][Key bindings]] 9 | 10 | * Description 11 | - smarter(?) full-screen magit display function 12 | - enable =magit-multi= purpose extension 13 | - slime completion buffer pops on the right 14 | - =org= purpose for Org-mode buffers 15 | - add =purpose-layouts= directory to =purpose-layout-dirs= 16 | * Install 17 | To use this configuration layer, add it to your =~/.spacemacs=. You will need 18 | to add =window-tweaks= to the existing =dotspacemacs-configuration-layers= 19 | list in this file. 20 | 21 | * Key bindings 22 | 23 | | Key Binding | Description | 24 | |-------------+----------------| 25 | | ~SPC x x x~ | Does thing01 | 26 | # Use GitHub URLs if you wish to link a Spacemacs documentation file or its heading. 27 | # Examples: 28 | # [[https://github.com/syl20bnr/spacemacs/blob/master/doc/VIMUSERS.org#sessions]] 29 | # [[https://github.com/syl20bnr/spacemacs/blob/master/layers/%2Bfun/emoji/README.org][Link to Emoji layer README.org]] 30 | # If space-doc-mode is enabled, Spacemacs will open a local copy of the linked file. 31 | -------------------------------------------------------------------------------- /layers/spaceline-tweaks/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- spaceline-tweaks layer packages file for Spacemacs. 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: Bar 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;; Commentary: 13 | 14 | ;;; Code: 15 | 16 | (defconst spaceline-tweaks-packages 17 | '(spaceline)) 18 | 19 | (defun spaceline-tweaks/post-init-spaceline () 20 | (setq powerline-default-separator 'bar) 21 | (set-face-attribute 'mode-line-inactive nil :box nil) 22 | (spaceline-toggle-minor-modes-off) 23 | (with-eval-after-load 'window-purpose 24 | (spaceline-define-segment purpose 25 | "Purpose of buffer." 26 | ;; (purpose--modeline-string) 27 | (when purpose-mode (format "%s%s%s" 28 | (purpose-buffer-purpose (current-buffer)) 29 | (if (window-dedicated-p) "#" "") 30 | (if (purpose-window-purpose-dedicated-p) "!" "")))) 31 | 32 | (let* ((main-mode-line (cdr (assq 'main spaceline--mode-lines))) 33 | (left-mode-line (car main-mode-line)) 34 | (right-mode-line (cdr main-mode-line))) 35 | (unless (memq 'purpose left-mode-line) 36 | (setcar main-mode-line 37 | (-insert-at (1+ (-elem-index 'major-mode left-mode-line)) 38 | 'purpose 39 | left-mode-line)))) 40 | ;; remove purpose-mode from minor-modes list 41 | (diminish 'purpose-mode)) 42 | (spaceline-compile)) 43 | 44 | 45 | ;;; packages.el ends here 46 | -------------------------------------------------------------------------------- /layers/window-tweaks/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- window-tweaks layer packages file for Spacemacs. 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: %USER_FULL_NAME% <%USER_MAIL_ADDRESS%> 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;; Commentary: 13 | 14 | ;; See the Spacemacs documentation and FAQs for instructions on how to implement 15 | ;; a new layer: 16 | ;; 17 | ;; SPC h SPC layers RET 18 | ;; 19 | ;; 20 | ;; Briefly, each package to be installed or configured by this layer should be 21 | ;; added to `window-tweaks-packages'. Then, for each package PACKAGE: 22 | ;; 23 | ;; - If PACKAGE is not referenced by any other Spacemacs layer, define a 24 | ;; function `window-tweaks/init-PACKAGE' to load and initialize the package. 25 | 26 | ;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so 27 | ;; define the functions `window-tweaks/pre-init-PACKAGE' and/or 28 | ;; `window-tweaks/post-init-PACKAGE' to customize the package as it is loaded. 29 | 30 | ;;; Code: 31 | 32 | (defconst window-tweaks-packages 33 | '(magit 34 | slime 35 | window-purpose)) 36 | 37 | (defun window-tweaks/post-init-magit () 38 | ;; go fullscreen only for magit status, not other buffers 39 | (with-eval-after-load 'window-purpose 40 | (purpose-x-magit-multi-on) 41 | (when git-magit-status-fullscreen 42 | (setq magit-display-buffer-function 43 | (lambda (buffer) 44 | (if (or 45 | ;; the original should stay alive, so we can't go fullscreen 46 | magit-display-buffer-noselect 47 | ;; go fullscreen only for magit status 48 | (not (with-current-buffer buffer (derived-mode-p 'magit-status-mode)))) 49 | ;; open buffer according to original magit rules 50 | (magit-display-buffer-traditional buffer) 51 | ;; open buffer in fullscreen 52 | (delete-other-windows) 53 | ;; make sure the window isn't dedicated, otherwise 54 | ;; `set-window-buffer' throws an error 55 | (set-window-dedicated-p nil nil) 56 | (purpose-set-window-purpose-dedicated-p nil nil) 57 | (set-window-buffer nil buffer) 58 | ;; return buffer's window 59 | (get-buffer-window buffer))))))) 60 | 61 | (defun window-tweaks/post-init-slime () 62 | (with-eval-after-load 'window-purpose 63 | (purpose-add-user-purposes :modes '((slime-repl-mode . terminal))) 64 | (defun display-buffer-split (buffer alist) 65 | (let ((window (split-window nil nil (cdr (assq 'split-side alist))))) 66 | (window--display-buffer buffer window 'window alist) 67 | window)) 68 | ;; slime doesn't handle case where fuzzy completion is displayed in the 69 | ;; repl's window (can happen if the other window is dedicated - bug in slime) 70 | (push "\\*Fuzzy Completions\\*" purpose-action-function-ignore-buffer-names) 71 | (push '("\\*Fuzzy Completions\\*" 72 | (purpose-display-reuse-window-buffer 73 | purpose-display-reuse-window-purpose 74 | purpose-display-maybe-other-window 75 | display-buffer-split) 76 | (split-side . right) 77 | (window-width . 60) 78 | (window-height . 24)) 79 | display-buffer-alist))) 80 | 81 | (defun window-tweaks/post-init-window-purpose () 82 | ;; no `with-eval-after-load' here because `window-purpose' isn't lazy-loaded 83 | (push (expand-file-name "purpose-layouts/" dotspacemacs-directory) 84 | purpose-layout-dirs) 85 | (purpose-add-user-purposes :modes '((org-mode . org)))) 86 | 87 | ;;; packages.el ends here 88 | -------------------------------------------------------------------------------- /layers/common-lisp/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- Common Lisp Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: Sylvain Benner 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (setq common-lisp-packages 13 | '(auto-highlight-symbol 14 | common-lisp-snippets 15 | company 16 | (slime-company :toggle (configuration-layer/layer-usedp 'auto-completion)) 17 | company 18 | slime)) 19 | 20 | (defun common-lisp/post-init-auto-highlight-symbol () 21 | (with-eval-after-load 'auto-highlight-symbol 22 | (add-to-list 'ahs-plugin-bod-modes 'lisp-mode))) 23 | 24 | (defun common-lisp/init-slime-company () 25 | (use-package slime-company 26 | :defer t 27 | :commands company-slime 28 | :config 29 | (slime-setup '(slime-fancy slime-company)))) 30 | 31 | (defun common-lisp/post-init-company () 32 | (push '(company-slime company-capf company-dabbrev-code) company-backends-lisp-mode) 33 | (spacemacs|add-company-hook lisp-mode)) 34 | 35 | (defun common-lisp/init-slime () 36 | (use-package slime 37 | :commands slime-mode 38 | :init 39 | (progn 40 | (spacemacs/register-repl 'slime 'slime-switch-to-output-buffer) 41 | (setq slime-contribs '(slime-fancy 42 | slime-indentation 43 | slime-sbcl-exts 44 | slime-scratch) 45 | inferior-lisp-program "sbcl") 46 | ;; enable fuzzy matching in code buffer and SLIME REPL 47 | (setq slime-complete-symbol*-fancy t) 48 | (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol) 49 | ;; enabel smartparen in code buffer and SLIME REPL 50 | ;; (add-hook 'slime-repl-mode-hook #'smartparens-strict-mode) 51 | (defun slime/disable-smartparens () 52 | (smartparens-strict-mode -1) 53 | (turn-off-smartparens-mode)) 54 | (add-hook 'slime-repl-mode-hook #'slime/disable-smartparens) 55 | (spacemacs/add-to-hooks 'slime-mode '(lisp-mode-hook))) 56 | :config 57 | (progn 58 | (slime-setup) 59 | ;; (dolist (m `(,slime-mode-map ,slime-repl-mode-map)) 60 | ;; (define-key m [(tab)] 'slime-fuzzy-complete-symbol)) 61 | (dolist (m `(,slime-repl-mode-map)) 62 | (define-key m [(tab)] 'slime-fuzzy-complete-symbol)) 63 | 64 | ;; TODO: Add bindings for the SLIME debugger? 65 | (spacemacs/set-leader-keys-for-major-mode 'lisp-mode 66 | "'" 'slime-switch-to-output-buffer 67 | 68 | "cc" 'slime-compile-file 69 | "cC" 'slime-compile-and-load-file 70 | "cl" 'slime-load-file 71 | "cf" 'slime-compile-defun 72 | "cr" 'slime-compile-region 73 | "cn" 'slime-remove-notes 74 | 75 | "eb" 'slime-eval-buffer 76 | "ef" 'slime-eval-defun 77 | "eF" 'slime-undefine-function 78 | "ee" 'slime-eval-last-sexp 79 | "er" 'slime-eval-region 80 | 81 | "gg" 'slime-inspect-definition 82 | "gb" 'slime-pop-find-definition-stack 83 | "gn" 'slime-next-note 84 | "gN" 'slime-previous-note 85 | 86 | "ha" 'slime-apropos 87 | "hA" 'slime-apropos-all 88 | "hd" 'slime-disassemble-symbol 89 | "hh" 'slime-describe-symbol 90 | "hH" 'slime-hyperspec-lookup 91 | "hp" 'slime-apropos-package 92 | "ht" 'slime-toggle-trace-fdefinition 93 | "hT" 'slime-untrace-all 94 | "h<" 'slime-who-calls 95 | "h>" 'slime-calls-who 96 | ;; TODO: Add key bindings for who binds/sets globals? 97 | "hr" 'slime-who-references 98 | "hm" 'slime-who-macroexpands 99 | "hs" 'slime-who-specializes 100 | 101 | "ma" 'slime-macroexpand-all 102 | "mo" 'slime-macroexpand-1 103 | 104 | "se" 'slime-eval-last-expression-in-repl 105 | "si" 'slime 106 | "sq" 'slime-quit-lisp 107 | 108 | "tf" 'slime-toggle-fancy-trace) 109 | 110 | (dolist (binding '(("mc" . "compile") 111 | ("me" . "eval") 112 | ("mg" . "goto") 113 | ("mh" . "help") 114 | ("mm" . "macro") 115 | ("ms" . "slime") 116 | ("mt" . "trace"))) 117 | (spacemacs/declare-prefix-for-mode 'lisp-mode (car binding) (cdr binding)))))) 118 | 119 | (when (configuration-layer/layer-usedp 'auto-completion) 120 | (defun common-lisp/init-common-lisp-snippets ())) 121 | -------------------------------------------------------------------------------- /layers/common-lisp/README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Common Lisp layer 2 | #+HTML_HEAD_EXTRA: 3 | 4 | [[file:img/slime.png]] 5 | 6 | * Table of Contents :TOC_4_org:noexport: 7 | - [[Description][Description]] 8 | - [[Install][Install]] 9 | - [[Key Bindings][Key Bindings]] 10 | - [[Working with lisp files (barfage, slurpage & more)][Working with lisp files (barfage, slurpage & more)]] 11 | - [[Leader][Leader]] 12 | - [[Help][Help]] 13 | - [[Evaluation][Evaluation]] 14 | - [[REPL][REPL]] 15 | - [[Compile][Compile]] 16 | - [[Navigation][Navigation]] 17 | - [[Macroexpansion][Macroexpansion]] 18 | 19 | * Description 20 | A Spacemacs contribution layer providing Common Lisp support via [[https://github.com/slime/slime][SLIME]]. 21 | 22 | * Install 23 | If you have previously installed slime in any other way, it is recommended that 24 | you uninstall it before proceeding. You should clean up any config files tied to 25 | slime that are left behind as well. Linux users can just purge the slime package 26 | if it was a distribution install. 27 | 28 | To use this configuration layer, add it to your =~/.spacemacs=. You will need to 29 | add =common-lisp= to the existing =dotspacemacs-configuration-layers= list in this 30 | file. 31 | 32 | This layer defaults to using [[http://www.sbcl.org/][sbcl]]. If you want to use a different implementation 33 | of Common Lisp, you can specify it in your =~/.spacemacs= 34 | 35 | #+BEGIN_SRC emacs-lisp 36 | (defun dotspacemacs/user-config () 37 | (setq inferior-lisp-program "/path/to/your/lisp")) 38 | #+END_SRC 39 | 40 | * Key Bindings 41 | ** Working with lisp files (barfage, slurpage & more) 42 | Spacemacs comes with a special ~lisp-state~ for working with lisp code that 43 | supports slurpage, barfage and more tools you'll likely want when working with 44 | lisp. 45 | 46 | As this state works the same for all files, the documentation is in global 47 | [[https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.org#lisp-key-bindings][DOCUMENTATION.org]]. In general, use ~SPC k~ to interact with the lisp-state. 48 | 49 | ** Leader 50 | *** Help 51 | 52 | | Key Binding | Description | 53 | |-------------+---------------------------------------------------------| 54 | | ~SPC m h a~ | SLIME apropos | 55 | | ~SPC m h d~ | Disassemble symbol at point | 56 | | ~SPC m h h~ | Describe symbol at point | 57 | | ~SPC m h H~ | Hyperspec lookup symbol at point | 58 | | ~SPC m h p~ | Browse apropos results for a package's exported symbols | 59 | | ~SPC m h t~ | Toggle tracing of the function at point | 60 | | ~SPC m h T~ | Untrace all functions | 61 | | ~SPC m h <~ | Show all known callers | 62 | | ~SPC m h >~ | Show all known callees | 63 | | ~SPC m h m~ | Show all usages of a macro | 64 | | ~SPC m h r~ | Show references to global variable | 65 | | ~SPC m h s~ | Show all methods specialized on a class | 66 | 67 | *** Evaluation 68 | 69 | | Key Binding | Description | 70 | |-------------+---------------------------------| 71 | | ~SPC m e b~ | Evaluate buffer | 72 | | ~SPC m e e~ | Evaluate last expression | 73 | | ~SPC m e f~ | Evaluate top level s-expression | 74 | | ~SPC m e F~ | Undefine the function at point | 75 | | ~SPC m e r~ | Evaluate region | 76 | 77 | *** REPL 78 | 79 | | Key Binding | Description | 80 | |-------------+----------------------------------| 81 | | ~SPC m s i~ | Start an inferior process | 82 | | ~SPC m s e~ | Evaluate last expression in REPL | 83 | | ~SPC m s q~ | Quit | 84 | 85 | *** Compile 86 | 87 | | Key Binding | Description | 88 | |-------------+--------------------------| 89 | | ~SPC m c c~ | Compile file | 90 | | ~SPC m c C~ | Compile file and load it | 91 | | ~SPC m c l~ | Load file | 92 | | ~SPC m c n~ | Remove compilation notes | 93 | | ~SPC m c f~ | Compile function | 94 | | ~SPC m c r~ | Compile region | 95 | 96 | *** Navigation 97 | 98 | 99 | | Key Binding | Description | 100 | |---------------------------+--------------------| 101 | | ~SPC m g g~ | Inspect definition | 102 | | ~SPC m g b~ | Go back | 103 | | ~SPC m g n~ | Next note | 104 | | ~SPC m g N~ or ~SPC m g p | Previous note | 105 | 106 | *** Macroexpansion 107 | 108 | | Key Binding | Description | 109 | |-------------+-----------------------------------------------| 110 | | ~SPC m m a~ | Macroexpand the expression at point completly | 111 | | ~SPC m m o~ | Macroexpand the expression at point once | 112 | -------------------------------------------------------------------------------- /layers/window-purpose/README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: window-purpose contribution layer for Spacemacs 2 | 3 | * Table of Contents :TOC@4: 4 | - [[#description][Description]] 5 | - [[#purposes][Purposes]] 6 | - [[#switch-to-buffer-and-display-buffer][switch-to-buffer and display-buffer]] 7 | - [[#features][Features]] 8 | - [[#window-purpose-purpose-mode][window-purpose (purpose-mode)]] 9 | - [[#purpose-popwinel-pupo-mode][purpose-popwin.el (pupo-mode)]] 10 | - [[#misc][misc]] 11 | - [[#install][Install]] 12 | - [[#usage][Usage]] 13 | - [[#key-bindings][Key Bindings]] 14 | - [[#caveats][Caveats]] 15 | - [[#popwin-and-guide-key][Popwin and guide-key]] 16 | - [[#packages-that-do-display-management][Packages that do display management]] 17 | 18 | * Description 19 | 20 | This layer enables [[https://github.com/bmag/emacs-purpose][window-purpose]], which provides an alternative, purpose-based 21 | window manager for Emacs. With this layer, your window layout should be robust 22 | and shouldn't change too much when opening all sorts of buffers. 23 | 24 | Regular [[https://github.com/m2ym/popwin-el][popwin]] is not triggered when window-purpose is enabled. However, the 25 | window-purpose layer provides a purpose-popwin extension, which brings popwin's 26 | behavior to window-purpose and solves that problem. 27 | 28 | ** Purposes 29 | 30 | window-purpose contains a configuration which assigns a purpose for each buffer. 31 | Later, when Emacs needs to display a buffer in a window, its purpose helps make 32 | a better decision of which window to use. 33 | 34 | For example, consider the following case: Emacs frame shows three windows - one 35 | for code, one for a terminal and one general-purpose window. The general window 36 | is selected and you want to open a code file. How do you ensure that the code 37 | file will be displayed in the code window? With window-purpose you don't need to 38 | worry about it - you open the file and window-purpose places it in the correct 39 | window. 40 | 41 | Additionally, you can dedicate a window to a purpose - so that window is 42 | reserved only for buffers that share that purpose. 43 | 44 | ** switch-to-buffer and display-buffer 45 | 46 | In regular Emacs, =switch-to-buffer= follows different rules than the other 47 | switching and popping commands, because it doesn't use =display-buffer= (which 48 | the other commands do). With window-purpose, this behavior is fixed. The result 49 | is a better control over how buffers are displayed, since =switch-to-buffer= 50 | doesn't ignore the user's customizations anymore. 51 | 52 | * Features 53 | 54 | ** window-purpose (purpose-mode) 55 | - window layout is more robust and less likely to change unintentionally 56 | - dedicate window to a purpose 57 | - user-defined purposes 58 | - extensible window display behavior 59 | - empty =purpose-mode-map=, to avoid conflicts with other key maps 60 | 61 | ** purpose-popwin.el (pupo-mode) 62 | - replicate popwin behavior for purpose-mode - almost no regression in popup 63 | behavior from using window-purpose. 64 | - reuses popwin's settings: =popwin:special-display-config=, 65 | =popwin:popup-window-height= and =popwin:popup-window-width=. 66 | - difference from popwin: when several windows are open, popup window is 67 | sometimes bigger than with regular popwin in the same situation. 68 | 69 | ** misc 70 | - specialized helm source similar to =helm-source-buffers-list= 71 | 72 | * Install 73 | 74 | To use this contribution add it to your =~/.spacemacs= 75 | 76 | #+BEGIN_SRC emacs-lisp 77 | (setq-default dotspacemacs-configuration-layers '(window-purpose)) 78 | #+END_SRC 79 | 80 | * Usage 81 | 82 | With window-purpose layer installed, =purpose-mode= and =pupo-mode= are enabled. 83 | You can toggle =purpose-mode= (~SPC : purpose-mode~) at any time to return to 84 | purpose-less behavior. You can toggle =pupo-mode= (~SPC : pupo-mode~) to turn 85 | off only the purpose-popwin integration. 86 | 87 | If you change =popwin:special-display-config= in your =dotspacemacs/config=, you 88 | should call =pupo/update-purpose-config= to update purpose-popwin with those 89 | changes. 90 | 91 | See [[https://github.com/bmag/emacs-purpose/wiki][window-purpose wiki]] to learn more about window-purpose. 92 | 93 | * Key Bindings 94 | 95 | | Key Binding | Description | 96 | |-------------+-------------------------------------------------------------------------------------| 97 | | ~SPC r b~ | Open a buffer. Only buffers with the same purpose as the current buffer are listed. | 98 | | ~SPC r B~ | Open any buffer and ignore window-purpose when displaying the buffer. | 99 | | ~SPC r d~ | Toggle dedication of selected window to its current purpose. | 100 | | ~SPC r D~ | Delete all non-dedicated windows. | 101 | | ~SPC r p~ | Choose a purpose and open a buffer with that purpose. | 102 | | ~SPC r P~ | Change the purpose of the selected window. Changes the window's buffer accordingly. | 103 | 104 | * Caveats 105 | 106 | ** Popwin and guide-key 107 | 108 | If a buffer is displayed in two different windows, and only one of those windows 109 | is purpose-dedicated, then invoking guide-key will cause both windows to become 110 | purpose-dedicated. 111 | 112 | ** Packages that do display management 113 | 114 | Some packages that manage how windows are displayed, such as =gdb= with 115 | =gdb-many-windows=, might not play nicely with =window-purpose=. However, it is 116 | usually possible to find a solution. After all, even =helm= and =popwin= work 117 | with =window-purpose=. 118 | -------------------------------------------------------------------------------- /layers/window-purpose/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- window-purpose Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2012-2014 Sylvain Benner 4 | ;; Copyright (c) 2014-2015 Sylvain Benner & Contributors 5 | ;; 6 | ;; Author: Sylvain Benner 7 | ;; URL: https://github.com/syl20bnr/spacemacs 8 | ;; 9 | ;; This file is not part of GNU Emacs. 10 | ;; 11 | ;;; License: GPLv3 12 | 13 | (setq window-purpose-packages '(eyebrowse 14 | (helm-purpose :toggle (configuration-layer/layer-usedp 'helm)) 15 | (ivy-purpose :toggle (configuration-layer/layer-usedp 'ivy)) 16 | popwin 17 | (purpose-popwin :location local) 18 | window-purpose)) 19 | 20 | (setq window-purpose-excluded-packages '()) 21 | 22 | (defun window-purpose/post-init-eyebrowse () 23 | (defvar window-purpose--eyebrowse-new-workspace eyebrowse-new-workspace 24 | "Internal backup of `eyebrowse-new-workspace'.") 25 | 26 | ;; replacement for `eyebrowse-new-workspace' that handles purpose-dedicated 27 | ;; windows correctly 28 | (defun window-purpose/new-workspace () 29 | "Create a new eyebrowse workspace." 30 | ;; call original `eyebrowse-new-workspace' (partially copied from 31 | ;; `eyebrowse-switch-to-window-config') 32 | (cond 33 | ((stringp window-purpose--eyebrowse-new-workspace) 34 | (switch-to-buffer (get-buffer-create window-purpose--eyebrowse-new-workspace))) 35 | ((functionp window-purpose--eyebrowse-new-workspace) 36 | (funcall window-purpose--eyebrowse-new-workspace)) 37 | (t (switch-to-buffer "*scratch*"))) 38 | 39 | ;; in case opening the new buffer splitted the frame (e.g. 40 | ;; `eyebrowse-switch-to-window-config' was called from a purpose-dedicated 41 | ;; buffer) 42 | (delete-other-windows)) 43 | 44 | (defun window-purpose/sync-eyebrowse () 45 | "Synchronize window-purpose layer with eyebrowse. 46 | Set `eyebrowse-new-workspace' value depending on the state of `purpose-mode'." 47 | (if purpose-mode 48 | (setq eyebrowse-new-workspace #'window-purpose/new-workspace) 49 | (setq eyebrowse-new-workspace window-purpose--eyebrowse-new-workspace))) 50 | (add-hook 'purpose-mode-hook #'window-purpose/sync-eyebrowse) 51 | (when (boundp 'purpose-mode) 52 | ;; sync with eyebrowse now if window-purpose was already loaded 53 | (window-purpose/sync-eyebrowse))) 54 | 55 | (defun window-purpose/init-helm-purpose () 56 | (setq purpose-preferred-prompt 'helm) 57 | ;; remap bindings defined with `spacemacs/set-leader-keys' 58 | (global-set-key [remap purpose-switch-buffer-with-purpose] 59 | #'helm-purpose-switch-buffer-with-purpose) 60 | (global-set-key [remap switch-buffer-without-purpose] 61 | #'helm-purpose-mini-ignore-purpose) 62 | (global-set-key [remap purpose-switch-buffer-with-some-purpose] 63 | #'helm-purpose-switch-buffer-with-some-purpose)) 64 | 65 | (defun window-purpose/init-ivy-purpose () 66 | ;; vanilla lets `ivy' take over 67 | (use-package ivy-purpose 68 | :defer t 69 | :commands (ivy-purpose-switch-buffer-with-purpose 70 | ivy-purpose-switch-buffer-without-purpose 71 | ivy-purpose-switch-buffer-with-some-purpose) 72 | :init 73 | (progn 74 | (setq purpose-preferred-prompt 'vanilla) 75 | (global-set-key [remap purpose-switch-buffer-with-purpose] 76 | #'ivy-purpose-switch-buffer-with-purpose) 77 | (global-set-key [remap purpose-switch-buffer-without-purpose] 78 | #'ivy-purpose-switch-buffer-without-purpose) 79 | (global-set-key [remap purpose-switch-buffer-with-some-purpose] 80 | #'ivy-purpose-switch-buffer-with-some-purpose)))) 81 | 82 | (defun window-purpose/post-init-popwin () 83 | ;; when popwin creates a popup window, it removes the `purpose-dedicated' 84 | ;; window parameter from all windows, so we must save and restore it 85 | ;; ourselves. this works well as long as no buffer is displayed in more than 86 | ;; one window. if a buffer is displayed in several windows, and at least one 87 | ;; of these windows is purpose-dedicated, then all these windows will become 88 | ;; purpose-dedicated after popwin creates a popup window. 89 | ;; there is no problem if the local purpose-popwin extension is used, as long 90 | ;; as the user doesn't call `popwin:create-popup-window' directly (e.g. 91 | ;; from `helm-mini') 92 | 93 | (defvar window-purpose--dedicated-windows nil) 94 | 95 | (defadvice popwin:create-popup-window (before window-purpose/save-dedicated-windows) 96 | (setq window-purpose--dedicated-windows 97 | (cl-loop for window in (window-list) 98 | if (purpose-window-purpose-dedicated-p window) 99 | collect (window-buffer window)))) 100 | 101 | (defadvice popwin:create-popup-window (after window-purpose/restore-dedicated-windows) 102 | (cl-loop for buffer in window-purpose--dedicated-windows 103 | do (cl-loop for window in (get-buffer-window-list buffer) 104 | do (purpose-set-window-purpose-dedicated-p window t)))) 105 | 106 | (defun window-purpose/sync-popwin () 107 | "Synchronize window-purpose layer with popwin. 108 | Enable or disable advices to popwin, according to the state of `purpose-mode'." 109 | (if purpose-mode 110 | (progn 111 | (ad-enable-advice 'popwin:create-popup-window 112 | 'before 'window-purpose/save-dedicated-windows) 113 | (ad-enable-advice 'popwin:create-popup-window 114 | 'after 'window-purpose/restore-dedicated-windows) 115 | (ad-update 'popwin:create-popup-window) 116 | (ad-activate 'popwin:create-popup-window)) 117 | (ad-disable-advice 'popwin:create-popup-window 118 | 'before 'window-purpose/save-dedicated-windows) 119 | (ad-disable-advice 'popwin:create-popup-window 120 | 'after 'window-purpose/restore-dedicated-windows) 121 | (ad-update 'popwin:create-popup-window))) 122 | (add-hook 'purpose-mode-hook #'window-purpose/sync-popwin) 123 | (when (boundp 'purpose-mode) 124 | ;; sync with popwin now if window-purpose was already loaded 125 | (window-purpose/sync-popwin))) 126 | 127 | (defun window-purpose/init-purpose-popwin () 128 | (use-package purpose-popwin 129 | ;; don't load purpose-popwin if popwin is excluded. 130 | ;; can't wrap `window-purpose/init-purpose-popwin' in a top-level `when' 131 | ;; because popwin isn't yet marked as used then. the condition won't work in 132 | ;; top-level, only here 133 | :if (configuration-layer/package-usedp 'popwin) 134 | ;; purpose-popwin needs to be configured after popwin and window-purpose. 135 | ;; popwin is guaranteed to run before purpose-popwin due to alphabetic order, 136 | ;; but for window-purpose we need to use :after 137 | :after window-purpose 138 | :config 139 | (progn 140 | (pupo-mode) 141 | ;; override popwin commands with pupo commands 142 | (spacemacs/set-leader-keys 143 | "wpp" #'pupo/close-window 144 | "wpP" #'pupo/close-all-windows)))) 145 | 146 | (defun window-purpose/init-window-purpose () 147 | (use-package window-purpose 148 | :init 149 | ;; overriding `purpose-mode-map' with empty keymap, so it doesn't conflict 150 | ;; with original `C-x C-f', `C-x b', etc. and `semantic' key bindings. must 151 | ;; be done before `window-purpose' is loaded 152 | (setq purpose-mode-map (make-sparse-keymap)) 153 | :config 154 | (progn 155 | ;; 'r' is for "puRpose" ('w', 'p' are crowded, 'W', 'P' aren't comfortable) 156 | (spacemacs/set-leader-keys 157 | "rb" 'purpose-switch-buffer-with-purpose 158 | "rB" 'switch-buffer-without-purpose 159 | "rd" 'purpose-toggle-window-purpose-dedicated 160 | "rD" 'purpose-delete-non-dedicated-windows 161 | "rp" 'purpose-switch-buffer-with-some-purpose 162 | "rP" 'purpose-set-window-purpose) 163 | 164 | (purpose-mode) 165 | (purpose-x-golden-ratio-setup) 166 | ;; when killing a purpose-dedicated buffer that is displayed in a window, 167 | ;; ensure that the buffer is replaced by a buffer with the same purpose 168 | ;; (or the window deleted, if no such buffer) 169 | (purpose-x-kill-setup)))) 170 | -------------------------------------------------------------------------------- /layers/window-purpose/local/purpose-popwin/purpose-popwin.el: -------------------------------------------------------------------------------- 1 | ;;; purpose-popwin.el --- Purpose extension to act like Popwin -*- lexical-binding: t -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defconst pupo--direction-to-purpose '((left . popl) 8 | (right . popr) 9 | (top . popt) 10 | (bottom . popb)) 11 | "Mapping of popwin positions to purposes.") 12 | 13 | (defconst pupo--purposes 14 | (loop for (direction . purpose) in pupo--direction-to-purpose collect purpose) 15 | "List of purposes used to present popwin positions.") 16 | 17 | (defvar pupo--windows nil 18 | "List of popup windows.") 19 | (defvar pupo--auto-windows nil 20 | "List of popup windows that should be closed automatically.") 21 | (defvar pupo--saved-buffers nil 22 | "Temporary list of displayed popup buffers.") 23 | (defvar pupo--saved-auto-buffers nil 24 | "Temporary list of non-sticky displayed popup buffers.") 25 | 26 | (defun pupo//popup-function (position size) 27 | "Generate a display function to create a popup window. 28 | POSITION should be one of bottom, top, left and right. 29 | SIZE should be either a positive number of nil. Size is interpreted as 30 | width or height depending on POSITION." 31 | (let* ((size (cl-case position 32 | ('left (purpose--normalize-width (or size 33 | popwin:popup-window-width))) 34 | ('right (purpose--normalize-width (or size 35 | popwin:popup-window-width))) 36 | ('top (purpose--normalize-height (or size 37 | popwin:popup-window-height))) 38 | ('bottom (purpose--normalize-height (or size 39 | popwin:popup-window-height))))) 40 | (size (when size (- size))) 41 | (side (cl-case position 42 | ('left 'left) 43 | ('right 'right) 44 | ('top 'above) 45 | ('bottom 'below)))) 46 | (lambda (buffer alist) 47 | (let ((window (ignore-errors 48 | (split-window (frame-root-window) size side)))) 49 | (when window 50 | (purpose-change-buffer buffer window 'window alist)))))) 51 | 52 | (defun pupo//position-to-display-function (position width height) 53 | "Generate a display function for creating a popup window. 54 | POSITION defaults to bottom. 55 | WIDTH and HEIGHT should be either a positive number or nil." 56 | (cl-case (or position 'bottom) 57 | ((left right) (pupo//popup-function position width)) 58 | ((top bottom) (pupo//popup-function position height)))) 59 | 60 | (defun pupo//position-to-purpose (position) 61 | "Translate POSITION to a purpose. 62 | Direction -> purpose: 63 | left -> popl 64 | right -> popr 65 | top -> popt 66 | bottom -> popb 67 | POSITION defaults to bottom." 68 | (cl-case (or position 'bottom) 69 | ;; names are short so they don't take much room in the mode-line 70 | ('left 'popl) 71 | ('right 'popr) 72 | ('top 'popt) 73 | ('bottom 'popb))) 74 | 75 | (defun pupo//actions (settings) 76 | "Generate list of display functions for displaying a popup window. 77 | SETTINGS is the settings for the popup buffer, and corresponds to what 78 | popwin calls \"config keywords\"." 79 | (delq nil 80 | (list #'purpose-display-reuse-window-buffer 81 | (unless (plist-get settings :dedicated) 82 | #'purpose-display-reuse-window-purpose) 83 | (pupo//position-to-display-function (plist-get settings :position) 84 | (plist-get settings :width) 85 | (plist-get settings :height))))) 86 | 87 | (defun pupo/display-condition (_purpose buffer _alist) 88 | "A condition to be used in `purpose-special-action-sequences'. 89 | Return non-nil if BUFFER is a popup buffer, according to the settings in 90 | `popwin:special-display-config'. 91 | 92 | See `purpose-special-action-sequences' for a description of _PURPOSE, 93 | BUFFER and _ALIST." 94 | (popwin:match-config buffer)) 95 | 96 | (defun pupo/display-function (buffer alist) 97 | "A display function to be used in `purpose-special-action-sequences'. 98 | Display BUFFER as a popup buffer, according to the settings in 99 | `popwin:special-display-config'. 100 | 101 | See `purpose-special-action-sequences' for a description of BUFFER and 102 | ALIST." 103 | (do ((display-fns (pupo//actions (cdr (popwin:match-config buffer))) 104 | (cdr display-fns)) 105 | (window nil (and display-fns (funcall (car display-fns) buffer alist)))) 106 | ((or window (null display-fns)) window))) 107 | 108 | (defun pupo/after-display (window) 109 | "Additional initialization for popup windows. 110 | Sets properties for WINDOW and updates some variables, if WINDOW is a 111 | popup window. 112 | 113 | This function should be hooked to `purpose-display-buffer-functions'." 114 | (let* ((buffer (window-buffer window)) 115 | (config (popwin:match-config buffer)) 116 | (settings (cdr (popwin:listify config)))) 117 | (when config 118 | (setq pupo--windows (delete window pupo--windows)) 119 | (push window pupo--windows) 120 | (when (plist-get settings :dedicated) 121 | (set-window-dedicated-p window t)) 122 | (unless (plist-get settings :stick) 123 | (push window pupo--auto-windows)) 124 | (unless (or (minibuffer-window-active-p (selected-window)) 125 | (plist-get settings :noselect)) 126 | ;; popwin selects window unless :noselect is t 127 | ;; in contrast, popwin doesn't prevent selection when :noselect is nil 128 | (select-window window)) 129 | ;; make \\[C-g] delete last popup window 130 | (global-set-key [remap keyboard-quit] #'pupo/close-window)))) 131 | 132 | (defun pupo//safe-delete-window (&optional window) 133 | "Delete WINDOW if possible. 134 | Return t if successful, nil otherwise. 135 | WINDOW defaults to the selected window." 136 | (ignore-errors (delete-window window) t)) 137 | 138 | (defun pupo/auto-delete-windows (window) 139 | "Delete all non-sticky popup windows, unless WINDOW is a popup window. 140 | This function should be hooked to `purpose-display-buffer-functions'." 141 | (unless (member (purpose-window-purpose window) pupo--purposes) 142 | (mapc #'pupo//safe-delete-window pupo--auto-windows) 143 | (setq pupo--auto-windows nil))) 144 | 145 | (defun pupo/close-window () 146 | "Close most recent popup window. 147 | This command can be used repeatedly to close all popup windows." 148 | (interactive) 149 | (let ((searching t)) 150 | (while (and pupo--windows searching) 151 | (when (window-live-p (car pupo--windows)) 152 | (pupo//safe-delete-window (car pupo--windows)) 153 | (setq searching nil)) 154 | (pop pupo--windows)) 155 | (unless pupo--windows 156 | ;; no more popup windows, revert \\[C-g] to `keyboard-quit' 157 | (global-set-key [remap keyboard-quit] nil)))) 158 | 159 | (defun pupo/close-all-windows () 160 | "Close all popup windows." 161 | (interactive) 162 | (dolist (purpose pupo--purposes) 163 | (mapc #'pupo//safe-delete-window (purpose-windows-with-purpose purpose)))) 164 | 165 | (defun pupo/popwin-config-to-purpose-config () 166 | "Create a purpose configuration matching current popwin's settings. 167 | Return a `purpose-conf' object. 168 | Popwin's settings are taken from `popwin:special-display-config'." 169 | (let (mode-purposes name-purposes regexp-purposes) 170 | (loop for config-entry in popwin:special-display-config 171 | for (pattern . settings) = (popwin:listify config-entry) 172 | do 173 | (push (cons pattern 174 | (pupo//position-to-purpose (plist-get settings :position))) 175 | (cond ((symbolp pattern) mode-purposes) 176 | ((plist-get settings :regexp) regexp-purposes) 177 | (t name-purposes)))) 178 | (purpose-conf "pupo" 179 | :mode-purposes mode-purposes 180 | :name-purposes name-purposes 181 | :regexp-purposes regexp-purposes))) 182 | 183 | (defun pupo/update-purpose-config () 184 | "Update purpose configuration according to current popwin's settings. 185 | Popwin's settings are taken from `popwin:special-display-config'." 186 | (purpose-set-extension-configuration :pupo (pupo/popwin-config-to-purpose-config))) 187 | 188 | (define-minor-mode pupo-mode 189 | "Minor mode for combining `purpose-mode' and `popwin-mode'." 190 | :global t 191 | (if pupo-mode 192 | (progn 193 | (pupo/update-purpose-config) 194 | (push '(pupo/display-condition pupo/display-function) 195 | purpose-special-action-sequences) 196 | (add-hook 'purpose-display-buffer-functions #'pupo/after-display) 197 | (add-hook 'purpose-display-buffer-functions #'pupo/auto-delete-windows)) 198 | (purpose-del-extension-configuration :pupo) 199 | (setq purpose-special-action-sequences 200 | (delete '(pupo/display-condition pupo/display-function) 201 | purpose-special-action-sequences)) 202 | (remove-hook 'purpose-display-buffer-functions #'pupo/after-display) 203 | (remove-hook 'purpose-display-buffer-functions #'pupo/auto-delete-windows))) 204 | 205 | (defadvice popwin:create-popup-window (before pupo/before-popwin-create) 206 | "Save current popup windows for later restoration. 207 | The windows are restored in `pupo/after-popwin-create'. 208 | Note that the windows themselves aren't saved, but some internal 209 | variables are updated instead." 210 | (setq pupo--saved-buffers (mapcar #'window-buffer pupo--windows)) 211 | (setq pupo--saved-auto-buffers (mapcar #'window-buffer pupo--auto-windows))) 212 | 213 | (defadvice popwin:create-popup-window (after pupo/after-popwin-create) 214 | "Restore popup windows. 215 | The windows were saved in `pupo/before-popwin-create'. 216 | Note that the windows themselves aren't restored, but some internal 217 | variables are updated instead." 218 | (setq pupo--windows nil) 219 | (loop for buffer in pupo--saved-buffers 220 | do (setq pupo--windows 221 | (append pupo--windows 222 | (get-buffer-window-list buffer)))) 223 | (setq pupo--auto-windows nil) 224 | (loop for buffer in pupo--saved-auto-buffers 225 | do (setq pupo--auto-windows 226 | (append pupo--auto-windows 227 | (get-buffer-window-list buffer))))) 228 | 229 | (defun pupo/sync-advices () 230 | (if pupo-mode 231 | (progn 232 | (ad-enable-advice 'popwin:create-popup-window 'before 'pupo/before-popwin-create) 233 | (ad-enable-advice 'popwin:create-popup-window 'after 'pupo/after-popwin-create) 234 | (ad-update 'popwin:create-popup-window) 235 | (ad-activate 'popwin:create-popup-window)) 236 | (ad-disable-advice 'popwin:create-popup-window 'before 'pupo/before-popwin-create) 237 | (ad-disable-advice 'popwin:create-popup-window 'after 'pupo/after-popwin-create) 238 | (ad-update 'popwin:create-popup-window))) 239 | (add-hook 'pupo-mode-hook #'pupo/sync-advices) 240 | 241 | (provide 'purpose-popwin) 242 | ;;; purpose-popwin.el ends here 243 | -------------------------------------------------------------------------------- /init.el: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | ;; This file is loaded by Spacemacs at startup. 3 | ;; It must be stored in your home directory. 4 | 5 | (defun dotspacemacs/layers () 6 | "Configuration Layers declaration. 7 | You should not put any user code in this function besides modifying the variable 8 | values." 9 | (setq-default 10 | ;; Base distribution to use. This is a layer contained in the directory 11 | ;; `+distribution'. For now available distributions are `spacemacs-base' 12 | ;; or `spacemacs'. (default 'spacemacs) 13 | dotspacemacs-distribution 'spacemacs 14 | ;; Lazy installation of layers (i.e. layers are installed only when a file 15 | ;; with a supported type is opened). Possible values are `all', `unused' 16 | ;; and `nil'. `unused' will lazy install only unused layers (i.e. layers 17 | ;; not listed in variable `dotspacemacs-configuration-layers'), `all' will 18 | ;; lazy install any layer that support lazy installation even the layers 19 | ;; listed in `dotspacemacs-configuration-layers'. `nil' disable the lazy 20 | ;; installation feature and you have to explicitly list a layer in the 21 | ;; variable `dotspacemacs-configuration-layers' to install it. 22 | ;; (default 'unused) 23 | dotspacemacs-enable-lazy-installation nil 24 | ;; If non-nil then Spacemacs will ask for confirmation before installing 25 | ;; a layer lazily. (default t) 26 | dotspacemacs-ask-for-lazy-installation t 27 | ;; If non-nil layers with lazy install support are lazy installed. 28 | ;; List of additional paths where to look for configuration layers. 29 | ;; Paths must have a trailing slash (i.e. `~/.mycontribs/') 30 | 31 | ;; gotcha: using "~/.spacemacs.d/" is wrong then trying to use a 32 | ;; different dotspacemacs directory (e.g. via SPACEMACSDIR) 33 | dotspacemacs-configuration-layer-path (list (expand-file-name "layers/" dotspacemacs-directory)) 34 | ;; List of configuration layers to load. 35 | dotspacemacs-configuration-layers 36 | '( 37 | ;; completion layer 38 | ;; helm 39 | ivy ivy-tweaks 40 | 41 | ;; tools 42 | (auto-completion :variables 43 | ;; auto-completion-complete-with-key-sequence "jk" 44 | ;; auto-completion-complete-with-key-sequence-delay 0.5 45 | auto-completion-enable-snippets-in-popup nil 46 | auto-completion-enable-help-tooltip t 47 | company-tooltip-align-annotations t) 48 | command-log 49 | evil-cleverparens 50 | (git :variables git-magit-status-fullscreen t) 51 | ;; gtags 52 | ibuffer 53 | imenu-list 54 | nlinum 55 | org 56 | pdf-tools 57 | ;; ranger 58 | (shell :variables 59 | shell-default-shell 'shell 60 | shell-default-height 30 61 | shell-default-position 'bottom) 62 | ;; semantic 63 | smex 64 | syntax-checking 65 | version-control 66 | 67 | ;; languages 68 | c-c++ 69 | (clojure :variables 70 | clojure-enable-fancify-symbols nil) 71 | emacs-lisp 72 | (latex :variables 73 | latex-enable-auto-fill t 74 | latex-enable-folding t) 75 | markdown 76 | octave 77 | python 78 | ruby 79 | 80 | ;; private layers 81 | common-lisp 82 | ;; disabled nameless because it delays opening of elisp files significally 83 | ;; (~2-3 seconds) 84 | ;; nameless 85 | spaceline-tweaks 86 | window-purpose 87 | window-tweaks 88 | 89 | ;; themes 90 | themes-megapack 91 | (theming :variables 92 | theming-modifications 93 | '((spacemacs-dark (aw-leading-char-face :foreground "red" :height 3.0)) 94 | (spacemacs-light (aw-leading-char-face :foreground "red" :height 3.0)) 95 | (monokai (aw-leading-char-face :foreground "red" :height 3.0)) 96 | (flatland (aw-leading-char-face :foreground "red" :height 3.0)))) 97 | ) 98 | ;; List of additional packages that will be installed without being 99 | ;; wrapped in a layer. If you need some configuration for these 100 | ;; packages, then consider creating a layer. You can also put the 101 | ;; configuration in `dotspacemacs/user-config'. 102 | dotspacemacs-additional-packages '(tabbar-ruler flycheck-package vimrc-mode buttercup el-mock) 103 | ;; A list of packages that cannot be updated. 104 | dotspacemacs-frozen-packages '() 105 | ;; A list of packages that will not be install and loaded. 106 | dotspacemacs-excluded-packages '() 107 | ;; Defines the behaviour of Spacemacs when downloading packages. 108 | ;; Possible values are `used', `used-but-keep-unused' and `all'. `used' will 109 | ;; download only explicitly used packages and remove any unused packages as 110 | ;; well as their dependencies. `used-but-keep-unused' will download only the 111 | ;; used packages but won't delete them if they become unused. `all' will 112 | ;; download all the packages regardless if they are used or not and packages 113 | ;; won't be deleted by Spacemacs. (default is `used') 114 | dotspacemacs-download-packages 'used-but-keep-unused)) 115 | 116 | (defun dotspacemacs/init () 117 | "Initialization function. 118 | This function is called at the very startup of Spacemacs initialization 119 | before layers configuration. 120 | You should not put any user code in there besides modifying the variable 121 | values." 122 | ;; This setq-default sexp is an exhaustive list of all the supported 123 | ;; spacemacs settings. 124 | (setq-default 125 | ;; If non nil ELPA repositories are contacted via HTTPS whenever it's 126 | ;; possible. Set it to nil if you have no way to use HTTPS in your 127 | ;; environment, otherwise it is strongly recommended to let it set to t. 128 | ;; This variable has no effect if Emacs is launched with the parameter 129 | ;; `--insecure' which forces the value of this variable to nil. 130 | ;; (default t) 131 | dotspacemacs-elpa-https t 132 | ;; Maximum allowed time in seconds to contact an ELPA repository. 133 | dotspacemacs-elpa-timeout 5 134 | ;; If non nil then spacemacs will check for updates at startup 135 | ;; when the current branch is not `develop'. (default t) 136 | dotspacemacs-check-for-update nil 137 | 138 | ;; `dotspacemacs-enable-multiple-emacs-version' doesn't exist yet, it's just 139 | ;; part of a PR for now. 140 | ;; If non nil, different emacs versions have different package directories. 141 | ;; e.g. for Emacs 24.5, packages are stored in elpa/24.5/. Rollback 142 | ;; directories are also separated. 143 | dotspacemacs-enable-multiple-emacs-version t 144 | ;; One of `vim', `emacs' or `hybrid'. 145 | ;; `hybrid' is like `vim' except that `insert state' is replaced by the 146 | ;; `hybrid state' with `emacs' key bindings. The value can also be a list 147 | ;; with `:variables' keyword (similar to layers). Check the editing styles 148 | ;; section of the documentation for details on available variables. 149 | ;; (default 'vim) 150 | dotspacemacs-editing-style '(hybrid :variables 151 | hybrid-mode-default-state 'normal 152 | hybrid-mode-enable-evilified-state t 153 | hybrid-mode-enable-hjkl-bindings nil) 154 | ;; If non nil output loading progress in `*Messages*' buffer. (default nil) 155 | dotspacemacs-verbose-loading nil 156 | ;; Specify the startup banner. Default value is `official', it displays 157 | ;; the official spacemacs logo. An integer value is the index of text 158 | ;; banner, `random' chooses a random text banner in `core/banners' 159 | ;; directory. A string value must be a path to an image format supported 160 | ;; by your Emacs build. 161 | ;; If the value is nil then no banner is displayed. (default 'official) 162 | dotspacemacs-startup-banner 'official 163 | ;; List of items to show in startup buffer or an association list of of 164 | ;; the form `(list-type . list-size)`. If nil it is disabled. 165 | ;; Possible values for list-type are: 166 | ;; `recents' `bookmarks' `projects' `agenda' `todos'." 167 | dotspacemacs-startup-lists '((recents . 10) 168 | (projects . 7)) 169 | ;; Default major mode of the scratch buffer (default `text-mode') 170 | dotspacemacs-scratch-mode 'emacs-lisp-mode 171 | ;; List of themes, the first of the list is loaded when spacemacs starts. 172 | ;; Press T n to cycle to the next theme in the list (works great 173 | ;; with 2 themes variants, one dark and one light) 174 | dotspacemacs-themes '(spacemacs-dark 175 | spacemacs-light 176 | monokai 177 | flatland) 178 | ;; If non nil the cursor color matches the state color in GUI Emacs. 179 | dotspacemacs-colorize-cursor-according-to-state t 180 | ;; Default font, or prioritized list of fonts. `powerline-scale' allows to 181 | ;; quickly tweak the mode-line size to make separators look not too crappy. 182 | dotspacemacs-default-font '("Source Code Pro" 183 | :size 14 184 | :weight normal 185 | :width normal 186 | :powerline-scale 1.2) 187 | ;; The leader key 188 | dotspacemacs-leader-key "SPC" 189 | ;; The leader key accessible in `emacs state' and `insert state' 190 | ;; (default "M-m") 191 | dotspacemacs-emacs-leader-key "M-m" 192 | ;; Major mode leader key is a shortcut key which is the equivalent of 193 | ;; pressing ` m`. Set it to `nil` to disable it. (default ",") 194 | dotspacemacs-major-mode-leader-key "," 195 | ;; Major mode leader key accessible in `emacs state' and `insert state'. 196 | ;; (default "C-M-m) 197 | dotspacemacs-major-mode-emacs-leader-key "C-M-m" 198 | ;; The key used for Emacs commands (M-x) (after pressing on the leader key). 199 | ;; (default "SPC") 200 | dotspacemacs-emacs-command-key ":" 201 | ;; These variables control whether separate commands are bound in the GUI to 202 | ;; the key pairs C-i, TAB and C-m, RET. 203 | ;; Setting it to a non-nil value, allows for separate commands under 204 | ;; and TAB or and RET. 205 | ;; In the terminal, these pairs are generally indistinguishable, so this only 206 | ;; works in the GUI. (default nil) 207 | dotspacemacs-distinguish-gui-tab t 208 | ;; If non nil `Y' is remapped to `y$'. (default t) 209 | dotspacemacs-remap-Y-to-y$ t 210 | ;; If non-nil, the shift mappings `<' and `>' retain visual state if used 211 | ;; there. (default t) 212 | dotspacemacs-retain-visual-state-on-shift t 213 | ;; If non-nil, J and K move lines up and down when in visual mode. 214 | ;; (default nil) 215 | dotspacemacs-visual-line-move-text nil 216 | ;; If non nil, inverse the meaning of `g' in `:substitute' Evil ex-command. 217 | ;; (default nil) 218 | dotspacemacs-ex-substitute-global nil 219 | ;; Name of the default layout (default "Default") 220 | dotspacemacs-default-layout-name "Default" 221 | ;; If non nil the default layout name is displayed in the mode-line. 222 | ;; (default nil) 223 | dotspacemacs-display-default-layout nil 224 | ;; If non nil then the last auto saved layouts are resume automatically upon 225 | ;; start. (default nil) 226 | dotspacemacs-auto-resume-layouts nil 227 | ;; Size (in MB) above which spacemacs will prompt to open the large file 228 | ;; literally to avoid performance issues. Opening a file literally means that 229 | ;; no major mode or minor modes are active. (default is 1) 230 | dotspacemacs-large-file-size 1 231 | ;; Location where to auto-save files. Possible values are `original' to 232 | ;; auto-save the file in-place, `cache' to auto-save the file to another 233 | ;; file stored in the cache directory and `nil' to disable auto-saving. 234 | ;; (default 'cache) 235 | dotspacemacs-auto-save-file-location 'cache 236 | ;; Maximum number of rollback slots to keep in the cache. (default 5) 237 | dotspacemacs-max-rollback-slots 7 238 | ;; If non nil, `helm' will try to minimize the space it uses. (default nil) 239 | dotspacemacs-helm-resize nil 240 | ;; if non nil, the helm header is hidden when there is only one source. 241 | ;; (default nil) 242 | dotspacemacs-helm-no-header nil 243 | ;; define the position to display `helm', options are `bottom', `top', 244 | ;; `left', or `right'. (default 'bottom) 245 | dotspacemacs-helm-position 'bottom 246 | ;; If non nil the paste micro-state is enabled. When enabled pressing `p` 247 | ;; several times cycle between the kill ring content. (default nil) 248 | dotspacemacs-enable-paste-transient-state t 249 | ;; Which-key delay in seconds. The which-key buffer is the popup listing 250 | ;; the commands bound to the current keystroke sequence. (default 0.4) 251 | dotspacemacs-which-key-delay 0.4 252 | ;; Which-key frame position. Possible values are `right', `bottom' and 253 | ;; `right-then-bottom'. right-then-bottom tries to display the frame to the 254 | ;; right; if there is insufficient space it displays it at the bottom. 255 | ;; (default 'bottom) 256 | dotspacemacs-which-key-position 'bottom 257 | ;; If non nil a progress bar is displayed when spacemacs is loading. This 258 | ;; may increase the boot time on some systems and emacs builds, set it to 259 | ;; nil to boost the loading time. (default t) 260 | dotspacemacs-loading-progress-bar t 261 | ;; If non nil the frame is fullscreen when Emacs starts up. (default nil) 262 | ;; (Emacs 24.4+ only) 263 | dotspacemacs-fullscreen-at-startup nil 264 | ;; If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen. 265 | ;; Use to disable fullscreen animations in OSX. (default nil) 266 | dotspacemacs-fullscreen-use-non-native nil 267 | ;; If non nil the frame is maximized when Emacs starts up. 268 | ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil. 269 | ;; (default nil) (Emacs 24.4+ only) 270 | dotspacemacs-maximized-at-startup nil 271 | ;; A value from the range (0..100), in increasing opacity, which describes 272 | ;; the transparency level of a frame when it's active or selected. 273 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 274 | dotspacemacs-active-transparency 90 275 | ;; A value from the range (0..100), in increasing opacity, which describes 276 | ;; the transparency level of a frame when it's inactive or deselected. 277 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 278 | dotspacemacs-inactive-transparency 90 279 | ;; If non nil show the titles of transient states. (default t) 280 | dotspacemacs-show-transient-state-title t 281 | ;; If non nil show the color guide hint for transient state keys. (default t) 282 | dotspacemacs-show-transient-state-color-guide t 283 | ;; If non nil unicode symbols are displayed in the mode line. (default t) 284 | dotspacemacs-mode-line-unicode-symbols t 285 | ;; If non nil smooth scrolling (native-scrolling) is enabled. Smooth 286 | ;; scrolling overrides the default behavior of Emacs which recenters point 287 | ;; when it reaches the top or bottom of the screen. (default t) 288 | dotspacemacs-smooth-scrolling t 289 | ;; If non nil line numbers are turned on in all `prog-mode' and `text-mode' 290 | ;; derivatives. If set to `relative', also turns on relative line numbers. 291 | ;; (default nil) 292 | dotspacemacs-line-numbers nil 293 | ;; Code folding method. Possible values are `evil' and `origami'. 294 | ;; (default 'evil) 295 | dotspacemacs-folding-method 'origami 296 | ;; If non-nil smartparens-strict-mode will be enabled in programming modes. 297 | ;; (default nil) 298 | dotspacemacs-smartparens-strict-mode t 299 | ;; If non-nil pressing the closing parenthesis `)' key in insert mode passes 300 | ;; over any automatically added closing parenthesis, bracket, quote, etc… 301 | ;; This can be temporary disabled by pressing `C-q' before `)'. (default nil) 302 | dotspacemacs-smart-closing-parenthesis nil 303 | ;; Select a scope to highlight delimiters. Possible values are `any', 304 | ;; `current', `all' or `nil'. Default is `all' (highlight any scope and 305 | ;; emphasis the current one). (default 'all) 306 | dotspacemacs-highlight-delimiters 'all 307 | ;; If non nil advises quit functions to keep server open when quitting. 308 | ;; (default nil) 309 | dotspacemacs-persistent-server nil 310 | ;; List of search tool executable names. Spacemacs uses the first installed 311 | ;; tool of the list. Supported tools are `ag', `pt', `ack' and `grep'. 312 | ;; (default '("ag" "pt" "ack" "grep")) 313 | dotspacemacs-search-tools '("ag" "pt" "ack" "grep") 314 | ;; The default package repository used if no explicit repository has been 315 | ;; specified with an installed package. 316 | ;; Not used for now. (default nil) 317 | dotspacemacs-default-package-repository nil 318 | ;; Delete whitespace while saving buffer. Possible values are `all' 319 | ;; to aggressively delete empty line and long sequences of whitespace, 320 | ;; `trailing' to delete only the whitespace at end of lines, `changed'to 321 | ;; delete only whitespace for changed lines or `nil' to disable cleanup. 322 | ;; (default nil) 323 | dotspacemacs-whitespace-cleanup nil 324 | )) 325 | 326 | (defun dotspacemacs/user-init () 327 | "Initialization function for user code. 328 | It is called immediately after `dotspacemacs/init', before layer configuration 329 | executes. 330 | This function is mostly useful for variables that need to be set 331 | before packages are loaded. If you are unsure, you should try in setting them in 332 | `dotspacemacs/user-config' first." 333 | ;; small graphical changes 334 | (setq frame-title-format "Spacemacs") 335 | 336 | (when (eq system-type 'gnu/linux) 337 | (let ((machine-home (expand-file-name "machines/linux/" dotspacemacs-directory))) 338 | ;; give machine its own cache 339 | (setq spacemacs-cache-directory (expand-file-name "cache/" machine-home)))) 340 | 341 | (when (eq system-type 'windows-nt) 342 | (let ((machine-home (expand-file-name "machines/windows/" dotspacemacs-directory))) 343 | ;; give machine its own cache 344 | (setq spacemacs-cache-directory (expand-file-name "cache/" machine-home)) 345 | (push (expand-file-name "bin/" machine-home) exec-path) 346 | (push (expand-file-name "bin/diffutils/" machine-home) exec-path))) 347 | 348 | ;; share packages between machines (`dotspacemacs-directory' and `package-user-dir' are shared) 349 | (setq custom-file (expand-file-name "mycustom.el" dotspacemacs-directory)) 350 | (setq configuration-layer-rollback-directory (expand-file-name "rollback/" dotspacemacs-directory)) 351 | 352 | (load custom-file 'noerror) 353 | (setq paradox-github-token t) 354 | ) 355 | 356 | (defun dotspacemacs/user-config () 357 | "Configuration function for user code. 358 | This function is called at the very end of Spacemacs initialization after 359 | layers configuration. You are free to put any user code." 360 | ;; recenter window-point after imenu jumps 361 | (add-hook 'imenu-after-jump-hook (lambda () (recenter 10))) 362 | 363 | ;; TODO: make a PR for evil-cp settings 364 | ;; properly enable/disable cleverparens 365 | (add-hook 'smartparens-enabled-hook #'spacemacs/toggle-evil-cleverparens-on) 366 | (add-hook 'smartparens-disabled-hook #'spacemacs/toggle-evil-cleverparens-off) 367 | ;; cleverparens works better with these settings 368 | (setq evil-move-cursor-back nil 369 | evil-move-beyond-eol t) 370 | 371 | ;; anzu commands provide a preview of matches 372 | (global-set-key [remap query-replace] #'anzu-query-replace) 373 | (global-set-key [remap query-replace-regexp] #'anzu-query-replace-regexp) 374 | 375 | (when (configuration-layer/layer-usedp 'helm) 376 | ;; un-fuzzy helm-locate 377 | (setq helm-locate-fuzzy-match nil) 378 | (spacemacs/set-leader-keys "oi" #'helm-comint-input-ring)) 379 | 380 | (when (configuration-layer/layer-usedp 'ivy) 381 | (spacemacs/set-leader-keys "oi" #'counsel-shell-history)) 382 | 383 | ;; TODO: make PR upstream? 384 | ;; automatically toggle emacs state with artist-mode 385 | (defun artist-mode-toggle-emacs-state () 386 | (if artist-mode 387 | (unless (evil-emacs-state-p) 388 | (evil-emacs-state)) 389 | (evil-exit-emacs-state))) 390 | (unless (eq dotspacemacs-editing-style 'emacs) 391 | (add-hook 'artist-mode-hook #'artist-mode-toggle-emacs-state)) 392 | 393 | (when (configuration-layer/package-usedp 'avy) 394 | ;; (spacemacs/set-leader-keys "jj" #'evil-avy-goto-word-0) 395 | (spacemacs/set-leader-keys "SPC" #'evil-avy-goto-word-0) 396 | (with-eval-after-load 'avy 397 | (add-to-list 'avy-keys-alist 398 | (cons 'avy-goto-word-0 (list ?a ?s ?d ?f ?l ?k ?j 399 | ?w ?e ?u ?i ?v ?n 400 | ?g ?h))))) 401 | 402 | (when (configuration-layer/package-usedp 'magit) 403 | (add-to-list 'spacemacs-useful-buffers-regexp "^\\*magit")) 404 | ;; (spacemacs/set-leader-keys 405 | ;; "rsw" #'window-configuration-to-register 406 | ;; "rsf" #'frame-configuration-to-register 407 | ;; "rsp" #'point-to-register 408 | ;; "rj" #'jump-to-register) 409 | ;; (spacemacs/declare-prefix "rs" "save register") 410 | ;; (spacemacs/declare-prefix "rj" "load register") 411 | 412 | ;; tabbar-ruler causes display issues for hydra-powered transient states :-( 413 | ;; (use-package tabbar-ruler 414 | ;; :init 415 | ;; (setq tabbar-ruler-global-tabbar t) 416 | ;; :config 417 | ;; (setq tabbar-buffer-groups-function 'tabbar-buffer-groups)) 418 | 419 | ;; let emacs know where to find source files 420 | (when (and (version< emacs-version "25.0") 421 | (version<= "24.5" emacs-version)) 422 | ;; this doesn't working... 423 | ;; (setq find-function-source-path '("~/Documents/emacs/24.5/lisp/")) 424 | (setq find-function-C-source-directory "~/Documents/emacs/24.5/src/")) 425 | 426 | (defun set-transperancy (&optional frame) 427 | (let ((frame (or frame (selected-frame)))) 428 | (if (display-graphic-p frame) 429 | (set-frame-parameter frame 'alpha '(80 80)) 430 | (set-face-background 'default "unspecified-bg" frame)))) 431 | 432 | ;; TODO: move to a layer (or add upstream?) 433 | (when (and (configuration-layer/layer-usedp 'auto-complete) 434 | (configuration-layer/layer-usedp 'octave)) 435 | (defun company-octave (command &optional arg &rest args) 436 | "`company-mode' backend using `completion-at-point-functions'." 437 | (interactive (list 'interactive)) 438 | (if (eq command 'doc-buffer) 439 | ;; TODO `octave-help' displays the help buffer, we'd rather use a function 440 | ;; that doesn't display the help buffer 441 | (save-window-excursion 442 | (ignore-errors 443 | (octave-help arg) 444 | (get-buffer octave-help-buffer))) 445 | (apply #'company-capf command arg args))) 446 | 447 | (spacemacs|defvar-company-backends octave-mode) 448 | (spacemacs|defvar-company-backends inferior-octave-mode) 449 | (spacemacs|add-company-hook octave-mode) 450 | (spacemacs|add-company-hook inferior-octave-mode) 451 | (push 'company-octave company-backends-octave-mode) 452 | (push 'company-octave company-backends-inferior-octave-mode)) 453 | 454 | ;; one-project-per-layout workflow 455 | (defun bm-add-project-buffers-to-layout () 456 | "Add all of current project's buffers to current layout. 457 | Handy after creating project layout with [SPC p l]." 458 | (interactive) 459 | (let ((persp-switch-to-added-buffer nil)) 460 | (mapc #'persp-add-buffer (projectile-project-buffers)))) 461 | 462 | (defun bm-project-buffer-p (buffer) 463 | "Return non-nil if BUFFER belongs in current project." 464 | (projectile-project-buffer-p buffer (projectile-project-root))) 465 | 466 | (defun bm-remove-non-project-buffers-from-layout () 467 | "Remove from current layout all buffers that aren't in the current project." 468 | (interactive) 469 | (cl-loop for buffer in (persp-buffers (get-current-persp)) 470 | unless (bm-project-buffer-p buffer) 471 | do (persp-remove-buffer buffer))) 472 | 473 | (defun bm-buffer-project-layout (buffer) 474 | "Get BUFFER's project's layout, if it exists." 475 | (with-current-buffer buffer 476 | (when (projectile-project-p) 477 | (let ((root (projectile-project-root))) 478 | (cl-loop for persp in (persp-persps) 479 | when (f-equal? root (safe-persp-name persp)) 480 | return persp))))) 481 | 482 | (defun bm-display-buffer-in-project-layout-condition (buffer alist) 483 | (let ((persp (bm-buffer-project-layout buffer))) 484 | (and persp 485 | (not (get-buffer-window buffer (cdr (assq 'reusable-frames alist)))) 486 | (not (equalp persp (get-current-persp)))))) 487 | 488 | (defun bm-display-buffer-in-project-layout (buffer _alist) 489 | "Display BUFFER in its project's layout. 490 | This function actually just switches to the project's layout, but 491 | doesn't display the buffer. Instead, it returns nil so 492 | `display-buffer' will display the buffer with another display function. 493 | 494 | This function is meant to be used in `display-buffer-alist', or 495 | in the action argument for `display-buffer' or `pop-to-buffer'." 496 | (let ((persp (bm-buffer-project-layout buffer))) 497 | (persp-switch (persp-name persp)) 498 | ;; ;; re-run `display-buffer' 499 | ;; (display-buffer buffer) 500 | ;; let `display-buffer' fall-through to remaining display functions 501 | nil)) 502 | 503 | (defun bm-display-buffer-in-project-layout-maybe (buffer alist) 504 | (when (bm-display-buffer-in-project-layout-condition buffer alist) 505 | (bm-display-buffer-in-project-layout buffer alist))) 506 | 507 | (defun bm-goto-buffer-project-layout (buffer) 508 | "Show BUFFER in its project's layout. 509 | If BUFFER doesn't have a project, or the project doesn't have a 510 | layout, display BUFFER in the current layout." 511 | (interactive "B") 512 | (if (bm-display-buffer-in-project-layout-condition buffer nil) 513 | (pop-to-buffer buffer '((bm-display-buffer-in-project-layout-maybe) 514 | (inhibit-same-window . nil))) 515 | ;; fallback to display in current window 516 | (switch-to-buffer buffer))) 517 | 518 | ;; append - so popwin has preference (sometimes projectil thinks that buffers 519 | ;; like "*Help*" are part of the project). 520 | ;; `projectile-globally-ignored-buffers' looks relevant 521 | (add-to-list 'display-buffer-alist 522 | '(bm-display-buffer-in-project-layout-condition 523 | bm-display-buffer-in-project-layout) 524 | 'append) 525 | (add-to-list 'purpose-special-action-sequences 526 | (list (lambda (purpose buffer alist) 527 | (bm-display-buffer-in-project-layout-condition buffer alist)) 528 | #'bm-display-buffer-in-project-layout) 529 | 'append) 530 | ) 531 | --------------------------------------------------------------------------------