2015-01-27 03:51:47 +00:00
|
|
|
;;; core-dotspacemacs.el --- Spacemacs Core File
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
2014-12-25 20:24:26 +00:00
|
|
|
(defconst dotspacemacs-template-directory
|
|
|
|
(expand-file-name (concat spacemacs-core-directory "templates/"))
|
|
|
|
"Templates directory.")
|
|
|
|
|
2015-09-01 01:52:47 +00:00
|
|
|
(defconst dotspacemacs-test-results-buffer "*dotfile-test-results*"
|
|
|
|
"Name of the buffer to display dotfile test results.")
|
|
|
|
|
2015-05-29 17:08:48 +00:00
|
|
|
(defconst dotspacemacs-directory
|
|
|
|
(let* ((env (getenv "SPACEMACSDIR"))
|
2015-06-05 23:50:03 +00:00
|
|
|
(env-dir (when env (expand-file-name (concat env "/"))))
|
2015-05-29 17:08:48 +00:00
|
|
|
(no-env-dir-default (expand-file-name
|
|
|
|
(concat user-home-directory
|
|
|
|
".spacemacs.d/"))))
|
|
|
|
(cond
|
|
|
|
((and env (file-exists-p env-dir))
|
|
|
|
env-dir)
|
|
|
|
((file-exists-p no-env-dir-default)
|
|
|
|
no-env-dir-default)
|
|
|
|
(t
|
|
|
|
nil)))
|
|
|
|
"Optional spacemacs directory, which defaults to
|
|
|
|
~/.spacemacs.d. This setting can be overridden using the
|
|
|
|
SPACEMACSDIR environment variable. If neither of these
|
|
|
|
directories exist, this variable will be nil.")
|
|
|
|
|
2015-04-30 08:03:06 +00:00
|
|
|
(defconst dotspacemacs-filepath
|
2015-05-29 17:08:48 +00:00
|
|
|
(let* ((default (concat user-home-directory ".spacemacs"))
|
2015-06-05 23:50:03 +00:00
|
|
|
(spacemacs-dir-init (when dotspacemacs-directory
|
2015-05-29 17:08:48 +00:00
|
|
|
(concat dotspacemacs-directory
|
|
|
|
"init.el"))))
|
|
|
|
(if (and (not (file-exists-p default))
|
|
|
|
dotspacemacs-directory
|
|
|
|
(file-exists-p spacemacs-dir-init))
|
|
|
|
spacemacs-dir-init
|
|
|
|
default))
|
|
|
|
"Filepath to the installed dotfile. If ~/.spacemacs exists,
|
|
|
|
then this is used. If ~/.spacemacs does not exist, then check
|
|
|
|
for init.el in dotspacemacs-directory and use this if it
|
|
|
|
exists. Otherwise, fallback to ~/.spacemacs")
|
2015-03-31 02:18:32 +00:00
|
|
|
|
2015-04-06 03:45:02 +00:00
|
|
|
(defvar dotspacemacs-verbose-loading nil
|
|
|
|
"If non nil output loading progess in `*Messages*' buffer.")
|
|
|
|
|
2015-09-08 01:16:15 +00:00
|
|
|
(defvar dotspacemacs-distribution 'spacemacs
|
|
|
|
"Base distribution to use. This is a layer contained in the directory
|
|
|
|
`!distribution'. For now available distributions are `spacemacs-core'
|
|
|
|
or `spacemacs'.")
|
|
|
|
|
2014-11-22 02:19:50 +00:00
|
|
|
(defvar dotspacemacs-configuration-layer-path '()
|
|
|
|
"List of additional paths where to look for configuration layers.
|
2015-02-15 03:15:25 +00:00
|
|
|
Paths must have a trailing slash (ie. `~/.mycontribs/')")
|
2014-11-22 02:19:50 +00:00
|
|
|
|
2015-04-21 04:33:23 +00:00
|
|
|
(defvar dotspacemacs-additional-packages '()
|
|
|
|
"List of additional packages that will be installed wihout being
|
|
|
|
wrapped in a layer. If you need some configuration for these
|
|
|
|
packages then consider to create a layer, you can also put the
|
2015-04-27 16:31:01 +00:00
|
|
|
configuration in `dotspacemacs/config'.")
|
2015-04-21 04:33:23 +00:00
|
|
|
|
2015-03-19 04:29:42 +00:00
|
|
|
(defvar dotspacemacs-editing-style 'vim
|
|
|
|
"Either `vim' or `emacs'. Evil is always enabled but if the variable
|
|
|
|
is `emacs' then the `holy-mode' is enabled at startup.")
|
|
|
|
|
2015-03-13 03:55:38 +00:00
|
|
|
(defvar dotspacemacs-startup-banner 'official
|
|
|
|
"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 a .PNG file.
|
|
|
|
If the value is nil then no banner is displayed.")
|
2014-12-25 20:38:13 +00:00
|
|
|
|
2014-11-22 02:19:50 +00:00
|
|
|
(defvar dotspacemacs-configuration-layers '()
|
2015-02-15 03:15:25 +00:00
|
|
|
"List of configuration layers to load. If it is the symbol `all' instead
|
|
|
|
of a list then all discovered layers will be installed.")
|
2014-11-22 02:19:50 +00:00
|
|
|
|
2015-07-05 03:51:32 +00:00
|
|
|
(defvar dotspacemacs-themes '(spacemacs-dark
|
|
|
|
spacemacs-light
|
2015-01-28 02:45:39 +00:00
|
|
|
solarized-dark
|
2015-07-05 03:51:32 +00:00
|
|
|
solarized-light
|
2015-07-09 05:01:20 +00:00
|
|
|
leuven)
|
2015-01-24 03:02:08 +00:00
|
|
|
"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")
|
2014-11-28 04:14:51 +00:00
|
|
|
|
2015-02-24 05:41:50 +00:00
|
|
|
(defvar dotspacemacs-colorize-cursor-according-to-state t
|
|
|
|
"If non nil the cursor color matches the state color.")
|
|
|
|
|
2014-12-06 22:55:20 +00:00
|
|
|
(defvar dotspacemacs-leader-key "SPC"
|
|
|
|
"The leader key.")
|
|
|
|
|
2015-03-23 23:06:48 +00:00
|
|
|
(defvar dotspacemacs-emacs-leader-key "M-m"
|
2015-03-19 04:29:42 +00:00
|
|
|
"The leader key accessible in `emacs state' and `insert state'")
|
|
|
|
|
2014-12-19 05:35:14 +00:00
|
|
|
(defvar dotspacemacs-major-mode-leader-key ","
|
|
|
|
"Major mode leader key is a shortcut key which is the equivalent of
|
2015-03-08 03:24:42 +00:00
|
|
|
pressing `<leader> m`. Set it to `nil` to disable it.")
|
2014-12-19 05:35:14 +00:00
|
|
|
|
2015-03-23 23:06:48 +00:00
|
|
|
(defvar dotspacemacs-major-mode-emacs-leader-key "C-M-m"
|
2015-03-19 04:29:42 +00:00
|
|
|
"Major mode leader key accessible in `emacs state' and `insert state'")
|
|
|
|
|
2015-01-27 03:40:02 +00:00
|
|
|
(defvar dotspacemacs-default-font '("Source Code Pro"
|
|
|
|
:size 13
|
|
|
|
:weight normal
|
|
|
|
:width normal
|
2015-01-28 02:46:37 +00:00
|
|
|
:powerline-scale 1.1)
|
2015-02-08 01:05:24 +00:00
|
|
|
"Default font. `powerline-scale' allows to quickly tweak the mode-line
|
2015-01-27 03:40:02 +00:00
|
|
|
size to make separators look not too crappy.")
|
|
|
|
|
2014-12-11 03:12:19 +00:00
|
|
|
(defvar dotspacemacs-command-key ":"
|
|
|
|
"The key used for Evil commands (ex-commands) and Emacs commands (M-x).
|
|
|
|
By default the command key is `:' so ex-commands are executed like in Vim
|
|
|
|
with `:' and Emacs commands are executed with `<leader> :'.")
|
|
|
|
|
2015-06-01 01:48:16 +00:00
|
|
|
(defvar dotspacemacs-use-ido nil
|
|
|
|
"If non nil then `ido' replaces `helm' for some commands. For now only
|
|
|
|
`find-files' (SPC f f) is replaced.")
|
|
|
|
|
2015-08-28 06:38:29 +00:00
|
|
|
(defvar dotspacemacs-helm-resize nil
|
|
|
|
"If non nil, `helm' will try to miminimize the space it uses.")
|
|
|
|
|
2015-09-07 00:51:07 +00:00
|
|
|
(defvar dotspacemacs-helm-no-header nil
|
|
|
|
"if non nil, the helm header is hidden when there is only one source.")
|
|
|
|
|
2015-08-28 06:35:40 +00:00
|
|
|
(defvar dotspacemacs-helm-position 'bottom
|
|
|
|
"Position in which to show the `helm' mini-buffer.")
|
|
|
|
|
2015-06-19 03:54:07 +00:00
|
|
|
(defvar dotspacemacs-auto-save-file-location 'cache
|
|
|
|
"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 value is `cache'.")
|
2015-05-04 12:12:39 +00:00
|
|
|
|
2015-03-10 00:57:58 +00:00
|
|
|
(defvar dotspacemacs-enable-paste-micro-state t
|
|
|
|
"If non nil the paste micro-state is enabled. While enabled pressing `p`
|
|
|
|
several times cycle between the kill ring content.'")
|
|
|
|
|
2015-07-25 16:56:06 +00:00
|
|
|
(defvar dotspacemacs-which-key-delay 0.4
|
2015-08-28 16:41:52 +00:00
|
|
|
"Delay in seconds starting from the last keystroke after which
|
|
|
|
the which-key buffer will be shown if you have not completed a
|
|
|
|
key sequence. Setting this variable is equivalent to setting
|
|
|
|
`which-key-idle-delay'.")
|
|
|
|
|
|
|
|
(defvar dotspacemacs-which-key-position 'bottom
|
|
|
|
"Location of the which-key popup buffer. Possible choices are bottom,
|
|
|
|
right, and right-then-bottom. The last one will display on the
|
|
|
|
right if possible and fallback to bottom if not.")
|
2015-07-25 16:56:06 +00:00
|
|
|
|
2015-02-16 02:25:12 +00:00
|
|
|
(defvar dotspacemacs-loading-progress-bar t
|
|
|
|
"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.")
|
|
|
|
|
2015-01-13 04:27:07 +00:00
|
|
|
(defvar dotspacemacs-fullscreen-at-startup nil
|
|
|
|
"If non nil the frame is fullscreen when Emacs starts up (Emacs 24.4+ only).")
|
|
|
|
|
2015-01-12 17:22:17 +00:00
|
|
|
(defvar dotspacemacs-fullscreen-use-non-native nil
|
|
|
|
"If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen. Use
|
|
|
|
to disable fullscreen animations in OSX.")
|
|
|
|
|
2014-12-15 13:19:24 +00:00
|
|
|
(defvar dotspacemacs-maximized-at-startup nil
|
2014-12-16 02:13:01 +00:00
|
|
|
"If non nil the frame is maximized when Emacs starts up (Emacs 24.4+ only).
|
|
|
|
Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil.")
|
2014-11-22 02:19:50 +00:00
|
|
|
|
2014-12-27 18:15:18 +00:00
|
|
|
(defvar 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 active or selected. Transparency
|
|
|
|
can be toggled through `toggle-transparency'.")
|
|
|
|
|
|
|
|
(defvar dotspacemacs-inactive-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'.")
|
|
|
|
|
2014-12-23 21:39:57 +00:00
|
|
|
(defvar dotspacemacs-mode-line-unicode-symbols t
|
|
|
|
"If non nil unicode symbols are displayed in the mode-line (eg. for lighters)")
|
|
|
|
|
2014-11-22 02:19:50 +00:00
|
|
|
(defvar dotspacemacs-smooth-scrolling t
|
|
|
|
"If non nil smooth scrolling (native-scrolling) is enabled. Smooth scrolling
|
|
|
|
overrides the default behavior of Emacs which recenters the point when
|
|
|
|
it reaches the top or bottom of the screen.")
|
|
|
|
|
2014-12-12 22:59:49 +00:00
|
|
|
(defvar dotspacemacs-persistent-server nil
|
|
|
|
"If non nil advises quit functions to keep server open when quitting.")
|
|
|
|
|
2014-12-12 05:08:30 +00:00
|
|
|
(defvar dotspacemacs-smartparens-strict-mode nil
|
|
|
|
"If non-nil smartparens-strict-mode will be enabled in programming modes.")
|
|
|
|
|
2015-04-19 05:04:05 +00:00
|
|
|
(defvar dotspacemacs-highlight-delimiters 'all
|
2015-07-24 00:41:52 +00:00
|
|
|
"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.")
|
2015-04-16 11:15:50 +00:00
|
|
|
|
2015-02-17 18:31:51 +00:00
|
|
|
(defvar dotspacemacs-delete-orphan-packages t
|
2015-02-15 03:03:30 +00:00
|
|
|
"If non-nil spacemacs will delete any orphan packages, i.e. packages that are
|
|
|
|
declared in a layer which is not a member of
|
|
|
|
`dotspacemacs-configuration-layers'")
|
|
|
|
|
2015-04-15 02:23:57 +00:00
|
|
|
(defvar dotspacemacs-search-tools '("ag" "pt" "ack" "grep")
|
|
|
|
"List of search tool executable names. Spacemacs uses the first installed
|
|
|
|
tool of the list. Supported tools are `ag', `pt', `ack' and `grep'.")
|
|
|
|
|
2014-11-22 02:19:50 +00:00
|
|
|
(defvar dotspacemacs-default-package-repository 'melpa-stable
|
|
|
|
"The default package repository used if no explicit repository has been
|
|
|
|
specified with an installed package.
|
2015-02-15 03:15:25 +00:00
|
|
|
NOT USED FOR NOW :-)")
|
2014-11-22 02:19:50 +00:00
|
|
|
|
2015-04-02 04:12:19 +00:00
|
|
|
(defvar dotspacemacs-startup-lists '(recents projects)
|
|
|
|
"List of items to show in the startup buffer. If nil it is disabled.
|
|
|
|
Possible values are: `recents' `bookmarks' `projects'.")
|
2015-03-28 14:30:56 +00:00
|
|
|
|
2014-11-22 02:19:50 +00:00
|
|
|
(defvar dotspacemacs-excluded-packages '()
|
|
|
|
"A list of packages and/or extensions that will not be install and loaded.")
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
;; only for backward compatibility
|
|
|
|
(defalias 'dotspacemacs-mode 'emacs-lisp-mode)
|
2015-03-01 17:49:39 +00:00
|
|
|
|
2015-03-31 03:16:33 +00:00
|
|
|
(defun dotspacemacs/sync-configuration-layers (&optional arg)
|
2015-03-02 05:27:36 +00:00
|
|
|
"Synchronize declared layers in dotfile with spacemacs.
|
|
|
|
|
2015-03-02 06:12:34 +00:00
|
|
|
If ARG is non nil then `dotspacemacs/config' is skipped."
|
2015-03-02 05:27:36 +00:00
|
|
|
(interactive "P")
|
2015-03-31 03:16:33 +00:00
|
|
|
(when (file-exists-p dotspacemacs-filepath)
|
2015-09-01 03:26:47 +00:00
|
|
|
(with-current-buffer (find-file-noselect dotspacemacs-filepath)
|
|
|
|
(let ((dotspacemacs-loading-progress-bar nil))
|
|
|
|
(setq spacemacs-loading-string "")
|
|
|
|
(save-buffer)
|
|
|
|
(let ((tests-ok (dotspacemacs/test-dotfile t)))
|
|
|
|
(if tests-ok
|
|
|
|
(progn
|
|
|
|
(load-file buffer-file-name)
|
|
|
|
(dotspacemacs|call-func dotspacemacs/init
|
|
|
|
"Calling dotfile init...")
|
|
|
|
(configuration-layer/sync)
|
|
|
|
(if arg
|
|
|
|
(message (concat "Done (`dotspacemacs/config'function has "
|
|
|
|
"been skipped)."))
|
2015-09-01 21:05:39 +00:00
|
|
|
;; TODO remove support for dotspacemacs/config in 0.105
|
|
|
|
(if (fboundp 'dotspacemacs/user-config)
|
|
|
|
(dotspacemacs|call-func dotspacemacs/user-config
|
|
|
|
"Calling dotfile user config...")
|
|
|
|
(spacemacs-buffer/warning (concat "`dotspacemacs/config' is deprecated, "
|
|
|
|
"please rename your function to "
|
|
|
|
"`dotspacemacs/user-config'"))
|
|
|
|
(dotspacemacs|call-func dotspacemacs/config
|
|
|
|
"Calling dotfile user config..."))
|
2015-09-01 03:26:47 +00:00
|
|
|
(message "Done."))
|
|
|
|
(when (configuration-layer/package-usedp 'powerline)
|
|
|
|
(spacemacs//restore-powerline (current-buffer))))
|
|
|
|
(switch-to-buffer-other-window dotspacemacs-test-results-buffer)
|
|
|
|
(spacemacs-buffer/warning "Some tests failed, check `%s' buffer"
|
|
|
|
dotspacemacs-test-results-buffer)))))))
|
2015-03-02 04:02:14 +00:00
|
|
|
|
2015-09-01 03:16:14 +00:00
|
|
|
(defun dotspacemacs/get-variable-string-list ()
|
|
|
|
"Return a list of all the dotspacemacs variables as strings."
|
|
|
|
(all-completions "" obarray
|
|
|
|
(lambda (x)
|
|
|
|
(and (boundp x)
|
|
|
|
(not (keywordp x))
|
|
|
|
(string-prefix-p "dotspacemacs"
|
|
|
|
(symbol-name x))))))
|
|
|
|
|
|
|
|
(defun dotspacemacs/get-variable-list ()
|
|
|
|
"Return a list of all dotspacemacs variable symbols."
|
|
|
|
(mapcar 'intern (dotspacemacs/get-variable-string-list)))
|
|
|
|
|
2015-08-14 16:25:54 +00:00
|
|
|
(defmacro dotspacemacs|symbol-value (symbol)
|
|
|
|
"Return the value of SYMBOL corresponding to a dotspacemacs variable.
|
|
|
|
If SYMBOL value is `display-graphic-p' then return the result of
|
|
|
|
`(display-graphic-p)', otherwise return the value of the symbol."
|
|
|
|
`(if (eq 'display-graphic-p ,symbol) (display-graphic-p) ,symbol))
|
|
|
|
|
2014-11-22 02:19:50 +00:00
|
|
|
(defun dotspacemacs/location ()
|
|
|
|
"Return the absolute path to the spacemacs dotfile."
|
2015-04-30 08:03:06 +00:00
|
|
|
dotspacemacs-filepath)
|
2014-11-22 02:19:50 +00:00
|
|
|
|
2015-03-31 02:18:32 +00:00
|
|
|
(defun dotspacemacs/copy-template ()
|
|
|
|
"Copy `.spacemacs.template' in home directory. Ask for confirmation
|
|
|
|
before copying the file if the destination already exists."
|
2014-11-22 03:33:54 +00:00
|
|
|
(interactive)
|
2015-03-31 02:18:32 +00:00
|
|
|
(let* ((copy? (if (file-exists-p dotspacemacs-filepath)
|
|
|
|
(y-or-n-p
|
|
|
|
(format "%s already exists. Do you want to overwite it ? "
|
|
|
|
dotspacemacs-filepath)) t)))
|
|
|
|
(when copy?
|
|
|
|
(copy-file (concat dotspacemacs-template-directory
|
|
|
|
".spacemacs.template") dotspacemacs-filepath t)
|
|
|
|
(message "%s has been installed." dotspacemacs-filepath))))
|
|
|
|
|
|
|
|
(defun dotspacemacs//ido-completing-read (prompt candidates)
|
|
|
|
"Call `ido-completing-read' with a CANDIDATES alist where the key is
|
|
|
|
a display strng and the value is the actual value to return."
|
2015-03-31 03:16:33 +00:00
|
|
|
(let ((ido-max-window-height (1+ (length candidates))))
|
|
|
|
(cadr (assoc (ido-completing-read prompt (mapcar 'car candidates))
|
|
|
|
candidates))))
|
2015-03-31 02:18:32 +00:00
|
|
|
|
|
|
|
(defun dotspacemacs/install (arg)
|
2015-03-31 03:16:33 +00:00
|
|
|
"Install the dotfile, return non nil if the doftile has been installed.
|
2015-03-31 02:18:32 +00:00
|
|
|
|
|
|
|
If ARG is non nil then Ask questions to the user before installing the dotfile."
|
|
|
|
(interactive "P")
|
|
|
|
;; preferences is an alist where the key is the text to replace by
|
|
|
|
;; the value in the dotfile
|
|
|
|
(let ((preferences
|
|
|
|
(when arg
|
|
|
|
;; editing style
|
|
|
|
`(("dotspacemacs-editing-style 'vim"
|
2015-09-01 02:08:10 +00:00
|
|
|
,(format
|
|
|
|
"dotspacemacs-editing-style '%S"
|
|
|
|
(dotspacemacs//ido-completing-read
|
|
|
|
"What is your preferred style? "
|
|
|
|
'(("Among the stars aboard the Evil flagship (vim)"
|
|
|
|
vim)
|
|
|
|
("On the planet Emacs in the Holy control tower (emacs)"
|
|
|
|
emacs)))))))))
|
2015-03-31 02:18:32 +00:00
|
|
|
(with-current-buffer (find-file-noselect
|
|
|
|
(concat dotspacemacs-template-directory
|
|
|
|
".spacemacs.template"))
|
|
|
|
(dolist (p preferences)
|
|
|
|
(beginning-of-buffer)
|
|
|
|
(re-search-forward (car p))
|
|
|
|
(replace-match (cadr p)))
|
|
|
|
(let ((install
|
|
|
|
(if (file-exists-p dotspacemacs-filepath)
|
|
|
|
(y-or-n-p
|
|
|
|
(format "%s already exists. Do you want to overwite it ? "
|
|
|
|
dotspacemacs-filepath)) t)))
|
2015-03-31 03:16:33 +00:00
|
|
|
(when install
|
|
|
|
(write-file dotspacemacs-filepath)
|
|
|
|
(message "%s has been installed." dotspacemacs-filepath)
|
|
|
|
t)))))
|
2015-03-31 02:18:32 +00:00
|
|
|
|
|
|
|
(defun dotspacemacs//install-and-replace (&optional values)
|
|
|
|
"Install the dotfile and replace its content according to VALUES.
|
|
|
|
|
|
|
|
VALUES is an alist where the key is the text to replace and value is the new
|
|
|
|
value."
|
|
|
|
)
|
2014-11-22 03:33:54 +00:00
|
|
|
|
2015-03-01 04:33:57 +00:00
|
|
|
(defun dotspacemacs/load-file ()
|
2015-02-18 00:04:16 +00:00
|
|
|
"Load ~/.spacemacs if it exists."
|
2014-11-22 02:19:50 +00:00
|
|
|
(let ((dotspacemacs (dotspacemacs/location)))
|
|
|
|
(if (file-exists-p dotspacemacs) (load dotspacemacs))))
|
|
|
|
|
2015-02-11 22:00:22 +00:00
|
|
|
(defmacro dotspacemacs|call-func (func &optional msg)
|
|
|
|
"Call the function from the dotfile only if it is bound.
|
|
|
|
If MSG is not nil then display a message in `*Messages'."
|
|
|
|
`(progn
|
2015-04-12 04:24:03 +00:00
|
|
|
(when ,msg (spacemacs-buffer/message ,msg))
|
2015-02-11 22:00:22 +00:00
|
|
|
(if (fboundp ',func) (,func))))
|
2014-11-22 02:19:50 +00:00
|
|
|
|
2015-06-26 16:27:40 +00:00
|
|
|
(defun dotspacemacs//test-dotspacemacs/layers ()
|
|
|
|
"Tests for `dotspacemacs/layers'"
|
2015-06-30 02:53:51 +00:00
|
|
|
(insert
|
2015-09-01 02:08:10 +00:00
|
|
|
(format (concat "\n* Testing settings in dotspacemacs/layers "
|
|
|
|
"[[file:%s::dotspacemacs/layers][Show in File]]\n")
|
2015-06-30 02:53:51 +00:00
|
|
|
dotspacemacs-filepath))
|
2015-06-26 16:27:40 +00:00
|
|
|
;; protect global values of these variables
|
|
|
|
(let (dotspacemacs-configuration-layer-path dotspacemacs-configuration-layers
|
|
|
|
dotspacemacs-additional-packages dotspacemacs-excluded-packages
|
|
|
|
dotspacemacs-delete-orphan-packages
|
|
|
|
(passed-tests 0) (total-tests 0))
|
|
|
|
(load dotspacemacs-filepath)
|
|
|
|
(dotspacemacs/layers)
|
|
|
|
(spacemacs//test-list
|
2015-09-01 02:08:10 +00:00
|
|
|
'stringp 'dotspacemacs-configuration-layer-path
|
|
|
|
"is a string" "path")
|
2015-06-26 16:27:40 +00:00
|
|
|
(spacemacs//test-list
|
2015-09-01 02:08:10 +00:00
|
|
|
'file-directory-p 'dotspacemacs-configuration-layer-path
|
|
|
|
"exists in filesystem" "path")
|
2015-06-26 16:27:40 +00:00
|
|
|
(setq dotspacemacs-configuration-layers
|
2015-09-01 02:08:10 +00:00
|
|
|
(mapcar (lambda (l) (if (listp l) (car l) l))
|
|
|
|
dotspacemacs-configuration-layers))
|
2015-06-26 16:27:40 +00:00
|
|
|
(spacemacs//test-list
|
2015-06-30 02:53:51 +00:00
|
|
|
'configuration-layer/get-layer-path
|
|
|
|
'dotspacemacs-configuration-layers "can be found" "layer")
|
|
|
|
(insert (format
|
2015-09-01 02:08:10 +00:00
|
|
|
(concat "** RESULTS: "
|
|
|
|
"[[file:%s::dotspacemacs/layers][dotspacemacs/layers]] "
|
|
|
|
"passed %s out of %s tests\n")
|
2015-09-01 01:52:47 +00:00
|
|
|
dotspacemacs-filepath passed-tests total-tests))
|
|
|
|
(equal passed-tests total-tests)))
|
2015-06-26 16:27:40 +00:00
|
|
|
|
2015-09-01 03:16:14 +00:00
|
|
|
(defmacro dotspacemacs||let-init-test (&rest body)
|
|
|
|
"Macro to protect dotspacemacs variables"
|
|
|
|
`(let ((fpath dotspacemacs-filepath)
|
|
|
|
,@(dotspacemacs/get-variable-list)
|
|
|
|
(passed-tests 0) (total-tests 0))
|
|
|
|
(setq dotspacemacs-filepath fpath)
|
|
|
|
(load dotspacemacs-filepath)
|
|
|
|
,@body))
|
|
|
|
|
2015-06-26 16:27:40 +00:00
|
|
|
(defun dotspacemacs//test-dotspacemacs/init ()
|
|
|
|
"Tests for `dotspacemacs/init'"
|
2015-06-30 02:53:51 +00:00
|
|
|
(insert
|
2015-09-01 02:08:10 +00:00
|
|
|
(format (concat "\n* Testing settings in dotspacemacs/init "
|
|
|
|
"[[file:%s::dotspacemacs/init][Show in File]]\n")
|
2015-06-30 02:53:51 +00:00
|
|
|
dotspacemacs-filepath))
|
2015-09-01 03:16:14 +00:00
|
|
|
(dotspacemacs||let-init-test
|
|
|
|
(dotspacemacs/init)
|
|
|
|
(spacemacs//test-var
|
2015-09-01 03:35:28 +00:00
|
|
|
(lambda (x) (member x '(vim emacs hybrid)))
|
|
|
|
'dotspacemacs-editing-style "is \'vim, \'emacs or \'hybrid")
|
2015-09-01 03:16:14 +00:00
|
|
|
(spacemacs//test-var
|
|
|
|
(lambda (x) (member x '(original cache nil)))
|
|
|
|
'dotspacemacs-auto-save-file-location (concat "is one of \'original, "
|
|
|
|
"\'cache or nil"))
|
|
|
|
(spacemacs//test-var
|
|
|
|
(lambda (x) (member x '(all current nil)))
|
|
|
|
'dotspacemacs-highlight-delimiters "is one of \'all, \'current or nil")
|
|
|
|
(spacemacs//test-list
|
|
|
|
(lambda (x) (member x '(recents bookmarks projects)))
|
|
|
|
'dotspacemacs-startup-lists (concat "includes only \'recents, "
|
|
|
|
"\'bookmarks or \'projects"))
|
|
|
|
(spacemacs//test-var 'stringp 'dotspacemacs-leader-key "is a string")
|
|
|
|
(spacemacs//test-var 'stringp 'dotspacemacs-emacs-leader-key "is a string")
|
|
|
|
(spacemacs//test-var
|
|
|
|
'stringp 'dotspacemacs-major-mode-leader-key "is a string")
|
|
|
|
(spacemacs//test-var 'stringp 'dotspacemacs-command-key "is a string")
|
|
|
|
(insert (format
|
|
|
|
(concat "** RESULTS: "
|
|
|
|
"[[file:%s::dotspacemacs/init][dotspacemacs/init]] "
|
|
|
|
"passed %s out of %s tests\n")
|
|
|
|
dotspacemacs-filepath passed-tests total-tests))
|
|
|
|
(equal passed-tests total-tests)))
|
2015-06-26 16:27:40 +00:00
|
|
|
|
2015-09-01 01:52:47 +00:00
|
|
|
(defun dotspacemacs/test-dotfile (&optional hide-buffer)
|
|
|
|
"Test settings in dotfile for correctness.
|
|
|
|
Return non-nil if all the tests passed."
|
2015-06-26 16:27:40 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((min-version "0.0"))
|
|
|
|
;; dotspacemacs-version not implemented yet
|
|
|
|
;; (if (version< dotspacemacs-version min-version)
|
|
|
|
(if nil
|
2015-09-01 02:08:10 +00:00
|
|
|
(error (format (concat "error: dotspacemacs/test-dotfile requires "
|
|
|
|
"dotspacemacs-version %s") min-version))
|
2015-09-01 01:52:47 +00:00
|
|
|
(with-current-buffer (get-buffer-create dotspacemacs-test-results-buffer)
|
|
|
|
(unless hide-buffer
|
|
|
|
(switch-to-buffer-other-window dotspacemacs-test-results-buffer))
|
2015-06-30 02:53:51 +00:00
|
|
|
(org-mode)
|
2015-09-01 02:13:56 +00:00
|
|
|
(org-indent-mode)
|
|
|
|
(view-mode)
|
|
|
|
(when (bound-and-true-p flyspell-mode)
|
|
|
|
(flyspell-mode -1))
|
|
|
|
(let (buffer-read-only)
|
|
|
|
(erase-buffer)
|
|
|
|
(insert (format "* Running tests on [[file:%s][%s]] (v%s)\n"
|
|
|
|
dotspacemacs-filepath dotspacemacs-filepath "0.0"))
|
|
|
|
;; dotspacemacs-version not implemented yet
|
|
|
|
;; (insert (format "* Running tests on %s (v%s)\n" dotspacemacs-filepath dotspacemacs-version))
|
|
|
|
(prog1
|
2015-09-01 03:27:18 +00:00
|
|
|
;; execute all tests no matter what
|
|
|
|
(reduce (lambda (x y)
|
|
|
|
(and (funcall y) x))
|
|
|
|
'(dotspacemacs//test-dotspacemacs/layers
|
|
|
|
dotspacemacs//test-dotspacemacs/init)
|
|
|
|
:initial-value t)
|
2015-09-01 02:13:56 +00:00
|
|
|
(goto-char (point-min))))))))
|
2015-06-26 16:27:40 +00:00
|
|
|
|
2015-01-27 03:51:47 +00:00
|
|
|
(provide 'core-dotspacemacs)
|