Skip to content

Instantly share code, notes, and snippets.

@weaming weaming/spacemacs.el
Created Apr 11, 2019

What would you like to do?
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory as ~/.spacemacs
;; Use "SPC f e d" to open it
;; TODO:
;; change temp file directory
;; show code tree
;; open file in new window when searching recent files
;; open file in special window when navigate in file tree
;; refactor code
;; setup proxy
;; Spacemacs Startup:
;; emacs-lisp:
;; # Needed features of one editor
;; - [x] auto-completion
;; - [x] code goto definition, go back
;; - [x] documentation look up
;; - [x] virtualenv
;; - [ ] code running
;; - [ ] test running
;; - [x] code format
;; - [ ] refactor code
;; - [x] file tree
;; - [ ] code tree
;; - [x] code search
;; - [ ] code regexp search
;; - [ ] global search in project
;; - [ ] global replace in project
;; Concepts:
;; state:
;; (VIM) normal insert visual
;; (Evil only) motion emacs replace
;; (Spacemacs only) hybrid evilified lisp iedit iedit-insert
;; modes: major-mode, minor-mode
;; layer: plugins in VIM
;; transient-states
;; <Leader> key: SPC
;; buffers
;; windows
;; Emacs Lisp:
;; variables
;; keybindings
;; SPC o and SPC m o : are reserved for the user
;; SPC m : major mode key
;; functions
;; layout: a layout is a window configuration associated with a list of buffers
;; default layout; project layouts; custom layouts
;; workspaces: are sub-layouts, allowed to define multiple layouts into a given layout, those share the same buffer as the parent layout
;; Code guideline
;; spacemacs/xxx : interactive function
;; spacemacs//xxx : private function
;; spacemacs|xxx : macro
;; spacemacs-xxx : variable
;; spacemacs--xxx : private variable
;; <layer>/init-<package> : initial functions
;; Example Key Bindings (SPC is space key on your keyboard):
;; Pointer / cursor
;; h move cursor left
;; j move cursor down
;; k move cursor up
;; l move cursor right
;; H move cursor to the top of the screen
;; L move cursor to the bottom of the screen
;; SPC j 0 go to the beginning of line (and set a mark at the previous location in the line)
;; SPC j $ go to the end of line (and set a mark at the previous location in the line)
;; SPC t - lock the cursor at the center of the screen
;; Vim motions with avy
;; SPC j b go back to the previous location (before the jump)
;; SPC j j initiate avy jump char
;; SPC j w initiate avy jump word
;; SPC j l initiate avy jump line
;; Unimpaired bindings
;; [ SPC Insert space above
;; ] SPC Insert space below
;; [ b Go to previous buffer
;; ] b Go to next buffer
;; [ f Go to previous file in directory
;; ] f Go to next file in directory
;; [ l Go to the previous error
;; ] l Go to the next error
;; [ h Go to the previous vcs hunk
;; ] h Go to the next vcs hunk
;; [ q Go to the previous error
;; ] q Go to the next error
;; [ t Go to the previous frame
;; ] t Go to the next frame
;; [ w Go to the previous window
;; ] w Go to the next window
;; [ e Move line up
;; ] e Move line down
;; [ p Paste above current line
;; ] p Paste below current line
;; g p Select pasted text
;; Jumping
;; SPC j 0 go to the beginning of line (and set a mark at the previous location in the line)
;; SPC j $ go to the end of line (and set a mark at the previous location in the line)
;; SPC j b undo a jump (go back to previous location)
;; SPC j d jump to a listing of the current directory
;; SPC j D jump to a listing of the current directory (other window)
;; SPC j f jump to the definition of an Emacs Lisp function
;; SPC j i jump to a definition in buffer (imenu)
;; SPC j I jump to a definition in any buffer (imenu)
;; SPC j j jump to a character in the buffer (works as an evil motion)
;; SPC j J jump to a suite of two characters in the buffer (works as an evil motion)
;; SPC j k jump to next line and indent it using auto-indent rules
;; SPC j l jump to a line with avy (works as an evil motion)
;; SPC j q show the dumb-jump quick look tooltip
;; SPC j u jump to a URL in the current buffer
;; SPC j v jump to the definition/declaration of an Emacs Lisp variable
;; SPC j w jump to a word in the current buffer (works as an evil motion)
;; Joining and Splitting
;; J join the current line with the next line
;; SPC j k go to next line and indent it using auto-indent rules
;; SPC j n split the current line at point, insert a new line and auto-indent
;; SPC j s split a quoted string or s-expression in place
;; SPC j S split a quoted string or s-expression, insert a new line and auto-indent
;; f: file
;; :x save the current file and quit
;; SPC f b go to file bookmarks
;; SPC f c copy current file to a different location
;; SPC f C d convert file from unix to dos encoding
;; SPC f C u convert file from dos to unix encoding
;; SPC f D delete a file and the associated buffer (ask for confirmation)
;; SPC f E open a file with elevated privileges (sudo edit)
;; SPC f f open file with helm
;; SPC f F try to open the file under point helm
;; SPC f h open binary file with hexl (a hex editor)
;; SPC f j jump to the current buffer file in dired
;; SPC f J open a junk file, in mode determined by the file extension provided (defaulting to fundamental mode), using helm (or ivy)
;; SPC f l open file literally in fundamental mode
;; SPC f L Locate a file (using locate)
;; SPC f o open a file using the default external program
;; SPC f R rename the current file
;; SPC f s save a file
;; SPC f S save all files
;; SPC f r open a recent file with helm
;; SPC f t toggle file tree side bar using NeoTree
;; SPC f v d add a directory variable
;; SPC f v f add a local variable to the current file
;; SPC f v p add a local variable to the first line of the current file
;; SPC f y show and copy current file absolute path in the minibuffer
;; SPC f e d open the spacemacs dotfile (~/.spacemacs)
;; SPC f e D open ediff buffer of ~/.spacemacs and .spacemacs.template
;; SPC f e f discover the FAQ using helm
;; SPC f e i open the all mighty init.el
;; SPC f e l locate an Emacs library
;; SPC f e R resync the dotfile with spacemacs
;; SPC f e v display and copy the spacemacs version
;; ido ???
;; Bookmarkets
;; SPC f b : open an helm window with the current bookmarkets
;; C-d delete the selected bookmark
;; C-e edit the selected bookmark
;; C-f toggle filename location
;; C-o open the selected bookmark in another window
;; DocView ...
;; T: UI
;; SPC T M : max window size
;; q: quit
;; SPC q R : restart emacs
;; p: project
;; SPC p ' open a shell in project's root (with the shell layer)
;; SPC p ! run shell command in project's root
;; SPC p & run async shell command in project's root
;; SPC p % replace a regexp
;; SPC p a toggle between implementation and test
;; SPC p b switch to project buffer
;; SPC p c compile project using projectile
;; SPC p d find directory
;; SPC p D open project root in dired
;; SPC p f find file
;; SPC p F find file based on path around point
;; SPC p g find tags
;; SPC p C-g regenerate the project's etags / gtags
;; SPC p h find file using helm
;; SPC p I invalidate the projectile cache
;; SPC p k kill all project buffers
;; SPC p o run multi-occur
;; SPC p p switch project
;; SPC p r open a recent file
;; SPC p R replace a string
;; SPC p t open NeoTree in projectile root
;; SPC p T test project
;; SPC p v open project root in vc-dir or magit
;; SPC / search in project with the best search tool available
;; SPC s p see search in project
;; SPC s a p run ag
;; SPC s g p run grep
;; SPC s k p run ack
;; SPC s t p run pt
;; SPC p l : create a project layout
;; w: window
;; `ace-window' is meant to replace `other-window'.
;; SPC 0..9 : jump to nth window
;; SPC w = : balance split windows
;; SPC w b : force the focus back to the minibuffer (usefull with helm popups)
;; SPC w c : maximize/minimize a window and center it
;; SPC w C : maximize/minimize a window and center it using ace-window
;; SPC w d : delete a window
;; SPC u SPC w d : delete a window and its current buffer (does not delete the file)
;; SPC w D : delete another window using ace-window
;; SPC u SPC w D : delete another window and its current buffer using ace-window
;; SPC w t : toggle window dedication (dedicated window cannot be reused by a mode)
;; SPC w f : toggle follow mode
;; SPC w F : create new frame
;; SPC w h : move to window on the left
;; SPC w j : move to window below
;; SPC w k : move to window above
;; SPC w l : move to window on the right
;; SPC w H : move window to the left
;; SPC w J : move window to the bottom
;; SPC w K : move window to the top
;; SPC w L : move window to the right
;; SPC w m : maximize/minimize a window (maximize is equivalent to delete other windows)
;; SPC w M : swap windows using ace-window
;; SPC w o : cycle and focus between frames
;; SPC w p m : open messages buffer in a popup window
;; SPC w p p : close the current sticky popup window
;; SPC w r : rotate windows forward
;; SPC w R : rotate windows backward
;; SPC w s or SPC w - : horizontal split
;; SPC w S : horizontal split and focus new window
;; SPC w v or SPC w / : vertical split
;; SPC w V : vertical split and focus new window
;; SPC w u : undo window layout (used to effectively undo a closed window)
;; SPC w U : redo window layout
;; SPC w w : cycle and focus between windows
;; SPC w W : select window using ace-window
;; b: buffer
;; SPC TAB switch to alternate buffer in the current window (switch back and forth)
;; SPC b b switch to a buffer using helm
;; SPC b d kill the current buffer (does not delete the visited file)
;; SPC u SPC b d kill the current buffer and window (does not delete the visited file)
;; SPC b D kill a visible buffer using ace-window
;; SPC u SPC b D kill a visible buffer and its window using ace-window
;; SPC b C-d kill buffers using a regular expression
;; SPC b e erase the content of the buffer (ask for confirmation)
;; SPC b h open *spacemacs* home buffer
;; SPC b n switch to next buffer avoiding special buffers
;; SPC b m kill all buffers except the current one
;; SPC u SPC b m kill all buffers and windows except the current one
;; SPC b M kill all buffers matching the regexp
;; SPC b p switch to previous buffer avoiding special buffers
;; SPC b P copy clipboard and replace buffer (useful when pasting from a browser)
;; SPC b R revert the current buffer (reload from disk)
;; SPC b s switch to the *scratch* buffer (create it if needed)
;; SPC b w toggle read-only (writable state)
;; SPC b Y copy whole buffer to clipboard (useful when copying to a browser)
;; z f Make current function or comments visible in buffer as much as possible
;; SPC b f : open file in osx Finder
;; SPC b W : goto buffer workspace
;; SPC b 1..9 : move current buffer to window
;; x: text
;; SPC x o : open link
;; h: help
;; SPC h h : show documentation in another window
;; SPC h d f : describe function
;; SPC h d k : describe key
;; SPC h d m : describe mode
;; SPC h d v : describe variable
;; SPC h SPC : list all layers and files of them
;; l: layout
;; SPC l s : save layout
;; SPC l L : load layout
;; s: searching
;; example: SPC s a a
;; a --> ag
;; g --> grep
;; k --> ack
;; t --> pt
;; b --> opened buffers
;; f --> files in a given directory
;; p --> current project
;; searching in current file (a)
;; SPC s s search with the first found tool
;; SPC s S search with the first found tool with default input
;; SPC s a a ag
;; SPC s a A ag with default input
;; SPC s g g grep
;; SPC s g G grep with default input
;; searching in all open buffers visiting files (b)
;; SPC s b search with the first found tool
;; SPC s B search with the first found tool with default input
;; SPC s a b ag
;; SPC s a B ag with default text
;; SPC s g b grep
;; SPC s g B grep with default text
;; SPC s k b ack
;; SPC s k B ack with default text
;; SPC s t b pt
;; SPC s t B pt with default text
;; searching in files in an arbitrary directory (f)
;; SPC s f search with the first found tool
;; SPC s F search with the first found tool with default input
;; SPC s a f ag
;; SPC s a F ag with default text
;; SPC s g f grep
;; SPC s g F grep with default text
;; SPC s k f ack
;; SPC s k F ack with default text
;; SPC s t f pt
;; SPC s t F pt with default text
;; searching in a project (p)
;; SPC / or SPC s p search with the first found tool
;; SPC * or SPC s P search with the first found tool with default input
;; SPC s a p ag
;; SPC s a P ag with default text
;; SPC s g p grep with default text
;; SPC s k p ack
;; SPC s k P ack with default text
;; SPC s t p pt
;; SPC s t P pt with default text
;; searching the web
;; SPC s w g Get Google suggestions in emacs. Opens Google results in Browser.
;; SPC s w w Get Wikipedia suggestions in emacs. Opens Wikipedia page in Browser.
;; registers
;; SPC r e show evil yank and named registers
;; SPC r m show marks register
;; SPC r r show helm register
;; SPC r y show kill ring
;; error handling
;; SPC t s toggle flycheck
;; SPC e c clear all errors
;; SPC e h describe a flycheck checker
;; SPC e l toggle the display of the flycheck list of errors/warnings
;; SPC e n go to the next error
;; SPC e p go to the previous error
;; SPC e v verify flycheck setup (useful to 3rd party tools configuration)
;; SPC e . error transient state
;; other
;; SPC ; : comment/uncomment code
;; SPC ? : list all key bindings
;; m: major mode
;; SPC m g a : go to alternate file
;; SPC m g b : go back to previous location
;; SPC m g g : go to definition under point
;; SPC m g G : go to things under point on the other window
;; SPC m g t : go to correspoding test file if any
;; m e: evaluation
;; SPC m e $
;; SPC m e b
;; SPC m e e
;; SPC m e f
;; SPC m e l
;; SPC m e r
;; m t: toggle
;; m s: REPLs
;; m c: compile
;; SPC m c c: use `helm-make' via project file
;; SPC m c C: compile
;; SPC m c d: close compilation window
;; SPC m c k: kill compilation
;; SPC m c m: `helm-make'
;; SPC m c r: recompile
;; m d: debug
;; m t: test
;; m r: refactor
;; m f: format
;; plain text edition:
;; emacs --debug-init --timed-requires
;; Learning Emacs Lisp:
;; Some Concepts:
;; Lisp Machine
;; MacLisp (a lisp dialect)
;; IELM: Emacs Lisp interactive shell (REPL)
;; Basic Syntax:
;; + - * /
;; concat
;; defun
;; defvar
;; let
;; let*
;; progn
;; setq
;; eq
;; equal
;; =
;; >
;; string=
;; string>
;; car
;; cdr
;; Data Structures:
;; lists
;; vectors
;; rings
;; hashtables
;; Key Bindings:
;; Key Notation:
;; M Meta Alt
;; A Meta Alt
;; C Control Ctrl
;; S Shift Shift
;; SPC Space Space
;; Key Sequence:
;; C-x <keys> General extend commands
;; C-h <keys> Help commands
;; k finding functions of keybingds
;; f show documentation for a function
;; v show documentation for a variable
;; b show a massive list of keybindings and the command they run
;; C-c <keys> Mode specific extended commands
;; M-x Reserved to execute Emacs commands
;; apropos : search for documentation topics
;; apropos-command
;; apropos-library
;; apropos-documentation
;; describe-mode (C-h m)
;; describe-face
;; C-g Reserved to cancel Emacs commands
;; Key Mnemonics:
;; p previous
;; n next
;; b backward
;; f forward
;; a beginning
;; e end
;; More details in
;; Evaluation:
;; M-:
;; C-x C-e (undefined in spacesmacs) to evaluate the previous s-expression in the buffer
;; C-M-x to evaluate the current top-level s-expression. I use this to re-apply defvar and defun declarations.
;; M-x ielm REPL for emacs
;; M-x eval-buffer (key binding is ", e b" in spacemacs)
;; Basic Concepts:
;; Buffer:
;; (current-buffer)
;; (with-current-buffer buffer-or-name ...)
;; (set-buffer buffer-or-name)
;; (switch-to-buffer name)
;; (buffer-list)
;; Buffer-local variables
;; Project-wide buffer-local variables
;; Point
;; Text properties
;; property lists
;; each property has a name and a value
;; both of these can be any Lisp object, but the name is normally a symbol
;; example properties:
;; face
;; category
;; Mark
;; Region
;; (region-beginning)
;; (region-end)
;; (use-region-p)
;; (region-active-p)
;; Frame
;; Windows
;; Fill
;; Yank
;; Process
;; Mode line
;; Font locking : syntax coloring
;; Debugging:
;; `M-: (setq debug-on-error t) RET'
;; Editing:
;; Paredit
;; Manipulating the buffer:
;; (insert "foo" "bar")
;; (delete-region start end)
;; (insert-buffer-substring-no-properties buffer start end)
;; (insert-file-contents <filename>)
;; Tetxt properties:
;; (put-text-property start end 'my-property-name <value>)
;; (set-text-properties start end 'my-property-name <value>)
;; (get-text-property <point> 'my-property-name)
;; (propertize "hello" 'my-property-name <value> 'another-prop <value2>)
;; Navigating the buffer:
;; (got-char <point>)
;; (forward-char <point>)
;; (end-of-line)
;; (beginning-of-line)
;; (skip-chars-forward "chars")
;; (skip-chars-backward "chars")
;; (search-forward "foo")
;; (search-backward "foo")
;; (search-forward-regexp "blah")
;; (search-backward-regexp "blah")
;; save excursion:
;; (save-excursion ...) e.g. (save-excursion (beginning-of-line) (looking-at "X"))
;; (save-window-excursion ...)
;; Querying the buffer:
;; (buffer-substring start end)
;; (buffer-substring-no-properties start end)
;; (buffer-string)
;; (looking-at "[a-zA-Z]+")
;; (looking-back "[a-zA-Z]+")
;; Temporary buffer:
;; (with-temp-buffer (insert "Hello!"))
;; Defining interactive functions:
;; (interactive)
;; Defining your own major mode:
;; (define-derived-mode ...)
;; Defining a minor mode: Minor modes act as enhancements to existing modes.
;; (define-minor-mode ...)
;; Markets: Markers are handy objects that store a point, and changes to the buffer make the marker position move along.
;; Overlays:
;; Knowledge points:
;; Emacs was written in 1976 by Richard Stallman
;; Elisp Programming:
;; Elisp programming:
;; mathematical:
;; + - * / > < = /= exp log sin cos tan
;; number:
;; 1e3
;; string:
;; "Hello world Emacs Literals"
;; symbol:
;; 'this-a-symbol
;; 'vector->list
;; 'symbol?
;; boolean:
;; t nil '()
;; everything that is not "nil" is true
;; pair / cons cell:
;; '(a . b)
;; list:
;; '(10 20 "hello" () ("empty" 77))
;; vector:
;; [1 2 3 4 (+ 1 2 3 4)]
;; types predicate:
;; null
;; numberp
;; stringp
;; symbolp
;; atom : everything that is not a list or pair is an atom
;; listp
;; consp
;; vectorp
;; bufferp
;; windowp
;; framep
;; processp
;; type-of
;; boundp
;; fboundp
;; define variables:
;; defconst
;; set : set is not used very much
;; setq : the most used
;; (seq a 10 b 20 c "hello")
;; let : local variables
;; defining functions:
;; (defun <function name> (<parameters>) (<body>))
;; lambda:
;; (lambda (<parameters>) (<body>))
;; function as arguments:
;; (caller-function #'<function-1> #'<function-2> arg1 arg2) : pass as parameter
;; (funcall function1 arg1 arg2 arg3) : call the function passed
;; variadic functions:
;; (defun sum (&res numbers) (apply #'+ numbers))
;; (defun <name> (a &optional b) ...)
;; functions with property list argument:
;; (defun <name> (&res params) ...)
;; (let ((name plist-get params :name) (age plist-get params :age)))
;; (<func-name> :name "emily" :age 18)
;; closures:
;; (setq lexical-binding t) : Emacs lisp dialect doesn’t have closure by default
;; list operations:
;; cons: a cons cell is an object that consists of two slots, called the car slot and the cdr slot.
;; list: a list is a series of cons cells. '(a b c) == (cons 'a (cons 'b (cons 'c nil)))
;; association list:
;; clist: a list of cons pairs, '((a . b) (x . y) (2 . 3) (4 . (1 2 3)))
;; alist: a list of lists of two elements, '((a b) (x y) (2 3) (4 (1 2 3)))
;; plist: property list, '(:key1 value1 :key2 valu2 :key3 value3)
;; (quote (1 2 3))
;; (length '(1 2 3))
;; (nth 0 '(0 1 2 3)) : return 0
;; (member 1 '(0 1 2 3)) : return '(1 2 3)
;; (position 2 '(0 1 2 3)) : return 2, prior to emacs 24.4
;; (cl-position 2 '(0 1 2 3)) : return 2, emacs 24.4 or later
;; (cdr '(0 1 2 3)) : return '(1 2 3), tail
;; (car '(0 1 2 3)) : return 0, first
;; (cons -1 '(0 1 2 3)) : return '(-1 0 1 2 3)
;; (car (last '(0 1 2 3))) : return 3, last
;; (reverse '(0 1 2 3))
;; (append '(1 2) nil '("a" "b" "c") nil)
;; (remove-if-not (lambda (x) (> x 3)) '(1 2 3 4 5))
;; (null '(1 2 3))
;; (nthcdr 2 '(1 2 3)) : drop the first n elements
;; (delq 2 '(1 2 3)) : but doesn't work to delete sublists
;; (delete '(5) '(1 2 (5) 6))
;; (coerce [1 2 3] 'list)
;; (number-sequence 0 10 2) : '(0 2 4 6 8 10)
;; (number-sequence 7 4 -1) : '(7 6 5 4)
;; (push 'symbol <list-name>) : add(modify) to the head of a list
;; (pop <list-name>) : pop(modify) from the head of a list
;; (assoc 'key dict) : get a cell associated with a key
;; (mapcar #'car dict) : get all keys
;; (mapcar #'cdr dict) : get all values
;; (plist-get <list> <property-name>)
;; strings:
;; (split-string "hello world")
;; (split-string "hello\nworld" "\n")
;; (format-time-string "%Y-%m-%d %H:%M:%S" (current-time))
;; (concat "hello" "world")
;; (mapconcat 'identity '("aaa" "bbb" "ccc") ",")
;; (string-width "hello world")
;; (substring "hello world" 0 5)
;; (string-match "hello world" "ell")
;; (make-string 5 ?x)
;; symbol / string conversion:
;; (symbol-name 'hello-world)
;; (intern "hello-world")
;; read s-expression from string:
;; (read-from-string ...)
;; symbol:
;; (intern "a-symbol")
;; (symbol-name 'a-symbol)
;; (symbolp (intern "a-symbol"))
;; (setq sym '(1 2 3 4))
;; (boundp 'sym) : test if variable is defined
;; (symbol-value 'sym)
;; (symbol-function 'sym)
;; (symbol-plist 'sym)
;; (fboundp 'sym) : test if function is defined
;; (subrp (symbol-function 'my-function))
;; type conversion:
;; (type-of <value-or-symbol>)
;; (number-to-string 123)
;; (string-to-number "200")
;; (symbol-name 'my-symbol)
;; (symbol-name :my-symbol)
;; (intern "my-symbol")
;; (read "(:x 3 :y 4 :z 5)")
;; eval:
;; (eval '(+ 1 2 3))
;; (defun eval-string (str) (eval (read str)))
;; (eval-string "(+ 1 2 3)")
;; (format "%S" <s-epxression-symbol>)
;; emacs lisp mode:
;; (emacs-lisp-mode)
;; (eval-defun)
;; (eval-region)
;; (eval-buffer)
;; (eval-expression)
;; (load-file)
;; defalias:
;; (require 'cl)
;; (defalias 'map 'mapcar)
;; (defalias 'filter 'remove-if-not)
;; control-structures:
;; (if <condition> <then value> <else value>)
;; (not <condition>)
;; (when <condition> <body>)
;; (cond ((<condition> <branch>) ...))
;; (defun test-cl-switch ...)
;; (dolist (<loop var> <list>) <body>)
;; (dotimes (<loop var> <time count>) <body>)
;; (loop <expression1> <expression2>)
;; (loop for <loop var> from 1 to 10 collecting <body>)
;; (loop for <loop var> below 10 collecting <body>)
;; (loop for <loop var> in <list> do <body>)
;; (do (variable-definition*) (end-test-form result-form*) statement*)
;; (do ((i 0 (1+ i))) ((>= i 4)) (print i))
;; functional programming:
;; (mapcar 'my-func <list>)
;; (remove-if-not 'my-func <list>)
;; (remove-if 'my-func <list>)
;; (lambda (x) (* x 10))
;; (funcall <lambda> <arguments>)
;; (apply <func> <list of arguments>)
;; (defun compose ...)
;; (lexical-let ...)
;; (reduce ...)
;; (defun <func name> "documentation" (interactive) ...) : Interactive functions can be called using: M-x <function>. The user can create custom emacs commands with interactive functions.
;; (defun map ...)
;; (defun filter ...)
;; (defun take ...)
;; (defun drop ...)
;; (defun map-apply (fun xss) ...)
;; (defun zip (&rest xss) ...)
;; (defun zipwith (f &rest xss) ...)
;; (defun foldr (f acc xss))
;; (defun foldl (f acc xss))
;; (defun map-pair (func xs))
;; (defun map-xypair (func-x func-y xs))
;; (defmacro juxt (&rest xs_f)) : apply a list of functions to a single argument.
;; (defmacro map-juxt (xs_f xs))
;; (defmacro $f ...) : $ as lambda's argument
;; (defmacro $c ...) : partial application
;; structures:
;; (defstruct ...)
;; macro and metaprogramming:
;; Macros are useful to create new lisp special forms like if and when, create new control structures, domain specific languages,
;; eliminate boilerplate code, automate code and redefine syntax. Elisp macro constructs has the same syntax of Common Lisp.
;; Quasi-quote(`() and , and ,@): useful to create s-expression templates, data structure templates and lisp macros.
;; (defmacro λ (args body) `(lambda ,args ,body))
;; (defmacro def/defn/fn/letc/define) : Clojure style forms
;; (macroexpand ...)
;; (defmacro defrebindfun ...)
;; (defmacro $ (a op b) `(,op ,a ,b)) : convert infix operator to prefix operator
;; (defmacro $debug ...)
;; Elisp Snippets:
;; A Lisp macro object is a list whose car is macro, and whose cdr is a function.
;; strings:
;; (concat "hello" " world")
;; (apply #'concat '("hello" " world"))
;; (defun join (sep lst) (mapconcat 'identity lst sep))
;; (split-string "hello world elisp")
;; (split-string (getenv "PATH") ":")
;; (split-string-and-unquote "/bin/app -x -y \"/home/user/some name with space/etc\" -k cmd")
;; text manipulation: IGNORE
;; S-expressions:
;; (read "(+ 1 2 3 4)")
;; (eval (read "(+ 1 2 3 4)"))
;; clipboard:
;; (defun clipboard/set () ...)
;; (defun clipboard/get () ...)
;; (defun buffer/copy-file-name () ...)
;; (defun buffer/copy-path () ...)
;; (defun buffer/copy-content () ...)
;; elisp:
;; (load-file <path>)
;; (defun load-dir (path extension) ...)
;; (add-to-list 'load-path <path>)
;; (defun scratch() ...)
;; (defun eval-string (string) ...)
;; (defun eval-clip () (eval-string (shell-command-to-string "xclip -o")))
;; (documentation 'function-name)
;; (symbol-function 'function-name)
;; (help-function-arglist 'function-name)
;; common lisp emulation library:
;; (require 'cl)
;; (cl-reduce)
;; buffer and region:
;; (save-buffer)
;; (kill-buffer <buffer-object or buffer-name)
;; (defun buffer-content)
;; (defun get-selection)
;; (defun python/scratch)
;; (defun sh/scratch)
;; (buffer-local-variables)
;; (buffer-local-variables <buffer-name>)
;; (buffer-local-value <variable> <buffer>)
;; (append-to-file <point-min> <point-max> <file-name>)
;; (revert-buffer t t t)
;; IO:
;; (read-string)
;; (read-file-name)
;; (read-directory-name)
;; (read-regexp)
;; (read-passwd)
;; (read-shell-command)
;; (read-command)
;; (read-envvar-name)
;; (read-key)
;; (read-key-sequence)
;; (read-number)
;; (read-regexp)
;; (message <text>)
;; (message-box <text>)
;; (tooltip-show <text>)
;; interacting with OS and external app:
;; (shell-command)
;; (async-shell-command)
;; (start-process)
;; (call-process)
;; (shell-command-to-string)
;; (shell-command-on-region)
;; (getenv)
;; (setenv)
;; (defun add-to-path-var (&rest pathlist))
;; (defun ping-host)
;; (defun traceroute-host)
;; (term <program>)
;; (defun shell-command-in-terminal (command))
;; (defun shell-launch)
;; (defun shell/buffer-repl)
;; (defun shell/send-region)
;; compilation:
;; %f buffer file name
;; %n buffer base name
;; %d buffer directory
;; file:
;; (file-exist-p <path>)
;; (expand-file-name <path>)
;; (defun readfile (filename) ...)
;; (printc)
;; (find-file)
;; (find-file-other-window)
;; (find-file-other-frame)
;; (defun open-as-root)
;; (defun open-buffer-as-root)
;; file name manipulation:
;; (buffer-file-name)
;; (file-name-nondirectory)
;; (file-name-base)
;; (file-name-directory)
;; (expand-file-name)
;; (defun file-replace-extension)
;; directory:
;; (dired)
;; (dired-other-window)
;; (dired-other-frame)
;; (directory-files)
;; dired mode snippets:
;; (defun dired-copy-path)
;; (defun dired-paste-file-from-clipboard)
;; (defun dired-touch)
;; (defun dired-open-files)
;; (defun compose)
;; (defun dired-close-files)
;; (defun xdg-open)
;; (defun dired-xdg)
;; (defun dired-close-all)
;; (defun dired-bookmarks)
;; (defun dired/filter-extension)
;; (defun dired/filter)
;; (defun dired-exec-exploer)
;; date time:
;; (format-time-string "%Y-%m-%d")
;; (current-time)
;; (current-time-string)
;; (float-time)
;; (current-time-zone)
;; emacs introspection:
;; (user-init-file)
;; (user-emacs-directory)
;; (defun test-window-system)
;; web browser:
;; (browser-url)
;; (defun open-yandex)
;; (setq browse-url-browser-function 'browse-url-chromium)
;; (defun search-google)
;; (defun search-google-url)
;; (defun search-hacknews-with-google)
;; (defun search-reddit-with-google)
;; (defun search-stackoverflow-with-google)
;; (defun search-github)
;; (defun search-gisthub)
;; (defun open-emacs-mannual)
;; (format "" (url-encode-url (read-string "Dictionary: ")))
;; (eww-browse-url <url>)
;; (eww-open-file <path>)
;; (url-copy-file)
;; (url-retrieve-synchronously URL &optional SILENT INHIBIT-COOKIES)
;; (defun download-url-to-file)
;; (defun download-code-view)
;; http requests:
;; (defun url-http-post)
;; (defun url-http-get)
;; packages:
;; (package-installed-p 'helm-core)
;; (defun package-install-url)
;; helm snippets:
;; (defun buffer/with-file-in-directory-p)
;; (defun buffer/switch-in-directory)
;; (defun helm-recent-files)
;; (defun unique)
;; (defun helm-recent-dirs)
;; (defun get-executables)
;; (defun run-async)
;; (defun run-async-lst)
;; (defun run-launcher)
;; (defun switch-file)
;; (defun helm-switch-mode)
;; (defun helm-web)
;; (defun re-seq)
;; (defun helm-make)
;; persistence:
;; (defun file-contents)
;; (defun write-file)
;; (defun make-session-code)
;; (defun save-session)
;; (defun load-session)
;; (defun save-view)
;; (defun restore-view)
;; (add-hook ...)
;; IELM - inferior emacs lisp mode:
;; (setq ielm-prompt "> ")
;; (defun ielm/clear)
;; (defun ielm/send-region)
;; (defun ielm-select-buffer-other-window)
;; (defun ielm-this-buffer)
;; emacs server and client:
;; Opening a new file in the same `emacs-session' requires the use of `emacsclient'.
;; By default Emacs pulls packages from a GNU package repository called ELPA.
;; org-mode:
;; Key Bindings / Shortcuts:
;; Settings and Packages:
;; Emacs Utilities:
;; Miscellaneous:
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable values."
;; Base distribution to use. This is a layer contained in the directory
;; `+distribution'. For now available distributions are `spacemacs-base'
;; or `spacemacs'. (default 'spacemacs)
dotspacemacs-distribution 'spacemacs
;; Lazy installation of layers (i.e. layers are installed only when a file
;; with a supported type is opened). Possible values are `all', `unused'
;; and `nil'. `unused' will lazy install only unused layers (i.e. layers
;; not listed in variable `dotspacemacs-configuration-layers'), `all' will
;; lazy install any layer that support lazy installation even the layers
;; listed in `dotspacemacs-configuration-layers'. `nil' disable the lazy
;; installation feature and you have to explicitly list a layer in the
;; variable `dotspacemacs-configuration-layers' to install it.
;; (default 'unused)
dotspacemacs-enable-lazy-installation 'unused
;; If non-nil then Spacemacs will ask for confirmation before installing
;; a layer lazily. (default t)
dotspacemacs-ask-for-lazy-installation t
;; If non-nil layers with lazy install support are lazy installed.
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (i.e. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
;; List of configuration layers to load.
;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press <SPC f e R> (Vim style) or
;; <M-m f e R> (Emacs style) to install them.
;; ----------------------------------------------------------------
;; auto-completion
;; better-defaults
;; git
;; markdown
;; org
;; (shell :variables
;; shell-default-height 30
;; shell-default-position 'bottom)
;; spell-checking
;; syntax-checking
;; version-control
;; SPC a o # : org agenda list stuck projects
;; SPC a o / : org occur in agenda files
;; SPC a o a : org agenda list
;; SPC a o c : org capture
;; SPC a o e : org store agenda views
;; SPC a o l : org store link
;; SPC a o m : org tags view
;; SPC a o o : org agenda
;; SPC a o O : org clock out
;; SPC a o s : org search view
;; SPC a o t : org todo list
;; SPC C c : org-capture
(org :variables org-projectile-file "")
;; SPC a f : start elfeed
(elfeed :variables
;; rmh-elfeed-org-files (list "~/.emacs.d/weaming/")
elfeed-feeds '(("" golang blog)
("" wanqu))
(auto-completion :variables
auto-completion-return-key-behavior 'complete
auto-completion-tab-key-behavior 'cycle
auto-completion-complete-with-key-sequence nil
auto-completion-complete-with-key-sequence-delay 0.1
auto-completion-private-snippets-directory nil)
;; SPC m g c : generate GTAGS database
(gtags :variables gtags-enable-by-default t)
(shell :variables shell-default-shell 'eshell
shell-default-position 'bottom
shell-default-height 30)
;; functions prefixes
;; SPC m v : multiple python version (pyenv)
;; SPC m V : virtual environment (virtualenvwrapper)
;; , v a : activate any virtual environment by selected path
;; SPC m c : execute
;; SPC m t : test
;; SPC m r : refactor
;; SPC m s : Hy REPL process
;; SPC m l : live code
(python :variables
python-enable-yapf-format-on-save t
python-fill-column 120)
;; SPC m = : reformat the buffer
;; SPC m c . : repeat the last Cargo command
;; SPC m c C : remove build artifacts with Cargo
;; SPC m c X : execute a project example with Cargo
;; SPC m c c : compile project with Cargo
;; SPC m c d : generate documentation with Cargo
;; SPC m c e : run benchmarks with Cargo
;; SPC m c f : run the current test with Cargo
;; SPC m c i : create a new project with Cargo (init)
;; SPC m c n : create a new project with Cargo (new)
;; SPC m c o : run all tests in current file with Cargo
;; SPC m c s : search for packages on with Cargo
;; SPC m c u : update dependencies with Cargo
;; SPC m c x : execute a project with Cargo
;; SPC m g g : jump to definition
;; SPC m t : run tests with Cargo
;; SPC m h h : godoc at point
;; SPC m i g : goto imports
;; SPC m i a : add import
;; SPC m i r : remove unused import
;; SPC m e b : go-play buffer
;; SPC m e r : go-play region
;; SPC m e d : download go-play snippet
;; SPC m x x : run "go run" for the current 'main' package
;; SPC m g a : jump to matching test file or back from test to code file
;; SPC m g c : open a clone of the current buffer with a coverage info (go tool cover -h for help)
;; SPC m g g : go jump to definition
;; SPC m r n : go rename
;; SPC m t p : run "go test" for the current package
;; SPC m t P : run "go test" for the current package and all packages under it
;; SPC m t t : run "go test" for the function you're currently in (while you're in a _.test.go file)
;; SPC m t s : run "go test" for the suite you're currently in (requires gocheck)
(go :variables go-tab-width 4)
;; elixir
;; SPC m \ : insert end-of-line backslashes to the lines in the region
;; yarn global add tern js-beautify eslint
;; List of additional packages that will be installed without being
;; wrapped in a layer. If you need some configuration for these
;; packages, then consider creating a layer. You can also put the
;; configuration in `dotspacemacs/user-config'.
dotspacemacs-additional-packages '()
;; A list of packages that cannot be updated.
dotspacemacs-frozen-packages '()
;; A list of packages that will not be installed and loaded.
dotspacemacs-excluded-packages '()
;; Defines the behaviour of Spacemacs when installing packages.
;; Possible values are `used-only', `used-but-keep-unused' and `all'.
;; `used-only' installs only explicitly used packages and uninstall any
;; unused packages as well as their unused dependencies.
;; `used-but-keep-unused' installs only the used packages but won't uninstall
;; them if they become unused. `all' installs *all* packages supported by
;; Spacemacs and never uninstall them. (default is `used-only')
dotspacemacs-install-packages 'used-only))
(defun dotspacemacs/init ()
"Initialization function.
This function is called at the very startup of Spacemacs initialization before layers configuration.
You should not put any user code in there besides modifying the variable values."
;; This setq-default sexp is an exhaustive list of all the supported
;; spacemacs settings.
;; If non nil ELPA repositories are contacted via HTTPS whenever it's
;; possible. Set it to nil if you have no way to use HTTPS in your
;; environment, otherwise it is strongly recommended to let it set to t.
;; This variable has no effect if Emacs is launched with the parameter
;; `--insecure' which forces the value of this variable to nil.
;; (default t)
dotspacemacs-elpa-https t
;; Maximum allowed time in seconds to contact an ELPA repository.
dotspacemacs-elpa-timeout 5
;; If non nil then spacemacs will check for updates at startup
;; when the current branch is not `develop'. Note that checking for
;; new versions works via git commands, thus it calls GitHub services
;; whenever you start Emacs. (default nil)
dotspacemacs-check-for-update nil
;; If non-nil, a form that evaluates to a package directory. For example, to
;; use different package directories for different Emacs versions, set this
;; to `emacs-version'.
dotspacemacs-elpa-subdirectory nil
;; One of `vim', `emacs' or `hybrid'.
;; `hybrid' is like `vim' except that `insert state' is replaced by the
;; `hybrid state' with `emacs' key bindings. The value can also be a list
;; with `:variables' keyword (similar to layers). Check the editing styles
;; section of the documentation for details on available variables.
;; (default 'vim)
dotspacemacs-editing-style 'vim
;; If non nil output loading progress in `*Messages*' buffer. (default nil)
dotspacemacs-verbose-loading nil
;; Specify the startup banner. Default value is `official', it displays
;; the official spacemacs logo. An integer value is the index of text
;; banner, `random' chooses a random text banner in `core/banners'
;; directory. A string value must be a path to an image format supported
;; by your Emacs build.
;; If the value is nil then no banner is displayed. (default 'official)
dotspacemacs-startup-banner 'official
;; List of items to show in startup buffer or an association list of
;; the form `(list-type . list-size)`. If nil then it is disabled.
;; Possible values for list-type are:
;; `recents' `bookmarks' `projects' `agenda' `todos'."
;; List sizes may be nil, in which case
;; `spacemacs-buffer-startup-lists-length' takes effect.
dotspacemacs-startup-lists '((recents . 5)
(projects . 7))
;; True if the home buffer should respond to resize events.
dotspacemacs-startup-buffer-responsive t
;; Default major mode of the scratch buffer (default `text-mode')
dotspacemacs-scratch-mode 'text-mode
;; List of themes, the first of the list is loaded when spacemacs starts.
;; Press <SPC> T n to cycle to the next theme in the list (works great
;; with 2 themes variants, one dark and one light)
dotspacemacs-themes '(spacemacs-dark
;; If non nil the cursor color matches the state color in GUI Emacs.
dotspacemacs-colorize-cursor-according-to-state t
;; Default font, or prioritized list of fonts. `powerline-scale' allows to
;; quickly tweak the mode-line size to make separators look not too crappy.
dotspacemacs-default-font '("Source Code Pro"
:size 14
:weight normal
:width normal
:powerline-scale 1.1)
;; The leader key
dotspacemacs-leader-key "SPC"
;; The key used for Emacs commands (M-x) (after pressing on the leader key).
;; (default "SPC")
dotspacemacs-emacs-command-key "SPC"
;; The key used for Vim Ex commands (default ":")
dotspacemacs-ex-command-key ":"
;; The leader key accessible in `emacs state' and `insert state'
;; (default "M-m")
dotspacemacs-emacs-leader-key "M-m"
;; Major mode leader key is a shortcut key which is the equivalent of
;; pressing `<leader> m`. Set it to `nil` to disable it. (default ",")
dotspacemacs-major-mode-leader-key ","
;; Major mode leader key accessible in `emacs state' and `insert state'.
;; (default "C-M-m")
dotspacemacs-major-mode-emacs-leader-key "C-M-m"
;; These variables control whether separate commands are bound in the GUI to
;; the key pairs C-i, TAB and C-m, RET.
;; Setting it to a non-nil value, allows for separate commands under <C-i>
;; and TAB or <C-m> and RET.
;; In the terminal, these pairs are generally indistinguishable, so this only
;; works in the GUI. (default nil)
dotspacemacs-distinguish-gui-tab nil
;; If non nil `Y' is remapped to `y$' in Evil states. (default nil)
dotspacemacs-remap-Y-to-y$ nil
;; If non-nil, the shift mappings `<' and `>' retain visual state if used
;; there. (default t)
dotspacemacs-retain-visual-state-on-shift t
;; If non-nil, J and K move lines up and down when in visual mode.
;; (default nil)
dotspacemacs-visual-line-move-text nil
;; If non nil, inverse the meaning of `g' in `:substitute' Evil ex-command.
;; (default nil)
dotspacemacs-ex-substitute-global nil
;; Name of the default layout (default "Default")
dotspacemacs-default-layout-name "Default"
;; If non nil the default layout name is displayed in the mode-line.
;; (default nil)
dotspacemacs-display-default-layout nil
;; If non nil then the last auto saved layouts are resume automatically upon
;; start. (default nil)
dotspacemacs-auto-resume-layouts nil
;; Size (in MB) above which spacemacs will prompt to open the large file
;; literally to avoid performance issues. Opening a file literally means that
;; no major mode or minor modes are active. (default is 1)
dotspacemacs-large-file-size 1
;; Location where to auto-save files. Possible values are `original' to
;; auto-save the file in-place, `cache' to auto-save the file to another
;; file stored in the cache directory and `nil' to disable auto-saving.
;; (default 'cache)
dotspacemacs-auto-save-file-location 'cache
;; Maximum number of rollback slots to keep in the cache. (default 5)
dotspacemacs-max-rollback-slots 5
;; If non nil, `helm' will try to minimize the space it uses. (default nil)
dotspacemacs-helm-resize nil
;; if non nil, the helm header is hidden when there is only one source.
;; (default nil)
dotspacemacs-helm-no-header nil
;; define the position to display `helm', options are `bottom', `top',
;; `left', or `right'. (default 'bottom)
dotspacemacs-helm-position 'bottom
;; Controls fuzzy matching in helm. If set to `always', force fuzzy matching
;; in all non-asynchronous sources. If set to `source', preserve individual
;; source settings. Else, disable fuzzy matching in all sources.
;; (default 'always)
dotspacemacs-helm-use-fuzzy 'always
;; If non nil the paste micro-state is enabled. When enabled pressing `p`
;; several times cycle between the kill ring content. (default nil)
dotspacemacs-enable-paste-transient-state nil
;; Which-key delay in seconds. The which-key buffer is the popup listing
;; the commands bound to the current keystroke sequence. (default 0.4)
dotspacemacs-which-key-delay 0.4
;; Which-key frame position. Possible values are `right', `bottom' and
;; `right-then-bottom'. right-then-bottom tries to display the frame to the
;; right; if there is insufficient space it displays it at the bottom.
;; (default 'bottom)
dotspacemacs-which-key-position 'bottom
;; If non nil a progress bar is displayed when spacemacs is loading. This
;; may increase the boot time on some systems and emacs builds, set it to
;; nil to boost the loading time. (default t)
dotspacemacs-loading-progress-bar t
;; If non nil the frame is fullscreen when Emacs starts up. (default nil)
;; (Emacs 24.4+ only)
dotspacemacs-fullscreen-at-startup nil
;; If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen.
;; Use to disable fullscreen animations in OSX. (default nil)
dotspacemacs-fullscreen-use-non-native nil
;; If non nil the frame is maximized when Emacs starts up.
;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil.
;; (default nil) (Emacs 24.4+ only)
dotspacemacs-maximized-at-startup nil
;; A value from the range (0..100), in increasing opacity, which describes
;; the transparency level of a frame when it's active or selected.
;; Transparency can be toggled through `toggle-transparency'. (default 90)
dotspacemacs-active-transparency 90
;; A value from the range (0..100), in increasing opacity, which describes
;; the transparency level of a frame when it's inactive or deselected.
;; Transparency can be toggled through `toggle-transparency'. (default 90)
dotspacemacs-inactive-transparency 90
;; If non nil show the titles of transient states. (default t)
dotspacemacs-show-transient-state-title t
;; If non nil show the color guide hint for transient state keys. (default t)
dotspacemacs-show-transient-state-color-guide t
;; If non nil unicode symbols are displayed in the mode line. (default t)
dotspacemacs-mode-line-unicode-symbols t
;; If non nil smooth scrolling (native-scrolling) is enabled. Smooth
;; scrolling overrides the default behavior of Emacs which recenters point
;; when it reaches the top or bottom of the screen. (default t)
dotspacemacs-smooth-scrolling t
;; Control line numbers activation.
;; If set to `t' or `relative' line numbers are turned on in all `prog-mode' and
;; `text-mode' derivatives. If set to `relative', line numbers are relative.
;; This variable can also be set to a property list for finer control:
;; '(:relative nil
;; :disabled-for-modes dired-mode
;; doc-view-mode
;; markdown-mode
;; org-mode
;; pdf-view-mode
;; text-mode
;; :size-limit-kb 1000)
;; (default nil)
dotspacemacs-line-numbers nil
;; Code folding method. Possible values are `evil' and `origami'.
;; (default 'evil)
dotspacemacs-folding-method 'evil
;; If non-nil smartparens-strict-mode will be enabled in programming modes.
;; (default nil)
dotspacemacs-smartparens-strict-mode nil
;; If non-nil pressing the closing parenthesis `)' key in insert mode passes
;; over any automatically added closing parenthesis, bracket, quote, etc…
;; This can be temporary disabled by pressing `C-q' before `)'. (default nil)
dotspacemacs-smart-closing-parenthesis nil
;; Select a scope to highlight delimiters. Possible values are `any',
;; `current', `all' or `nil'. Default is `all' (highlight any scope and
;; emphasis the current one). (default 'all)
dotspacemacs-highlight-delimiters 'all
;; If non nil, advise quit functions to keep server open when quitting.
;; (default nil)
dotspacemacs-persistent-server nil
;; List of search tool executable names. Spacemacs uses the first installed
;; tool of the list. Supported tools are `ag', `pt', `ack' and `grep'.
;; (default '("ag" "pt" "ack" "grep"))
dotspacemacs-search-tools '("ag" "pt" "ack" "grep")
;; The default package repository used if no explicit repository has been
;; specified with an installed package.
;; Not used for now. (default nil)
dotspacemacs-default-package-repository nil
;; Delete whitespace while saving buffer. Possible values are `all'
;; to aggressively delete empty line and long sequences of whitespace,
;; `trailing' to delete only the whitespace at end of lines, `changed'to
;; delete only whitespace for changed lines or `nil' to disable cleanup.
;; (default nil)
dotspacemacs-whitespace-cleanup nil
dotspacemacs-maximized-at-startup t
dotspacemacs-elpa-https nil
dotspacemacs-line-numbers 'relative
;; dotspacemacs-editing-style 'hybrid
dotspacemacs-auto-resume-layouts nil
;; evil-escape-key-sequence "jk"
(defun dotspacemacs/user-init ()
"Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration executes.
This function is mostly useful for variables that need to be set before packages are loaded.
If you are unsure, you should try in setting them in `dotspacemacs/user-config' first."
;; ;; Package deletion failing on OSX with trash installed via Homebrew
;; (if (executable-find "trash")
;; (defun system-move-file-to-trash (file)
;; "Use `trash' to move FILE to the system trash. Can be installed with `brew install trash', or `brew install osxutils'."
;; (call-process (executable-find "trash") nil 0 nil file))
;; ;; regular move to trash directory
;; (setq trash-directory "~/.Trash/emacs"))
(setq backup-directory-alist '((".*" . "~/.emacs.d/mybackup")))
(setq racer-rust-src-path "~/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src")
;; save buffer when lose focus
(add-hook 'focus-out-hook 'save-buffer)
;; save all open buffers when lose focus
(add-hook 'focus-out-hook (lambda () (save-some-buffers t)))
(defun dotspacemacs/user-config ()
"Configuration function for user code.
This function is called at the very end of Spacemacs initialization after layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
;; activate virtualenv in ~/.emacs.d crated by pipenv
;; (pyvenv-workon ".emacs.d-yURiBdRl")
(pyvenv-activate "~/.pyvenv/spacemacs")
(add-hook 'hack-local-variables-hook (lambda () (setq truncate-lines t)))
;; (setq url-proxy-services
;; '(("no_proxy" . "^\\(\\|localhost\\|10.*\\)")
;; ("http" . "")
;; ("https" . "")))
;; Do not write anything past this comment. This is where Emacs will
;; auto-generate custom variable definitions.
(defun dotspacemacs/emacs-custom-settings ()
"Emacs custom settings.
This is an auto-generated function, do not modify its content directly, use
Emacs customize menu instead.
This function is called at the very end of Spacemacs initialization."
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(prettier-js helm-git-grep go-impl go-gen-test go-fill-struct gitignore-templates doom-modeline eldoc-eval shrink-path dotenv-mode zenburn-theme zen-and-art-theme yasnippet-snippets yapfify yaml-mode xterm-color ws-butler winum white-sand-theme which-key web-mode web-beautify volatile-highlights vimrc-mode vi-tilde-fringe uuidgen use-package unfill underwater-theme ujelly-theme twilight-theme twilight-bright-theme twilight-anti-bright-theme toxi-theme toml-mode toc-org tao-theme tangotango-theme tango-plus-theme tango-2-theme tagedit symon sunny-day-theme sublime-themes subatomic256-theme subatomic-theme string-inflection spaceline-all-the-icons spacegray-theme soothe-theme solarized-theme soft-stone-theme soft-morning-theme soft-charcoal-theme smyx-theme smeargle slim-mode shell-pop seti-theme scss-mode sass-mode reverse-theme reveal-in-osx-finder restart-emacs rebecca-theme rainbow-delimiters railscasts-theme racer pyvenv pytest pyenv-mode py-isort purple-haze-theme pug-mode professional-theme planet-theme pippel pipenv pip-requirements phoenix-dark-pink-theme phoenix-dark-mono-theme persp-mode pcre2el pbcopy password-generator paradox overseer osx-trash osx-dictionary orgit organic-green-theme org-projectile org-present org-pomodoro org-mime org-download org-bullets org-brain open-junk-file omtose-phellack-theme oldlace-theme occidental-theme obsidian-theme noctilux-theme neotree naquadah-theme nameless mwim mustang-theme multi-term move-text monokai-theme monochrome-theme molokai-theme moe-theme mmm-mode minimal-theme material-theme markdown-toc majapahit-theme magit-svn magit-gitflow madhat2r-theme macrostep lush-theme lorem-ipsum livid-mode live-py-mode link-hint light-soap-theme launchctl kaolin-themes json-navigator json-mode js2-refactor js-doc jbeans-theme jazz-theme ir-black-theme insert-shebang inkpot-theme indent-guide importmagic impatient-mode hungry-delete hl-todo highlight-parentheses highlight-numbers highlight-indentation heroku-theme hemisu-theme helm-xref helm-themes helm-swoop helm-pydoc helm-purpose helm-projectile helm-mode-manager helm-make helm-gtags helm-gitignore helm-flx helm-descbinds helm-css-scss helm-company helm-c-yasnippet helm-ag hc-zenburn-theme gruvbox-theme gruber-darker-theme grandshell-theme gotham-theme google-translate golden-ratio godoctor go-tag go-rename go-guru go-eldoc gnuplot gitconfig-mode gitattributes-mode git-timemachine git-messenger git-link gh-md ggtags gandalf-theme fuzzy font-lock+ flycheck-bashate flx-ido flatui-theme flatland-theme fish-mode fill-column-indicator farmhouse-theme fancy-battery eziam-theme eyebrowse expand-region exotica-theme exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-org evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-magit evil-lisp-state evil-lion evil-indent-plus evil-iedit-state evil-goggles evil-exchange evil-escape evil-ediff evil-cleverparens evil-args evil-anzu eval-sexp-fu espresso-theme eshell-z eshell-prompt-extras esh-help emmet-mode elisp-slime-nav elfeed-web elfeed-org elfeed-goodies editorconfig dumb-jump dracula-theme doom-themes django-theme diminish darktooth-theme darkokai-theme darkmine-theme darkburn-theme dakrone-theme dactyl-mode cython-mode cyberpunk-theme counsel-projectile company-web company-tern company-statistics company-shell company-go company-anaconda column-enforce-mode color-theme-sanityinc-tomorrow color-theme-sanityinc-solarized clues-theme clean-aindent-mode cherry-blossom-theme centered-cursor-mode cargo busybee-theme bubbleberry-theme birds-of-paradise-plus-theme badwolf-theme auto-yasnippet auto-highlight-symbol auto-compile apropospriate-theme anti-zenburn-theme ample-zen-theme ample-theme alect-themes aggressive-indent afternoon-theme ace-window ace-link ace-jump-helm-line ac-ispell)))
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.