Skip to content

Commit

Permalink
core: dotspacemacs-distribution, spacemacs-core layer and rename contrib
Browse files Browse the repository at this point in the history
- Rename contrib directory to layers
- Add new variable dotspacemacs-distribution
- Move spacemacs layer to layers/!distribution
- New layer spacemacs-core in layers/!distribution
- User can now set dotspacemacs-distribution to spacemacs or
  spacemacs-core (default spacemacs)

spacemacs-core is very lightweight layer sufficient to build upon
spacemacs.
  • Loading branch information
syl20bnr committed Sep 8, 2015
1 parent 3760916 commit 6b33031
Show file tree
Hide file tree
Showing 474 changed files with 9,649 additions and 1,930 deletions.
37 changes: 19 additions & 18 deletions core/core-configuration-layer.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
(expand-file-name (concat spacemacs-core-directory "templates/"))
"Configuration layer templates directory.")

(defconst configuration-layer-contrib-directory
(expand-file-name (concat user-emacs-directory "contrib/"))
(defconst configuration-layer-directory
(expand-file-name (concat user-emacs-directory "layers/"))
"Spacemacs contribution layers base directory.")

(defconst configuration-layer-private-directory
Expand Down Expand Up @@ -392,7 +392,7 @@ Possible return values:
(if (string-match
"^!" (file-name-nondirectory
(directory-file-name
(concat configuration-layer-contrib-directory path))))
(concat configuration-layer-directory path))))
'category
(let ((files (directory-files path)))
;; most frequent files encoutered in a layer are tested first
Expand All @@ -410,7 +410,7 @@ Returns nil if the directory is not a category."
(when (file-directory-p dirpath)
(let ((dirname (file-name-nondirectory
(directory-file-name
(concat configuration-layer-contrib-directory
(concat configuration-layer-directory
dirpath)))))
(when (string-match "^!" dirname)
(intern (substring dirname 1))))))
Expand All @@ -421,7 +421,7 @@ path."
;; load private layers at the end on purpose we asume that the user layers
;; must have the final word on configuration choices. Let
;; `dotspacemacs-directory' override the private directory if it exists.
(let ((search-paths (append (list configuration-layer-contrib-directory)
(let ((search-paths (append (list configuration-layer-directory)
dotspacemacs-configuration-layer-path
(list configuration-layer-private-layer-directory)
(when dotspacemacs-directory
Expand Down Expand Up @@ -455,8 +455,6 @@ path."
(t
;; layer not found, add it to search path
(setq search-paths (cons sub search-paths)))))))))
;; add the spacemacs layer
(puthash 'spacemacs (expand-file-name user-emacs-directory) result)
;; add discovered layers to hash table
(mapc (lambda (l)
(if (ht-contains? result (car l))
Expand All @@ -472,19 +470,22 @@ path."
result))

(defun configuration-layer//declare-layers ()
"Add default layers and user layers declared in the dotfile."
"Declare default layers and user layers declared in the dotfile."
(setq configuration-layer--layers nil)
(setq configuration-layer-paths (configuration-layer//discover-layers))
(if (eq 'all dotspacemacs-configuration-layers)
(setq dotspacemacs-configuration-layers
;; spacemacs is contained in configuration-layer-paths
(ht-keys configuration-layer-paths))
(setq configuration-layer--layers
(list (configuration-layer/make-layer 'spacemacs))))
(setq configuration-layer--layers
(reverse (append (configuration-layer//make-layers
dotspacemacs-configuration-layers)
configuration-layer--layers))))
(when (eq 'all dotspacemacs-configuration-layers)
(setq dotspacemacs-configuration-layers
(ht-keys configuration-layer-paths)))
(dolist (layer dotspacemacs-configuration-layers)
(let ((layer-name (if (listp layer) (car layer) layer)))
(unless (string-match-p "!distribution"
(ht-get configuration-layer-paths layer-name))
(push (configuration-layer/make-layer layer)
configuration-layer--layers))))
(setq configuration-layer--layers (reverse configuration-layer--layers))
;; distribution layer is always first
(push (configuration-layer/make-layer dotspacemacs-distribution)
configuration-layer--layers))

(defun configuration-layer/declare-layers (layer-names)
"Add layer with LAYER-NAMES to used layers."
Expand Down
5 changes: 5 additions & 0 deletions core/core-dotspacemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ exists. Otherwise, fallback to ~/.spacemacs")
(defvar dotspacemacs-verbose-loading nil
"If non nil output loading progess in `*Messages*' buffer.")

(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'.")

(defvar dotspacemacs-configuration-layer-path '()
"List of additional paths where to look for configuration layers.
Paths must have a trailing slash (ie. `~/.mycontribs/')")
Expand Down
4 changes: 4 additions & 0 deletions core/templates/.spacemacs.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; `!distribution'. For now available distributions are `spacemacs-core'
;; or `spacemacs'. (default 'spacemacs)
dotspacemacs-distribution 'spacemacs
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (i.e. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
138 changes: 4 additions & 134 deletions spacemacs/config.el → ...rs/!distribution/spacemacs-core/config.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; config.el --- Spacemacs Layer configuration File
;;; config.el --- Spacemacs Core Layer configuration File
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
Expand Down Expand Up @@ -70,34 +70,22 @@
;; Navigation
;; ---------------------------------------------------------------------------

(ido-mode t)
(setq ido-save-directory-list-file (concat spacemacs-cache-directory "ido.last")
;; enable fuzzy matching
ido-enable-flex-matching t)
;; Auto refresh buffers
;; Auto refresh
(global-auto-revert-mode 1)
;; Also auto refresh dired, but be quiet about it
(setq global-auto-revert-non-file-buffers t
auto-revert-verbose nil)

;; Regexp for useful and useless buffers for smarter buffer switching
(defvar spacemacs-useless-buffers-regexp '("*\.\+")
"Regexp used to determine if a buffer is not useful.")
(defvar spacemacs-useful-buffers-regexp '("\\*\\(scratch\\|terminal\.\+\\|ansi-term\\|eshell\\)\\*")
"Regexp used to define buffers that are useful despite matching
`spacemacs-useless-buffers-regexp'.")

;; activate winner mode use to undo and redo windows layout
(winner-mode t)
;; no beep pleeeeeease ! (and no visual blinking too please)
(setq ring-bell-function 'ignore
visible-bell nil)
;; required for evil folding
(defun spacemacs//enable-hs-minor-mode ()
"Enable hs-minor-mode for code folding."
(ignore-errors
(hs-minor-mode)
(spacemacs|hide-lighter hs-minor-mode)))
(add-hook 'prog-mode-hook 'spacemacs//enable-hs-minor-mode)

;; Hack to fix a bug with tabulated-list.el
;; see: http://redd.it/2dgy52
Expand Down Expand Up @@ -126,25 +114,11 @@ It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'."
;; start scratch in text mode (usefull to get a faster Emacs load time
;; because it avoids autoloads of elisp modes)
(setq initial-major-mode 'text-mode)
;; whitespace-mode
(defcustom spacemacs-show-trailing-whitespace t
"If t, show trailing whitespace."
:type 'boolean
:group 'spacemacs)

(add-hook 'prog-mode-hook (lambda ()
(when spacemacs-show-trailing-whitespace
(set-face-attribute 'trailing-whitespace nil
:background (face-attribute 'font-lock-comment-face
:foreground))
(setq show-trailing-whitespace 1))))


;; use only spaces and no tabs
(setq-default indent-tabs-mode nil
default-tab-width 2)
;; turn on electric-indent-mode for both 24.3 and 24.4
(electric-indent-mode)

;; Text
(setq longlines-show-hard-newlines t)

Expand Down Expand Up @@ -193,23 +167,16 @@ It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'."
(fset 'yes-or-no-p 'y-or-n-p)
;; draw underline lower
(setq x-underline-at-descent-line t)
;; setup right and left margins
;; (add-hook 'window-configuration-change-hook
;; (lambda ()
;; (set-window-margins (car (get-buffer-window-list (current-buffer) nil t)) 0 0)))

;; don't let the cursor go into minibuffer prompt
;; Tip taken from Xah Lee: http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
(setq minibuffer-prompt-properties
'(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt))

;; Emacs 24.4 new features
(unless (version< emacs-version "24.4")
(if dotspacemacs-fullscreen-at-startup
(spacemacs/toggle-frame-fullscreen)
(if dotspacemacs-maximized-at-startup
(add-hook 'window-setup-hook 'toggle-frame-maximized))))

(defvar spacemacs--global-mode-line-excludes nil
"List of elements to exclude from the global modeline string.
These should have their own segments in the modeline.")
Expand Down Expand Up @@ -249,12 +216,6 @@ These should have their own segments in the modeline.")
(_ (setq auto-save-default nil
auto-save-list-file-prefix nil)))

(require 'uniquify)
;; When having windows with repeated filenames, uniquify them
;; by the folder they are in rather those annoying <2>,<3>,.. etc
(setq uniquify-buffer-name-style 'post-forward-angle-brackets
;; don't screw special buffers
uniquify-ignore-buffers-re "^\\*")
;; remove annoying ellipsis when printing sexp in message buffer
(setq eval-expression-print-length nil
eval-expression-print-level nil)
Expand All @@ -278,94 +239,3 @@ These should have their own segments in the modeline.")
(defun server-remove-kill-buffer-hook ()
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function))
(add-hook 'server-visit-hook 'server-remove-kill-buffer-hook)

;; The following code is kept as reference -----------------------------------

;; ;; save a bunch of variables to the desktop file
;; ;; for lists specify the len of the maximal saved data also
;; (setq desktop-globals-to-save
;; (append '((extended-command-history . 30)
;; (file-name-history . 100)
;; (grep-history . 30)
;; (compile-history . 30)
;; (minibuffer-history . 50)
;; (query-replace-history . 60)
;; (read-expression-history . 60)
;; (regexp-history . 60)
;; (regexp-search-ring . 20)
;; (search-ring . 20)
;; (shell-command-history . 50)
;; (evil-ex .100)
;; tags-file-name
;; register-alist)))

;; ;; Make emacs open all files in last emacs session (taken from ergoemacs).

;; ;; This functionality is provided by desktop-save-mode
;; ;; (“feature” name: “desktop”).
;; ;;
;; ;; The mode is not on by default in emacs 23.1, and has a lot options.
;; ;; The following is init settings for the mode for ErgoEmacs.
;; ;; Goal: have emacs always auto open the set of opened files in last session,
;; ;; even if emacs crashed in last session or the OS crashed in last session.
;; ;; Also, don't bother users by asking questions like “do you want to save
;; ;; desktop?” or “do you want to override last session file?”, because these are
;; ;; annoying and terms like “session” or “desktop” are confusing to most users
;; ;; because it can have many meanings.
;; ;;
;; ;; Some tech detail: set the desktop session file 〔.emacs.desktop〕
;; ;; at the variable “user-emacs-directory” (default value is “~/.emacs.d/”).
;; ;; This file is our desktop file. It will be auto created and or over-written.
;; ;; If a emacs expert has other desktop session files elsewhere, he can still use
;; ;; or manage those.

;; (require 'desktop)

;; (defun desktop-settings-setup ()
;; "Some settings setup for desktop-save-mode."
;; (interactive)

;; ;; At this point the desktop.el hook in after-init-hook was
;; ;; executed, so (desktop-read) is avoided.
;; (when (not (eq (emacs-pid) (desktop-owner))) ; Check that emacs did not load a desktop yet
;; ;; Here we activate the desktop mode
;; (desktop-save-mode 1)
;; ;; The default desktop is saved always
;; (setq desktop-save t)
;; ;; The default desktop is loaded anyway if it is locked
;; (setq desktop-load-locked-desktop t)
;; ;; Set the location to save/load default desktop
;; (setq desktop-dirname user-emacs-directory)
;; ;; Make sure that even if emacs or OS crashed, emacs
;; ;; still have last opened files.
;; (add-hook 'find-file-hook
;; (lambda ()
;; (run-with-timer 5 nil
;; (lambda ()
;; ;; Reset desktop modification time so the user is not bothered
;; (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))
;; (desktop-save user-emacs-directory)))))
;; ;; Read default desktop
;; (if (file-exists-p (concat desktop-dirname desktop-base-file-name))
;; (desktop-read desktop-dirname))
;; ;; Add a hook when emacs is closed to we reset the desktop
;; ;; modification time (in this way the user does not get a warning
;; ;; message about desktop modifications)
;; (add-hook 'kill-emacs-hook
;; (lambda ()
;; ;; Reset desktop modification time so the user is not bothered
;; (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))))
;; )
;; )

;; (add-hook 'after-init-hook
;; ;; 'desktop-settings-setup
;; (lambda ()
;; ;; No splash screen
;; (setq inhibit-startup-screen t)
;; ;; ;; If the *scratch* buffer is the current one, then create a new
;; ;; ;; empty untitled buffer to hide *scratch*
;; ;; (if (string= (buffer-name) "*scratch*")
;; ;; (spacemacs/new-empty-buffer))
;; )
;; t) ;; append this hook to the tail
Loading

0 comments on commit 6b33031

Please sign in to comment.