├── private ├── ess │ ├── img │ │ └── r.jpg │ ├── README.org │ ├── local │ │ ├── essh │ │ │ └── essh.el │ │ └── electric-spacing-r │ │ │ └── electric-spacing-r.el │ ├── config.el │ └── packages.el ├── snippets │ ├── markdown-mode │ │ ├── par │ │ ├── snotes │ │ ├── note │ │ └── col │ └── README.md ├── elpy │ ├── config.el │ ├── funcs.el │ ├── README.org │ └── packages.el ├── templates │ └── README.md ├── funk │ ├── keybindings.el │ └── funcs.el ├── README.md ├── polymode │ └── packages.el └── local │ └── README.md ├── LICENSE ├── README.md └── spacemacs.el /private/ess/img/r.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandomayer/spacemacs/HEAD/private/ess/img/r.jpg -------------------------------------------------------------------------------- /private/snippets/markdown-mode/par: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: par 3 | # key: par 4 | # binding: "keybinding" 5 | # -- 6 | [**p. $1, par. $2, l. $3**] $0 7 | -------------------------------------------------------------------------------- /private/snippets/markdown-mode/snotes: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: snotes 3 | # key: snotes 4 | # binding: "keybinding" 5 | # -- 6 | ::: {.notes} 7 | $1 8 | ::: 9 | -------------------------------------------------------------------------------- /private/snippets/markdown-mode/note: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: note 3 | # key: note 4 | # binding: "keybinding" 5 | # -- 6 | ::: {.callout-note title="$1"} 7 | 8 | ::: -------------------------------------------------------------------------------- /private/elpy/config.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | ;; 3 | ;; Author: Rainer Gemulla 4 | ;; 5 | ;; This file is not part of GNU Emacs. 6 | ;; 7 | ;;; Code: 8 | 9 | (spacemacs|define-jump-handlers python-mode) 10 | -------------------------------------------------------------------------------- /private/snippets/markdown-mode/col: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: col 3 | # key: col 4 | # binding: "keybinding" 5 | # -- 6 | :::: {.columns} 7 | 8 | ::: {.column width="50%"} 9 | $1 10 | ::: 11 | 12 | ::: {.column width="50%"} 13 | $2 14 | ::: 15 | 16 | :::: 17 | -------------------------------------------------------------------------------- /private/snippets/README.md: -------------------------------------------------------------------------------- 1 | # Private directory for Yasnippets snippets 2 | 3 | The content of this directory is ignored by Git. This is the default place 4 | where to store your private yasnippets. 5 | 6 | This path will be loaded automatically and used whenever Yasnippets loads. 7 | -------------------------------------------------------------------------------- /private/templates/README.md: -------------------------------------------------------------------------------- 1 | # Private directory for Yatemplate templates 2 | 3 | The content of this directory is ignored by Git. This is the default place 4 | where to store your private templates. 5 | 6 | This path will be loaded automatically and used whenever Yatemplate loads. 7 | -------------------------------------------------------------------------------- /private/funk/keybindings.el: -------------------------------------------------------------------------------- 1 | ;;====================================================================== 2 | ;; Keybindings only 3 | ;;====================================================================== 4 | 5 | ;; C-TAB move between buffers 6 | (global-set-key [(control tab)] 'other-window) 7 | 8 | ;; Change font size 9 | (define-key global-map (kbd "C-+") 'text-scale-increase) 10 | (define-key global-map (kbd "C--") 'text-scale-decrease) 11 | -------------------------------------------------------------------------------- /private/elpy/funcs.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | ;; 3 | ;; Author: Rainer Gemulla 4 | ;; 5 | ;; This file is not part of GNU Emacs. 6 | ;; 7 | ;;; Code: 8 | 9 | 10 | (defun elpy/insert-codecell-above () 11 | (interactive) 12 | (save-excursion 13 | (beginning-of-line) 14 | (insert "# \n"))) 15 | 16 | (defun elpy/insert-markdowncell-above () 17 | (interactive) 18 | (save-excursion 19 | (beginning-of-line) 20 | (insert "# \n"))) 21 | -------------------------------------------------------------------------------- /private/README.md: -------------------------------------------------------------------------------- 1 | # Private directory 2 | 3 | The content of this directory is ignored by Git. This is the default place 4 | where to store your private configuration layers. 5 | 6 | To create a new configuration layer: 7 | 8 | SPC SPC configuration-layer/create-layer RET 9 | 10 | Then enter the name of your configuration in the prompt. 11 | 12 | A directory named after the created configuration layer will be created here 13 | along with template files within it (packages.el and extensions.el, more info 14 | on the meaning of those files can be found in the [documentation][conf_layers]). 15 | 16 | Each created file has further guidance written in them. 17 | 18 | Once the configuration is done, restart Emacs to load, install and configure 19 | your layer. 20 | 21 | [conf_layers]: https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.org#extensions-and-packages 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Fernando Mayer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /private/polymode/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- polymode layer packages file for Spacemacs. 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: Walmes Zeviani & Fernando Mayer 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | 8 | ;;; Code: 9 | 10 | (defconst polymode-packages 11 | '(polymode)) 12 | 13 | (defun polymode/init-polymode () 14 | (use-package polymode 15 | :mode (("\\.Rmd" . Rmd-mode)) 16 | :init 17 | (progn 18 | (defun Rmd-mode () 19 | "ESS Markdown mode for Rmd files" 20 | (interactive) 21 | (require 'poly-R) 22 | (require 'poly-markdown) 23 | (R-mode) 24 | (poly-markdown+r-mode)) 25 | )) 26 | (use-package polymode 27 | :mode (("\\.Rnw" . Rnw-mode)) 28 | :init 29 | (progn 30 | (defun Rnw-mode () 31 | "ESS LaTeX mode for Rnw files" 32 | (interactive) 33 | (require 'poly-R) 34 | (require 'poly-noweb) 35 | (R-mode) 36 | (poly-noweb+r-mode)) 37 | )) 38 | (use-package quarto-mode 39 | :mode (("\\.qmd" . poly-quarto-mode)) 40 | ) 41 | ) 42 | 43 | ;;; packages.el ends here 44 | -------------------------------------------------------------------------------- /private/local/README.md: -------------------------------------------------------------------------------- 1 | # Private directory for local packages 2 | 3 | The content of this directory is ignored by Git. 4 | 5 | This is the place to store the local packages that you define in the 6 | `dotspacemacs-additional-packages` variable of your dotfile. 7 | 8 | Additional packages can be added using the same recipe as for [adding packages 9 | to layers](https://develop.spacemacs.org/doc/LAYERS.html#packagesel) i.e.: 10 | 11 | - For a local package: 12 | - Load the file explicitly, using the full path to the file, by placing a 13 | `(load "~/.emacs.d/private/local/package-name")` within the body of the 14 | `dotspacemacs/user-config` function of your dotspacemacs file. 15 | - Alternatively create a directory with the name of the package in the 16 | `.emacs.d/private/local` directory, and add that directory to the load-path 17 | variable by adding `(some-package :location local)` to the list 18 | `dotspacemacs-additional-packages` within the `dotspacemacs/layers` function 19 | of your dotspacemacs file. After placing your package file into this 20 | package-directory the file can be loaded, without requiring the full path, by 21 | placing a `(require 'package-name)` within the body of the 22 | `dotspacemacs/user-config` function of your dotspacemacs file. 23 | 24 | - If the package is on (M)ELPA simply add the package name to the list 25 | `dotspacemacs-additional-packages` in your dotspacemacs file 26 | 27 | - For a package hosted on github the recipe for github packages can be used i.e. add 28 | 29 | ``` 30 | (some-package :location (recipe 31 | :fetcher github 32 | :repo "some/repo")) 33 | ``` 34 | 35 | to the list `dotspacemacs-additional-packages` in your dotspacemacs file. 36 | -------------------------------------------------------------------------------- /private/ess/README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: ESS (R) layer 2 | #+HTML_HEAD_EXTRA: 3 | 4 | [[file:img/r.jpg]] 5 | 6 | * Table of Contents :TOC_4_org:noexport: 7 | - [[Install][Install]] 8 | - [[Key Bindings][Key Bindings]] 9 | - [[Inferior REPL process][Inferior REPL process]] 10 | - [[Helpers][Helpers]] 11 | - [[Options][Options]] 12 | 13 | * Install 14 | To use this configuration layer, add it to your =~/.spacemacs=. You will need to 15 | add =ess= to the existing =dotspacemacs-configuration-layers= list in this 16 | file. 17 | 18 | * Key Bindings 19 | 20 | ** Inferior REPL process 21 | Send code to inferior process with these commands: 22 | 23 | | Key Binding | Description | 24 | |-------------+------------------------------------------------------------------| 25 | | ~SPC m c c~ | send knitr/sweave chunk and keep buffer focused | 26 | | ~SPC m c C~ | send knitr/sweave chunk and switch to REPL in insert mode | 27 | | ~SPC m c d~ | send knitr/sweave chunk and step to next chunk | 28 | | ~SPC m c m~ | mark knitr/sweave chunk around point | 29 | | ~SPC m c n~ | next knitr/sweave chunk | 30 | | ~SPC m c N~ | previous knitr/sweave chunk | 31 | | ~SPC m s b~ | send buffer and keep code buffer focused | 32 | | ~SPC m s B~ | send buffer and switch to REPL in insert mode | 33 | | ~SPC m s d~ | send region or line and step (debug) | 34 | | ~SPC m s D~ | send function or paragraph and step (debug) | 35 | | ~SPC m s i~ | start an inferior REPL process | 36 | | ~SPC m s l~ | send line and keep code buffer focused | 37 | | ~SPC m s L~ | send line and switch to REPL in insert mode | 38 | | ~SPC m s r~ | send region and keep code buffer focused | 39 | | ~SPC m s R~ | send region and switch to REPL in insert mode | 40 | | ~SPC m s t~ | send thing at point (function) and keep code buffer focused | 41 | | ~SPC m s T~ | send thing at point (function) and switch to REPL in insert mode | 42 | | ~CTRL+j~ | next item in REPL history | 43 | | ~CTRL+k~ | previous item in REPL history | 44 | 45 | ** Helpers 46 | Helpers for inspecting objects at point are available in R buffers only. 47 | | Key Binding | Description | 48 | |-------------+---------------------------------------------------------------------| 49 | | ~SPC m h d~ | view data under point using [ess-R-data-view][ess-R-data-view] | 50 | | ~SPC m h i~ | object introspection popup [ess-R-object-popup][ess-R-object-popup] | 51 | | ~SPC m h t~ | view table using [ess-R-data-view][ess-R-data-view] | 52 | 53 | * Options 54 | =ess-smart-equals= is disabled by default. In order to enable it, set in your 55 | =~/.spacemacs= 56 | 57 | #+BEGIN_SRC emacs-lisp 58 | (setq-default dotspacemacs-configuration-layers '((ess :variables 59 | ess-enable-smart-equals t))) 60 | #+END_SRC 61 | 62 | To turn off the automatic replacement of underscores by =<-=, add the following 63 | hook: 64 | 65 | #+begin_src emacs-lisp 66 | (add-hook 'ess-mode-hook 67 | (lambda () 68 | (ess-toggle-underscore nil))) 69 | #+end_src 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spacemacs 2 | 3 | ## Spacemacs configuration files and private layers 4 | 5 | [Spacemacs] is a set of configurations available to power up your 6 | [Emacs], the best text editor in the world. Spacemacs brings a modern 7 | interface, and many smart defaults, so you don't have to struggle to let 8 | your `.emacs` the way you want (although many like the challenge). 9 | Anyway, Spacemacs let you configure it the same old way, but based on 10 | *layers*, which makes things much more organized. By the way, Spacemacs 11 | even let [Vim] users to use keybindings they were used to, but 12 | with the power of Emacs. 13 | 14 | This repository contains my `.spacemacs` file (named `spacemacs.el`) and 15 | some private layers. 16 | 17 | Layers are in the `private` directory, and now they are: 18 | 19 | - `ess`: This is a clone of the original Spacemacs ess layer 20 | (available at `layers/+lang/ess`), but it includes the following 21 | modifications: 22 | - Use [R Coding Standards] instead of Hadley's coding standards (the 23 | default in the official layer) 24 | - Create a new variable, `ess-enable-smartparens`, to allow 25 | `smartparens` package to be used in ess. It can be specified in your 26 | `.spacemacs` the same way as `ess-enable-smart-equals` (both are 27 | disabled by default) 28 | - `polymode`: Creates a layer to install and configure [polymode], 29 | adding support for R markdown (`Rmd`) files in Spacemacs. 30 | (Note that ess already supports `Rnw` files, and this is enabled by 31 | default in Spacemacs). 32 | - `funk`: This is a layer to hold my personal (misc) functions and 33 | keybindings. It doesn't install any packages, just enable functions in 34 | `funcs.el`, and enables some keybindings setted in `keybindings.el` 35 | 36 | These layers are enabled by moving them to `~/.emacs.d/private` and adding 37 | these lines at `dotspacemacs-configuration-layers` in `.spacemacs` 38 | 39 | ``` 40 | ess 41 | funk 42 | polymode 43 | ``` 44 | 45 | ## Miscelaneous 46 | 47 | ### Using elpy instead of python layer 48 | 49 | To use Python in spacemacs, the default choice is to enable the `python` 50 | layer. This layer has by default the `anaconda-mode`, which has some 51 | particularities I personally don't like. An alternative is to use 52 | [elpy], which is a completely different project, and is much more 53 | similar to the ESS layer for R. 54 | 55 | To avoid conflicts, Spacemacs doesn't have an `elpy` layer by default. 56 | So, it is necessary to include this layer by yourself. To do this, you 57 | can copy this layer from this 58 | [repository](https://github.com/rgemulla/spacemacs-layers) and place it 59 | under your `~/.emacs.d/private/` directory. After doin that, you can 60 | enable the `elpy` layer in your `~/.spacemacs`. 61 | 62 | **Important:** don't enable the `python` layer at the same time as the 63 | `elpy` layer as this may cause some conflicts. The `elpy` layer will be 64 | the only one responsible for handling python files and modes. 65 | 66 | ### Maxima mode 67 | 68 | There is no specific layer to enable the `maxima-mode` in Spacemacs. 69 | Anyway you can just follow the instructions from 70 | [here](https://www.emacswiki.org/emacs/MaximaMode) and include the 71 | appropriate lines in `user-config()` section of your `~/.spacemacs`. 72 | 73 | Some details: 74 | 75 | - Use `.max` extension 76 | - `M-x maxima-mode` in the file 77 | - `M-x imaxima` to open a Maxima terminal with the output rendered as 78 | LaTeX 79 | - Basic commands: 80 | - `C-c C-c`: send a line 81 | - `C-c *`: open a commentary block 82 | - `M-;`: comment a line 83 | 84 | 85 | [polymode]: https://github.com/vspinu/polymode 86 | [R Coding Standards]: https://cran.r-project.org/doc/manuals/R-ints.html#R-coding-standards 87 | [Spacemacs]: http://spacemacs.org/ 88 | [Emacs]: https://www.gnu.org/software/emacs/ 89 | [Vim]: http://www.vim.org/ 90 | [elpy]: https://github.com/jorgenschaefer/elpy 91 | -------------------------------------------------------------------------------- /private/elpy/README.org: -------------------------------------------------------------------------------- 1 | * elpy layer 2 | A [[http:spacemacs.org][Spacemacs]] layer that allows to work with Python in style similar to [[http:ess.r-project.org][ESS]]. The 3 | layer is based on [[https:github.com/jorgenschaefer/elpy][elpy]] and is an alternative to the ~python~ layer of Spacemacs. 4 | 5 | Most of the functionality originally provided by this layer has meanwhile been 6 | integrated into ~elpy~. This layer now mainly sets things up an adds suitable 7 | keybindings. 8 | 9 | ** Sending code fragments to the shell 10 | 11 | Provides keybindings to send a Python statement, function definition, a class 12 | definition, a top-level statement, a group of Python statements, a cell, a 13 | region, or a buffer to the Python shell. 14 | 15 | Each evaluation function has four variants, one for each combination of: whether 16 | or not the point should move after sending ("step"), and whether or not the 17 | Python shell should be focused after sending ("go"). 18 | 19 | These commands are bound to prefix ~,e~ (send and keep point) and prefix ~,s~ 20 | (send and step). The suffixes are ~e~ for statement, ~f~ for function, ~c~ for 21 | class, ~s~ for top-level statement, ~g~ for group (sequence of top-level 22 | statements not separated by a blank line), ~w~ for cell, ~r~ for region, and ~b~ 23 | for buffer. Capital suffix letters focus on the Python shell after sending. 24 | 25 | For example: 26 | | ~,ef~ | Evaluate current function and keep the point where it is | 27 | | ~,eF~ | Evaluate current function, keep the point where it is, and switch focus to the Python shell | 28 | | ~,sf~ | Evaluate current function and move point to first subsequent statement | 29 | | ~,sF~ | Evaluate current function, move point to first subsequent statement, and switch focus to the Python shell | 30 | 31 | ** Toggles 32 | | ~,td~ | Toggle whether to show the shell buffer after sending something to it | 33 | | ~,ti~ | Toggle whether to show code fragments sent to the shell in the shell buffer | 34 | | ~,to~ | Toggle whether to show shell outputs in the echo area | 35 | 36 | ** python-mode bindings 37 | | ~,h~ | elpy-doc | 38 | | ~,ga~ | elpy-goto-assignment | 39 | | ~,gA~ | elpy-goto-assignment-other-window | 40 | | ~,gg~ | elpy-goto-definition | 41 | | ~,go~ | elpy-occur-definitions | 42 | | ~,gG~ | elpy-goto-definition-other-window | 43 | | ~,gi~ | elpy-shell-switch-to-shell | 44 | | ~,gI~ | elpy-shell-switch-to-shell-in-current-window | 45 | | ~,ee~ | elpy-shell-send-statement | 46 | | ~,eE~ | elpy-shell-send-statement-and-go | 47 | | ~,es~ | elpy-shell-send-top-statement | 48 | | ~,eS~ | elpy-shell-send-top-statement-and-go | 49 | | ~,ef~ | elpy-shell-send-defun | 50 | | ~,eF~ | elpy-shell-send-defun-and-go | 51 | | ~,ec~ | elpy-shell-send-defclass | 52 | | ~,eC~ | elpy-shell-send-defclass-and-go | 53 | | ~,eg~ | elpy-shell-send-group | 54 | | ~,eG~ | elpy-shell-send-group-and-go | 55 | | ~,ew~ | elpy-shell-send-codecell | 56 | | ~,eW~ | elpy-shell-send-codecell-and-go | 57 | | ~,er~ | elpy-shell-send-region-or-buffer | 58 | | ~,eR~ | elpy-shell-send-region-or-buffer-and-go | 59 | | ~,eb~ | elpy-shell-send-buffer | 60 | | ~,eB~ | elpy-shell-send-buffer-and-go | 61 | | ~,se~ | elpy-shell-send-statement-and-step | 62 | | ~,sE~ | elpy-shell-send-statement-and-step-and-go | 63 | | ~,ss~ | elpy-shell-send-top-statement-and-step | 64 | | ~,sS~ | elpy-shell-send-top-statement-and-step-and-go | 65 | | ~,sf~ | elpy-shell-send-defun-and-step | 66 | | ~,sF~ | elpy-shell-send-defun-and-step-and-go | 67 | | ~,sc~ | elpy-shell-send-defclass-and-step | 68 | | ~,sC~ | elpy-shell-send-defclass-and-step-and-go | 69 | | ~,sg~ | elpy-shell-send-group-and-step | 70 | | ~,sG~ | elpy-shell-send-group-and-step-and-go | 71 | | ~,sw~ | elpy-shell-send-codecell-and-step | 72 | | ~,sW~ | elpy-shell-send-codecell-and-step-and-go | 73 | | ~,sr~ | elpy-shell-send-region-or-buffer-and-step | 74 | | ~,sR~ | elpy-shell-send-region-or-buffer-and-step-and-go | 75 | | ~,sb~ | elpy-shell-send-buffer-and-step | 76 | | ~,sB~ | elpy-shell-send-buffer-and-step-and-go | 77 | | ~,Va~ | pyvenv-activate | 78 | | ~,Vd~ | pyvenv-deactivate | 79 | | ~,Vw~ | pyvenv-workon | 80 | | ~,nc~ | elpy/insert-codecell-above | 81 | | ~,nm~ | elpy/insert-markdowncell-above | 82 | 83 | ** inferior-python-mode bindings 84 | In the Python shell, ~C-r~ is bound to counsel the shell history. 85 | 86 | | ~,gi~ | elpy-shell-switch-to-buffer | 87 | | ~,gI~ | elpy-shell-switch-to-buffer-in-current-window | 88 | -------------------------------------------------------------------------------- /private/elpy/packages.el: -------------------------------------------------------------------------------- 1 | ;; -*- lexical-binding: t -*- 2 | ;; 3 | ;; Author: Rainer Gemulla 4 | ;; 5 | ;; This file is not part of GNU Emacs. 6 | ;; 7 | ;;; Code: 8 | 9 | (defconst elpy-packages 10 | '(python 11 | elpy 12 | jedi)) 13 | 14 | (defun elpy/init-python () 15 | (use-package python 16 | :defer t 17 | :mode (("\\.py\\'" . python-mode) 18 | ("\\.ipy\\'" . python-mode)) 19 | :init 20 | (setq-default python-indent-offset 4) 21 | :config 22 | (add-hook 'inferior-python-mode-hook 23 | (lambda () 24 | ;; disable smartscan-mode to make M-p and M-n select previous/next statement in python shell 25 | (when (featurep 'smartscan) 26 | (smartscan-mode -1)) 27 | 28 | ;; for some reason, q is bound to exit even in insert state -> undo this 29 | (define-key evil-insert-state-local-map "q" 'self-insert-command) 30 | )) 31 | )) 32 | 33 | (defun elpy/init-jedi () 34 | (use-package jedi 35 | :after python 36 | )) 37 | 38 | (defun elpy/init-elpy () 39 | (use-package elpy 40 | :after (python jedi) 41 | :config 42 | ;; enable elpy 43 | (elpy-enable) 44 | 45 | ;; set lighter 46 | (diminish 'elpy-mode " Ⓔ") 47 | 48 | ;; configure auto-completion 49 | (setq elpy-rpc-backend "jedi") 50 | (add-hook 'elpy-mode-hook 51 | '(lambda () 52 | ;; after 2 seconds or C-tab 53 | (setq company-minimum-prefix-length 2) 54 | (setq company-idle-delay 2) 55 | (define-key elpy-mode-map (kbd "") 'company-complete))) 56 | 57 | ;; python-mode key bindings 58 | (spacemacs/declare-prefix-for-mode 'python-mode "mh" "help") 59 | (spacemacs/declare-prefix-for-mode 'python-mode "mg" "goto") 60 | (spacemacs/declare-prefix-for-mode 'python-mode "me" "send to REPL") 61 | (spacemacs/declare-prefix-for-mode 'python-mode "ms" "send to REPL and step") 62 | (spacemacs/declare-prefix-for-mode 'python-mode "mr" "refactor") 63 | (spacemacs/declare-prefix-for-mode 'python-mode "mV" "pyvenv") 64 | (spacemacs/declare-prefix-for-mode 'python-mode "mn" "notebook") 65 | (spacemacs/declare-prefix-for-mode 'python-mode "mt" "toggle") 66 | (spacemacs/set-leader-keys-for-major-mode 'python-mode 67 | "hh" 'elpy-doc 68 | "ga" 'elpy-goto-assignment 69 | "gA" 'elpy-goto-assignment-other-window 70 | "go" 'elpy-occur-definitions 71 | "gi" 'elpy-shell-switch-to-shell 72 | "gI" 'elpy-shell-switch-to-shell-in-current-window 73 | "ee" 'elpy-shell-send-statement 74 | "eE" 'elpy-shell-send-statement-and-go 75 | "es" 'elpy-shell-send-top-statement 76 | "eS" 'elpy-shell-send-top-statement-and-go 77 | "ef" 'elpy-shell-send-defun 78 | "eF" 'elpy-shell-send-defun-and-go 79 | "ec" 'elpy-shell-send-defclass 80 | "eC" 'elpy-shell-send-defclass-and-go 81 | "eg" 'elpy-shell-send-group 82 | "eG" 'elpy-shell-send-group-and-go 83 | "ew" 'elpy-shell-send-codecell 84 | "eW" 'elpy-shell-send-codecell-and-go 85 | "er" 'elpy-shell-send-region-or-buffer 86 | "eR" 'elpy-shell-send-region-or-buffer-and-go 87 | "eb" 'elpy-shell-send-buffer 88 | "eB" 'elpy-shell-send-buffer-and-go 89 | "se" 'elpy-shell-send-statement-and-step 90 | "sE" 'elpy-shell-send-statement-and-step-and-go 91 | "ss" 'elpy-shell-send-top-statement-and-step 92 | "sS" 'elpy-shell-send-top-statement-and-step-and-go 93 | "sf" 'elpy-shell-send-defun-and-step 94 | "sF" 'elpy-shell-send-defun-and-step-and-go 95 | "sc" 'elpy-shell-send-defclass-and-step 96 | "sC" 'elpy-shell-send-defclass-and-step-and-go 97 | "sg" 'elpy-shell-send-group-and-step 98 | "sG" 'elpy-shell-send-group-and-step-and-go 99 | "sw" 'elpy-shell-send-codecell-and-step 100 | "sW" 'elpy-shell-send-codecell-and-step-and-go 101 | "sr" 'elpy-shell-send-region-or-buffer-and-step 102 | "sR" 'elpy-shell-send-region-or-buffer-and-step-and-go 103 | "sb" 'elpy-shell-send-buffer-and-step 104 | "sB" 'elpy-shell-send-buffer-and-step-and-go 105 | "rc" 'elpy-check 106 | "re" 'elpy-multiedit 107 | "rf" 'elpy-format-code 108 | "rr" 'elpy-refactor 109 | "rs" 'elpy-rgrep-symbol 110 | "Va" 'pyvenv-activate 111 | "Vd" 'pyvenv-deactivate 112 | "Vw" 'pyvenv-workon 113 | "nc" 'elpy/insert-codecell-above 114 | "nm" 'elpy/insert-markdowncell-above) 115 | 116 | ;; jump handlers 117 | (add-to-list 'spacemacs-jump-handlers-python-mode 118 | '(elpy-goto-definition) t) 119 | (add-to-list 'spacemacs-jump-handlers-python-mode 120 | '(dumb-jump-go) t) 121 | 122 | ;; inferior-python-mode key bindings 123 | (spacemacs/declare-prefix-for-mode 'inferior-python-mode "mg" "goto") 124 | (spacemacs/set-leader-keys-for-major-mode 'inferior-python-mode 125 | "gi" 'elpy-shell-switch-to-buffer 126 | "gI" 'elpy-shell-switch-to-buffer-in-current-window) 127 | (with-eval-after-load 'counsel 128 | (define-key inferior-python-mode-map (kbd "C-r") 'counsel-shell-history)) 129 | (with-eval-after-load 'helm 130 | (define-key inferior-python-mode-map (kbd "C-r") 'spacemacs/helm-shell-history)) 131 | 132 | ;; toggles 133 | (spacemacs/declare-prefix-for-mode 'python-mode "mt" "toggles") 134 | (spacemacs|add-toggle elpy/shell-display-buffer-after-send 135 | :documentation "Toggles whether to show the python shell after sending something to it" 136 | :status elpy-shell-display-buffer-after-send 137 | :on (setq elpy-shell-display-buffer-after-send t) 138 | :off (setq elpy-shell-display-buffer-after-send nil) 139 | :evil-leader-for-mode (python-mode . "td")) 140 | 141 | (spacemacs|add-toggle elpy/shell-echo-input 142 | :documentation "Toggles whether to echo input sent to the Python shell in the shell buffer" 143 | :status elpy-shell-echo-input 144 | :on (setq elpy-shell-echo-input t) 145 | :off (setq elpy-shell-echo-input nil) 146 | :evil-leader-for-mode (python-mode . "ti")) 147 | 148 | (spacemacs|add-toggle elpy/shell-echo-output 149 | :documentation "Toggles whether to echo the Python shell output in the echo area" 150 | :status elpy-shell-echo-output 151 | :on (setq elpy-shell-echo-output 'when-shell-not-visible) 152 | :off (setq elpy-shell-echo-output nil) 153 | :evil-leader-for-mode (python-mode . "to")) 154 | )) 155 | -------------------------------------------------------------------------------- /private/ess/local/essh/essh.el: -------------------------------------------------------------------------------- 1 | ;;; essh.el --- a set of commands that emulate for bash what ESS is to R. 2 | ;; https://www.emacswiki.org/emacs/essh.el 3 | ;; Filename: essh.el 4 | 5 | 6 | ;; ------------------------------------------------------------------ ;; 7 | ;; TO INSTALL: ;; 8 | ;; 1. add essh.el in your load-path. ;; 9 | ;; ;; 10 | ;; 2. add to your .emacs file: ;; 11 | ;; ;; 12 | ;; (require 'essh) ;; 13 | ;; (defun essh-sh-hook () ;; 14 | ;; (define-key sh-mode-map "\C-c\C-r" 'pipe-region-to-shell) ;; 15 | ;; (define-key sh-mode-map "\C-c\C-b" 'pipe-buffer-to-shell) ;; 16 | ;; (define-key sh-mode-map "\C-c\C-j" 'pipe-line-to-shell) ;; 17 | ;; (define-key sh-mode-map "\C-c\C-n" 'pipe-line-to-shell-and-step) ;; 18 | ;; (define-key sh-mode-map "\C-c\C-f" 'pipe-function-to-shell) ;; 19 | ;; (define-key sh-mode-map "\C-c\C-d" 'shell-cd-current-directory)) ;; 20 | ;; (add-hook 'sh-mode-hook 'essh-sh-hook) ;; 21 | ;; ------------------------------------------------------------------ ;; 22 | 23 | ;; function taken from ess package 24 | (defun essh-next-code-line (&optional arg) 25 | "Move ARG lines of code forward (backward if ARG is negative). 26 | Skips past all empty and comment lines. Default for ARG is 1. 27 | 28 | On success, return 0. Otherwise, go as far as possible and return -1." 29 | (interactive "p") 30 | (or arg (setq arg 1)) 31 | (beginning-of-line) 32 | (let ((n 0) 33 | (inc (if (> arg 0) 1 -1))) 34 | (while (and (/= arg 0) (= n 0)) 35 | (setq n (forward-line inc)); n=0 is success 36 | (while (and (= n 0) 37 | (looking-at "\\s-*\\($\\|\\s<\\)")) 38 | (setq n (forward-line inc))) 39 | (setq arg (- arg inc))) 40 | n)) 41 | 42 | (defun process-shell () 43 | "returns a list with existing shell process." 44 | (interactive) 45 | (setq listpr (process-list)) 46 | (setq lengthpr (length listpr)) 47 | (setq i 0) 48 | (setq listshellp '()) 49 | (while (< i lengthpr) 50 | (setq pos (string-match "shell" (prin1-to-string (elt listpr i)))) 51 | (if pos (add-to-list 'listshellp (process-name (get-process (elt listpr i))))) 52 | (setq i (+ 1 i))) 53 | listshellp) 54 | 55 | 56 | (defun process-shell-choose () 57 | "returns which process to use." 58 | (interactive) 59 | (setq outpr 0) 60 | (setq cbuf (current-buffer)) 61 | (setq shelllist (process-shell)) 62 | (setq shelln (length shelllist)) 63 | (if (eq shelln 0) 64 | (progn (shell) 65 | (switch-to-buffer cbuf) 66 | (setq outpr (get-process "shell")) 67 | (sleep-for 0.5))) 68 | (if (eq shelln 1) 69 | (setq outpr (get-process (elt shelllist 0)))) 70 | (if (> shelln 1) 71 | (progn 72 | (setq proc (completing-read "Send code to:" shelllist nil t (elt shelllist 0))) 73 | (setq outpr (get-process proc)))) 74 | outpr) 75 | 76 | 77 | (defun shell-eval-line (sprocess command) 78 | "Evaluates a single command into the shell process." 79 | (setq sbuffer (process-buffer sprocess)) 80 | (setq command (concat command "\n")) 81 | (accept-process-output sprocess 0 10) 82 | (with-current-buffer sbuffer 83 | (end-of-buffer) ;point is not seen being moved (unless sbuffer is focused) 84 | (insert command) ;pastes the command to shell 85 | (set-marker (process-mark sprocess) (point-max)) 86 | (process-send-string sprocess command) 87 | ;; (accept-process-output sprocess 0 10) 88 | )) 89 | 90 | (defun shell-cd-current-directory () 91 | "Changes the shell working directory to the current buffer's one." 92 | (interactive) 93 | (setq sprocess (process-shell-choose)) 94 | (setq com (format "cd %s" (file-name-directory default-directory))) 95 | (shell-eval-line sprocess com)) 96 | 97 | 98 | (defun pipe-line-to-shell (&optional step) 99 | "Evaluates the current line to the shell." 100 | (interactive ()) 101 | (setq com (buffer-substring (point-at-bol) (point-at-eol))) 102 | (if (> (length com) 0) 103 | (progn 104 | (setq sprocess (process-shell-choose)) 105 | (shell-eval-line sprocess com) 106 | (when step (essh-next-code-line))) 107 | (message "No command in this line"))) 108 | 109 | (defun pipe-line-to-shell-and-step () 110 | "Evaluates the current line to the shell and goes to next line." 111 | (interactive) 112 | (pipe-line-to-shell t)) 113 | 114 | (defun pipe-region-to-shell (start end) 115 | "Sends a region to the shell." 116 | (interactive "r") 117 | (setq com (buffer-substring start end)) ;reads command 118 | (setq lcom (length com)) ;count chars 119 | (setq lastchar (substring com (1- lcom) lcom)) ;get last char 120 | (unless (string-match "\n" lastchar) ;if last char is not "\n", then... 121 | (setq com (concat com "\n"))) ;...add it! 122 | (setq sprocess (process-shell-choose)) 123 | (setq sbuffer (process-buffer sprocess)) 124 | (while (> (length com) 0) 125 | (setq pos (string-match "\n" com)) 126 | (setq scom (substring com 0 pos)) 127 | (setq com (substring com (min (length com) (1+ pos)))) 128 | (shell-eval-line sprocess scom) 129 | (accept-process-output sprocess 0 10) 130 | )) 131 | 132 | 133 | (defun pipe-buffer-to-shell () 134 | "Evaluate whole buffer to the shell." 135 | (interactive) 136 | (pipe-region-to-shell (point-min) (point-max))) 137 | 138 | (defun pipe-function-to-shell () 139 | "Evaluate function to the shell." 140 | (interactive) 141 | (setq beg-end (essh-beg-end-of-function)) 142 | (if beg-end 143 | (save-excursion 144 | (setq beg (nth 0 beg-end)) 145 | (setq end (nth 1 beg-end)) 146 | (goto-line beg) 147 | (setq origin (point-at-bol)) 148 | (goto-line end) 149 | (setq terminal (point-at-eol)) 150 | (pipe-region-to-shell origin terminal)) 151 | (message "No function at current point."))) 152 | 153 | (defun essh-beg-end-of-function () 154 | "Returns the lines where the function starts and ends. If there is no function at current line, it returns nil." 155 | (interactive) 156 | (setq curline (line-number-at-pos)) ;current line 157 | (setq curcom (buffer-substring (point-at-bol) (point-at-eol))) 158 | (setq pos (string-match "function" curcom)) 159 | (save-excursion 160 | (if pos 161 | (progn 162 | (setq beg curline)) 163 | (progn 164 | (while (not pos) 165 | (setq curline (1- curline)) ;current line 166 | (previous-line) ;go to previous line 167 | (setq curcom (buffer-substring (point-at-bol) (point-at-eol))) 168 | (setq pos (string-match "function" curcom))) 169 | (setq beg curline))) 170 | (beginning-of-line) 171 | (forward-list) ; move pointer to first matching brace 172 | (setq end (line-number-at-pos))) 173 | ;; (message (format "%d %d" beg end)) 174 | (if (and (<= (line-number-at-pos) end) (>= (line-number-at-pos) beg)) 175 | (list beg end) 176 | nil)) 177 | 178 | 179 | (provide 'essh) 180 | -------------------------------------------------------------------------------- /private/funk/funcs.el: -------------------------------------------------------------------------------- 1 | ;;====================================================================== 2 | ;; Functions only 3 | ;;====================================================================== 4 | 5 | ;;====================================================================== 6 | ;; (R) markdown mode 7 | ;;====================================================================== 8 | 9 | ;; Insert a new (empty) chunk to R markdown ============================ 10 | (defun insert-chunk () 11 | "Insert chunk environment Rmd sessions." 12 | (interactive) 13 | (insert "```{r}\n\n```") 14 | (forward-line -1) 15 | ) 16 | ;; key binding 17 | (global-set-key (kbd "C-c i") 'insert-chunk) 18 | 19 | ;; Insert a special comment ============================================ 20 | ;; To give a name to a code block, to be used in knitr code 21 | ;; externalization scripts 22 | (defun insert-chunk-name () 23 | "Create special commments for code externalization" 24 | (interactive) 25 | (insert "## ----- ") 26 | ) 27 | ;; key binding 28 | (global-set-key (kbd "C-c n") 'insert-chunk-name) 29 | 30 | ;; Mark a word at a point ============================================== 31 | ;; http://www.emacswiki.org/emacs/ess-edit.el 32 | (defun ess-edit-word-at-point () 33 | (save-excursion 34 | (buffer-substring 35 | (+ (point) (skip-chars-backward "a-zA-Z0-9._")) 36 | (+ (point) (skip-chars-forward "a-zA-Z0-9._"))))) 37 | ;; eval any word where the cursor is (objects, functions, etc) 38 | (defun ess-eval-word () 39 | (interactive) 40 | (let ((x (ess-edit-word-at-point))) 41 | (ess-eval-linewise (concat x))) 42 | ) 43 | ;; key binding 44 | (global-set-key (kbd "C-c r") 'ess-eval-word) 45 | 46 | ;;====================================================================== 47 | ;; Text functions 48 | ;; From @walmes in 49 | ;; https://github.com/walmes/emacs/blob/master/functions.el 50 | ;;====================================================================== 51 | 52 | ;; Duplicate lines ===================================================== 53 | (defun duplicate-line () 54 | (interactive) 55 | (move-beginning-of-line 1) 56 | (kill-line) 57 | (yank) 58 | (newline) 59 | (yank) 60 | ) 61 | ;; key binding 62 | (global-set-key (kbd "\C-c d") 'duplicate-line) 63 | 64 | ;; (un)Comment without selection ======================================= 65 | (defun comment-line-or-region () 66 | "Comment or uncomment current line, or current text selection." 67 | (interactive) 68 | (if (region-active-p) 69 | (comment-or-uncomment-region 70 | (region-beginning) 71 | (region-end) 72 | ) 73 | (comment-or-uncomment-region 74 | (line-beginning-position) 75 | (line-beginning-position 2) 76 | ) 77 | ) 78 | ) 79 | ;; key binding 80 | (global-set-key (kbd "M-;") 'comment-line-or-region) 81 | 82 | ;; Commented rules to divide code ====================================== 83 | (defun blank-line-p () 84 | (string-match "^[[:space:]]*$" 85 | (buffer-substring-no-properties 86 | (line-beginning-position) 87 | (line-end-position) ))) 88 | 89 | (defun insert-rule-from-point-to-margin (&optional rule-char) 90 | "Insert a commented rule with dashes (-) from the `point' to 91 | the `fill-column' if the line has only spaces. If the line has 92 | text, fill with dashes until the `fill-column'. Useful to 93 | divide your code in sections. If a non nil prefix argument is 94 | passed, then (=) is used instead." 95 | (interactive) 96 | (if (blank-line-p) 97 | (progn 98 | (insert "-") 99 | (comment-line-or-region) 100 | (delete-char -2)) 101 | nil) 102 | (if rule-char 103 | (insert (make-string (- fill-column (current-column)) ?=)) 104 | (insert (make-string (- fill-column (current-column)) ?-))) 105 | ) 106 | ;; key binding 107 | (global-set-key [?\C-\M--] 'insert-rule-from-point-to-margin) 108 | (global-set-key [?\C-\M-=] 109 | (lambda () 110 | (interactive) 111 | (insert-rule-from-point-to-margin 1))) 112 | 113 | (defun insert-rule-and-comment-3 () 114 | "Insert a commented rule with 43 dashes (-). Useful to divide 115 | your code in sections." 116 | (interactive) 117 | (insert (make-string 43 ?-)) 118 | (comment-or-uncomment-region 119 | (line-beginning-position) 120 | (line-beginning-position 2)) 121 | (backward-char 44) 122 | (delete-char 1) 123 | (move-end-of-line nil) 124 | ) 125 | ;; key binding 126 | (global-set-key [?\C--] 'insert-rule-and-comment-3) 127 | 128 | 129 | ;; Move lines ========================================================== 130 | ;; http://www.emacswiki.org/emacs/MoveLine 131 | (defun move-line (n) 132 | "Move the current line up or down by N lines." 133 | (interactive "p") 134 | (setq col (current-column)) 135 | (beginning-of-line) (setq start (point)) 136 | (end-of-line) (forward-char) (setq end (point)) 137 | (let ((line-text (delete-and-extract-region start end))) 138 | (forward-line n) 139 | (insert line-text) 140 | ;; restore point to original column in moved line 141 | (forward-line -1) 142 | (forward-char col))) 143 | 144 | (defun move-line-up (n) 145 | "Move the current line up by N lines." 146 | (interactive "p") 147 | (move-line (if (null n) -1 (- n)))) 148 | 149 | (defun move-line-down (n) 150 | "Move the current line down by N lines." 151 | (interactive "p") 152 | (move-line (if (null n) 1 n))) 153 | 154 | (global-set-key (kbd "M-[") 'move-line-up) 155 | (global-set-key (kbd "M-]") 'move-line-down) 156 | 157 | ;; Move regions ======================================================== 158 | (defun move-region (start end n) 159 | "Move the current region up or down by N lines." 160 | (interactive "r\np") 161 | (let ((line-text (delete-and-extract-region start end))) 162 | (forward-line n) 163 | (let ((start (point))) 164 | (insert line-text) 165 | (setq deactivate-mark nil) 166 | (set-mark start)))) 167 | 168 | (defun move-region-up (start end n) 169 | "Move the current line up by N lines." 170 | (interactive "r\np") 171 | (move-region start end (if (null n) -1 (- n)))) 172 | 173 | (defun move-region-down (start end n) 174 | "Move the current line down by N lines." 175 | (interactive "r\np") 176 | (move-region start end (if (null n) 1 n))) 177 | 178 | (global-set-key (kbd "M-{") 'move-region-up) 179 | (global-set-key (kbd "M-}") 'move-region-down) 180 | 181 | ;;====================================================================== 182 | 183 | ;; To revert-buffer without confirmation =============================== 184 | ;; Source: http://www.emacswiki.org/emacs-en/download/misc-cmds.el 185 | (defun revert-buffer-no-confirm () 186 | "Revert buffer without confirmation." 187 | (interactive) 188 | (revert-buffer t t)) 189 | ;; key binding 190 | (global-set-key [f5] 'revert-buffer-no-confirm) 191 | 192 | ;; COPY the current line, whithout selecting it ======================== 193 | ;; Source: http://www.emacswiki.org/emacs/CopyingWholeLines 194 | (defun quick-copy-line () 195 | "Copy the whole line that point is on and move to the beginning of the next line. 196 | Consecutive calls to this command append each line to the 197 | kill-ring." 198 | (interactive) 199 | (let ((beg (line-beginning-position 1)) 200 | (end (line-beginning-position 2))) 201 | (if (eq last-command 'quick-copy-line) 202 | (kill-append (buffer-substring beg end) (< end beg)) 203 | (kill-new (buffer-substring beg end)))) 204 | (beginning-of-line 2)) 205 | ;; key binding 206 | ;; (global-set-key "\C-c\M-w" 'quick-copy-line) 207 | (global-set-key (kbd "C-") 'quick-copy-line) 208 | 209 | ;; CUT the current line without selecting it 210 | (defun quick-cut-line () 211 | "Cut the whole line that point is on. Consecutive calls to this 212 | command append each line to the kill-ring." 213 | (interactive) 214 | (let ((beg (line-beginning-position 1)) 215 | (end (line-beginning-position 2))) 216 | (if (eq last-command 'quick-cut-line) 217 | (kill-append (buffer-substring beg end) (< end beg)) 218 | (kill-new (buffer-substring beg end))) 219 | (delete-region beg end)) 220 | (beginning-of-line 1) 221 | (setq this-command 'quick-cut-line)) 222 | ;; key binding 223 | ;; (global-set-key "\C-c\M-k" 'quick-cut-line) 224 | (global-set-key (kbd "s-") 'quick-cut-line) 225 | -------------------------------------------------------------------------------- /private/ess/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- ESS 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 | (defvar ess-enable-smart-equals nil 15 | "If non-nil smart-equal support is enabled") 16 | 17 | (defvar ess-enable-smartparens nil 18 | "If non-nil smartparens support is enabled") 19 | 20 | ;; List of available commands to weave Rnw files. This changes the 21 | ;; default to pdflatex 22 | (setq ess-swv-pdflatex-commands '("pdflatex" "make" "texi2pdf")) 23 | 24 | ;; Set ess-eval-visibly to true, since from version 19.04 (March 2020), 25 | ;; it was set to nil by default. When non-nil, this makes code sent to 26 | ;; iESS buffer to appear in the console, instead of appearing only 27 | ;; outputs. 28 | (setq ess-eval-visibly t) 29 | 30 | ;; No indent levels, i.e., no more identation with one '#' 31 | (setq ess-indent-with-fancy-comments nil) 32 | 33 | (setq ess-offset-arguments 'prev-line) 34 | 35 | ;;====================================================================== 36 | ;; Content from ess-style-alist 37 | 38 | ;; ess-style-alist is a variable defined in ‘ess-custom.el’. 39 | 40 | ;; Its value is shown below. 41 | 42 | ;; Predefined formatting styles for ESS code. 43 | ;; Use ‘ess-set-style’ to apply a style in all R buffers. The values of 44 | ;; all styles except OWN are fixed. To change the value of variables 45 | ;; in the OWN group, customize the variable ‘ess-own-style-list’. 46 | ;; DEFAULT style picks default (aka global) values from ESS 47 | ;; indentation variables. In addition, ESS provides many indentation 48 | ;; styles, the most important being the RRR and the RStudio 49 | ;; variants. 50 | 51 | ;; RRR is the common R style that adheres closely to R internal 52 | ;; standards. RRR+ is the same except it also aligns blocks in 53 | ;; function calls with the opening delimiter, producing more 54 | ;; indentation. The C++ style (named like this for historical 55 | ;; reasons rather than any resemblance to existing C++ indentation 56 | ;; schemes) is halfway between these two styles and indent block 57 | ;; arguments from the start of the surrounding function’s name. 58 | 59 | ;; The RStudio style closely mimics the indentation of the RStudio 60 | ;; editor. RStudio- is the same except it does not align arguments 61 | ;; in function calls, which corresponds to the settings of some 62 | ;; RStudio users. 63 | 64 | ;; ESS indentation is fully specified by the following offsets and 65 | ;; variables. See the documentation of these variables for examples. 66 | 67 | ;; Offsets: 68 | 69 | ;; - ‘ess-indent-offset’: main offset inherited by other settings 70 | 71 | ;; - ‘ess-offset-arguments’: offset type for function and bracket 72 | ;; arguments 73 | 74 | ;; - ‘ess-offset-arguments-newline’: offset type of arguments 75 | ;; when ( or [ is followed by a new line. 76 | 77 | ;; - ‘ess-offset-block’: offset type for brace and anonymous 78 | ;; parenthesis blocks 79 | 80 | ;; - ‘ess-offset-continued’: offset type for continuation lines in 81 | ;; multiline statements 82 | 83 | 84 | ;; Overrides (implies vertical alignment): 85 | 86 | ;; - ‘ess-align-nested-calls’: functions whose nested calls 87 | ;; should be aligned. 88 | 89 | ;; - ‘ess-align-arguments-in-calls’: calls where 90 | ;; ‘ess-offset-arguments’ should be ignored 91 | 92 | ;; - ‘ess-align-continuations-in-calls’: whether to ignore 93 | ;; ‘ess-offset-continued’ in calls. 94 | 95 | ;; - ‘ess-align-blocks’: whether to ignore ‘ess-offset-blocks’ for 96 | ;; function declarations or control flow statements. 97 | 98 | 99 | ;; Control variables: 100 | 101 | ;; - ‘ess-indent-from-lhs’: whether to indent arguments from 102 | ;; left-hand side of an assignment or parameter declaration. 103 | 104 | ;; - ‘ess-indent-from-chain-start’: whether to indent arguments from 105 | ;; the first of several consecutive calls. 106 | 107 | ;; - ‘ess-indent-with-fancy-comments’: whether to indent #, ## and 108 | ;; ### comments distinctly. 109 | 110 | ;; Value: 111 | ;; ((OWN 112 | ;; (ess-indent-offset . 2) 113 | ;; (ess-offset-arguments . open-delim) 114 | ;; (ess-offset-arguments-newline . prev-line) 115 | ;; (ess-offset-block . prev-line) 116 | ;; (ess-offset-continued . straight) 117 | ;; (ess-align-nested-calls "ifelse") 118 | ;; (ess-align-arguments-in-calls "function[ ]*(") 119 | ;; (ess-align-continuations-in-calls . t) 120 | ;; (ess-align-blocks control-flow) 121 | ;; (ess-indent-from-lhs arguments fun-decl-opening) 122 | ;; (ess-indent-from-chain-start . t) 123 | ;; (ess-indent-with-fancy-comments)) 124 | ;; (BSD 125 | ;; (ess-indent-offset . 8) 126 | ;; (ess-offset-arguments . open-delim) 127 | ;; (ess-offset-arguments-newline . prev-line) 128 | ;; (ess-offset-block . prev-call) 129 | ;; (ess-offset-continued . straight) 130 | ;; (ess-align-nested-calls . #1=("ifelse")) 131 | ;; (ess-align-arguments-in-calls . #2=("function[ ]*(")) 132 | ;; (ess-align-continuations-in-calls . t) 133 | ;; (ess-align-blocks . #3=(control-flow)) 134 | ;; (ess-indent-from-lhs . #4=(arguments fun-decl-opening)) 135 | ;; (ess-indent-from-chain-start . t) 136 | ;; (ess-indent-with-fancy-comments)) 137 | ;; (C++ 138 | ;; (ess-indent-offset . 4) 139 | ;; (ess-offset-arguments . open-delim) 140 | ;; (ess-offset-arguments-newline . prev-line) 141 | ;; (ess-offset-block . prev-call) 142 | ;; (ess-offset-continued . straight) 143 | ;; (ess-align-nested-calls . #1#) 144 | ;; (ess-align-arguments-in-calls . #2#) 145 | ;; (ess-align-continuations-in-calls . t) 146 | ;; (ess-align-blocks . #3#) 147 | ;; (ess-indent-from-lhs arguments) 148 | ;; (ess-indent-from-chain-start . t) 149 | ;; (ess-indent-with-fancy-comments)) 150 | ;; (CLB 151 | ;; (ess-indent-offset . 2) 152 | ;; (ess-offset-arguments . open-delim) 153 | ;; (ess-offset-arguments-newline . prev-line) 154 | ;; (ess-offset-block . prev-line) 155 | ;; (ess-offset-continued straight 4) 156 | ;; (ess-align-nested-calls . #1#) 157 | ;; (ess-align-arguments-in-calls . #2#) 158 | ;; (ess-align-continuations-in-calls . t) 159 | ;; (ess-align-blocks . #3#) 160 | ;; (ess-indent-from-lhs . #4#) 161 | ;; (ess-indent-from-chain-start . t) 162 | ;; (ess-indent-with-fancy-comments)) 163 | ;; (GNU 164 | ;; (ess-indent-offset . 2) 165 | ;; (ess-offset-arguments . open-delim) 166 | ;; (ess-offset-arguments-newline prev-call 4) 167 | ;; (ess-offset-block . prev-line) 168 | ;; (ess-offset-continued . straight) 169 | ;; (ess-align-nested-calls . #1#) 170 | ;; (ess-align-arguments-in-calls . #2#) 171 | ;; (ess-align-continuations-in-calls . t) 172 | ;; (ess-align-blocks . #3#) 173 | ;; (ess-indent-from-lhs . #4#) 174 | ;; (ess-indent-from-chain-start . t) 175 | ;; (ess-indent-with-fancy-comments)) 176 | ;; (K&R 177 | ;; (ess-indent-offset . 5) 178 | ;; (ess-offset-arguments . open-delim) 179 | ;; (ess-offset-arguments-newline . prev-line) 180 | ;; (ess-offset-block . prev-call) 181 | ;; (ess-offset-continued . straight) 182 | ;; (ess-align-nested-calls . #1#) 183 | ;; (ess-align-arguments-in-calls . #2#) 184 | ;; (ess-align-continuations-in-calls . t) 185 | ;; (ess-align-blocks . #3#) 186 | ;; (ess-indent-from-lhs . #4#) 187 | ;; (ess-indent-from-chain-start . t) 188 | ;; (ess-indent-with-fancy-comments)) 189 | ;; (RRR 190 | ;; (ess-indent-offset . 4) 191 | ;; (ess-offset-arguments . open-delim) 192 | ;; (ess-offset-arguments-newline . prev-line) 193 | ;; (ess-offset-block . prev-line) 194 | ;; (ess-offset-continued . straight) 195 | ;; (ess-align-nested-calls . #1#) 196 | ;; (ess-align-arguments-in-calls . #2#) 197 | ;; (ess-align-continuations-in-calls . t) 198 | ;; (ess-align-blocks . #3#) 199 | ;; (ess-indent-from-lhs . #4#) 200 | ;; (ess-indent-from-chain-start . t) 201 | ;; (ess-indent-with-fancy-comments)) 202 | ;; (RRR+ 203 | ;; (ess-indent-offset . 4) 204 | ;; (ess-offset-arguments . open-delim) 205 | ;; (ess-offset-arguments-newline . prev-line) 206 | ;; (ess-offset-block . open-delim) 207 | ;; (ess-offset-continued . straight) 208 | ;; (ess-align-nested-calls . #1#) 209 | ;; (ess-align-arguments-in-calls . #2#) 210 | ;; (ess-align-continuations-in-calls . t) 211 | ;; (ess-align-blocks . #3#) 212 | ;; (ess-indent-from-lhs arguments) 213 | ;; (ess-indent-from-chain-start) 214 | ;; (ess-indent-with-fancy-comments)) 215 | ;; (RStudio 216 | ;; (ess-indent-offset . 2) 217 | ;; (ess-offset-arguments . open-delim) 218 | ;; (ess-offset-arguments-newline . prev-line) 219 | ;; (ess-offset-block . prev-line) 220 | ;; (ess-offset-continued . straight) 221 | ;; (ess-align-nested-calls) 222 | ;; (ess-align-arguments-in-calls . #2#) 223 | ;; (ess-align-continuations-in-calls) 224 | ;; (ess-align-blocks) 225 | ;; (ess-indent-from-lhs arguments) 226 | ;; (ess-indent-from-chain-start . t) 227 | ;; (ess-indent-with-fancy-comments)) 228 | ;; (RStudio- 229 | ;; (ess-indent-offset . 2) 230 | ;; (ess-offset-arguments . prev-line) 231 | ;; (ess-offset-arguments-newline . prev-line) 232 | ;; (ess-offset-block . prev-line) 233 | ;; (ess-offset-continued . straight) 234 | ;; (ess-align-nested-calls) 235 | ;; (ess-align-arguments-in-calls . #2#) 236 | ;; (ess-align-continuations-in-calls) 237 | ;; (ess-align-blocks) 238 | ;; (ess-indent-from-lhs arguments) 239 | ;; (ess-indent-from-chain-start . t) 240 | ;; (ess-indent-with-fancy-comments)) 241 | ;; (DEFAULT 242 | ;; (ess-indent-offset . 2) 243 | ;; (ess-offset-arguments . open-delim) 244 | ;; (ess-offset-arguments-newline . prev-line) 245 | ;; (ess-offset-block . prev-line) 246 | ;; (ess-offset-continued . straight) 247 | ;; (ess-align-nested-calls . #1#) 248 | ;; (ess-align-arguments-in-calls . #2#) 249 | ;; (ess-align-continuations-in-calls . t) 250 | ;; (ess-align-blocks . #3#) 251 | ;; (ess-indent-from-lhs . #4#) 252 | ;; (ess-indent-from-chain-start . t) 253 | ;; (ess-indent-with-fancy-comments))) 254 | 255 | ;; [back] 256 | 257 | ;;====================================================================== 258 | -------------------------------------------------------------------------------- /private/ess/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- ESS (R) 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 ess-packages 13 | '( 14 | ;; company 15 | ess 16 | ess-R-data-view 17 | ;; ess-R-object-popup 18 | ess-smart-equals 19 | rainbow-delimiters 20 | (electric-spacing-r :location local) 21 | (essh :location local) 22 | smartparens 23 | essgd 24 | ;; :local electric-spacing-r 25 | )) 26 | 27 | (defun ess/init-ess () 28 | (use-package ess-site 29 | :mode (("\\.sp\\'" . S-mode) 30 | ("/R/.*\\.q\\'" . R-mode) 31 | ("\\.[qsS]\\'" . S-mode) 32 | ("\\.ssc\\'" . S-mode) 33 | ("\\.SSC\\'" . S-mode) 34 | ("\\.[rR]\\'" . R-mode) 35 | ("\\.[rR]nw\\'" . Rnw-mode) 36 | ("\\.[sS]nw\\'" . Snw-mode) 37 | ("\\.[rR]profile\\'" . R-mode) 38 | ("NAMESPACE\\'" . R-mode) 39 | ("CITATION\\'" . R-mode) 40 | ("\\.omg\\'" . omegahat-mode) 41 | ("\\.hat\\'" . omegahat-mode) 42 | ("\\.lsp\\'" . XLS-mode) 43 | ("\\.do\\'" . STA-mode) 44 | ("\\.ado\\'" . STA-mode) 45 | ("\\.[Ss][Aa][Ss]\\'" . SAS-mode) 46 | ("\\.jl\\'" . ess-julia-mode) 47 | ("\\.[Ss]t\\'" . S-transcript-mode) 48 | ("\\.Sout" . S-transcript-mode) 49 | ("\\.[Rr]out" . R-transcript-mode) 50 | ("\\.Rd\\'" . Rd-mode) 51 | ("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode) 52 | ("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode) 53 | ("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode) 54 | ("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode) 55 | ("\\.[Jj][Oo][Gg]\\'" . ess-jags-mode) 56 | ("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode)) 57 | :commands (R stata julia SAS) 58 | :init 59 | (progn 60 | (when (configuration-layer/package-usedp 'company) 61 | (add-hook 'ess-mode-hook 'company-mode))) 62 | (use-package ess-r-mode 63 | :bind 64 | (:map ess-r-mode-map 65 | ("M--" . ess-insert-assign) 66 | ("M-p" . add-pipe-magrittr) 67 | ("M-o" . add-pipe-native) 68 | ("M-k" . add-knitr-opts)) 69 | (:map inferior-ess-r-mode-map 70 | ("M--" . ess-insert-assign) 71 | ("M-p" . add-pipe-magrittr-inf) 72 | ("M-o" . add-pipe-native-inf)) 73 | :config 74 | (defun add-pipe-magrittr () 75 | (interactive) 76 | (end-of-line) 77 | (unless (looking-back "%>%" nil) 78 | (just-one-space 1) 79 | (insert "%>%")) 80 | (newline-and-indent)) 81 | (defun add-pipe-magrittr-inf () 82 | (interactive) 83 | (end-of-line) 84 | (unless (looking-back "%>%" nil) 85 | (just-one-space 1) 86 | (insert "%>% "))) 87 | 88 | (defun add-pipe-native () 89 | (interactive) 90 | (end-of-line) 91 | (unless (looking-back "|>" nil) 92 | (just-one-space 1) 93 | (insert "|>")) 94 | (newline-and-indent)) 95 | 96 | ;; (defun add-pipe-native () 97 | ;; (interactive) 98 | ;; (end-of-line) 99 | ;; (unless (looking-back "|>" nil) 100 | ;; (just-one-space 1) 101 | ;; (insert "|>")) 102 | ;; (save-excursion 103 | ;; ;; (forward-line 1) 104 | ;; (next-line 1) 105 | ;; (beginning-of-line) 106 | ;; (if (looking-at-p "[[:blank:]][[:alpha:]]$") ; Check if the next line is empty 107 | ;; (indent) 108 | ;; (newline)))) 109 | 110 | ;; (defun add-pipe-native () 111 | ;; (interactive) 112 | ;; (end-of-line) 113 | ;; (unless (looking-back "|>" nil) 114 | ;; (just-one-space 1) 115 | ;; (insert "|>")) 116 | ;; (save-excursion 117 | ;; (forward-line 1) 118 | ;; (beginning-of-line) 119 | ;; (if (looking-at-p "^\\s-*$") ; Check if the next line is empty 120 | ;; (delete-blank-lines) 121 | ;; (newline-and-indent)))) 122 | 123 | (defun add-pipe-native-inf () 124 | (interactive) 125 | (end-of-line) 126 | (unless (looking-back "|>" nil) 127 | (just-one-space 1) 128 | (insert "|> "))) 129 | (defun add-knitr-opts () 130 | (interactive) 131 | (beginning-of-line) 132 | (unless (looking-back "#|" nil) 133 | (just-one-space 0) 134 | (insert "#| ") 135 | (end-of-line))) 136 | )) 137 | 138 | ;; R -------------------------------------------------------------------------- 139 | (with-eval-after-load 'ess-site 140 | ;; ESS 141 | (add-hook 'ess-mode-hook 142 | (lambda () 143 | (ess-set-style 'C++ 'quiet) 144 | ;; Because 145 | ;; DEF GNU BSD K&R C++ 146 | ;; ess-indent-level 2 2 8 5 4 147 | ;; ess-continued-statement-offset 2 2 8 5 4 148 | ;; ess-brace-offset 0 0 -8 -5 -4 149 | ;; ess-arg-function-offset 2 4 0 0 0 150 | ;; ess-expression-offset 4 2 8 5 4 151 | ;; ess-else-offset 0 0 0 0 0 152 | ;; ess-close-brace-offset 0 0 0 0 0 153 | (add-hook 'local-write-file-hooks 154 | (lambda () 155 | (ess-nuke-trailing-whitespace))))) 156 | (setq ess-nuke-trailing-whitespace-p 'ask) 157 | ;; or even 158 | ;; (setq ess-nuke-trailing-whitespace-p t) 159 | ;; Perl 160 | (add-hook 'perl-mode-hook 161 | (lambda () (setq perl-indent-level 4))) 162 | 163 | (defun spacemacs/ess-start-repl () 164 | "Start a REPL corresponding to the ess-language of the current buffer." 165 | (interactive) 166 | (cond 167 | ((string= "S" ess-language) (call-interactively 'R)) 168 | ((string= "STA" ess-language) (call-interactively 'stata)) 169 | ((string= "SAS" ess-language) (call-interactively 'SAS)))) 170 | 171 | (spacemacs/set-leader-keys-for-major-mode 'ess-julia-mode 172 | "si" 'julia) 173 | (spacemacs/set-leader-keys-for-major-mode 'ess-mode 174 | "si" 'spacemacs/ess-start-repl 175 | ;; noweb 176 | "cC" 'ess-eval-chunk-and-go 177 | "cc" 'ess-eval-chunk 178 | "cd" 'ess-eval-chunk-and-step 179 | "cm" 'ess-noweb-mark-chunk 180 | "cN" 'ess-noweb-previous-chunk 181 | "cn" 'ess-noweb-next-chunk 182 | ;; REPL 183 | "sB" 'ess-eval-buffer-and-go 184 | "sb" 'ess-eval-buffer 185 | "sD" 'ess-eval-function-or-paragraph-and-step 186 | "sd" 'ess-eval-region-or-line-and-step 187 | "sL" 'ess-eval-line-and-go 188 | "sl" 'ess-eval-line 189 | "sR" 'ess-eval-region-and-go 190 | "sr" 'ess-eval-region 191 | "sT" 'ess-eval-function-and-go 192 | "st" 'ess-eval-function 193 | ;; R helpers 194 | "hd" 'ess-R-dv-pprint 195 | "hi" 'ess-R-object-popup 196 | "ht" 'ess-R-dv-ctable 197 | ) 198 | (define-key ess-mode-map (kbd "") 'ess-eval-line) 199 | (define-key inferior-ess-mode-map (kbd "C-j") 'comint-next-input) 200 | (define-key inferior-ess-mode-map (kbd "C-k") 'comint-previous-input))) 201 | 202 | (defun ess/init-ess-R-data-view ()) 203 | 204 | (defun ess/init-ess-R-object-popup ()) 205 | 206 | (defun ess/post-init-rainbow-delimiters () 207 | (add-hook 'ess-mode-hook #'rainbow-delimiters-mode)) 208 | 209 | ;; To enable smart-equals-mode 210 | (defun ess/init-ess-smart-equals () 211 | (use-package ess-smart-equals 212 | :defer t 213 | :if ess-enable-smart-equals 214 | :init 215 | ;; (setq ess-smart-equals-extra-ops '(brace paren percent)) 216 | (progn 217 | (add-hook 'ess-mode-hook 'ess-smart-equals-mode) 218 | (add-hook 'inferior-ess-mode-hook 'ess-smart-equals-mode)))) 219 | 220 | ;; To enable smartparens-mode in ess and iess 221 | (defun ess/post-init-smartparens () 222 | (use-package smartparens 223 | :defer t 224 | :if ess-enable-smartparens 225 | :diminish smartparens-mode 226 | :config 227 | (progn 228 | (require 'smartparens-config) 229 | (smartparens-global-mode 1) 230 | (sp-pair "\"" nil :unless '(sp-point-after-word-p)) 231 | (sp-pair "'" nil :unless '(sp-point-after-word-p)) 232 | (sp-local-pair '(ess-mode inferior-ess-mode) "(" nil :unless '(sp-point-before-word-p)) 233 | (sp-local-pair '(ess-mode inferior-ess-mode) "[" nil :unless '(sp-point-before-word-p)) 234 | (sp-local-pair '(ess-mode inferior-ess-mode) "{" nil :unless '(sp-point-before-word-p))) 235 | :init 236 | (progn 237 | (add-hook 'ess-mode-hook 'smartparens-mode) 238 | (add-hook 'inferior-ess-mode-hook 'smartparens-mode)))) 239 | 240 | ;; To enable electric-spacing-mode in ess and iess 241 | (defun ess/init-electric-spacing-r () 242 | (use-package electric-spacing-r 243 | ;; :defer t 244 | :if ess-enable-electric-spacing-r 245 | :init 246 | (progn 247 | (add-hook 'ess-mode-hook 'electric-spacing-mode)))) 248 | ;; (add-hook 'inferior-ess-mode-hook 'electric-spacing-mode)))) 249 | 250 | (defun ess/init-essh () 251 | (use-package essh 252 | :config 253 | (progn 254 | (add-hook 255 | 'sh-mode-hook 256 | #'(lambda () 257 | (define-key sh-mode-map "\C-c\C-r" 'pipe-region-to-shell) 258 | (define-key sh-mode-map "\C-c\C-b" 'pipe-buffer-to-shell) 259 | (define-key sh-mode-map "\C-c\C-j" 'pipe-line-to-shell) 260 | ;; (define-key sh-mode-map "\C-c\C-n" 'pipe-line-to-shell-and-step) 261 | (define-key sh-mode-map (kbd "") 'pipe-line-to-shell-and-step) 262 | (define-key sh-mode-map "\C-c\C-f" 'pipe-function-to-shell) 263 | (define-key sh-mode-map "\C-c\C-d" 'shell-cd-current-directory)))))) 264 | 265 | (defun wz-ess-find-and-insert-namespace (beg end) 266 | "Preceds a function with its namespace, 267 | so `mean(x) -> stats::mean(x)' and 268 | `xyplot(...) -> lattice::xyplot()'. 269 | Call this function in a R major mode buffer with the function name 270 | selected. By Walmes Zeviani." 271 | (interactive "r") 272 | (let ((string 273 | (replace-regexp-in-string 274 | "\"" "\\\\\\&" 275 | (replace-regexp-in-string 276 | "\\\\\"" "\\\\\\&" 277 | (buffer-substring-no-properties beg end)))) 278 | (buf (get-buffer-create "*ess-command-output*"))) 279 | (ess-force-buffer-current "Process to load into:") 280 | (ess-command 281 | (format 282 | "local({ 283 | x <- \"%s\" 284 | cat(paste0(sub('.*:', '', utils::find(x)), '::', x), \"\\n\") 285 | })\n" 286 | string) buf) 287 | (with-current-buffer buf 288 | (goto-char (point-max)) 289 | (let ((end (point))) 290 | (goto-char (point-min)) 291 | (skip-chars-forward " +") 292 | (setq string (buffer-substring-no-properties (point) end)))) 293 | (delete-region beg end) 294 | (insert string) 295 | (delete-char -1))) 296 | 297 | (add-hook 298 | 'ess-mode-hook 299 | (lambda () 300 | (local-set-key (kbd "C-:") 'wz-ess-find-and-insert-namespace))) 301 | 302 | ;; essgd for plots inside emacs buffer. See 303 | ;; https://melpa.org/#/essgd 304 | ;; https://github.com/sje30/essgd 305 | (defun ess/init-essgd () 306 | "Initialize essgd package." 307 | (use-package essgd 308 | ;; Add any specific configuration or keybindings here 309 | )) 310 | 311 | ;; This was done to facilitate sending dev.off() to iESS when using 312 | ;; options(device = "cairo_pdf") 313 | (defun ess-dev-off () 314 | "Send dev.off() to the inferior R process." 315 | (interactive) 316 | (ess-eval-linewise "dev.off()")) 317 | 318 | ;; Set keybindings 319 | (defun ess/post-init-ess () 320 | ;; R source buffers: C-. to dev.off() 321 | (with-eval-after-load 'ess-r-mode 322 | (define-key ess-r-mode-map (kbd "C-.") #'ess-dev-off)) 323 | 324 | ;; iESS (*R* REPL) – bind when the mode starts, no map needed at compile time 325 | (add-hook 'inferior-ess-r-mode-hook 326 | (lambda () 327 | (local-set-key (kbd "C-.") #'ess-dev-off))) 328 | 329 | ;; Markdown / Rmarkdown 330 | (add-hook 'markdown-mode-hook 331 | (lambda () 332 | (local-set-key (kbd "C-.") #'ess-dev-off))) 333 | 334 | ;; Polymode host for Rmarkdown/Quarto 335 | (add-hook 'poly-markdown+r-mode-hook 336 | (lambda () 337 | (local-set-key (kbd "C-.") #'ess-dev-off))) 338 | 339 | ;; Quarto major mode 340 | (add-hook 'quarto-mode-hook 341 | (lambda () 342 | (local-set-key (kbd "C-.") #'ess-dev-off))) 343 | 344 | ;; --- Bind C-c C-p ONLY inside R code chunks --- 345 | ;; This was done to avoid the cursor stepping out from a code chunk to the 346 | ;; text in quarto/Rmarkdown files 347 | ;; Polymode inner R mode (most common) 348 | (add-hook 'poly-r-mode-hook 349 | (lambda () 350 | (local-set-key (kbd "C-c C-p") #'ess-eval-paragraph))) 351 | 352 | ;; Older polymode ESS inner mode 353 | (add-hook 'poly-ess-r-mode-hook 354 | (lambda () 355 | (local-set-key (kbd "C-c C-p") #'ess-eval-paragraph))) 356 | 357 | ;; Fallback: indirect ESS R buffer inside polymode 358 | ;; (safe to include; triggers only in R chunk buffers) 359 | (add-hook 'ess-r-mode-hook 360 | (lambda () 361 | (when (bound-and-true-p polymode-mode) 362 | (local-set-key (kbd "C-c C-p") #'ess-eval-paragraph)))) 363 | ) 364 | -------------------------------------------------------------------------------- /private/ess/local/electric-spacing-r/electric-spacing-r.el: -------------------------------------------------------------------------------- 1 | ;;; electric-spacing-r.el --- Insert operators with surrounding spaces smartly 2 | 3 | ;; Copyright (C) 2004, 2005, 2007-2016 Free Software Foundation, Inc. 4 | 5 | ;; Author: William Xu 6 | ;; Version: 5.0.1 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation; either version 3, or (at your option) 11 | ;; any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, but 14 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | ;; General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with EMMS; see the file COPYING. If not, write to the 20 | ;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 21 | ;; Boston, MA 02110-1301, USA. 22 | 23 | ;;; Commentary: 24 | 25 | ;; Smart Operator mode is a minor mode which automatically inserts 26 | ;; surrounding spaces around operator symbols. For example, `=' 27 | ;; becomes ` = ', `+=' becomes ` += '. This is most handy for writing 28 | ;; C-style source code. Also follows the R-style when in ess-mode. 29 | ;; 30 | ;; Type `M-x electric-spacing-mode' to toggle this minor mode. 31 | 32 | ;;; Contributions 33 | 34 | ;; Contributions made by Walmes Zeviani to 35 | ;; adapt the Smart Operator mode to R-style source code. 36 | 37 | ;;; Acknowledgements 38 | 39 | ;; Nikolaj Schumacher , for suggesting 40 | ;; reimplementing as a minor mode and providing an initial patch for 41 | ;; that. 42 | 43 | ;;; Code: 44 | 45 | ;;; electric-spacing minor mode 46 | 47 | (defcustom electric-spacing-double-space-docs t 48 | "Enable double spacing of . in document lines - e,g, type '.' => get '. '." 49 | :type 'boolean 50 | :group 'electricity) 51 | 52 | (defcustom electric-spacing-docs t 53 | "Enable electric-spacing in strings and comments." 54 | :type 'boolean 55 | :group 'electricity) 56 | 57 | (defvar electric-spacing-rules 58 | '((?= . electric-spacing-self-insert-command) 59 | (?| . electric-spacing-self-insert-command) 60 | (?& . electric-spacing-self-insert-command) 61 | (?+ . electric-spacing-+) 62 | (?- . electric-spacing--) 63 | (?* . electric-spacing-*) 64 | (?< . electric-spacing-<) 65 | (?> . electric-spacing->) 66 | (?! . electric-spacing-!) 67 | (?% . electric-spacing-%) 68 | (?~ . electric-spacing-~) 69 | (?. . electric-spacing-.) 70 | (?/ . electric-spacing-/) 71 | (?{ . electric-spacing-{) 72 | ;; (?( . electric-spacing-\() 73 | (?, . electric-spacing-\,) 74 | ;; (?: . electric-spacing-:) 75 | ;; (?? . electric-spacing-?) 76 | )) 77 | 78 | (defun electric-spacing-post-self-insert-function () 79 | (when (electric-spacing-should-run?) 80 | (let ((rule (cdr (assq last-command-event electric-spacing-rules)))) 81 | (when rule 82 | (goto-char (electric--after-char-pos)) 83 | (delete-char -1) 84 | (funcall rule))))) 85 | 86 | ;;;###autoload 87 | (define-minor-mode electric-spacing-mode 88 | "Toggle automatic surrounding space insertion (Electric Spacing mode). 89 | With a prefix argument ARG, enable Electric Spacing mode if 90 | ARG is positive, and disable it otherwise. If called from 91 | Lisp, enable the mode if ARG is omitted or nil. 92 | 93 | This is a local minor mode. When enabled, typing an operator 94 | automatically inserts surrounding spaces. e.g., `=' becomes ` 95 | = ',`+=' becomes ` += '. This is very handy for many 96 | programming languages." 97 | :global nil 98 | :group 'electricity 99 | :lighter " _+_" 100 | 101 | ;; body 102 | (if electric-spacing-mode 103 | (add-hook 'post-self-insert-hook 104 | #'electric-spacing-post-self-insert-function nil t) 105 | (remove-hook 'post-self-insert-hook 106 | #'electric-spacing-post-self-insert-function t))) 107 | 108 | (defun electric-spacing-self-insert-command () 109 | "Insert character with surrounding spaces." 110 | (electric-spacing-insert (string last-command-event))) 111 | 112 | (defun electric-spacing-insert (op &optional only-where) 113 | "See `electric-spacing-insert-1'." 114 | (delete-horizontal-space) 115 | (cond ((and (electric-spacing-lispy-mode?) 116 | (not (electric-spacing-document?))) 117 | (electric-spacing-lispy op)) 118 | (t 119 | (electric-spacing-insert-1 op only-where)))) 120 | 121 | (defun electric-spacing-insert-1 (op &optional only-where) 122 | "Insert operator OP with surrounding spaces. 123 | e.g., `=' becomes ` = ', `+=' becomes ` += '. 124 | - When `only-where' is 'after, we will insert space at back only; 125 | - when `only-where' is 'before, we will insert space at front only; 126 | - when `only-where' is 'middle, we will not insert space." 127 | (pcase only-where 128 | (`before (insert " " op)) 129 | (`middle (insert op)) 130 | (`after (insert op " ")) 131 | (`both (insert " " op " ")) 132 | (_ 133 | (let ((begin? (bolp))) 134 | (unless 135 | (or (looking-back 136 | (regexp-opt 137 | (mapcar 'char-to-string 138 | (mapcar 'car electric-spacing-rules))) 139 | (line-beginning-position)) 140 | begin?) 141 | (insert " ")) 142 | (insert op " ") 143 | (when begin? 144 | (indent-according-to-mode)))))) 145 | 146 | (defun electric-spacing-document? () 147 | (nth 8 (syntax-ppss))) 148 | 149 | (defun electric-spacing-should-run? () 150 | (or (not electric-spacing-docs) 151 | (not (electric-spacing-document?)))) 152 | 153 | (defun electric-spacing-lispy-mode? () 154 | (derived-mode-p 'emacs-lisp-mode 155 | 'lisp-mode 156 | 'lisp-interaction-mode 157 | 'scheme-mode)) 158 | 159 | (defun electric-spacing-lispy (op) 160 | "We're in a Lisp-ish mode, so let's look for parenthesis. 161 | Meanwhile, if not found after ( operators are more likely to 162 | be function names, so let's not get too insert-happy." 163 | (cond 164 | ((save-excursion 165 | (backward-char 1) 166 | (looking-at "(")) 167 | (if (equal op ",") 168 | (electric-spacing-insert-1 op 'middle) 169 | (electric-spacing-insert-1 op 'after))) 170 | ((equal op ",") 171 | (electric-spacing-insert-1 op 'before)) 172 | (t 173 | (electric-spacing-insert-1 op 'middle)))) 174 | 175 | (defconst electric-spacing-operators-regexp 176 | (regexp-opt 177 | (mapcar (lambda (el) (char-to-string (car el))) 178 | electric-spacing-rules))) 179 | 180 | ;;;--------------------------------------------------------------------- 181 | ;;; Fine Tunings - eletric-spacing-* functions. 182 | 183 | ;;------------------------------------------- 184 | ;; Arithmetic operators. 185 | 186 | (defun electric-spacing-* () 187 | "See `electric-spacing-insert'." 188 | (cond ((derived-mode-p 'ess-mode) 189 | ;; ,----[ cases ] 190 | ;; | a * b 191 | ;; | a %*% b 192 | ;; | a**b = a^b 193 | ;; | y ~ a + . * b 194 | ;; `---- 195 | (cond ((looking-back "% *" 1) 196 | (electric-spacing-insert "*" 'middle)) 197 | ((looking-back " \\* *" 1) 198 | (fixup-whitespace) 199 | (delete-char -1) 200 | (fixup-whitespace) 201 | (insert " %*% ")) 202 | ((looking-back "[~.] *" 1) 203 | (electric-spacing-insert "*" 'both)) 204 | (t 205 | (electric-spacing-insert "*")))) 206 | ((derived-mode-p 'python-mode) 207 | ;; ,----[ cases ] 208 | ;; | a * b 209 | ;; | "string" * 10 210 | ;; | a**b 211 | ;; `---- 212 | (cond ((looking-back " \\* *" 1) 213 | (delete-char -3) 214 | (insert "**")) 215 | (t 216 | (electric-spacing-insert "*")))) 217 | (t 218 | (electric-spacing-insert "*")) 219 | )) 220 | 221 | (defun electric-spacing-+ () 222 | "See `electric-spacing-insert'." 223 | (cond ((derived-mode-p 'ess-mode 'python-mode) 224 | ;; ,----[ cases ] 225 | ;; | a + b 226 | ;; | y ~ a + b 227 | ;; | y ~ . + b 228 | ;; | 10e+5 229 | ;; | 10E+5 230 | ;; `---- 231 | (cond ((looking-back "[~.] *" 1) 232 | (electric-spacing-insert "+" 'both)) 233 | ((looking-back "[([{/^] *" 1) 234 | (insert "+")) 235 | ((looking-back "[0-9.]+[eE] *" 1) 236 | (insert "+")) 237 | ((looking-back "^\\s-*" 1) 238 | (insert "+")) 239 | (t 240 | (electric-spacing-insert "+"))) 241 | ) 242 | (t 243 | (electric-spacing-insert "+")))) 244 | 245 | (defun electric-spacing-- () 246 | "See `electric-spacing-insert'." 247 | (cond ((derived-mode-p 'ess-mode) 248 | ;; ,----[ cases ] 249 | ;; | a - b 250 | ;; | a * (-b) 251 | ;; | a * -b 252 | ;; | a + -b 253 | ;; | a & -5 > b 254 | ;; | a | -5 > b 255 | ;; | a < -5 256 | ;; | a > -5 257 | ;; | y ~ -1+x 258 | ;; | y ~ . - x 259 | ;; | a = -5 260 | ;; | a <- -5 261 | ;; | a[-b, -x] 262 | ;; | c(1, -2) 263 | ;; | 10e-5 264 | ;; | 10E-5 265 | ;; | 10^-5 266 | ;; | 10/-5 267 | ;; | 10/-5 268 | ;; | -5 269 | ;; | -.5 270 | ;; `---- 271 | (cond ((or (looking-back "[=~,*+<>&|.] *" 1) 272 | (looking-back "<- *" 1)) 273 | (electric-spacing-insert "-" 'before)) 274 | ((looking-back "[([{/^] *" 1) 275 | (insert "-")) 276 | ((looking-back "[0-9.]+[eE]" 1) 277 | (insert "-")) 278 | ((looking-back "^\\s-*" 1) 279 | (insert "-")) 280 | (t 281 | (electric-spacing-insert "-")))) 282 | ;; exponent notation, e.g. 1e-10: don't space 283 | ((looking-back "[0-9.]+[eE]" 1) 284 | (insert "-")) 285 | ;; a = -9 286 | ((and 287 | (looking-back (concat electric-spacing-operators-regexp " *") 1) 288 | (not (looking-back "- *" 1))) 289 | (electric-spacing-insert "-" 'before)) 290 | (t 291 | (electric-spacing-insert "-")))) 292 | 293 | ;;------------------------------------------- 294 | ;; Relational operators. 295 | 296 | (defun electric-spacing-> () 297 | "See `electric-spacing-insert'." 298 | (cond ((derived-mode-p 'ess-mode) 299 | ;; ,----[ cases ] 300 | ;; | 5 < 7 301 | ;; | 5 <= 7 302 | ;; | iris %>% 303 | ;; | filter(...) 304 | ;; `---- 305 | (cond ((looking-at " *=") 306 | (electric-spacing-insert ">" 'before)) 307 | ((looking-back " > *" 1) 308 | (fixup-whitespace) 309 | (delete-char -1) 310 | (fixup-whitespace) 311 | (insert " %>%\n") 312 | (ess-indent-or-complete)) 313 | (t 314 | (electric-spacing-insert ">")))) 315 | ((derived-mode-p 'python-mode) 316 | ;; ,----[ cases ] 317 | ;; | 5 < 7 318 | ;; | 5 <= 7 319 | ;; `---- 320 | (cond ((looking-at " *=") 321 | (electric-spacing-insert ">" 'before)) 322 | (t 323 | (electric-spacing-insert ">")))) 324 | (t 325 | (electric-spacing-insert ">")))) 326 | 327 | (defun electric-spacing-< () 328 | "See `electric-spacing-insert'." 329 | (cond ((derived-mode-p 'ess-mode) 330 | ;; ,----[ cases ] 331 | ;; | 5 > 7 332 | ;; | 5 >= 7 333 | ;; | x <<- 10 334 | ;; `---- 335 | (cond ((looking-at " *=") 336 | (electric-spacing-insert "<" 'before)) 337 | ((looking-back " < *" 1) 338 | (fixup-whitespace) 339 | (delete-char -1) 340 | (fixup-whitespace) 341 | (insert " <<- ")) 342 | (t 343 | (electric-spacing-insert "<")))) 344 | ((derived-mode-p 'python-mode) 345 | ;; ,----[ cases ] 346 | ;; | 5 < 7 347 | ;; | 5 <= 7 348 | ;; `---- 349 | (cond ((looking-at " *=") 350 | (electric-spacing-insert "<" 'before)) 351 | (t 352 | (electric-spacing-insert "<")))) 353 | (t 354 | (electric-spacing-insert "<")))) 355 | 356 | (defun electric-spacing-! () 357 | "See `electric-spacing-insert'." 358 | (cond ((derived-mode-p 'ess-mode) 359 | ;; ,----[ cases ] 360 | ;; | x <- !y 361 | ;; | x = !y 362 | ;; | x & !y 363 | ;; | x | !y 364 | ;; | a != b 365 | ;; | 2 != 4 366 | ;; | y[!a, !b] 367 | ;; | if (!x) ... 368 | ;; | if (a) { !b } ... 369 | ;; | x + !y 370 | ;; | x * !y 371 | ;; `---- 372 | (cond ((looking-back "[{([] *" 1) 373 | (insert "!")) 374 | ((looking-back "[[:alnum:],=|&*+-] *" 1) 375 | (electric-spacing-insert "!" 'before)) 376 | (t 377 | (insert "!")))) 378 | (t 379 | (insert "!")))) 380 | 381 | ;;------------------------------------------- 382 | ;; Other operators. 383 | 384 | ;; BUG: the %op% operator has something special that I didn't 385 | ;; understand. The rules does't apply to the openning % of the pair. I 386 | ;; think that this can be related to font face. Only the closing % of 387 | ;; the pair is affected by the rules below programmed. Meanwhile, to 388 | ;; solve the problem, the package key-combo can be used to set the rules 389 | ;; for the opening %. See the file 390 | ;; https://github.com/walmes/emacs/blob/master/init.el to details. 391 | 392 | ;; SOLVED: the above related problem was solved using the 393 | ;; `save-excursion' block. 394 | 395 | (defun electric-spacing-% () 396 | "See `electric-spacing-insert'." 397 | (cond ((derived-mode-p 'ess-mode) 398 | ;; ,----[ cases ] 399 | ;; | a %*% b 400 | ;; | a %/% b 401 | ;; | a %% b 402 | ;; | a %>% b 403 | ;; | a %o% b 404 | ;; | a %in% b 405 | ;; | sprintf("%d %d\n", a, b) 406 | ;; `---- 407 | (cond ((looking-back "[%][[:alnum:]$!?<>=_*+/.-]+ *" 1) 408 | (save-excursion 409 | (search-backward "%") 410 | (fixup-whitespace)) 411 | (electric-spacing-insert "%" 'after)) 412 | ((looking-back "% *" 1) 413 | (fixup-whitespace) 414 | (delete-char -1) 415 | (electric-spacing-insert "%%" 'both)) 416 | (t 417 | (electric-spacing-insert "%")))) 418 | ((derived-mode-p 'python-mode) 419 | ;; ,----[ cases ] 420 | ;; | a % b 421 | ;; | "%0.2f" % 3.1415 422 | ;; `---- 423 | (cond ((looking-back "% *" 1) 424 | (electric-spacing-insert "%" 'after)) 425 | (t 426 | (electric-spacing-insert "%")))) 427 | (t 428 | (insert "%")))) 429 | 430 | (defun electric-spacing-~ () 431 | "See `electric-spacing-insert'." 432 | (cond ((derived-mode-p 'ess-mode) 433 | ;; ,----[ cases ] 434 | ;; | a ~ b 435 | ;; | ~a + b 436 | ;; | x <- ~a + b 437 | ;; | x = ~a + b 438 | ;; | c(~a + b, ~x + y) 439 | ;; | update(model, . ~ .) 440 | ;; `---- 441 | (cond ((looking-back "\\(<-\\|[=,.]\\) *" 1) 442 | (electric-spacing-insert "~" 'before)) 443 | ((looking-back "( *" 1) 444 | (insert "~")) 445 | ((looking-back "^\\s-*" 1) 446 | (insert "~")) 447 | (t 448 | (electric-spacing-insert "~")))) 449 | (t 450 | (insert "~")))) 451 | 452 | (defun electric-spacing-. () 453 | "See `electric-spacing-insert'." 454 | (cond ((and electric-spacing-double-space-docs 455 | (electric-spacing-document?)) 456 | (electric-spacing-insert "." 'after) 457 | (insert " ")) 458 | ((derived-mode-p 'ess-mode) 459 | ;; ,----[ cases ] 460 | ;; | read.table() 461 | ;; | plot.default() 462 | ;; | 3.14 463 | ;; | 2 + .5 464 | ;; | x <- .5 465 | ;; | x = .5 466 | ;; | c(.9, .5) 467 | ;; | lm(y ~ .) 468 | ;; | update(model, . ~ . + I(x^2)) 469 | ;; | function(x, ...) 470 | ;; | obj$.x 471 | ;; | obj@.x 472 | ;; | .Machine$double.xmin 473 | ;; | fun <- .Call(...) 474 | ;; `---- 475 | (cond ((or (looking-back "[0-9({[.] *" 1) 476 | (looking-back "[A-Za-z]" 1)) 477 | (insert ".")) 478 | ((looking-back "[,*+=~-] *" 1) 479 | (electric-spacing-insert "." 'before)) 480 | (t 481 | (insert ".")))) 482 | ((derived-mode-p 'python-mode) 483 | ;; ,----[ cases ] 484 | ;; | pd.read_csv() 485 | ;; | 3.14 486 | ;; | 2 + .5 487 | ;; | x = .5 488 | ;; | (.9, .5) 489 | ;; | [.9, .5] 490 | ;; | .Machine.double.xmin 491 | ;; | fun = .hidden() 492 | ;; `---- 493 | (cond ((or (looking-back "[0-9([.] *" 1) 494 | (looking-back "[A-Za-z]" 1)) 495 | (insert ".")) 496 | ((looking-back "[,*+=-] *" 1) 497 | (electric-spacing-insert "." 'before)) 498 | (t 499 | (insert ".")))) 500 | (t 501 | (electric-spacing-insert "." 'after) 502 | (insert " ")))) 503 | 504 | (defun electric-spacing-/ () 505 | "See `electric-spacing-insert'." 506 | (cond ((derived-mode-p 'ess-mode) 507 | ;; ,----[ cases ] 508 | ;; | 5/3 509 | ;; | 5 %/% 3 510 | ;; `---- 511 | (cond ((looking-back "/ *" 1) 512 | (fixup-whitespace) 513 | (delete-char -1) 514 | (electric-spacing-insert "%/%" 'both)) 515 | (t 516 | (electric-spacing-insert "/" 'middle)))) 517 | (t 518 | (insert "/")))) 519 | 520 | (defun electric-spacing-{ () 521 | "See `electric-spacing-insert'." 522 | (cond ((and (derived-mode-p 'ess-mode) 523 | (or (looking-back "[^[:alnum:]_.]\\(repeat\\|else\\) *" 1) 524 | (looking-back ") *" 1))) 525 | ;; ,----[ cases ] 526 | ;; | for (i in 1:10) { ... 527 | ;; | function(x) { ... 528 | ;; | repeat { ... 529 | ;; | else { ... 530 | ;; `---- 531 | (electric-spacing-insert "{" 'before)) 532 | (t 533 | (insert "{")))) 534 | 535 | (defun electric-spacing-\( () 536 | "See `electric-spacing-insert'." 537 | (cond ((and (derived-mode-p 'ess-mode) 538 | (looking-back "[^[:alnum:]_.]\\(for\\|if\\|while\\) *" 1)) 539 | ;; ,----[ cases ] 540 | ;; | for (i in 1:10) { ... 541 | ;; | if (x == 2) { ... 542 | ;; | while (x < 10) { ... 543 | ;; `---- 544 | (electric-spacing-insert "(" 'before)) 545 | (t 546 | (insert "(")))) 547 | 548 | (defun electric-spacing-\, () 549 | "See `electric-spacing-insert'." 550 | (cond ((derived-mode-p 'python-mode) 551 | ;; ,----[ cases ] 552 | ;; | (1, 2, 3) 553 | ;; | [1, 2, 3] 554 | ;; | ([1, 2, 3], [123, 234, 345]) 555 | ;; `---- 556 | (electric-spacing-insert "," 'after)) 557 | (t 558 | (insert ",")))) 559 | 560 | ;; (defun electric-spacing-: () 561 | ;; "See `electric-spacing-insert'." 562 | ;; (cond ((derived-mode-p 'ess-mode) 563 | ;; (insert ":")) 564 | ;; (t 565 | ;; (electric-spacing-insert ":" 'after)))) 566 | ;; 567 | ;; (defun electric-spacing-? () 568 | ;; "See `electric-spacing-insert'." 569 | ;; (cond ((derived-mode-p 'ess-mode) 570 | ;; (electric-spacing-insert "?")) 571 | ;; (t 572 | ;; (electric-spacing-insert "?" 'after)))) 573 | 574 | ;;---------------------------------------------------------------------- 575 | 576 | (provide 'electric-spacing-r) 577 | 578 | ;;; electric-spacing-r.el ends here 579 | -------------------------------------------------------------------------------- /spacemacs.el: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp; lexical-binding: t -*- 2 | ;; This file is loaded by Spacemacs at startup. 3 | ;; It must be stored in your home directory. 4 | 5 | (defun dotspacemacs/layers () 6 | "Layer configuration: 7 | This function should only modify configuration layer settings." 8 | (setq-default 9 | ;; Base distribution to use. This is a layer contained in the directory 10 | ;; `+distribution'. For now available distributions are `spacemacs-base' 11 | ;; or `spacemacs'. (default 'spacemacs) 12 | dotspacemacs-distribution 'spacemacs 13 | 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 'unused 24 | 25 | ;; If non-nil then Spacemacs will ask for confirmation before installing 26 | ;; a layer lazily. (default t) 27 | dotspacemacs-ask-for-lazy-installation t 28 | 29 | ;; List of additional paths where to look for configuration layers. 30 | ;; Paths must have a trailing slash (i.e. "~/.mycontribs/") 31 | dotspacemacs-configuration-layer-path '() 32 | 33 | ;; List of configuration layers to load. 34 | dotspacemacs-configuration-layers 35 | '( 36 | ;; ---------------------------------------------------------------- 37 | ;; Example of useful layers you may want to use right away. 38 | ;; Uncomment some layer names and press `SPC f e R' (Vim style) or 39 | ;; `M-m f e R' (Emacs style) to install them. 40 | ;; ---------------------------------------------------------------- 41 | csv 42 | helm 43 | treemacs 44 | auto-completion 45 | better-defaults 46 | emacs-lisp 47 | git 48 | markdown 49 | multiple-cursors 50 | javascript ; for json files 51 | org 52 | (shell :variables 53 | shell-default-height 30 54 | shell-default-position 'bottom) 55 | (spell-checking :variables spell-checking-enable-by-default nil) 56 | ;; (syntax-checking :variables syntax-checking-enable-by-default nil) 57 | rust 58 | html 59 | yaml 60 | bm 61 | ;; For docker, see 62 | ;; https://develop.spacemacs.org/layers/+tools/docker/README.html 63 | ;; to install dependencies (hadolint is in AUR) 64 | (docker :variables docker-dockerfile-backend 'lsp) 65 | ;; version-control 66 | ;; ess 67 | latex 68 | ;; extra-langs 69 | ;; private layers 70 | elpy 71 | ipython-notebook 72 | ;; python 73 | (ess :variables 74 | ;; ess-enable-smart-equals t 75 | ess-enable-electric-spacing-r t 76 | ess-r-backend 'lsp 77 | ess-use-flymake nil 78 | ess-enable-smartparens t) 79 | funk 80 | polymode 81 | ) 82 | ;; List of additional packages that will be installed without being wrapped 83 | ;; in a layer (generally the packages are installed only and should still be 84 | ;; loaded using load/require/use-package in the user-config section below in 85 | ;; this file). If you need some configuration for these packages, then 86 | ;; consider creating a layer. You can also put the configuration in 87 | ;; `dotspacemacs/user-config'. To use a local version of a package, use the 88 | ;; `:location' property: '(your-package :location "~/path/to/your-package/") 89 | ;; Also include the dependencies as they will not be resolved automatically. 90 | dotspacemacs-additional-packages 91 | '( 92 | gptel 93 | gptel-commit 94 | poly-R 95 | quarto-mode 96 | poly-noweb 97 | poly-org 98 | poly-markdown 99 | (copilot :location (recipe 100 | :fetcher github 101 | :repo "copilot-emacs/copilot.el" 102 | :files ("*.el"))) 103 | ) 104 | ;; A list of packages that cannot be updated. 105 | dotspacemacs-frozen-packages '() 106 | 107 | ;; A list of packages that will not be installed and loaded. 108 | dotspacemacs-excluded-packages '() 109 | 110 | ;; Defines the behaviour of Spacemacs when installing packages. 111 | ;; Possible values are `used-only', `used-but-keep-unused' and `all'. 112 | ;; `used-only' installs only explicitly used packages and deletes any unused 113 | ;; packages as well as their unused dependencies. `used-but-keep-unused' 114 | ;; installs only the used packages but won't delete unused ones. `all' 115 | ;; installs *all* packages supported by Spacemacs and never uninstalls them. 116 | ;; (default is `used-only') 117 | dotspacemacs-install-packages 'used-only)) 118 | 119 | (defun dotspacemacs/init () 120 | "Initialization: 121 | This function is called at the very beginning of Spacemacs startup, 122 | before layer configuration. 123 | It should only modify the values of Spacemacs settings." 124 | ;; This setq-default sexp is an exhaustive list of all the supported 125 | ;; spacemacs settings. 126 | (setq-default 127 | ;; Maximum allowed time in seconds to contact an ELPA repository. 128 | ;; (default 5) 129 | dotspacemacs-elpa-timeout 5 130 | 131 | ;; Set `gc-cons-threshold' and `gc-cons-percentage' when startup finishes. 132 | ;; This is an advanced option and should not be changed unless you suspect 133 | ;; performance issues due to garbage collection operations. 134 | ;; (default '(100000000 0.1)) 135 | dotspacemacs-gc-cons '(100000000 0.1) 136 | 137 | ;; Set `read-process-output-max' when startup finishes. 138 | ;; This defines how much data is read from a foreign process. 139 | ;; Setting this >= 1 MB should increase performance for lsp servers 140 | ;; in emacs 27. 141 | ;; (default (* 1024 1024)) 142 | dotspacemacs-read-process-output-max (* 1024 1024) 143 | 144 | ;; If non-nil then Spacelpa repository is the primary source to install 145 | ;; a locked version of packages. If nil then Spacemacs will install the 146 | ;; latest version of packages from MELPA. Spacelpa is currently in 147 | ;; experimental state please use only for testing purposes. 148 | ;; (default nil) 149 | dotspacemacs-use-spacelpa nil 150 | 151 | ;; If non-nil then verify the signature for downloaded Spacelpa archives. 152 | ;; (default t) 153 | dotspacemacs-verify-spacelpa-archives t 154 | 155 | ;; If non-nil then spacemacs will check for updates at startup 156 | ;; when the current branch is not `develop'. Note that checking for 157 | ;; new versions works via git commands, thus it calls GitHub services 158 | ;; whenever you start Emacs. (default nil) 159 | dotspacemacs-check-for-update nil 160 | 161 | ;; If non-nil, a form that evaluates to a package directory. For example, to 162 | ;; use different package directories for different Emacs versions, set this 163 | ;; to `emacs-version'. (default 'emacs-version) 164 | dotspacemacs-elpa-subdirectory 'emacs-version 165 | 166 | ;; One of `vim', `emacs' or `hybrid'. 167 | ;; `hybrid' is like `vim' except that `insert state' is replaced by the 168 | ;; `hybrid state' with `emacs' key bindings. The value can also be a list 169 | ;; with `:variables' keyword (similar to layers). Check the editing styles 170 | ;; section of the documentation for details on available variables. 171 | ;; (default 'vim) 172 | dotspacemacs-editing-style 'emacs 173 | 174 | ;; If non-nil show the version string in the Spacemacs buffer. It will 175 | ;; appear as (spacemacs version)@(emacs version) 176 | ;; (default t) 177 | dotspacemacs-startup-buffer-show-version t 178 | 179 | ;; Specify the startup banner. Default value is `official', it displays 180 | ;; the official spacemacs logo. An integer value is the index of text 181 | ;; banner, `random' chooses a random text banner in `core/banners' 182 | ;; directory. A string value must be a path to an image format supported 183 | ;; by your Emacs build. 184 | ;; If the value is nil then no banner is displayed. (default 'official) 185 | dotspacemacs-startup-banner 'official 186 | 187 | ;; Scale factor controls the scaling (size) of the startup banner. Default 188 | ;; value is `auto' for scaling the logo automatically to fit all buffer 189 | ;; contents, to a maximum of the full image height and a minimum of 3 line 190 | ;; heights. If set to a number (int or float) it is used as a constant 191 | ;; scaling factor for the default logo size. 192 | dotspacemacs-startup-banner-scale 'auto 193 | 194 | ;; List of items to show in startup buffer or an association list of 195 | ;; the form `(list-type . list-size)`. If nil then it is disabled. 196 | ;; Possible values for list-type are: 197 | ;; `recents' `recents-by-project' `bookmarks' `projects' `agenda' `todos'. 198 | ;; List sizes may be nil, in which case 199 | ;; `spacemacs-buffer-startup-lists-length' takes effect. 200 | ;; The exceptional case is `recents-by-project', where list-type must be a 201 | ;; pair of numbers, e.g. `(recents-by-project . (7 . 5))', where the first 202 | ;; number is the project limit and the second the limit on the recent files 203 | ;; within a project. 204 | dotspacemacs-startup-lists '((recents . 5) 205 | (projects . 7)) 206 | 207 | ;; True if the home buffer should respond to resize events. (default t) 208 | dotspacemacs-startup-buffer-responsive t 209 | 210 | ;; Show numbers before the startup list lines. (default t) 211 | dotspacemacs-show-startup-list-numbers t 212 | 213 | ;; The minimum delay in seconds between number key presses. (default 0.4) 214 | dotspacemacs-startup-buffer-multi-digit-delay 0.4 215 | 216 | ;; If non-nil, show file icons for entries and headings on Spacemacs home buffer. 217 | ;; This has no effect in terminal or if "nerd-icons" package or the font 218 | ;; is not installed. (default nil) 219 | dotspacemacs-startup-buffer-show-icons nil 220 | 221 | ;; Default major mode for a new empty buffer. Possible values are mode 222 | ;; names such as `text-mode'; and `nil' to use Fundamental mode. 223 | ;; (default `text-mode') 224 | dotspacemacs-new-empty-buffer-major-mode 'text-mode 225 | 226 | ;; Default major mode of the scratch buffer (default `text-mode') 227 | dotspacemacs-scratch-mode 'text-mode 228 | 229 | ;; If non-nil, *scratch* buffer will be persistent. Things you write down in 230 | ;; *scratch* buffer will be saved and restored automatically. 231 | dotspacemacs-scratch-buffer-persistent nil 232 | 233 | ;; If non-nil, `kill-buffer' on *scratch* buffer 234 | ;; will bury it instead of killing. 235 | dotspacemacs-scratch-buffer-unkillable nil 236 | 237 | ;; Initial message in the scratch buffer, such as "Welcome to Spacemacs!" 238 | ;; (default nil) 239 | dotspacemacs-initial-scratch-message nil 240 | 241 | ;; List of themes, the first of the list is loaded when spacemacs starts. 242 | ;; Press `SPC T n' to cycle to the next theme in the list (works great 243 | ;; with 2 themes variants, one dark and one light). A theme from external 244 | ;; package can be defined with `:package', or a theme can be defined with 245 | ;; `:location' to download the theme package, refer the themes section in 246 | ;; DOCUMENTATION.org for the full theme specifications. 247 | dotspacemacs-themes '(spacemacs-dark 248 | spacemacs-light) 249 | 250 | ;; Set the theme for the Spaceline. Supported themes are `spacemacs', 251 | ;; `all-the-icons', `custom', `doom', `vim-powerline' and `vanilla'. The 252 | ;; first three are spaceline themes. `doom' is the doom-emacs mode-line. 253 | ;; `vanilla' is default Emacs mode-line. `custom' is a user defined themes, 254 | ;; refer to the DOCUMENTATION.org for more info on how to create your own 255 | ;; spaceline theme. Value can be a symbol or list with additional properties. 256 | ;; (default '(spacemacs :separator wave :separator-scale 1.5)) 257 | dotspacemacs-mode-line-theme '(spacemacs :separator wave :separator-scale 1.5) 258 | 259 | ;; If non-nil the cursor color matches the state color in GUI Emacs. 260 | ;; (default t) 261 | dotspacemacs-colorize-cursor-according-to-state t 262 | 263 | ;; Default font or prioritized list of fonts. This setting has no effect when 264 | ;; running Emacs in terminal. The font set here will be used for default and 265 | ;; fixed-pitch faces. The `:size' can be specified as 266 | ;; a non-negative integer (pixel size), or a floating-point (point size). 267 | ;; Point size is recommended, because it's device independent. (default 10.0) 268 | ;; "IBM Plex Mono" or "Source Code Pro" or "Fira Code" 269 | dotspacemacs-default-font '("JetBrains Mono" 270 | :size 13.0 271 | :weight normal 272 | :width normal 273 | :powerline-scale 1.1) 274 | 275 | ;; Default icons font, it can be `all-the-icons' or `nerd-icons'. 276 | dotspacemacs-default-icons-font 'all-the-icons 277 | 278 | ;; The leader key (default "SPC") 279 | dotspacemacs-leader-key "SPC" 280 | 281 | ;; The key used for Emacs commands `M-x' (after pressing on the leader key). 282 | ;; (default "SPC") 283 | dotspacemacs-emacs-command-key "SPC" 284 | 285 | ;; The key used for Vim Ex commands (default ":") 286 | dotspacemacs-ex-command-key ":" 287 | 288 | ;; The leader key accessible in `emacs state' and `insert state' 289 | ;; (default "M-m") 290 | dotspacemacs-emacs-leader-key "M-m" 291 | 292 | ;; Major mode leader key is a shortcut key which is the equivalent of 293 | ;; pressing ` m`. Set it to `nil` to disable it. (default ",") 294 | dotspacemacs-major-mode-leader-key "," 295 | 296 | ;; Major mode leader key accessible in `emacs state' and `insert state'. 297 | ;; (default "C-M-m" for terminal mode, "M-" for GUI mode). 298 | ;; Thus M-RET should work as leader key in both GUI and terminal modes. 299 | ;; C-M-m also should work in terminal mode, but not in GUI mode. 300 | dotspacemacs-major-mode-emacs-leader-key (if window-system "M-" "C-M-m") 301 | 302 | ;; These variables control whether separate commands are bound in the GUI to 303 | ;; the key pairs `C-i', `TAB' and `C-m', `RET'. 304 | ;; Setting it to a non-nil value, allows for separate commands under `C-i' 305 | ;; and TAB or `C-m' and `RET'. 306 | ;; In the terminal, these pairs are generally indistinguishable, so this only 307 | ;; works in the GUI. (default nil) 308 | dotspacemacs-distinguish-gui-tab nil 309 | 310 | ;; Name of the default layout (default "Default") 311 | dotspacemacs-default-layout-name "Default" 312 | 313 | ;; If non-nil the default layout name is displayed in the mode-line. 314 | ;; (default nil) 315 | dotspacemacs-display-default-layout nil 316 | 317 | ;; If non-nil then the last auto saved layouts are resumed automatically upon 318 | ;; start. (default nil) 319 | dotspacemacs-auto-resume-layouts nil 320 | 321 | ;; If non-nil, auto-generate layout name when creating new layouts. Only has 322 | ;; effect when using the "jump to layout by number" commands. (default nil) 323 | dotspacemacs-auto-generate-layout-names nil 324 | 325 | ;; Size (in MB) above which spacemacs will prompt to open the large file 326 | ;; literally to avoid performance issues. Opening a file literally means that 327 | ;; no major mode or minor modes are active. (default is 1) 328 | dotspacemacs-large-file-size 1 329 | 330 | ;; Location where to auto-save files. Possible values are `original' to 331 | ;; auto-save the file in-place, `cache' to auto-save the file to another 332 | ;; file stored in the cache directory and `nil' to disable auto-saving. 333 | ;; (default 'cache) 334 | dotspacemacs-auto-save-file-location 'cache 335 | 336 | ;; Maximum number of rollback slots to keep in the cache. (default 5) 337 | dotspacemacs-max-rollback-slots 5 338 | 339 | ;; If non-nil, the paste transient-state is enabled. While enabled, after you 340 | ;; paste something, pressing `C-j' and `C-k' several times cycles through the 341 | ;; elements in the `kill-ring'. (default nil) 342 | dotspacemacs-enable-paste-transient-state nil 343 | 344 | ;; Which-key delay in seconds. The which-key buffer is the popup listing 345 | ;; the commands bound to the current keystroke sequence. (default 0.4) 346 | dotspacemacs-which-key-delay 0.4 347 | 348 | ;; Which-key frame position. Possible values are `right', `bottom' and 349 | ;; `right-then-bottom'. right-then-bottom tries to display the frame to the 350 | ;; right; if there is insufficient space it displays it at the bottom. 351 | ;; It is also possible to use a posframe with the following cons cell 352 | ;; `(posframe . position)' where position can be one of `center', 353 | ;; `top-center', `bottom-center', `top-left-corner', `top-right-corner', 354 | ;; `top-right-corner', `bottom-left-corner' or `bottom-right-corner' 355 | ;; (default 'bottom) 356 | dotspacemacs-which-key-position 'bottom 357 | 358 | ;; Control where `switch-to-buffer' displays the buffer. If nil, 359 | ;; `switch-to-buffer' displays the buffer in the current window even if 360 | ;; another same-purpose window is available. If non-nil, `switch-to-buffer' 361 | ;; displays the buffer in a same-purpose window even if the buffer can be 362 | ;; displayed in the current window. (default nil) 363 | dotspacemacs-switch-to-buffer-prefers-purpose nil 364 | 365 | ;; Make consecutive tab key presses after commands such as 366 | ;; `spacemacs/alternate-buffer' (SPC TAB) cycle through previous 367 | ;; buffers/windows/etc. Please see the option's docstring for more information. 368 | ;; Set the option to t in order to enable cycling for all current and 369 | ;; future cycling commands. Alternatively, choose a subset of the currently 370 | ;; supported commands: '(alternate-buffer alternate-window). (default nil) 371 | dotspacemacs-enable-cycling nil 372 | 373 | ;; Whether side windows (such as those created by treemacs or neotree) 374 | ;; are kept or minimized by `spacemacs/toggle-maximize-window' (SPC w m). 375 | ;; (default t) 376 | dotspacemacs-maximize-window-keep-side-windows t 377 | 378 | ;; If nil, no load-hints enabled. If t, enable the `load-hints' which will 379 | ;; put the most likely path on the top of `load-path' to reduce walking 380 | ;; through the whole `load-path'. It's an experimental feature to speedup 381 | ;; Spacemacs on Windows. Refer the FAQ.org "load-hints" session for details. 382 | dotspacemacs-enable-load-hints nil 383 | 384 | ;; If t, enable the `package-quickstart' feature to avoid full package 385 | ;; loading, otherwise no `package-quickstart' attemption (default nil). 386 | ;; Refer the FAQ.org "package-quickstart" section for details. 387 | dotspacemacs-enable-package-quickstart nil 388 | 389 | ;; If non-nil a progress bar is displayed when spacemacs is loading. This 390 | ;; may increase the boot time on some systems and emacs builds, set it to 391 | ;; nil to boost the loading time. (default t) 392 | dotspacemacs-loading-progress-bar nil 393 | 394 | ;; If non-nil the frame is fullscreen when Emacs starts up. (default nil) 395 | ;; (Emacs 24.4+ only) 396 | dotspacemacs-fullscreen-at-startup nil 397 | 398 | ;; If non-nil `spacemacs/toggle-fullscreen' will not use native fullscreen. 399 | ;; Use to disable fullscreen animations in OSX. (default nil) 400 | dotspacemacs-fullscreen-use-non-native nil 401 | 402 | ;; If non-nil the frame is maximized when Emacs starts up. 403 | ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil. 404 | ;; (default t) (Emacs 24.4+ only) 405 | dotspacemacs-maximized-at-startup t 406 | 407 | ;; If non-nil the frame is undecorated when Emacs starts up. Combine this 408 | ;; variable with `dotspacemacs-maximized-at-startup' to obtain fullscreen 409 | ;; without external boxes. Also disables the internal border. (default nil) 410 | dotspacemacs-undecorated-at-startup nil 411 | 412 | ;; A value from the range (0..100), in increasing opacity, which describes 413 | ;; the transparency level of a frame when it's active or selected. 414 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 415 | dotspacemacs-active-transparency 90 416 | 417 | ;; A value from the range (0..100), in increasing opacity, which describes 418 | ;; the transparency level of a frame when it's inactive or deselected. 419 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 420 | dotspacemacs-inactive-transparency 90 421 | 422 | ;; A value from the range (0..100), in increasing opacity, which describes the 423 | ;; transparency level of a frame background when it's active or selected. Transparency 424 | ;; can be toggled through `toggle-background-transparency'. (default 90) 425 | dotspacemacs-background-transparency 90 426 | 427 | ;; If non-nil show the titles of transient states. (default t) 428 | dotspacemacs-show-transient-state-title t 429 | 430 | ;; If non-nil show the color guide hint for transient state keys. (default t) 431 | dotspacemacs-show-transient-state-color-guide t 432 | 433 | ;; If non-nil unicode symbols are displayed in the mode line. 434 | ;; If you use Emacs as a daemon and wants unicode characters only in GUI set 435 | ;; the value to quoted `display-graphic-p'. (default t) 436 | dotspacemacs-mode-line-unicode-symbols t 437 | 438 | ;; If non-nil smooth scrolling (native-scrolling) is enabled. Smooth 439 | ;; scrolling overrides the default behavior of Emacs which recenters point 440 | ;; when it reaches the top or bottom of the screen. (default t) 441 | dotspacemacs-smooth-scrolling t 442 | 443 | ;; Show the scroll bar while scrolling. The auto hide time can be configured 444 | ;; by setting this variable to a number. (default t) 445 | dotspacemacs-scroll-bar-while-scrolling t 446 | 447 | ;; Control line numbers activation. 448 | ;; If set to `t', `relative' or `visual' then line numbers are enabled in all 449 | ;; `prog-mode' and `text-mode' derivatives. If set to `relative', line 450 | ;; numbers are relative. If set to `visual', line numbers are also relative, 451 | ;; but only visual lines are counted. For example, folded lines will not be 452 | ;; counted and wrapped lines are counted as multiple lines. 453 | ;; This variable can also be set to a property list for finer control: 454 | ;; '(:relative nil 455 | ;; :visual nil 456 | ;; :disabled-for-modes dired-mode 457 | ;; doc-view-mode 458 | ;; markdown-mode 459 | ;; org-mode 460 | ;; pdf-view-mode 461 | ;; text-mode 462 | ;; :size-limit-kb 1000) 463 | ;; When used in a plist, `visual' takes precedence over `relative'. 464 | ;; (default nil) 465 | dotspacemacs-line-numbers nil 466 | 467 | ;; Code folding method. Possible values are `evil', `origami' and `vimish'. 468 | ;; (default 'evil) 469 | dotspacemacs-folding-method 'evil 470 | 471 | ;; If non-nil and `dotspacemacs-activate-smartparens-mode' is also non-nil, 472 | ;; `smartparens-strict-mode' will be enabled in programming modes. 473 | ;; (default nil) 474 | dotspacemacs-smartparens-strict-mode nil 475 | 476 | ;; If non-nil smartparens-mode will be enabled in programming modes. 477 | ;; (default t) 478 | dotspacemacs-activate-smartparens-mode t 479 | 480 | ;; If non-nil pressing the closing parenthesis `)' key in insert mode passes 481 | ;; over any automatically added closing parenthesis, bracket, quote, etc... 482 | ;; This can be temporary disabled by pressing `C-q' before `)'. (default nil) 483 | dotspacemacs-smart-closing-parenthesis nil 484 | 485 | ;; Select a scope to highlight delimiters. Possible values are `any', 486 | ;; `current', `all' or `nil'. Default is `all' (highlight any scope and 487 | ;; emphasis the current one). (default 'all) 488 | dotspacemacs-highlight-delimiters 'all 489 | 490 | ;; If non-nil, start an Emacs server if one is not already running. 491 | ;; (default nil) 492 | dotspacemacs-enable-server nil 493 | 494 | ;; Set the emacs server socket location. 495 | ;; If nil, uses whatever the Emacs default is, otherwise a directory path 496 | ;; like \"~/.emacs.d/server\". It has no effect if 497 | ;; `dotspacemacs-enable-server' is nil. 498 | ;; (default nil) 499 | dotspacemacs-server-socket-dir nil 500 | 501 | ;; If non-nil, advise quit functions to keep server open when quitting. 502 | ;; (default nil) 503 | dotspacemacs-persistent-server nil 504 | 505 | ;; List of search tool executable names. Spacemacs uses the first installed 506 | ;; tool of the list. Supported tools are `rg', `ag', `ack' and `grep'. 507 | ;; (default '("rg" "ag" "ack" "grep")) 508 | dotspacemacs-search-tools '("rg" "ag" "ack" "grep") 509 | 510 | ;; The backend used for undo/redo functionality. Possible values are 511 | ;; `undo-redo', `undo-fu' and `undo-tree' see also `evil-undo-system'. 512 | ;; Note that saved undo history does not get transferred when changing 513 | ;; your undo system from or to undo-tree. (default `undo-redo')" 514 | dotspacemacs-undo-system 'undo-redo 515 | 516 | ;; Format specification for setting the frame title. 517 | ;; %a - the `abbreviated-file-name', or `buffer-name' 518 | ;; %t - `projectile-project-name' 519 | ;; %I - `invocation-name' 520 | ;; %S - `system-name' 521 | ;; %U - contents of $USER 522 | ;; %b - buffer name 523 | ;; %f - visited file name 524 | ;; %F - frame name 525 | ;; %s - process status 526 | ;; %p - percent of buffer above top of window, or Top, Bot or All 527 | ;; %P - percent of buffer above bottom of window, perhaps plus Top, or Bot or All 528 | ;; %m - mode name 529 | ;; %n - Narrow if appropriate 530 | ;; %z - mnemonics of buffer, terminal, and keyboard coding systems 531 | ;; %Z - like %z, but including the end-of-line format 532 | ;; If nil then Spacemacs uses default `frame-title-format' to avoid 533 | ;; performance issues, instead of calculating the frame title by 534 | ;; `spacemacs/title-prepare' all the time. 535 | ;; (default "%I@%S") 536 | dotspacemacs-frame-title-format "%I@%S" 537 | 538 | ;; Format specification for setting the icon title format 539 | ;; (default nil - same as frame-title-format) 540 | dotspacemacs-icon-title-format nil 541 | 542 | ;; Color highlight trailing whitespace in all prog-mode and text-mode derived 543 | ;; modes such as c++-mode, python-mode, emacs-lisp, html-mode, rst-mode etc. 544 | ;; (default t) 545 | dotspacemacs-show-trailing-whitespace t 546 | 547 | ;; Delete whitespace while saving buffer. Possible values are `all' 548 | ;; to aggressively delete empty line and long sequences of whitespace, 549 | ;; `trailing' to delete only the whitespace at end of lines, `changed' to 550 | ;; delete only whitespace for changed lines or `nil' to disable cleanup. 551 | ;; The variable `global-spacemacs-whitespace-cleanup-modes' controls 552 | ;; which major modes have whitespace cleanup enabled or disabled 553 | ;; by default. 554 | ;; (default nil) 555 | dotspacemacs-whitespace-cleanup 'trailing 556 | 557 | ;; If non-nil activate `clean-aindent-mode' which tries to correct 558 | ;; virtual indentation of simple modes. This can interfere with mode specific 559 | ;; indent handling like has been reported for `go-mode'. 560 | ;; If it does deactivate it here. 561 | ;; (default t) 562 | dotspacemacs-use-clean-aindent-mode t 563 | 564 | ;; Accept SPC as y for prompts if non-nil. (default nil) 565 | dotspacemacs-use-SPC-as-y nil 566 | 567 | ;; If non-nil shift your number row to match the entered keyboard layout 568 | ;; (only in insert state). Currently supported keyboard layouts are: 569 | ;; `qwerty-us', `qwertz-de' and `querty-ca-fr'. 570 | ;; New layouts can be added in `spacemacs-editing' layer. 571 | ;; (default nil) 572 | dotspacemacs-swap-number-row nil 573 | 574 | ;; Either nil or a number of seconds. If non-nil zone out after the specified 575 | ;; number of seconds. (default nil) 576 | dotspacemacs-zone-out-when-idle nil 577 | 578 | ;; Run `spacemacs/prettify-org-buffer' when 579 | ;; visiting README.org files of Spacemacs. 580 | ;; (default nil) 581 | dotspacemacs-pretty-docs nil 582 | 583 | ;; If nil the home buffer shows the full path of agenda items 584 | ;; and todos. If non-nil only the file name is shown. 585 | dotspacemacs-home-shorten-agenda-source nil 586 | 587 | ;; If non-nil then byte-compile some of Spacemacs files. 588 | dotspacemacs-byte-compile nil)) 589 | 590 | (defun dotspacemacs/user-env () 591 | "Environment variables setup. 592 | This function defines the environment variables for your Emacs session. By 593 | default it calls `spacemacs/load-spacemacs-env' which loads the environment 594 | variables declared in `~/.spacemacs.env' or `~/.spacemacs.d/.spacemacs.env'. 595 | See the header of this file for more information." 596 | (spacemacs/load-spacemacs-env) 597 | ) 598 | 599 | (defun dotspacemacs/user-init () 600 | "Initialization for user code: 601 | This function is called immediately after `dotspacemacs/init', before layer 602 | configuration. 603 | It is mostly for variables that should be set before packages are loaded. 604 | If you are unsure, try setting them in `dotspacemacs/user-config' 605 | first." 606 | (spacemacs/force-init-spacemacs-env)) 607 | 608 | 609 | (defun dotspacemacs/user-load () 610 | "Library to load while dumping. 611 | This function is called only while dumping Spacemacs configuration. You can 612 | `require' or `load' the libraries of your choice that will be included in the 613 | dump." 614 | ) 615 | 616 | 617 | (defun dotspacemacs/user-config () 618 | "Configuration function for user code. 619 | This function is called at the very end of Spacemacs initialization after 620 | layers configuration. 621 | This is the place where most of your configurations should be done. Unless it is 622 | explicitly specified that a variable should be set before a package is loaded, 623 | you should place your code here." 624 | ;; Text settings ----------------------------------------------------- 625 | (setq-default 626 | ;; Break lines at specified column (<= 80, defaults 72) 627 | fill-column 80 628 | ;; Turns on auto-fill-mode to automatically break lines 629 | auto-fill-function 'do-auto-fill 630 | ;; Makes the kill-ring (emacs clipboard) to store only 4 entries, 631 | ;; otherwise it may flush memory 632 | kill-ring-max 2 633 | ;; Set the column number to start at 1 rather than 0 on spaceline 634 | column-number-indicator-zero-based nil 635 | ) 636 | ;; Disable auto-complation by default 637 | ;; (add-hook 'buffer-list-update-hook 'spacemacs/toggle-auto-completion-off) 638 | ;; When scrolling with the cursor, show 4 lines above/below 639 | (setq scroll-margin 5) 640 | ;; Deactivate scroll margin in terminals 641 | (defun spacemacs//unset-scroll-margin () 642 | (setq-local scroll-margin 0)) 643 | (spacemacs/add-to-hooks 644 | 'spacemacs//unset-scroll-margin 645 | '( 646 | messages-buffer-mode-hook 647 | comint-mode-hook 648 | term-mode-hook 649 | erc-mode-hook 650 | inferior-ess-mode-hook 651 | eshell-mode-hook 652 | inferior-python-mode-hook 653 | )) 654 | ;; Turn on FCI (Fill Column Indicator) mode 655 | ;; (turn-on-fci-mode) 656 | 657 | ;; imenu-mode -------------------------------------------------------- 658 | (setq imenu-list-position 'left) 659 | (setq imenu-list-size 20) 660 | (defun my-imenu-list-font-size () 661 | "Set a custom font size for `imenu-list`." 662 | (face-remap-add-relative 'default :height 0.8)) 663 | (add-hook 'imenu-list-major-mode-hook 'my-imenu-list-font-size) 664 | 665 | ;; Maxima mode https://www.emacswiki.org/emacs/MaximaMode ------------ 666 | ;; (add-to-list 'load-path "/usr/local/share/maxima/5.18.1/emacs/") 667 | (autoload 'maxima-mode "maxima" "Maxima mode" t) 668 | (autoload 'imaxima "imaxima" "Frontend for maxima with Image support" t) 669 | (autoload 'maxima "maxima" "Maxima interaction" t) 670 | (autoload 'imath-mode "imath" "Imath mode for math formula input" t) 671 | (setq imaxima-use-maxima-mode-flag t) 672 | (add-to-list 'auto-mode-alist '("\\.ma[cx]" . maxima-mode)) 673 | 674 | (with-eval-after-load 'company 675 | ;; disable inline previews 676 | (delq 'company-preview-if-just-one-frontend company-frontends)) 677 | 678 | ;; (with-eval-after-load 'copilot 679 | ;; (define-key copilot-completion-map (kbd "") 'copilot-accept-completion) 680 | ;; (define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion) 681 | ;; (define-key copilot-completion-map (kbd "s-TAB") 'copilot-accept-completion-by-word) 682 | ;; (define-key copilot-completion-map (kbd "s-") 'copilot-accept-completion-by-word)) 683 | 684 | ;; (customize-set-variable 'copilot-enable-predicates nil) 685 | ;; (add-hook 'prog-mode-hook 'copilot-mode) 686 | ;; (setq copilot--indent-warning-printed-p nil) 687 | 688 | ;; gptel-mode -------------------------------------------------------- 689 | (add-hook 'gptel-post-stream-hook 'gptel-auto-scroll) 690 | (add-hook 'gptel-post-response-functions 'gptel-end-of-response) 691 | (add-hook 'gptel-post-response-functions 'fill-region) 692 | (setq gptel-default-mode 'markdown-mode) 693 | ;; (setq-default gptel-model "gpt-4o") 694 | (setq gptel-model 'claude-sonnet-4.5 695 | gptel-backend (gptel-make-gh-copilot "Copilot")) 696 | 697 | ;; Set prompt and response prefixes for different modes 698 | (setq gptel-prompt-prefix-alist 699 | '((text-mode . "**Prompt**: ") 700 | (org-mode . "**Prompt**: ") 701 | (markdown-mode . "**Prompt**: "))) 702 | (setq gptel-response-prefix-alist 703 | '((text-mode . "**Response**: ") 704 | (org-mode . "**Response**: ") 705 | (markdown-mode . "**Response**: "))) 706 | 707 | ;; gptel-commit from https://github.com/lakkiy/gptel-commit 708 | (use-package gptel-commit 709 | :ensure t 710 | :after (gptel magit) 711 | :custom 712 | (gptel-commit-stream t)) 713 | 714 | ;; org-mode ---------------------------------------------------------- 715 | ;; (setq org-preview-latex-default-process 'dvisvgm) 716 | ;; (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5)) 717 | 718 | ;; magit ------------------------------------------------------------ 719 | ;; (setq magit-show-long-lines-warning nil) 720 | 721 | ) 722 | 723 | ;; Do not write anything past this comment. This is where Emacs will 724 | ;; auto-generate custom variable definitions. 725 | --------------------------------------------------------------------------------