(defvar prelude-dir (file-name-directory load-file-name) "The root dir of the Emacs Prelude distribution.") (defvar prelude-core-dir (expand-file-name "core" prelude-dir) "The home of Prelude's core functionality.") (defvar prelude-modules-dir (expand-file-name "modules" prelude-dir) "This directory houses all of the built-in Prelude modules.") (defvar prelude-personal-dir (expand-file-name "personal" prelude-dir) "This directory is for your personal configuration.
Users of Emacs Prelude are encouraged to keep their personal configuration changes in this directory. All Emacs Lisp files there are loaded automatically by Prelude.") (defvar prelude-personal-preload-dir (expand-file-name "preload" prelude-personal-dir) "This directory is for your personal configuration, that you want loaded before Prelude.") (defvar prelude-vendor-dir (expand-file-name "vendor" prelude-dir) "This directory houses packages that are not yet available in ELPA (or MELPA).") (defvar prelude-savefile-dir (expand-file-name "savefile" prelude-dir) "This folder stores all the automatically generated save/history-files.") (defvar prelude-modules-file (expand-file-name "prelude-modules.el" prelude-dir) "This files contains a list of modules that will be loaded by Prelude.")
;; reduce the frequency of garbage collection by making it happen on ;; each 50MB of allocated data (the default is on every 0.76MB) (setq gc-cons-threshold 50000000)
;; warn when opening files bigger than 100MB (setq large-file-warning-threshold 100000000)
;; preload the personal settings from `prelude-personal-preload-dir' (when (file-exists-p prelude-personal-preload-dir) (message "Loading personal configuration files in %s..." prelude-personal-preload-dir) (mapc 'load (directory-files prelude-personal-preload-dir 't "^[^#].*el$")))
(message "Loading Prelude's core...")
;; the core stuff (require 'prelude-packages) (require 'prelude-custom) ;; Needs to be loaded before core, editor and ui (require 'prelude-ui) (require 'prelude-core) (require 'prelude-mode) (require 'prelude-editor) (require 'prelude-global-keybindings)
;; OSX specific settings (when (eq system-type 'darwin) (require 'prelude-osx))
(message "Loading Prelude's modules...")
;; the modules (if (file-exists-p prelude-modules-file) (load prelude-modules-file) (message "Missing modules file %s" prelude-modules-file) (message "You can get started by copying the bundled example file"))
;; config changes made through the customize UI will be store here (setq custom-file (expand-file-name "custom.el" prelude-personal-dir))
;; load the personal settings (this includes `custom-file') (when (file-exists-p prelude-personal-dir) (message "Loading personal configuration files in %s..." prelude-personal-dir) (mapc 'load (directory-files prelude-personal-dir 't "^[^#].*el$")))
(message "Prelude is ready to do thy bidding, Master %s!" current-user)
(prelude-eval-after-init ;; greet the use with some useful tip (run-at-time 5 nil 'prelude-tip-of-the-day))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) ;; set package-user-dir to be relative to Prelude install path (setq package-user-dir (expand-file-name "elpa" prelude-dir)) (package-initialize)
;; 定义需要安装的插件列表,这些插件是基础插件,在第一次启动的时候会全部装上。 (defvar prelude-packages '(ace-window avy anzu beacon browse-kill-ring dash discover-my-major diff-hl diminish easy-kill epl expand-region flycheck gist git-timemachine gitconfig-mode gitignore-mode god-mode grizzl guru-mode ov projectile magit move-text operate-on-number smart-mode-line smartparens smartrep undo-tree volatile-highlights zenburn-theme ) "A list of packages to ensure are installed at launch.")
;; 判断插件列表中的插件是否都安装完毕 (defun prelude-packages-installed-p () "Check if all packages in `prelude-packages' are installed." (every #'package-installed-p prelude-packages))
(defun prelude-install-packages () "Install all packages listed in `prelude-packages'." (unless (prelude-packages-installed-p) ;; check for new packages (package versions) (message "%s" "Emacs Prelude is now refreshing its package database...") (package-refresh-contents) (message "%s" " done.") ;; install the missing packages (prelude-require-packages prelude-packages)))
;; 安装基础插件 (prelude-install-packages)
(defun prelude-list-foreign-packages () "Browse third-party packages not bundled with Prelude.
Behaves similarly to `package-list-packages', but shows only the packages that are installed and are not in `prelude-packages'. Useful for removing unwanted packages." (interactive) (package-show-package-list (set-difference package-activated-list prelude-packages)))
(defmacro prelude-auto-install (extension package mode) "When file with EXTENSION is opened triggers auto-install of PACKAGE. PACKAGE is installed only if not already present. The file is opened in MODE." `(add-to-list 'auto-mode-alist `(,extension . (lambda () (unless (package-installed-p ',package) (package-install ',package)) (,mode)))))
;; markdown-mode doesn't have autoloads for the auto-mode-alist ;; so we add them manually if it's already installed (when (package-installed-p 'markdown-mode) (add-to-list 'auto-mode-alist '("\\.markdown\\'" . gfm-mode)) (add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode)))
(defmacro prelude-auto-install (extension package mode) "When file with EXTENSION is opened triggers auto-install of PACKAGE. PACKAGE is installed only if not already present. The file is opened in MODE." `(add-to-list 'auto-mode-alist `(,extension . (lambda () (unless (package-installed-p ',package) (package-install ',package)) (,mode)))))
(defcustom prelude-clean-whitespace-on-save t "Cleanup whitespace from file before it's saved. Will only occur if `prelude-whitespace' is also enabled." :type 'boolean :group 'prelude)
(defcustom prelude-user-init-file (expand-file-name "personal/" user-emacs-directory) "Path to your personal customization file. Prelude recommends you only put personal customizations in the personal folder. This variable allows you to specify a specific folder as the one that should be visited when running `prelude-find-user-init-file'. This can be easily set to the desired buffer in lisp by putting `(setq prelude-user-init-file load-file-name)' in the desired elisp file." :type 'string :group 'prelude)
(defcustom prelude-indent-sensitive-modes '(conf-mode coffee-mode haml-mode python-mode slim-mode yaml-mode) "Modes for which auto-indenting is suppressed." :type 'list :group 'prelude)
(defcustom prelude-yank-indent-modes '(LaTeX-mode TeX-mode) "Modes in which to indent regions that are yanked (or yank-popped). Only modes that don't derive from `prog-mode' should be listed here." :type 'list :group 'prelude)
(defcustom prelude-yank-indent-threshold 1000 "Threshold (# chars) over which indentation does not automatically occur." :type 'number :group 'prelude)
(defcustom prelude-theme 'zenburn "The default color theme, change this in your /personal/preload config." :type 'symbol :group 'prelude)
(defcustom prelude-shell (getenv "SHELL") "The default shell to run with `prelude-visit-term-buffer'" :type 'string :group 'prelude)
;; 关闭工具条 ;; the toolbar is just a waste of valuable screen estate ;; in a tty tool-bar-mode does not properly auto-load, and is ;; already disabled anyway (when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(menu-bar-mode -1)
;; 禁用光标闪烁 ;; the blinking cursor is nothing, but an annoyance (blink-cursor-mode -1)
;; ;; more useful frame title, that show either a file or a ;; buffer name (if the buffer isn't visiting a file) (setq frame-title-format '("" invocation-name " Prelude - " (:eval (if (buffer-file-name) (abbreviate-file-name (buffer-file-name)) "%b"))))
;; 设置主题。默认prelude使用zenburn主题 ;; use zenburn as the default theme (when prelude-theme (load-theme prelude-theme t))
(require 'smart-mode-line) (setq sml/no-confirm-load-theme t) ;; delegate theming to the currently active theme (setq sml/theme nil) (add-hook 'after-init-hook #'sml/setup)
;; 启用beacon-mode,这个模式会在光标移动后闪亮当前行,效果图见下方 ;; show the cursor when moving after big movements in the window (require 'beacon) (beacon-mode +1)