Reorganize .emacs.el to use 'use-package', and add hydandata theme.

This commit is contained in:
Mikaël Capelle 2016-03-24 09:55:18 +01:00
parent d15b9a3e8e
commit 637991cc0b
5 changed files with 1937 additions and 152 deletions

View File

@ -0,0 +1,413 @@
;;; bind-key.el --- A simple way to manage personal keybindings
;; Copyright (c) 2012-2015 john wiegley
;; Author: John Wiegley <jwiegley@gmail.com>
;; Maintainer: John Wiegley <jwiegley@gmail.com>
;; Created: 16 Jun 2012
;; Version: 1.0
;; Keywords: keys keybinding config dotemacs
;; URL: https://github.com/jwiegley/use-package
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the gnu general public license as
;; published by the free software foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; without any warranty; without even the implied warranty of
;; merchantability or fitness for a particular purpose. see the gnu
;; general public license for more details.
;; You should have received a copy of the gnu general public license
;; along with gnu emacs; see the file copying. if not, write to the
;; free software foundation, inc., 59 temple place - suite 330,
;; boston, ma 02111-1307, usa.
;;; Commentary:
;; If you have lots of keybindings set in your .emacs file, it can be hard to
;; know which ones you haven't set yet, and which may now be overriding some
;; new default in a new emacs version. This module aims to solve that
;; problem.
;;
;; Bind keys as follows in your .emacs:
;;
;; (require 'bind-key)
;;
;; (bind-key "C-c x" 'my-ctrl-c-x-command)
;;
;; If you want the keybinding to override all minor modes that may also bind
;; the same key, use the `bind-key*' form:
;;
;; (bind-key* "<C-return>" 'other-window)
;;
;; If you want to rebind a key only in a particular keymap, use:
;;
;; (bind-key "C-c x" 'my-ctrl-c-x-command some-other-mode-map)
;;
;; To unbind a key within a keymap (for example, to stop your favorite major
;; mode from changing a binding that you don't want to override everywhere),
;; use `unbind-key':
;;
;; (unbind-key "C-c x" some-other-mode-map)
;;
;; To bind multiple keys at once, or set up a prefix map, a `bind-keys' macro
;; is provided. It accepts keyword arguments, please see its documentation
;; for a detailed description.
;;
;; To add keys into a specific map, use :map argument
;;
;; (bind-keys :map dired-mode-map
;; ("o" . dired-omit-mode)
;; ("a" . some-custom-dired-function))
;;
;; To set up a prefix map, use `:prefix-map' and `:prefix' arguments (both are
;; required)
;;
;; (bind-keys :prefix-map my-customize-prefix-map
;; :prefix "C-c c"
;; ("f" . customize-face)
;; ("v" . customize-variable))
;;
;; You can combine all the keywords together. Additionally,
;; `:prefix-docstring' can be specified to set documentation of created
;; `:prefix-map' variable.
;;
;; To bind multiple keys in a `bind-key*' way (to be sure that your bindings
;; will not be overridden by other modes), you may use `bind-keys*' macro:
;;
;; (bind-keys*
;; ("C-o" . other-window)
;; ("C-M-n" . forward-page)
;; ("C-M-p" . backward-page))
;;
;; After Emacs loads, you can see a summary of all your personal keybindings
;; currently in effect with this command:
;;
;; M-x describe-personal-keybindings
;;
;; This display will tell you if you've overriden a default keybinding, and
;; what the default was. Also, it will tell you if the key was rebound after
;; your binding it with `bind-key', and what it was rebound it to.
(require 'cl-lib)
(require 'easy-mmode)
(defgroup bind-key nil
"A simple way to manage personal keybindings"
:group 'emacs)
(defcustom bind-key-column-widths '(18 . 40)
"Width of columns in `describe-personal-keybindings'."
:type '(cons integer integer)
:group 'bind-key)
(defcustom bind-key-segregation-regexp
"\\`\\(\\(C-[chx] \\|M-[gso] \\)\\([CM]-\\)?\\|.+-\\)"
"Regular expression used to divide key sets in the output from
\\[describe-personal-keybindings]."
:type 'regexp
:group 'bind-key)
(defcustom bind-key-describe-special-forms nil
"If non-nil, extract docstrings from lambdas, closures and keymaps if possible."
:type 'boolean
:group 'bind-key)
;; Create override-global-mode to force key remappings
(defvar override-global-map (make-keymap)
"override-global-mode keymap")
(define-minor-mode override-global-mode
"A minor mode so that keymap settings override other modes."
t "")
;; the keymaps in `emulation-mode-map-alists' take precedence over
;; `minor-mode-map-alist'
(add-to-list 'emulation-mode-map-alists
`((override-global-mode . ,override-global-map)))
(defvar personal-keybindings nil
"List of bindings performed by `bind-key'.
Elements have the form ((KEY . [MAP]) CMD ORIGINAL-CMD)")
;;;###autoload
(defmacro bind-key (key-name command &optional keymap predicate)
"Bind KEY-NAME to COMMAND in KEYMAP (`global-map' if not passed).
KEY-NAME may be a vector, in which case it is passed straight to
`define-key'. Or it may be a string to be interpreted as
spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of
`edmacro-mode' for details.
If PREDICATE is non-nil, it is a form evaluated to determine when
a key should be bound. It must return non-nil in such cases.
Emacs can evaluate this form at any time that it does redisplay
or operates on menu data structures, so you should write it so it
can safely be called at any time."
(let ((namevar (make-symbol "name"))
(keyvar (make-symbol "key"))
(kdescvar (make-symbol "kdesc"))
(bindingvar (make-symbol "binding")))
`(let* ((,namevar ,key-name)
(,keyvar (if (vectorp ,namevar) ,namevar
(read-kbd-macro ,namevar)))
(,kdescvar (cons (if (stringp ,namevar) ,namevar
(key-description ,namevar))
(quote ,keymap)))
(,bindingvar (lookup-key (or ,keymap global-map) ,keyvar)))
(add-to-list 'personal-keybindings
(list ,kdescvar ,command
(unless (numberp ,bindingvar) ,bindingvar)))
,(if predicate
`(define-key (or ,keymap global-map) ,keyvar
'(menu-item "" nil :filter (lambda (&optional _)
(when ,predicate
,command))))
`(define-key (or ,keymap global-map) ,keyvar ,command)))))
;;;###autoload
(defmacro unbind-key (key-name &optional keymap)
"Unbind the given KEY-NAME, within the KEYMAP (if specified).
See `bind-key' for more details."
`(progn
(bind-key ,key-name nil ,keymap)
(setq personal-keybindings
(cl-delete-if #'(lambda (k)
,(if keymap
`(and (consp (car k))
(string= (caar k) ,key-name)
(eq (cdar k) ',keymap))
`(and (stringp (car k))
(string= (car k) ,key-name))))
personal-keybindings))))
;;;###autoload
(defmacro bind-key* (key-name command &optional predicate)
"Similar to `bind-key', but overrides any mode-specific bindings."
`(bind-key ,key-name ,command override-global-map ,predicate))
(defun bind-keys-form (args)
"Bind multiple keys at once.
Accepts keyword arguments:
:map MAP - a keymap into which the keybindings should be
added
:prefix KEY - prefix key for these bindings
:prefix-map MAP - name of the prefix map that should be created
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
;; jww (2016-02-26): This is a hack; this whole function needs to be
;; rewritten to normalize arguments the way that use-package.el does.
(if (and (eq (car args) :package)
(not (eq (car (cdr (cdr args))) :map)))
(setq args (cons :map (cons 'global-map args))))
(let* ((map (plist-get args :map))
(doc (plist-get args :prefix-docstring))
(prefix-map (plist-get args :prefix-map))
(prefix (plist-get args :prefix))
(filter (plist-get args :filter))
(menu-name (plist-get args :menu-name))
(pkg (plist-get args :package))
(key-bindings (progn
(while (keywordp (car args))
(pop args)
(pop args))
args)))
(when (or (and prefix-map (not prefix))
(and prefix (not prefix-map)))
(error "Both :prefix-map and :prefix must be supplied"))
(when (and menu-name (not prefix))
(error "If :menu-name is supplied, :prefix must be too"))
(let ((args key-bindings)
saw-map first next)
(while args
(if (keywordp (car args))
(progn
(setq next args)
(setq args nil))
(if first
(nconc first (list (car args)))
(setq first (list (car args))))
(setq args (cdr args))))
(cl-flet
((wrap (map bindings)
(if (and map pkg (not (eq map 'global-map)))
(if (boundp map)
bindings
`((eval-after-load
,(if (symbolp pkg) `',pkg pkg)
'(progn ,@bindings))))
bindings)))
(append
(when prefix-map
`((defvar ,prefix-map)
,@(when doc `((put ',prefix-map 'variable-documentation ,doc)))
,@(if menu-name
`((define-prefix-command ',prefix-map nil ,menu-name))
`((define-prefix-command ',prefix-map)))
,@(if (and map (not (eq map 'global-map)))
(wrap map `((bind-key ,prefix ',prefix-map ,map ,filter)))
`((bind-key ,prefix ',prefix-map nil ,filter)))))
(wrap map
(cl-mapcan
(lambda (form)
(if prefix-map
`((bind-key ,(car form) ',(cdr form) ,prefix-map ,filter))
(if (and map (not (eq map 'global-map)))
`((bind-key ,(car form) ',(cdr form) ,map ,filter))
`((bind-key ,(car form) ',(cdr form) nil ,filter)))))
first))
(when next
(bind-keys-form
(if pkg
(cons :package (cons pkg next))
next))))))))
;;;###autoload
(defmacro bind-keys (&rest args)
"Bind multiple keys at once.
Accepts keyword arguments:
:map MAP - a keymap into which the keybindings should be
added
:prefix KEY - prefix key for these bindings
:prefix-map MAP - name of the prefix map that should be created
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
(macroexp-progn (bind-keys-form args)))
;;;###autoload
(defmacro bind-keys* (&rest args)
(macroexp-progn
(bind-keys-form `(:map override-global-map ,@args))))
(defun get-binding-description (elem)
(cond
((listp elem)
(cond
((eq 'lambda (car elem))
(if (and bind-key-describe-special-forms
(stringp (nth 2 elem)))
(nth 2 elem)
"#<lambda>"))
((eq 'closure (car elem))
(if (and bind-key-describe-special-forms
(stringp (nth 3 elem)))
(nth 3 elem)
"#<closure>"))
((eq 'keymap (car elem))
"#<keymap>")
(t
elem)))
;; must be a symbol, non-symbol keymap case covered above
((and bind-key-describe-special-forms (keymapp elem))
(let ((doc (get elem 'variable-documentation)))
(if (stringp doc) doc elem)))
((symbolp elem)
elem)
(t
"#<byte-compiled lambda>")))
(defun compare-keybindings (l r)
(let* ((regex bind-key-segregation-regexp)
(lgroup (and (string-match regex (caar l))
(match-string 0 (caar l))))
(rgroup (and (string-match regex (caar r))
(match-string 0 (caar r))))
(lkeymap (cdar l))
(rkeymap (cdar r)))
(cond
((and (null lkeymap) rkeymap)
(cons t t))
((and lkeymap (null rkeymap))
(cons nil t))
((and lkeymap rkeymap
(not (string= (symbol-name lkeymap) (symbol-name rkeymap))))
(cons (string< (symbol-name lkeymap) (symbol-name rkeymap)) t))
((and (null lgroup) rgroup)
(cons t t))
((and lgroup (null rgroup))
(cons nil t))
((and lgroup rgroup)
(if (string= lgroup rgroup)
(cons (string< (caar l) (caar r)) nil)
(cons (string< lgroup rgroup) t)))
(t
(cons (string< (caar l) (caar r)) nil)))))
;;;###autoload
(defun describe-personal-keybindings ()
"Display all the personal keybindings defined by `bind-key'."
(interactive)
(with-output-to-temp-buffer "*Personal Keybindings*"
(princ (format (concat "Key name%s Command%s Comments\n%s %s "
"---------------------\n")
(make-string (- (car bind-key-column-widths) 9) ? )
(make-string (- (cdr bind-key-column-widths) 8) ? )
(make-string (1- (car bind-key-column-widths)) ?-)
(make-string (1- (cdr bind-key-column-widths)) ?-)))
(let (last-binding)
(dolist (binding
(setq personal-keybindings
(sort personal-keybindings
(lambda (l r)
(car (compare-keybindings l r))))))
(if (not (eq (cdar last-binding) (cdar binding)))
(princ (format "\n\n%s\n%s\n\n"
(cdar binding)
(make-string (+ 21 (car bind-key-column-widths)
(cdr bind-key-column-widths)) ?-)))
(if (and last-binding
(cdr (compare-keybindings last-binding binding)))
(princ "\n")))
(let* ((key-name (caar binding))
(at-present (lookup-key (or (symbol-value (cdar binding))
(current-global-map))
(read-kbd-macro key-name)))
(command (nth 1 binding))
(was-command (nth 2 binding))
(command-desc (get-binding-description command))
(was-command-desc (and was-command
(get-binding-description was-command)))
(at-present-desc (get-binding-description at-present))
)
(let ((line
(format
(format "%%-%ds%%-%ds%%s\n" (car bind-key-column-widths)
(cdr bind-key-column-widths))
key-name (format "`%s\'" command-desc)
(if (string= command-desc at-present-desc)
(if (or (null was-command)
(string= command-desc was-command-desc))
""
(format "was `%s\'" was-command-desc))
(format "[now: `%s\']" at-present)))))
(princ (if (string-match "[ \t]+\n" line)
(replace-match "\n" t t line)
line))))
(setq last-binding binding)))))
(provide 'bind-key)
;; Local Variables:
;; indent-tabs-mode: nil
;; End:
;;; bind-key.el ends here

View File

@ -0,0 +1,56 @@
(require 'font-lock)
;;###autoload
(define-minor-mode c++1x-minor-mode
"Extra highlighting for c++-mode that includes c++11 and c++14 keywords and features"
:lighter "c++1x"
(defun --copy-face (new-face face)
"Define NEW-FACE from existing FACE."
(copy-face face new-face)
(eval `(defvar ,new-face nil))
(set new-face new-face))
(--copy-face 'font-lock-label-face ; labels, case, public, private, proteced, namespace-tags
'font-lock-keyword-face)
(--copy-face 'font-lock-doc-markup-face ; comment markups such as Javadoc-tags
'font-lock-doc-face)
(--copy-face 'font-lock-doc-string-face ; comment markups
'font-lock-comment-face)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(font-lock-add-keywords
nil '(;; complete some fundamental keywords
("\\<\\(void\\|unsigned\\|signed\\|char\\|short\\|bool\\|int\\|long\\|float\\|double\\)\\>" . font-lock-keyword-face)
;; add the new C++11 keywords
("\\<\\(alignof\\|alignas\\|constexpr\\|noexcept\\|\\|static_assert\\|thread_local\\|override\\|final\\)\\>" . font-lock-keyword-face)
("\\<\\(decltype\\)\\>" . font-lock-builtin-face)
("\\<\\(nullptr\\)\\>" . font-lock-constant-face)
("\\<\\(char[0-9]+_t\\)\\>" . font-lock-keyword-face)
;; PREPROCESSOR_CONSTANT
("\\<[A-Z]+[A-Z_]+\\>" . font-lock-constant-face)
;; hexadecimal numbers
("\\<0[xX][0-9A-Fa-f]+\\>" . font-lock-constant-face)
;; integer/float/scientific numbers
("\\<[\\-+]*[0-9]*\\.?[0-9]+\\([ulUL]+\\|[eE][\\-+]?[0-9]+\\)?\\>" . font-lock-constant-face)
;; c++11 string literals
;; L"wide string"
;; L"wide string with UNICODE codepoint: \u2018"
;; u8"UTF-8 string", u"UTF-16 string", U"UTF-32 string"
("\\<\\([LuU8]+\\)\".*?\"" 1 font-lock-keyword-face)
;; R"(user-defined literal)"
;; R"( a "quot'd" string )"
;; R"delimiter(The String Data" )delimiter"
;; R"delimiter((a-z))delimiter" is equivalent to "(a-z)"
("\\(\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\)" 1 font-lock-keyword-face t) ; start delimiter
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\(.*?\\))[^\\s-\\\\()]\\{0,16\\}\"" 1 font-lock-string-face t) ; actual string
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(.*?\\()[^\\s-\\\\()]\\{0,16\\}\"\\)" 1 font-lock-keyword-face t) ; end delimiter
)))
;;###autoload
(add-hook 'c++-mode-hook 'c++1x-minor-mode)
(provide 'c++1x-minor-mode)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,165 @@
;;; hydandata-light-theme.el --- A light color theme that is easy on your eyes
;;; Copyright (C) 2016 David Chkhikvadze
;;; Copyright (C) 2010 Yves Senn
;;; Author: David Chkhikvadze <david.chk@outlook.com>
;;; Version: 0.2
;;; Created: 01 January 2016
;;; Keywords: color-theme theme
;;; This file is NOT part of GNU Emacs.
;;; License:
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3, or (at your option)
;;; any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Emacs; see the file COPYING. If not, write to the
;;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; A light color theme with bluish tint that is very easy on your
;;; eyes. Extracted from senny/theme-roller.el and modified for modern
;;; Emacs deftheme.
;;; Code:
(deftheme hydandata-light
"Light theme based on the one included with theme-roller by Yves Senn.")
(custom-theme-set-faces
'hydandata-light
'(default ((t (:inherit nil :stipple nil :background "#f8f8ff" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :width normal :bold nil))))
'(hl-line ((t (:background "#effca6"))))
'(highlight ((t (:background "#acc3e6"))))
'(region ((t (:background "#bcd5fa"))))
'(mode-line ((t (:background "#bcd5fa" :foreground "black"))))
'(minibuffer-prompt ((t (:foreground "#445588"))))
'(minibuffer-noticeable-prompt ((t (:foreground "#445588"))))
'(link ((t (:foreground "blue1" :underline t))))
'(fringe ((t (:background "gray95" :foreground "black"))))
'(linum ((t (:inherit fringe))))
'(show-paren-match ((t (:background "#bcd5fa" :foreground "white"))))
'(show-paren-mismatch ((t (:bold t :background "#9d1e15" :foreground "#f8f8f8"))))
'(font-lock-warning-face ((t (:background "#ffe4b5"))))
'(font-lock-comment-face ((t (:italic t :foreground "#999999" :slant italic))))
'(font-lock-comment-delimiter-face ((t (:inherit font-lock-comment-face))))
'(font-lock-builtin-face ((t (:inherit default))))
'(font-lock-constant-face ((t (:foreground "#3b5bb5"))))
'(font-lock-doc-face ((t (:foreground "#409b1c"))))
'(font-lock-doc-string-face ((t (:inherit font-lock-doc-face))))
'(font-lock-function-name-face ((t (:inherit default :bold t))))
'(font-lock-keyword-face ((t (:bold t :weight bold :foreground "#ff7800"))))
'(font-lock-preprocessor-face ((t (:foreground "#3a4a64" :background "gray95"))))
'(font-lock-reference-face ((t (nil))))
'(font-lock-negatoin-char-face ((t (nil))))
'(font-lock-regexp-grouping-backslash ((t (:inheirt font-lock-comment-face))))
'(font-lock-regexp-grouping-construct ((t (:foreground "red"))))
'(font-lock-string-face ((t (:foreground "#409b1c"))))
'(font-lock-type-face ((t (:foreground "#445588"))))
'(font-lock-variable-name-face ((t (:foreground "#671ebb"))))
'(mac-ts-caret-position ((t (:background "#effca6"))))
'(whitespace-line ((t (:inherit font-lock-code-warning))))
'(whitespace-tab ((t (:inherit font-lock-code-warning))))
'(compilation-info ((t (:inherit font-lock-string-face))))
'(compilation-line-number ((t (:foreground "#3b5bb5"))))
'(flymake-errline ((t (:bold t :background "#9d1e15" :foreground "#f8f8f8"))))
'(flymake-warnline ((t (:inherit font-lock-warning-face))))
'(flycheck-error ((t (:inherit font-lock-warning-face))))
'(flycheck-error-list-error ((t (:inherit font-lock-warning-face))))
'(flycheck-fringe-error ((t (:inherit font-lock-warning-face))))
'(flycheck-color-mode-line-info-face ((t (:inherit highlight))))
'(flycheck-color-mode-line-warning-face ((t (:inherit flycheck-fringe-error))))
'(flycheck-color-mode-line-error-face ((t (:inherit flycheck-fringe-error))))
'(diff-header ((t (:background "LightSteelBlue3"))))
'(diff-file-header ((t (:inherit diff-header :bold t))))
'(diff-added ((t (:background "DarkOliveGreen3"))))
'(diff-removed ((t (:background "IndianRed1"))))
'(diff-changed ((t (:background "burlywood3"))))
'(diff-context ((t (:background "gray90"))))
'(diff-index ((t (:inherit font-lock-comment-face))))
'(diff-refine-change ((t (:inherit font-lock-comment-face))))
'(magit-item-highlight ((t (:background nil :bold t))))
'(magit-diff-add ((t (:inherit diff-added))))
'(magit-diff-del ((t (:inherit diff-removed))))
'(magit-diff-none ((t (:inherit diff-context))))
'(magit-log-sha1 ((t (:inherit font-lock-code-keyword))))
'(magit-log-head-label-remote ((t (:inherit font-lock-string-face :box t))))
'(magit-log-head-label-local ((t (:inherit font-lock-variable-name-face :box t))))
'(ediff-current-diff-A ((t (:background "#01243C" :foreground "white"))))
'(ediff-current-diff-Ancestor ((t (:background "#4D0600" :foreground "white"))))
'(ediff-current-diff-B ((t (:background "#574A00" :foreground "white"))))
'(ediff-current-diff-C ((t (:background "#5C285C" :foreground "white"))))
'(ediff-even-diff-A ((t (:background "#222222"))))
'(ediff-even-diff-Ancestor ((t (:background "#222222"))))
'(ediff-even-diff-B ((t (:background "#222222"))))
'(ediff-even-diff-C ((t (:background "#222222"))))
'(ediff-fine-diff-A ((t (:background "#0B5C00" :foreground "white"))))
'(ediff-fine-diff-Ancestor ((t (:background "#0B5C00" :foreground "white"))))
'(ediff-fine-diff-B ((t (:background "#0B5C00" :foreground "white"))))
'(ediff-fine-diff-C ((t (:background "#0B5C00" :foreground "white"))))
'(ediff-odd-diff-A ((t (:background "#222222"))))
'(ediff-odd-diff-Ancestor ((t (:background "#222222"))))
'(ediff-odd-diff-B ((t (:background "#222222"))))
'(ediff-odd-diff-C ((t (:background "#222222"))))
'(org-done ((t (:inherit font-lock-string-face :bold t))))
'(org-todo ((t (:inherit font-lock-variable-name-face :bold t))))
'(org-level-1 ((t (:inherit default :underline t :bold t))))
'(org-level-2 ((t (:inherit font-lock-variable-name-face))))
'(org-level-3 ((t (:inherit font-lock-keyword-face))))
'(org-level-4 ((t (:inherit font-lock-type-face))))
'(org-special-keyword ((t (:inherit font-lock-doc-face))))
'(newsticker-treeview-selection-face ((t (:inherit highlight))))
'(newsticker-treeview-face ((t (:inherit default))))
'(newsticker-treeview-immortal-face ((t (:inherit font-lock-keyword-face))))
'(js2-error-face ((t (:bold t :background "#9d1e15" :foreground "#f8f8f8"))))
'(js2-external-variable-face ((t (:inherit font-lock-variable-name-face))))
'(js2-function-param-face ((t (:inherit font-lock-variable-name-face))))
'(js2-instance-member-face ((t (:inherit font-lock-variable-name-face))))
'(js2-private-function-call-face ((t (:inherit default))))
'(js2-private-member-face ((t (:inherit font-lock-variable-name-face))))
'(js2-warning-face ((t (:inherit font-lock-warning-face))))
'(html-tag-face ((t (:inherit font-lock-keyword-face))))
'(sgml-namespace ((t (:inherit font-locl-type-face))))
'(css-selector ((t (:inherit font-lock-keyword-face))))
'(border-glyph ((t (nil)))) ; flat borders
'(left-fringe ((t (nil)))))
;;;###autoload
(when load-file-name
(add-to-list
'custom-theme-load-path
(file-name-as-directory (file-name-directory load-file-name))))
(provide-theme 'hydandata-light)
;;; hydandata-light-theme.el ends here

286
.emacs.el Executable file → Normal file
View File

@ -1,4 +1,8 @@
(require 'iso-transl)
(add-to-list 'load-path "~/.emacs.d/one-file-mode/")
;; Themes
(setq custom-theme-directory "~/.emacs.d/themes/")
(load-theme 'hydandata-light t)
;; Packages
(require 'package) ;; You might already have this line
@ -11,134 +15,8 @@
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
(add-to-list 'load-path "~/.emacs.d/one-file-mode/")
;; Encoding
(set-language-environment "UTF-8")
(delete-selection-mode 1)
;; Indentation mode
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-screen t)
(setq tab-width 4)
;; Auto complete
(require 'yasnippet)
(yas-global-mode 1)
(define-key yas-minor-mode-map (kbd "<C-tab>") 'yas-next-field)
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
;; (require 'auto-complete-clang-async)
(require 'ac-c-headers)
(add-to-list 'ac-modes 'latex-mode) ; make auto-complete aware of `latex-mode`
(add-to-list 'ac-modes 'org-mode)
(require 'ac-math)
(defun ac-cc-mode-setup ()
(add-to-list 'ac-sources 'ac-source-c-headers)
(hs-minor-mode))
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'c++-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(defun ac-latex-mode-setup () ; add ac-sources to default ac-sources
(setq ac-sources
(append '(ac-source-math-unicode
ac-source-math-latex
ac-source-latex-commands)
ac-sources)))
(add-hook 'LaTeX-mode-hook 'ac-latex-mode-setup)
(global-auto-complete-mode t)
(setq ac-math-unicode-in-math-p t)
(ac-flyspell-workaround)
;; Latex
(require 'tex-mik)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(defun my-latex-mode-setup ()
"Redefines and updates variables for various customizations."
(setq LaTeX-paragraph-commands
'("If" "State" "Loop" "For" "ForAll"))
(setq LaTeX-begin-regexp
(concat LaTeX-begin-regexp "\\|If\\b" "\\|Loop\\b" "\\|For\\b" "\\|ForAll\\b"))
(setq LaTeX-end-regexp
(concat LaTeX-end-regexp "\\|EndIf\\b" "\\|EndLoop\\b"
"\\|EndFor\\b" "\\|Else\\b" "\\|ElsIf\\b"))
(setq LaTeX-paragraph-commands-regexp (LaTeX-paragraph-commands-regexp-make))
(defun LaTeX-indent-level-count ()
"Count indentation change caused by all \\left, \\right, \\begin, and
\\end commands in the current line."
(save-excursion
(save-restriction
(let ((count 0))
(narrow-to-region (point)
(save-excursion
(re-search-forward
(concat "[^" TeX-esc "]"
"\\(" LaTeX-indent-comment-start-regexp
"\\)\\|\n\\|\\'"))
(backward-char)
(point)))
(while (search-forward TeX-esc nil t)
(cond
((looking-at "left\\b")
(setq count (+ count LaTeX-left-right-indent-level)))
((looking-at "right\\b")
(setq count (- count LaTeX-left-right-indent-level)))
((looking-at LaTeX-begin-regexp)
(setq count (+ count LaTeX-indent-level)))
((looking-at "Else\\b"))
((looking-at "ElsIf\\b"))
((looking-at LaTeX-end-regexp)
(setq count (- count LaTeX-indent-level)))
((looking-at (regexp-quote TeX-esc))
(forward-char 1))))
count)))))
(add-hook 'LaTeX-mode-hook 'my-latex-mode-setup)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(require 'tex)
(TeX-global-PDF-mode t)
;; C mode
(setq c-default-style "k&r")
(setq c-basic-offset 4)
(setq c-doc-comment-style
'((java-mode . javadoc)
(pike-mode . autodoc)
(c-mode . javadoc)
(c++-mode . javadoc)))
(defun my-cc-init-hook ()
"Initialization hook for CC-mode runs before any other hooks."
(hide-ifdef-mode)
(setq hide-ifdef-shadow t))
(add-hook 'c-mode-hook 'my-cc-init-hook)
(add-hook 'c++-mode-hook 'my-cc-init-hook)
(add-to-list 'auto-mode-alist '("\\.hpp\\'" . c++-mode))
;; CSS style
(setq css-indent-offset 2)
(require 'iso-transl)
(require 'use-package)
;; No menu, scrollbar, display line and column
(menu-bar-mode -1)
@ -147,12 +25,109 @@
(column-number-mode t)
(line-number-mode t)
;; No split screen at startup
(setq inhibit-startup-screen t)
;; Encoding
(set-language-environment "UTF-8")
;; Selection mode
(delete-selection-mode 1)
;; Indentation mode
(setq-default indent-tabs-mode nil)
(setq tab-width 4)
;; Auto complete + Yasnippet
(use-package yasnippet
:config
(yas-global-mode 1))
(use-package auto-complete
:config
(require 'auto-complete-config)
(ac-config-default)
(require 'ac-c-headers)
(require 'ac-math)
(add-to-list 'ac-modes 'latex-mode)
(add-to-list 'ac-modes 'org-mode)
(add-to-list 'ac-sources 'ac-source-c-headers)
(defun ac-latex-mode-setup () ; add ac-sources to default ac-sources
(setq ac-sources
(append '(ac-source-math-unicode
ac-source-math-latex
ac-source-latex-commands)
ac-sources)))
(add-hook 'LaTeX-mode-hook 'ac-latex-mode-setup)
(global-auto-complete-mode t)
(ac-flyspell-workaround)
:config
(setq ac-math-unicode-in-math-p t))
;; Latex
(use-package tex-mik
:config
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(defun my-latex-mode-setup ()
"Redefines and updates variables for various customizations."
(setq LaTeX-paragraph-commands
'("If" "State" "Loop" "For" "ForAll"))
(setq LaTeX-begin-regexp
(concat LaTeX-begin-regexp "\\|If\\b" "\\|Loop\\b" "\\|For\\b" "\\|ForAll\\b"))
(setq LaTeX-end-regexp
(concat LaTeX-end-regexp "\\|EndIf\\b" "\\|EndLoop\\b"
"\\|EndFor\\b" "\\|Else\\b" "\\|ElsIf\\b"))
(setq LaTeX-paragraph-commands-regexp (LaTeX-paragraph-commands-regexp-make))
(defun LaTeX-indent-level-count ()
"Count indentation change caused by all \\left, \\right, \\begin, and
\\end commands in the current line."
(save-excursion
(save-restriction
(let ((count 0))
(narrow-to-region (point)
(save-excursion
(re-search-forward
(concat "[^" TeX-esc "]"
"\\(" LaTeX-indent-comment-start-regexp
"\\)\\|\n\\|\\'"))
(backward-char)
(point)))
(while (search-forward TeX-esc nil t)
(cond
((looking-at "left\\b")
(setq count (+ count LaTeX-left-right-indent-level)))
((looking-at "right\\b")
(setq count (- count LaTeX-left-right-indent-level)))
((looking-at LaTeX-begin-regexp)
(setq count (+ count LaTeX-indent-level)))
((looking-at "Else\\b"))
((looking-at "ElsIf\\b"))
((looking-at LaTeX-end-regexp)
(setq count (- count LaTeX-indent-level)))
((looking-at (regexp-quote TeX-esc))
(forward-char 1))))
count)))))
(add-hook 'LaTeX-mode-hook 'my-latex-mode-setup)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(require 'tex)
(TeX-global-PDF-mode t)
)
;; CSS style
(setq css-indent-offset 2)
;; Markdown mode
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(use-package markdown-mode
:mode "\\.text\\'" "\\.markdown\\'" "\\.md\\'")
;; White space mode
(setq whitespace-line-column 100)
@ -162,7 +137,6 @@
(add-hook 'python-mode-hook (lambda () (setq whitespace-line-column 140)))
(add-hook 'LaTeX-mode-hook (lambda () (setq whitespace-line-column -1)))
(global-whitespace-mode 1)
;; Electric pair mode
@ -170,6 +144,31 @@
(show-paren-mode 1)
(setq show-paren-delay 0)
;; C mode
(setq c-default-style "k&r")
(setq c-basic-offset 4)
(use-package c++1x-minor-mode)
(defun ac-cc-mode-setup ()
"Initialization hook for CC-mode runs before any other hooks."
(hide-ifdef-mode)
(setq hide-ifdef-shadow t)
(hs-minor-mode))
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'c++-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(setq c-doc-comment-style
'((java-mode . javadoc)
(pike-mode . autodoc)
(c-mode . javadoc)
(c++-mode . javadoc)))
(add-to-list 'auto-mode-alist '("\\.hpp\\'" . c++-mode))
;; Run C programs directly from within emacs
(setq execute-command nil)
(setq compile-command nil)
@ -231,20 +230,3 @@
(local-set-key [f8] 'fd-switch-dictionary))
(add-hook 'LaTeX-mode-hook 'key-latex-mode-setup)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
(quote
("737d9d0e0f6c4279e80f7479ec5138af6e4908a2d052126f254e1e6d1a0d0188" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(load-theme 'hydandata-light)