Skip to content

Commit

Permalink
Merge branch 'develop' (v0.12.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
syl20bnr committed Nov 17, 2014
2 parents b94038c + 9c46f35 commit 4ecf31f
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 147 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1222,21 +1222,18 @@ Key Binding | Description

#### Line formatting

`Spacemacs` replaces the default `J` Vi key binding (join current line with next
line) by a slightly more frequent action which is to `go to the line below point
and indent it`.

Join lines can still be performed with `<SPC> j k`
`Spacemacs` performs `go to the line below point and indent it` with `<SPC> j k`.
You may repeat this operation with `evil-repeat` if you need to indent many lines.

Line formatting commands start with `j`:

Key Binding | Description
------------------|------------------------------------------------------------
`J` | go to next line and indent it using auto-indent rules
`<SPC> j j` | same as `J` but will split the current line at point
`J` | join the current line with the next line
`<SPC> j j` | same as `<SPC> j k` but will split the current line at point
`<SPC> J` | split a quoted string or s-expression in place
`<SPC> j J` | split a quoted string or s-expression and auto-indent
`<SPC> j k` | join the current line with the next line
`<SPC> j k` | go to next line and indent it using auto-indent rules

Used together these key bindings are very powerful to quickly reformat the code.

Expand Down
32 changes: 17 additions & 15 deletions core/contribsys.el
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
;; Spacemacs Contribution System
(require 'package)
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
(setq warning-minimum-level :error)

;; Emacs 24.3 and above ships with python.el but in some Emacs 24.3.1 packages
;; for Ubuntu, python.el seems to be missing.
;; This hack adds marmalade repository for this case only.
(unless (or (package-installed-p 'python) (version< emacs-version "24.3"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/")))

(load (concat spacemacs-core-directory "ht.el"))

(defconst spacemacs-dotspacemacs-version "1.0"
"Minimum Version exepected for ~/.spacemacs file.")
Expand Down Expand Up @@ -78,6 +63,23 @@ NOT USED FOR NOW :-)"
(defvar dotspacemacs-excluded-packages '()
"A list of packages and/or extensions that will not be install and loaded.")

(defun contribsys/package.el-initialize ()
"Initialize package.el"
(require 'package)
(unless package--initialized
(load (concat spacemacs-core-directory "ht.el"))
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
;; Emacs 24.3 and above ships with python.el but in some Emacs 24.3.1 packages
;; for Ubuntu, python.el seems to be missing.
;; This hack adds marmalade repository for this case only.
(unless (or (package-installed-p 'python) (version< emacs-version "24.3"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/")))
(setq warning-minimum-level :error)))

(defun contribsys/dotfile-location ()
"Return the absolute path to the spacemacs dotfile."
(concat user-home-directory ".spacemacs"))
Expand Down
80 changes: 68 additions & 12 deletions core/spacemacs-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
(defvar spacemacs-min-version "24.3"
"Mininal required version of Emacs.")

(defvar spacemacs-title-length 70)
(defvar spacemacs-loading-counter 0)
(defvar spacemacs-loading-text "Loading")
(defvar spacemacs-loading-done-text "Ready!")
(defvar spacemacs-loading-dots-chunk-count 3)
(defvar spacemacs-loading-dots-count
(- spacemacs-title-length
(length spacemacs-loading-text)
(length spacemacs-loading-done-text)))
(defvar spacemacs-loading-dots-chunk-size
(/ spacemacs-loading-dots-count spacemacs-loading-dots-chunk-count))
(defvar spacemacs-loading-dots-chunk-threshold 0)
(defvar spacemacs-solarized-dark-createdp nil)

(define-derived-mode spacemacs-mode special-mode "spacemacs-mode"
"Spacemacs major mode for startup screen."
:syntax-table nil
Expand All @@ -12,29 +26,71 @@
(setq cursor-type nil)
;; no welcome buffer
(setq inhibit-startup-screen t)
;; load the default theme manually to give a smooth startup experience
(spacemacs/load-or-install-package 'dash)
(add-to-list 'load-path "~/.emacs.d/spacemacs/extensions/solarized-theme/")
(require 'solarized)
(deftheme solarized-dark "The dark variant of the Solarized colour theme")
(deftheme solarized-light "The light variant of the Solarized colour theme")
(create-solarized-theme 'light 'solarized-light)
;; font
;; Dynamic font size depending on the system
(let ((font "Source Code Pro"))
(when (member font (font-family-list))
(pcase window-system
(`x (spacemacs/set-font font 10))
(`mac (spacemacs/set-font font 12))
(`w32 (spacemacs/set-font font 9))
(other (spacemacs/set-font font 10)))))
;; edit area full screen
(tool-bar-mode -1)
(when (not (eq window-system 'mac))
(menu-bar-mode -1))
(scroll-bar-mode -1)
;; motion state since this is a special mode
(eval-after-load 'evil
'(add-to-list 'evil-motion-state-modes 'spacemacs-mode)))

(defun spacemacs/load-or-install-package (pkg)
"Load PKG package. PKG will be installed if it is not already
installed."
(condition-case nil
(require pkg)
(error
;; not installed, we try to initialize package.el only if required to
;; precious seconds during boot time
(require 'cl)
(let* ((elpa-dir (concat user-emacs-directory "elpa/"))
(pkg-elpa-dir
(if (file-exists-p elpa-dir)
(reduce (lambda (x y) (if x x y))
(mapcar (lambda (x)
(if (string-match (symbol-name pkg) x) x))
(directory-files elpa-dir))
:initial-value nil))))
(if pkg-elpa-dir
(add-to-list 'load-path (concat user-emacs-directory "elpa/"
pkg-elpa-dir))
;; install the package
(contribsys/package.el-initialize)
(package-refresh-contents)
(package-install pkg))
(require pkg)))))

(defun spacemacs/emacs-version-ok ()
(not (version< emacs-version spacemacs-min-version)))

(defun display-startup-echo-area-message ()
"Change the default welcome message of minibuffer to another one."
(message "Spacemacs is ready."))

(defvar spacemacs-title-length 70)
(defvar spacemacs-loading-counter 0)
(defvar spacemacs-loading-text "Loading")
(defvar spacemacs-loading-done-text "Ready!")
(defvar spacemacs-loading-dots-chunk-count 3)
(defvar spacemacs-loading-dots-count
(- spacemacs-title-length
(length spacemacs-loading-text)
(length spacemacs-loading-done-text)))
(defvar spacemacs-loading-dots-chunk-size
(/ spacemacs-loading-dots-count spacemacs-loading-dots-chunk-count))
(defvar spacemacs-loading-dots-chunk-threshold 0)
(defun spacemacs/set-font (font size &optional options)
(let* ((fontstr (if options
(format "%s-%s:%s" font size options)
(format "%s-%s" font size))))
(message (format "Set default font: %s" fontstr))
(add-to-list 'default-frame-alist (cons 'font fontstr))
(set-default-font fontstr)))

(defun spacemacs/buffer ()
"Create and initialize the spacemacs startup buffer."
Expand Down
3 changes: 2 additions & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(defconst spacemacs-core-directory
(expand-file-name (concat user-emacs-directory "core/"))
"Spacemacs core directory.")
(load (concat spacemacs-core-directory "contribsys.el"))
(load (concat spacemacs-core-directory "spacemacs-mode.el"))
(spacemacs/buffer)

Expand Down Expand Up @@ -31,7 +32,7 @@
"Dropbox directory.")
;; if you have a dropbox, then ~/Dropbox/emacs is added to load path
(add-to-list 'load-path (concat user-dropbox-directory "emacs/"))
(load (concat spacemacs-core-directory "contribsys.el"))
(contribsys/package.el-initialize)
;; User configuration file for Spacemacs: ~/.spacemacs
(contribsys/load-dotfile)
(contribsys/call-dotfile-func dotspacemacs/init)
Expand Down
24 changes: 0 additions & 24 deletions spacemacs/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,9 @@
;; Edit
;; ---------------------------------------------------------------------------

;; set the 2 keys sequence to return to normal state
;; default is "fd"
(defvar spacemacs-normal-state-sequence '(?f . ?d)
"Two keys sequence to return to normal state.")
(defvar spacemacs-normal-state-sequence-delay 0.2
"Maximum delay between the two keys to trigger the normal state.")
;; 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)
;; font size
;;(set-face-attribute 'default nil :height 110)
;; whitespace-mode
(setq-default show-trailing-whitespace nil)
;; When point is on paranthesis, highlight the matching one
Expand All @@ -52,11 +44,6 @@
(lambda () (setq mode-name "Elisp")))
;; important for golden-ratio to better work
(setq window-combination-resize t)
;; edit area full screen
(tool-bar-mode -1)
(when (not (eq window-system 'mac))
(menu-bar-mode -1))
(scroll-bar-mode -1)
;; fringes
(setq-default fringe-indicator-alist
'((truncation . nil) (continuation . nil)))
Expand All @@ -73,16 +60,6 @@
(setq tooltip-use-echo-area t)
;; When emacs asks for "yes" or "no", let "y" or "n" sufficide
(fset 'yes-or-no-p 'y-or-n-p)
;; font
;; (set-default-font "DejaVu Sans Mono-10")
;; Dynamic font size depending on the system
(let ((font "Source Code Pro"))
(when (member font (font-family-list))
(pcase window-system
(`x (spacemacs/set-font font 10))
(`mac (spacemacs/set-font font 12))
(`w32 (spacemacs/set-font font 9))
(other (spacemacs/set-font font 10)))))
;; draw underline lower
(setq x-underline-at-descent-line t)
;; setup right and left margins
Expand Down Expand Up @@ -239,4 +216,3 @@
(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)

18 changes: 0 additions & 18 deletions spacemacs/extensions.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
(defvar spacemacs-pre-extensions
'(
use-package
solarized-theme
))

;; Post extensions are loaded *after* the packages
Expand Down Expand Up @@ -99,20 +98,3 @@
(spray-quit)
(set-default-evil-insert-state-cursor)
(evil-normal-state))))))

;; solarized theme dependencies
(unless (package-installed-p 'dash)
(package-refresh-contents)
(package-install 'dash))
(defun spacemacs/init-solarized-theme ()
;; different method used than the documented one in order to speed up the
;; loading of emacs
(use-package solarized
:init
(progn
(deftheme solarized-dark "The dark variant of the Solarized colour theme")
(create-solarized-theme 'dark 'solarized-dark)
(deftheme solarized-light "The light variant of the Solarized colour theme")
(create-solarized-theme 'light 'solarized-light)
(spacemacs/post-theme-init 'solarized-light)
(redisplay))))
Loading

0 comments on commit 4ecf31f

Please sign in to comment.