2015-03-02 03:12:09 +00:00
|
|
|
;;; core-spacemacs.el --- Spacemacs Core File
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
2020-09-16 21:34:40 +00:00
|
|
|
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; 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)
|
|
|
|
|
2015-01-03 03:21:35 +00:00
|
|
|
(require 'subr-x nil 'noerror)
|
2018-01-13 03:37:04 +00:00
|
|
|
(require 'core-emacs-backports)
|
2018-06-25 06:16:27 +00:00
|
|
|
(require 'core-env)
|
2016-06-05 04:04:53 +00:00
|
|
|
(require 'page-break-lines)
|
2018-06-11 05:30:18 +00:00
|
|
|
(require 'core-hooks)
|
2016-01-07 03:50:13 +00:00
|
|
|
(require 'core-debug)
|
2016-06-10 03:09:59 +00:00
|
|
|
(require 'core-command-line)
|
2017-10-29 04:28:22 +00:00
|
|
|
(require 'core-configuration-layer)
|
2015-11-18 18:49:41 +00:00
|
|
|
(require 'core-dotspacemacs)
|
2016-11-23 03:49:23 +00:00
|
|
|
(require 'core-custom-settings)
|
2015-06-07 03:26:14 +00:00
|
|
|
(require 'core-release-management)
|
2016-08-13 13:43:37 +00:00
|
|
|
(require 'core-jump)
|
2015-08-14 04:50:53 +00:00
|
|
|
(require 'core-display-init)
|
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)
|
2015-12-11 08:07:15 +00:00
|
|
|
(require 'core-funcs)
|
2015-03-01 04:33:57 +00:00
|
|
|
(require 'core-micro-state)
|
2016-01-21 03:29:15 +00:00
|
|
|
(require 'core-transient-state)
|
2015-05-20 03:39:03 +00:00
|
|
|
(require 'core-use-package-ext)
|
2019-11-29 09:55:03 +00:00
|
|
|
(require 'core-spacebind)
|
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-)
|
|
|
|
|
2016-01-21 13:18:33 +00:00
|
|
|
(defvar spacemacs-post-user-config-hook nil
|
|
|
|
"Hook run after dotspacemacs/user-config")
|
|
|
|
(defvar spacemacs-post-user-config-hook-run nil
|
|
|
|
"Whether `spacemacs-post-user-config-hook' has been run")
|
2020-09-21 07:30:49 +00:00
|
|
|
(defvar spacemacs-scratch-mode-hook nil
|
|
|
|
"Hook run on buffer *scratch* after `dotspacemacs-scratch-mode' is invoked.")
|
2016-01-21 13:18:33 +00:00
|
|
|
|
2015-09-12 03:04:01 +00:00
|
|
|
(defvar spacemacs--default-mode-line mode-line-format
|
|
|
|
"Backup of default mode line format.")
|
2016-03-13 01:37:15 +00:00
|
|
|
(defvar spacemacs-initialized nil
|
|
|
|
"Whether or not spacemacs has finished initializing by completing
|
|
|
|
the final step of executing code in `emacs-startup-hook'.")
|
2015-09-12 03:04:01 +00:00
|
|
|
|
2015-03-01 04:33:57 +00:00
|
|
|
(defun spacemacs/init ()
|
2015-10-16 13:17:03 +00:00
|
|
|
"Perform startup initialization."
|
2020-08-30 01:31:58 +00:00
|
|
|
(setq command-line-args (spacemacs//parse-command-line command-line-args))
|
2016-01-07 03:50:13 +00:00
|
|
|
(when spacemacs-debugp (spacemacs/init-debug))
|
2015-12-13 20:32:29 +00:00
|
|
|
;; silence ad-handle-definition about advised functions getting redefined
|
|
|
|
(setq ad-redefinition-action 'accept)
|
2015-12-11 08:07:15 +00:00
|
|
|
;; this is for a smoother UX at startup (i.e. less graphical glitches)
|
|
|
|
(hidden-mode-line-mode)
|
2015-12-13 20:40:48 +00:00
|
|
|
(spacemacs//removes-gui-elements)
|
2017-01-24 04:40:26 +00:00
|
|
|
(spacemacs//setup-ido-vertical-mode)
|
2018-08-01 18:51:57 +00:00
|
|
|
;; explicitly set the preferred coding systems to avoid annoying prompt
|
2015-04-13 01:27:07 +00:00
|
|
|
;; from emacs (especially on Microsoft Windows)
|
|
|
|
(prefer-coding-system 'utf-8)
|
2016-01-09 17:25:02 +00:00
|
|
|
;; TODO move these variables when evil is removed from the bootstrapped
|
2015-11-18 18:49:41 +00:00
|
|
|
;; packages.
|
2016-01-09 17:25:02 +00:00
|
|
|
(setq-default evil-want-C-u-scroll t
|
|
|
|
;; `evil-want-C-i-jump' is set to nil to avoid `TAB' being
|
|
|
|
;; overlapped in terminal mode. The GUI specific `<C-i>' is used
|
2016-02-15 19:15:29 +00:00
|
|
|
;; instead.
|
2016-01-09 17:25:02 +00:00
|
|
|
evil-want-C-i-jump nil)
|
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...")
|
2019-05-24 15:13:49 +00:00
|
|
|
(when dotspacemacs-undecorated-at-startup
|
|
|
|
;; this should be called before toggle-frame-maximized
|
|
|
|
(set-frame-parameter nil 'undecorated t)
|
|
|
|
(add-to-list 'default-frame-alist '(undecorated . t)))
|
2016-10-20 12:06:25 +00:00
|
|
|
(when dotspacemacs-maximized-at-startup
|
2016-11-15 21:12:12 +00:00
|
|
|
(unless (frame-parameter nil 'fullscreen)
|
|
|
|
(toggle-frame-maximized))
|
2016-10-20 12:06:25 +00:00
|
|
|
(add-to-list 'default-frame-alist '(fullscreen . maximized)))
|
2018-03-31 04:31:52 +00:00
|
|
|
(spacemacs|unless-dumping
|
|
|
|
(dotspacemacs|call-func dotspacemacs/user-init "Calling dotfile user init..."))
|
2016-12-18 16:50:50 +00:00
|
|
|
;; Given the loading process of Spacemacs we have no choice but to set the
|
|
|
|
;; custom settings twice:
|
|
|
|
;; - once at the very beginning of startup (here)
|
|
|
|
;; - once at the very end of loading (in `spacemacs/setup-startup-hook')
|
|
|
|
;; The first application of custom settings is to be sure that Emacs knows all
|
|
|
|
;; the defined settings before saving them to a file (otherwise we loose all
|
|
|
|
;; the settings that Emacs does not know of).
|
|
|
|
;; The second application is to override any setting set in dotfile functions
|
|
|
|
;; like `dotspacemacs/user-config`, users expect the custom settings to be the
|
|
|
|
;; effective ones.
|
|
|
|
;; Note: Loading custom-settings twice is not ideal since they can have side
|
2018-08-01 18:51:57 +00:00
|
|
|
;; effects! Maybe an inhibit variable in Emacs can suppress these side effects?
|
2017-02-20 03:51:58 +00:00
|
|
|
(spacemacs/initialize-custom-file)
|
2017-10-29 14:39:48 +00:00
|
|
|
;; Commenting the first load although it is mentioned above that we must do it
|
|
|
|
;; I don't recall why we must load the custom settings twice and my experiment
|
|
|
|
;; seems to show that we don't need this double loading process anymore.
|
|
|
|
;; related issue: https://github.com/syl20bnr/spacemacs/issues/9736
|
|
|
|
;; (dotspacemacs|call-func dotspacemacs/emacs-custom-settings
|
|
|
|
;; "Calling dotfile Emacs custom settings...")
|
2016-03-17 02:43:50 +00:00
|
|
|
(setq dotspacemacs-editing-style (dotspacemacs//read-editing-style-config
|
|
|
|
dotspacemacs-editing-style))
|
2015-12-03 04:49:00 +00:00
|
|
|
(configuration-layer/initialize)
|
2017-04-28 22:44:27 +00:00
|
|
|
;; frame title init
|
2019-12-22 14:51:27 +00:00
|
|
|
(when dotspacemacs-frame-title-format
|
2017-04-29 03:39:41 +00:00
|
|
|
(require 'format-spec)
|
2017-04-28 22:44:27 +00:00
|
|
|
(setq frame-title-format '((:eval (spacemacs/title-prepare dotspacemacs-frame-title-format))))
|
|
|
|
(if dotspacemacs-icon-title-format
|
|
|
|
(setq icon-title-format '((:eval (spacemacs/title-prepare dotspacemacs-icon-title-format))))
|
|
|
|
(setq icon-title-format frame-title-format)))
|
2017-01-26 04:30:25 +00:00
|
|
|
;; theme
|
2017-06-16 07:34:39 +00:00
|
|
|
(spacemacs/load-default-theme spacemacs--fallback-theme 'disable)
|
2014-11-28 05:07:29 +00:00
|
|
|
;; font
|
2015-08-14 04:50:53 +00:00
|
|
|
(spacemacs|do-after-display-system-init
|
2016-04-19 21:34:17 +00:00
|
|
|
;; If you are thinking to remove this call to `message', think twice. You'll
|
|
|
|
;; break the life of several Spacemacser using Emacs in daemon mode. Without
|
|
|
|
;; this, their chosen font will not be set on the *first* instance of
|
|
|
|
;; emacsclient, at least if different than their system font. You don't
|
|
|
|
;; believe me? Go ahead, try it. After you'll have notice that this was true,
|
|
|
|
;; increase the counter bellow so next people will give it more confidence.
|
|
|
|
;; Counter = 1
|
2018-06-10 06:49:51 +00:00
|
|
|
(spacemacs-buffer/message "Setting the font...")
|
2016-06-03 19:19:32 +00:00
|
|
|
(unless (spacemacs/set-default-font dotspacemacs-default-font)
|
2016-05-05 13:10:30 +00:00
|
|
|
(spacemacs-buffer/warning
|
2016-06-03 19:19:32 +00:00
|
|
|
"Cannot find any of the specified fonts (%s)! Font settings may not be correct."
|
2016-06-04 19:40:50 +00:00
|
|
|
(if (listp (car dotspacemacs-default-font))
|
|
|
|
(mapconcat 'car dotspacemacs-default-font ", ")
|
|
|
|
(car dotspacemacs-default-font)))))
|
2015-12-13 20:32:29 +00:00
|
|
|
;; spacemacs init
|
2016-01-07 04:01:27 +00:00
|
|
|
(setq inhibit-startup-screen t)
|
2015-12-13 20:32:29 +00:00
|
|
|
(spacemacs-buffer/goto-buffer)
|
2016-01-07 03:14:17 +00:00
|
|
|
(unless (display-graphic-p)
|
|
|
|
;; explicitly recreate the home buffer for the first GUI client
|
|
|
|
;; in order to correctly display the logo
|
|
|
|
(spacemacs|do-after-display-system-init
|
|
|
|
(kill-buffer (get-buffer spacemacs-buffer-name))
|
|
|
|
(spacemacs-buffer/goto-buffer)))
|
2016-09-14 09:52:39 +00:00
|
|
|
;; This is set to nil during startup to allow Spacemacs to show buffers opened
|
|
|
|
;; as command line arguments.
|
2016-01-07 01:11:32 +00:00
|
|
|
(setq initial-buffer-choice nil)
|
|
|
|
(setq inhibit-startup-screen t)
|
2015-11-18 00:35:32 +00:00
|
|
|
(require 'core-keybindings)
|
2015-12-13 20:40:48 +00:00
|
|
|
;; for convenience and user support
|
|
|
|
(unless (fboundp 'tool-bar-mode)
|
2015-12-21 04:00:09 +00:00
|
|
|
(spacemacs-buffer/message (concat "No graphical support detected, "
|
|
|
|
"you won't be able to launch a "
|
|
|
|
"graphical instance of Emacs"
|
2015-12-13 20:40:48 +00:00
|
|
|
"with this build.")))
|
2015-01-08 05:34:23 +00:00
|
|
|
;; check for new version
|
|
|
|
(if dotspacemacs-mode-line-unicode-symbols
|
2016-11-07 15:37:38 +00:00
|
|
|
(setq-default spacemacs-version-check-lighter "[⇪]"))
|
2018-06-25 06:16:27 +00:00
|
|
|
;; load environment variables
|
2018-07-03 05:20:06 +00:00
|
|
|
(if (fboundp 'dotspacemacs/user-env)
|
|
|
|
(dotspacemacs/call-user-env)
|
|
|
|
(spacemacs/load-spacemacs-env))
|
2016-11-07 15:37:38 +00:00
|
|
|
;; install the dotfile if required
|
2017-01-26 04:30:25 +00:00
|
|
|
(dotspacemacs/maybe-install-dotfile))
|
2014-12-14 18:53:06 +00:00
|
|
|
|
2015-12-13 20:40:48 +00:00
|
|
|
(defun spacemacs//removes-gui-elements ()
|
|
|
|
"Remove the menu bar, tool bar and scroll bars."
|
|
|
|
;; removes the GUI elements
|
2017-06-20 21:10:25 +00:00
|
|
|
(when (and (fboundp 'scroll-bar-mode) (not (eq scroll-bar-mode -1)))
|
|
|
|
(scroll-bar-mode -1))
|
2017-01-25 05:24:02 +00:00
|
|
|
(when (and (fboundp 'tool-bar-mode) (not (eq tool-bar-mode -1)))
|
|
|
|
(tool-bar-mode -1))
|
2016-03-31 04:34:28 +00:00
|
|
|
(unless (spacemacs/window-system-is-mac)
|
2015-12-13 20:40:48 +00:00
|
|
|
(when (and (fboundp 'menu-bar-mode) (not (eq menu-bar-mode -1)))
|
|
|
|
(menu-bar-mode -1)))
|
|
|
|
;; tooltips in echo-aera
|
|
|
|
(when (and (fboundp 'tooltip-mode) (not (eq tooltip-mode -1)))
|
|
|
|
(tooltip-mode -1)))
|
|
|
|
|
2017-01-24 04:40:26 +00:00
|
|
|
(defun spacemacs//setup-ido-vertical-mode ()
|
|
|
|
"Setup `ido-vertical-mode'."
|
|
|
|
(require 'ido-vertical-mode)
|
|
|
|
(ido-vertical-mode t)
|
|
|
|
(add-hook
|
|
|
|
'ido-setup-hook
|
|
|
|
;; think about hacking directly `ido-vertical-mode' source in libs instead.
|
|
|
|
(defun spacemacs//ido-vertical-natural-navigation ()
|
|
|
|
;; more natural navigation keys: up, down to change current item
|
|
|
|
;; left to go up dir
|
|
|
|
;; right to open the selected item
|
|
|
|
(define-key ido-completion-map (kbd "<up>") 'ido-prev-match)
|
|
|
|
(define-key ido-completion-map (kbd "<down>") 'ido-next-match)
|
|
|
|
(define-key ido-completion-map (kbd "<left>") 'ido-delete-backward-updir)
|
|
|
|
(define-key ido-completion-map (kbd "<right>") 'ido-exit-minibuffer))))
|
|
|
|
|
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."))
|
|
|
|
|
2016-01-21 13:18:33 +00:00
|
|
|
(defun spacemacs/defer-until-after-user-config (func)
|
|
|
|
"Call FUNC if dotspacemacs/user-config has been called. Otherwise,
|
|
|
|
defer call using `spacemacs-post-user-config-hook'."
|
|
|
|
(if spacemacs-post-user-config-hook-run
|
|
|
|
(funcall func)
|
|
|
|
(add-hook 'spacemacs-post-user-config-hook func)))
|
|
|
|
|
2015-07-28 14:01:30 +00:00
|
|
|
(defun spacemacs/setup-startup-hook ()
|
2018-03-31 04:31:52 +00:00
|
|
|
"Add post init processing.
|
|
|
|
Note: the hooked function is not executed when in dumped mode."
|
2015-03-02 03:12:09 +00:00
|
|
|
(add-hook
|
2015-07-28 14:01:30 +00:00
|
|
|
'emacs-startup-hook
|
2017-01-22 05:31:30 +00:00
|
|
|
(defun spacemacs/startup-hook ()
|
2016-09-14 09:52:39 +00:00
|
|
|
;; This is set here so that emacsclient will show the startup buffer (and
|
|
|
|
;; so that it can be changed in user-config if necessary). It was set to
|
|
|
|
;; nil earlier in the startup process to properly handle command line
|
|
|
|
;; arguments.
|
|
|
|
(setq initial-buffer-choice (lambda () (get-buffer spacemacs-buffer-name)))
|
2019-08-04 12:49:10 +00:00
|
|
|
|
|
|
|
;; Activate winner-mode for non dumped emacs sessions. Do this prior to
|
|
|
|
;; user-config to allow users to disable the feature and patch ediff
|
|
|
|
;; themselves. See issue 12582 for details.
|
|
|
|
(winner-mode t)
|
|
|
|
|
2015-03-02 03:12:09 +00:00
|
|
|
;; Ultimate configuration decisions are given to the user who can defined
|
|
|
|
;; them in his/her ~/.spacemacs file
|
2016-01-18 03:06:04 +00:00
|
|
|
(dotspacemacs|call-func dotspacemacs/user-config
|
2019-08-04 12:49:10 +00:00
|
|
|
"Calling dotfile user config...")
|
2016-11-23 03:49:23 +00:00
|
|
|
(dotspacemacs|call-func dotspacemacs/emacs-custom-settings
|
2019-08-04 12:49:10 +00:00
|
|
|
"Calling dotfile Emacs custom settings...")
|
2019-02-18 16:56:41 +00:00
|
|
|
;; don't write custom settings into the dotfile before loading them,
|
|
|
|
;; otherwise https://github.com/syl20bnr/spacemacs/issues/10504 happens
|
|
|
|
(spacemacs/initialize-custom-file-sync)
|
2016-01-21 13:18:33 +00:00
|
|
|
(run-hooks 'spacemacs-post-user-config-hook)
|
|
|
|
(setq spacemacs-post-user-config-hook-run t)
|
2016-01-05 15:17:23 +00:00
|
|
|
(when (fboundp dotspacemacs-scratch-mode)
|
|
|
|
(with-current-buffer "*scratch*"
|
2020-09-21 07:30:49 +00:00
|
|
|
(funcall dotspacemacs-scratch-mode)
|
|
|
|
(run-hooks 'spacemacs-scratch-mode-hook)))
|
2017-01-26 04:30:25 +00:00
|
|
|
(when spacemacs--delayed-user-theme
|
2017-02-11 22:19:41 +00:00
|
|
|
(spacemacs/load-theme spacemacs--delayed-user-theme
|
|
|
|
spacemacs--fallback-theme t))
|
2016-04-03 16:02:28 +00:00
|
|
|
(configuration-layer/display-summary emacs-start-time)
|
2017-01-22 05:31:30 +00:00
|
|
|
(spacemacs-buffer//startup-hook)
|
2016-08-04 01:32:29 +00:00
|
|
|
(spacemacs/check-for-new-version nil spacemacs-version-check-interval)
|
2018-01-29 04:22:38 +00:00
|
|
|
(setq spacemacs-initialized t)
|
|
|
|
(setq gc-cons-threshold (car dotspacemacs-gc-cons)
|
2020-05-15 20:07:17 +00:00
|
|
|
gc-cons-percentage (cadr dotspacemacs-gc-cons))
|
|
|
|
(unless (version< emacs-version "27")
|
|
|
|
(setq read-process-output-max dotspacemacs-read-process-output-max)))))
|
2015-03-02 03:12:09 +00:00
|
|
|
|
|
|
|
(provide 'core-spacemacs)
|