2015-03-02 03:12:09 +00:00
|
|
|
;;; core-spacemacs.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-09-24 00:47:20 +00:00
|
|
|
(setq message-log-max 16384)
|
|
|
|
(defconst emacs-start-time (current-time))
|
|
|
|
|
2015-01-03 03:21:35 +00:00
|
|
|
(require 'subr-x nil 'noerror)
|
2015-11-28 05:13:31 +00:00
|
|
|
(require 'core-configuration-layer)
|
2015-11-18 18:49:41 +00:00
|
|
|
(require 'core-dotspacemacs)
|
2015-01-27 03:51:47 +00:00
|
|
|
(require 'core-emacs-backports)
|
2015-06-07 03:26:14 +00:00
|
|
|
(require 'core-release-management)
|
2015-04-11 19:10:21 +00:00
|
|
|
(require 'core-auto-completion)
|
2015-01-27 03:51:47 +00:00
|
|
|
(require 'core-themes-support)
|
|
|
|
(require 'core-fonts-support)
|
|
|
|
(require 'core-spacemacs-buffer)
|
2015-11-28 05:13:31 +00:00
|
|
|
(require 'core-keybindings)
|
2015-03-01 04:33:57 +00:00
|
|
|
(require 'core-toggle)
|
|
|
|
(require 'core-micro-state)
|
2015-05-20 03:39:03 +00:00
|
|
|
(require 'core-use-package-ext)
|
2015-01-02 05:50:21 +00:00
|
|
|
|
2015-01-08 05:34:23 +00:00
|
|
|
(defgroup spacemacs nil
|
|
|
|
"Spacemacs customizations."
|
|
|
|
:group 'starter-kit
|
|
|
|
:prefix 'spacemacs-)
|
|
|
|
|
2015-01-05 05:20:38 +00:00
|
|
|
;; loading progress bar variables
|
2015-03-12 03:46:37 +00:00
|
|
|
(defvar spacemacs-loading-char ?█)
|
|
|
|
(defvar spacemacs-loading-string "")
|
2014-11-17 03:39:03 +00:00
|
|
|
(defvar spacemacs-loading-counter 0)
|
2015-03-12 03:46:37 +00:00
|
|
|
;; (defvar spacemacs-loading-text "Loading")
|
|
|
|
;; (defvar spacemacs-loading-done-text "Ready!")
|
2014-11-17 03:39:03 +00:00
|
|
|
(defvar spacemacs-loading-dots-chunk-count 3)
|
2015-03-12 03:46:37 +00:00
|
|
|
(defvar spacemacs-loading-dots-count (window-total-size nil 'width))
|
2014-11-17 03:39:03 +00:00
|
|
|
(defvar spacemacs-loading-dots-chunk-size
|
|
|
|
(/ spacemacs-loading-dots-count spacemacs-loading-dots-chunk-count))
|
|
|
|
(defvar spacemacs-loading-dots-chunk-threshold 0)
|
|
|
|
|
2015-06-23 04:00:51 +00:00
|
|
|
(defvar spacemacs-mode-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2015-11-29 04:08:30 +00:00
|
|
|
(define-key map (kbd "<tab>") 'widget-forward)
|
|
|
|
(define-key map (kbd "<return>") 'widget-button-press)
|
|
|
|
(define-key map [backtab] 'widget-backward)
|
|
|
|
(define-key map [down-mouse-1] 'widget-button-click)
|
2015-06-23 04:00:51 +00:00
|
|
|
map)
|
|
|
|
"Keymap for spacemacs mode.")
|
|
|
|
|
2015-09-12 03:04:01 +00:00
|
|
|
(defvar spacemacs--default-mode-line mode-line-format
|
|
|
|
"Backup of default mode line format.")
|
|
|
|
|
2015-01-28 03:06:59 +00:00
|
|
|
(define-derived-mode spacemacs-mode special-mode "Spacemacs"
|
2015-06-23 04:00:51 +00:00
|
|
|
"Spacemacs major mode for startup screen.
|
|
|
|
|
|
|
|
\\<spacemacs-mode-map>
|
|
|
|
"
|
2015-03-01 17:49:39 +00:00
|
|
|
:group 'spacemacs
|
2014-09-10 03:12:31 +00:00
|
|
|
:syntax-table nil
|
|
|
|
:abbrev-table nil
|
|
|
|
(setq truncate-lines t)
|
2015-02-16 01:13:43 +00:00
|
|
|
;; motion state since this is a special mode
|
|
|
|
(add-to-list 'evil-motion-state-modes 'spacemacs-mode))
|
|
|
|
|
2015-03-01 04:33:57 +00:00
|
|
|
(defun spacemacs/init ()
|
2015-02-16 01:13:43 +00:00
|
|
|
"Create the special buffer for `spacemacs-mode' and perform startup
|
|
|
|
initialization."
|
2015-04-13 01:27:07 +00:00
|
|
|
;; explicitly set the prefered coding systems to avoid annoying prompt
|
|
|
|
;; from emacs (especially on Microsoft Windows)
|
|
|
|
(prefer-coding-system 'utf-8)
|
2015-11-18 18:49:41 +00:00
|
|
|
;; TODO move evil-want-C-u-scroll when evil is removed from the bootstrapped
|
|
|
|
;; packages.
|
2015-08-27 01:33:25 +00:00
|
|
|
(setq-default evil-want-C-u-scroll t)
|
2015-11-18 18:49:41 +00:00
|
|
|
(dotspacemacs/load-file)
|
2015-03-02 03:12:09 +00:00
|
|
|
(dotspacemacs|call-func dotspacemacs/init "Calling dotfile init...")
|
2015-06-26 16:27:40 +00:00
|
|
|
(dotspacemacs|call-func dotspacemacs/user-init "Calling dotfile user init...")
|
2015-03-02 03:12:09 +00:00
|
|
|
;; spacemacs init
|
2015-02-16 01:13:43 +00:00
|
|
|
(switch-to-buffer (get-buffer-create spacemacs-buffer-name))
|
2015-10-04 09:01:34 +00:00
|
|
|
(setq initial-buffer-choice (lambda () (get-buffer spacemacs-buffer-name)))
|
2015-04-12 04:24:03 +00:00
|
|
|
(spacemacs-buffer/set-mode-line "")
|
2014-10-24 03:11:18 +00:00
|
|
|
;; no welcome buffer
|
2014-11-04 03:37:25 +00:00
|
|
|
(setq inhibit-startup-screen t)
|
2015-09-30 01:10:59 +00:00
|
|
|
;; silence ad-handle-definition about advised functions getting redefined
|
|
|
|
(setq ad-redefinition-action 'accept)
|
2015-03-13 04:29:30 +00:00
|
|
|
;; removes the GUI elements
|
2015-03-18 04:09:24 +00:00
|
|
|
(when (and (fboundp 'tool-bar-mode) (not (eq tool-bar-mode -1)))
|
2015-03-13 04:29:30 +00:00
|
|
|
(tool-bar-mode -1))
|
2015-03-18 04:09:24 +00:00
|
|
|
(when (and (fboundp 'scroll-bar-mode) (not (eq scroll-bar-mode -1)))
|
2015-03-13 04:29:30 +00:00
|
|
|
(scroll-bar-mode -1))
|
|
|
|
;; tooltips in echo-aera
|
2015-03-18 04:09:24 +00:00
|
|
|
(when (and (fboundp 'tooltip-mode) (not (eq tooltip-mode -1)))
|
2015-03-13 04:29:30 +00:00
|
|
|
(tooltip-mode -1))
|
2015-03-17 03:39:19 +00:00
|
|
|
(unless (eq window-system 'mac)
|
2015-03-18 04:09:24 +00:00
|
|
|
(when (and (fboundp 'menu-bar-mode) (not (eq menu-bar-mode -1)))
|
2015-03-17 03:39:19 +00:00
|
|
|
(menu-bar-mode -1)))
|
2015-01-07 05:04:47 +00:00
|
|
|
;; for convenience and user support
|
2015-03-18 04:09:24 +00:00
|
|
|
(unless (fboundp 'tool-bar-mode)
|
2015-04-12 04:24:03 +00:00
|
|
|
(spacemacs-buffer/message (concat "No graphical support detected, you won't be"
|
2015-08-15 19:25:30 +00:00
|
|
|
"able to launch a graphical instance of Emacs"
|
|
|
|
"with this build.")))
|
2015-12-03 04:49:00 +00:00
|
|
|
;; initialize the configuration layer system
|
|
|
|
(require 'core-configuration-layer)
|
|
|
|
(configuration-layer/initialize)
|
|
|
|
;; default theme
|
|
|
|
(let ((default-theme (car dotspacemacs-themes)))
|
|
|
|
(spacemacs/load-theme default-theme)
|
|
|
|
;; protect used themes from deletion as orphans
|
|
|
|
(setq configuration-layer--protected-packages
|
|
|
|
(append
|
|
|
|
(delq nil (mapcar 'spacemacs//get-theme-package
|
|
|
|
dotspacemacs-themes))
|
|
|
|
configuration-layer--protected-packages))
|
|
|
|
(setq-default spacemacs--cur-theme default-theme)
|
|
|
|
(setq-default spacemacs--cycle-themes (cdr dotspacemacs-themes)))
|
2014-11-28 05:07:29 +00:00
|
|
|
;; font
|
2015-01-30 02:19:37 +00:00
|
|
|
(if (find-font (font-spec :name (car dotspacemacs-default-font)))
|
|
|
|
(spacemacs/set-default-font dotspacemacs-default-font)
|
2015-04-12 16:25:53 +00:00
|
|
|
(spacemacs-buffer/warning "Cannot find font \"%s\"!"
|
|
|
|
(car dotspacemacs-default-font)))
|
2014-12-12 16:53:19 +00:00
|
|
|
;; banner
|
2015-04-12 04:24:03 +00:00
|
|
|
(spacemacs-buffer/insert-banner-and-buttons)
|
2015-07-24 04:08:43 +00:00
|
|
|
;; mandatory dependencies
|
2015-02-06 04:20:14 +00:00
|
|
|
;; dash is required to prevent a package.el bug with f on 24.3.1
|
2015-11-04 13:21:36 +00:00
|
|
|
(spacemacs/load-or-install-protected-package 'dash t)
|
|
|
|
(spacemacs/load-or-install-protected-package 's t)
|
2015-12-03 04:25:00 +00:00
|
|
|
(spacemacs/load-or-install-protected-package 'bind-map t)
|
2014-12-18 00:02:34 +00:00
|
|
|
;; bind-key is required by use-package
|
2015-11-04 13:21:36 +00:00
|
|
|
(spacemacs/load-or-install-protected-package 'bind-key t)
|
|
|
|
(spacemacs/load-or-install-protected-package 'use-package t)
|
2015-10-07 19:29:20 +00:00
|
|
|
(setq use-package-verbose init-file-debug)
|
2015-08-05 01:06:12 +00:00
|
|
|
;; package-build is required by quelpa
|
2015-11-04 13:21:36 +00:00
|
|
|
(spacemacs/load-or-install-protected-package 'package-build t)
|
2015-10-07 19:29:20 +00:00
|
|
|
(setq quelpa-verbose init-file-debug
|
2015-08-05 01:06:12 +00:00
|
|
|
quelpa-dir (concat spacemacs-cache-directory "quelpa/")
|
|
|
|
quelpa-build-dir (expand-file-name "build" quelpa-dir)
|
|
|
|
quelpa-persistent-cache-file (expand-file-name "cache" quelpa-dir)
|
|
|
|
quelpa-update-melpa-p nil)
|
2015-11-04 13:21:36 +00:00
|
|
|
(spacemacs/load-or-install-protected-package 'quelpa t)
|
2015-05-20 03:39:03 +00:00
|
|
|
;; inject use-package hooks for easy customization of
|
|
|
|
;; stock package configuration
|
2015-05-21 02:39:14 +00:00
|
|
|
(setq use-package-inject-hooks t)
|
2015-07-24 04:08:43 +00:00
|
|
|
;; which-key
|
2015-11-04 13:21:36 +00:00
|
|
|
(spacemacs/load-or-install-protected-package 'which-key t)
|
2015-11-18 00:35:32 +00:00
|
|
|
;; evil must be installed at the beginning of the
|
2015-04-08 03:50:22 +00:00
|
|
|
;; boot sequence.
|
|
|
|
;; Use C-u as scroll-up (must be set before actually loading evil)
|
2015-11-04 13:21:36 +00:00
|
|
|
(spacemacs/load-or-install-protected-package 'evil t)
|
2015-11-18 00:35:32 +00:00
|
|
|
(require 'core-keybindings)
|
2015-01-08 05:34:23 +00:00
|
|
|
;; check for new version
|
|
|
|
(if dotspacemacs-mode-line-unicode-symbols
|
2015-01-09 05:22:17 +00:00
|
|
|
(setq-default spacemacs-version-check-lighter "[⇪]"))
|
2015-01-08 05:34:23 +00:00
|
|
|
(spacemacs/set-new-version-lighter-mode-line-faces)
|
2015-07-28 14:01:30 +00:00
|
|
|
(add-hook 'emacs-startup-hook 'spacemacs-buffer/goto-link-line)
|
2015-02-16 01:13:43 +00:00
|
|
|
(spacemacs-mode))
|
2014-12-14 18:53:06 +00:00
|
|
|
|
2015-03-31 03:16:33 +00:00
|
|
|
(defun spacemacs/maybe-install-dotfile ()
|
|
|
|
"Install the dotfile if it does not exist."
|
|
|
|
(unless (file-exists-p dotspacemacs-filepath)
|
2015-04-12 04:24:03 +00:00
|
|
|
(spacemacs-buffer/set-mode-line "Dotfile wizard installer")
|
2015-03-31 03:16:33 +00:00
|
|
|
(spacemacs//redisplay)
|
|
|
|
(when (dotspacemacs/install 'with-wizard)
|
2015-09-12 03:04:55 +00:00
|
|
|
(dotspacemacs/sync-configuration-layers '(16)))))
|
2015-03-31 03:16:33 +00:00
|
|
|
|
2015-01-01 04:53:38 +00:00
|
|
|
(defun spacemacs/display-and-copy-version ()
|
|
|
|
"Echo the current spacemacs version and copy it."
|
|
|
|
(interactive)
|
|
|
|
(let ((msg (format "Spacemacs v.%s" spacemacs-version)))
|
|
|
|
(message msg) (kill-new msg)))
|
|
|
|
|
2014-09-30 02:43:25 +00:00
|
|
|
(defun display-startup-echo-area-message ()
|
|
|
|
"Change the default welcome message of minibuffer to another one."
|
|
|
|
(message "Spacemacs is ready."))
|
|
|
|
|
2015-07-28 14:01:30 +00:00
|
|
|
(defun spacemacs/setup-startup-hook ()
|
2015-03-02 03:12:09 +00:00
|
|
|
"Add post init processing."
|
|
|
|
(add-hook
|
2015-07-28 14:01:30 +00:00
|
|
|
'emacs-startup-hook
|
2015-03-02 03:12:09 +00:00
|
|
|
(lambda ()
|
|
|
|
;; Ultimate configuration decisions are given to the user who can defined
|
|
|
|
;; them in his/her ~/.spacemacs file
|
2015-09-01 02:02:43 +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-03-02 03:12:09 +00:00
|
|
|
;; from jwiegley
|
|
|
|
;; https://github.com/jwiegley/dot-emacs/blob/master/init.el
|
|
|
|
(let ((elapsed (float-time
|
|
|
|
(time-subtract (current-time) emacs-start-time))))
|
2015-04-12 04:24:03 +00:00
|
|
|
(spacemacs-buffer/append
|
2015-04-13 06:17:48 +00:00
|
|
|
(format "\n[%s packages loaded in %.3fs]\n"
|
2015-08-09 02:57:12 +00:00
|
|
|
(configuration-layer/configured-packages-count)
|
2015-03-02 03:12:09 +00:00
|
|
|
elapsed)))
|
2015-04-02 04:32:38 +00:00
|
|
|
;; Display useful lists of items
|
|
|
|
(when dotspacemacs-startup-lists
|
2015-04-12 04:24:03 +00:00
|
|
|
(spacemacs-buffer/insert-startupify-lists))
|
2015-09-12 03:04:01 +00:00
|
|
|
(if configuration-layer-error-count
|
|
|
|
(spacemacs-buffer/set-mode-line
|
|
|
|
(format (concat "%s error(s) at startup! "
|
|
|
|
"Spacemacs may not be able to operate properly.")
|
|
|
|
configuration-layer-error-count))
|
|
|
|
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line))
|
|
|
|
(force-mode-line-update)
|
2015-12-02 00:25:37 +00:00
|
|
|
(spacemacs/check-for-new-version spacemacs-version-check-interval))))
|
2015-03-02 03:12:09 +00:00
|
|
|
|
2015-08-01 04:49:13 +00:00
|
|
|
(defun spacemacs/describe-system-info ()
|
2015-06-25 04:59:13 +00:00
|
|
|
"Gathers info about your Spacemacs setup and copies to clipboard."
|
|
|
|
(interactive)
|
2015-08-01 04:49:13 +00:00
|
|
|
(let ((sysinfo (format
|
|
|
|
(concat "#### System Info\n"
|
|
|
|
"- OS: %s\n"
|
|
|
|
"- Emacs: %s\n"
|
|
|
|
"- Spacemacs: %s\n"
|
2015-08-20 04:26:26 +00:00
|
|
|
"- Spacemacs branch: %s (rev. %s)\n"
|
2015-09-12 09:02:50 +00:00
|
|
|
"- Distribution: %s\n"
|
2015-08-01 04:49:13 +00:00
|
|
|
"- Layers:\n```elisp\n%s```\n")
|
|
|
|
system-type
|
|
|
|
emacs-version
|
|
|
|
spacemacs-version
|
|
|
|
(spacemacs/git-get-current-branch)
|
2015-08-20 04:26:26 +00:00
|
|
|
(spacemacs/git-get-current-branch-rev)
|
2015-09-12 09:02:50 +00:00
|
|
|
dotspacemacs-distribution
|
2015-08-01 04:49:13 +00:00
|
|
|
(pp dotspacemacs-configuration-layers))))
|
|
|
|
(kill-new sysinfo)
|
2015-08-01 19:34:07 +00:00
|
|
|
(message sysinfo)
|
|
|
|
(message (concat "Information has been copied to clipboard.\n"
|
|
|
|
"You can paste it in the gitter chat.\n"
|
|
|
|
"Check the *Messages* buffer if you need to review it"))))
|
2015-06-25 04:59:13 +00:00
|
|
|
|
2015-03-02 03:12:09 +00:00
|
|
|
(provide 'core-spacemacs)
|