Libraries used during initialization.
(require 'cl)
(require 'assoc)
(require 'info)
(info-initialize)
Customization of Emacs itself.
Functions and macros asisting the initialization process.
Manual hygiene.
(defmacro* with-unique-names (vars &body body)
"Evaluate BODY with each VAR in VARS bound to a unique name.
\n(fn VARS BODY...)"
(declare (indent 1))
`(let ,(loop for var in vars
collect `(,var (gensym ,(symbol-name var))))
,@body))
Support Common Lisp conventions in dolist
.
(defmacro* dolist* ((args list &optional result) &body body)
"Loop over a list.
Like normal `dolist', except ARGS allows full Common Lisp conventions.
\n(fn (ARGS LIST [RESULT]) BODY...)"
(declare (indent 1))
(with-unique-names (loop-var)
`(dolist (,loop-var ,list ,result)
(destructuring-bind ,args ,loop-var
,@body))))
Easier local variables.
(defmacro setl (sym val)
"Like setq, but makes sym a local variable first."
`(set (make-local-variable ',sym) ,val))
Sugar for after-init-hook
.
(defmacro* eval-after-init (&body body)
"Arrange that BODY will be run in `after-init-hook'."
(declare (indent 0))
`(add-hook 'after-init-hook (lambda () ,@body)))
Restart Emacs.
(defun restart-emacs ()
"Kill all unmodified buffers except for `shell', `eshell' and `org-agenda'."
(interactive)
(let* ((kept-buffers '("*shell*" "*eshell*" "*Org Agenda*")))
(dolist (buffer (buffer-list))
(unless (or (member (buffer-name buffer) kept-buffers)
(and (buffer-file-name buffer)
(buffer-modified-p buffer)))
(kill-buffer buffer)))))
Kill Emacs with a 5 second timeout.
(defun kill-emacs-with-timeout (prompt)
"Automatically kill Emacs after a 5 second delay."
(let* ((message "will exit automatically in 5 seconds")
(prompt (format "%s(%s) " prompt message)))
(y-or-n-p-with-timeout prompt 5 t)))
(defun ns-command-key (&rest keys)
(let ((modifier (case window-system
(ns ns-command-modifier)
(mac mac-command-modifier)
(otherwise 'meta))))
(vector (cons modifier keys))))
Check for indentation at point
.
(defun in-indentation? ()
"Return t if point is currently inside indentation."
(looking-at-p (rx bol (0+ blank))))
Configure consistent tab-width
and tab-stop-list
.
(defun set-tab-width (width)
"Set `tab-width' and `tab-stop-list' to match WIDTH."
(setq tab-width width)
(setl tab-stop-list (number-sequence width 120 width)))
(defun chomp (string)
"Remove any trailing newline characters from STRING."
(let ((regexp (rx ?\r ?\n)))
(while (and (> (length string) 0)
(string-match regexp (substring string -1)))
(setq string (substring string 0 -1)))
string))
Support for older Emacsen.
(unless (functionp 'region-active-p)
(defun region-active-p ()
"Return t if Transient Mark mode is enabled and the mark is active."
(and transient-mark-mode mark-active)))
(unless (functionp 'locate-dominating-file)
(defun locate-dominating-file (file name)
"Look up the directory hierarchy from FILE for a file named NAME.
Stop at the first parent directory containing a file NAME,
and return the directory. Return nil if not found."
;; We used to use the above locate-dominating-files code, but the
;; directory-files call is very costly, so we're much better off doing
;; multiple calls using the code in here.
;;
;; Represent /home/luser/foo as ~/foo so that we don't try to look for
;; `name' in /home or in /.
(setq file (abbreviate-file-name file))
(let ((root nil)
(prev-file file)
;; `user' is not initialized outside the loop because
;; `file' may not exist, so we may have to walk up part of the
;; hierarchy before we find the "initial UID".
(user nil)
try)
(while (not (or root
(null file)
;; FIXME: Disabled this heuristic because it is sometimes
;; inappropriate.
;; As a heuristic, we stop looking up the hierarchy of
;; directories as soon as we find a directory belonging
;; to another user. This should save us from looking in
;; things like /net and /afs. This assumes that all the
;; files inside a project belong to the same user.
;; (let ((prev-user user))
;; (setq user (nth 2 (file-attributes file)))
;; (and prev-user (not (equal user prev-user))))
(string-match locate-dominating-stop-dir-regexp file)))
(setq try (file-exists-p (expand-file-name name file)))
(cond (try (setq root file))
((equal file (setq prev-file file
file (file-name-directory
(directory-file-name file))))
(setq file nil))))
root))
(defvar locate-dominating-stop-dir-regexp
"\\`\\(?:[\\/][\\/][^\\/]+\\|/\\(?:net\\|afs\\|\\.\\.\\.\\)/\\)\\'"))
(unless (functionp 'subword-mode)
(defalias 'subword-mode 'c-subword-mode))
Use Command as the Meta key.
(setq ns-option-modifier nil)
(setq ns-command-modifier 'meta)
(setq mac-option-modifier nil)
(setq mac-command-modifier 'meta)
(setq mac-pass-control-to-system nil)
(setq mac-pass-command-to-system nil)
Use a helpful frame title.
(case window-system
(mac (setq frame-title-format "%b")))
Support hiding Emacs.
(defun mac-do-hide-emacs ()
(interactive)
(do-applescript
(format "tell app \"System Events\"
set visible of application process \"%s\" to false
end tell" invocation-name)))
(case window-system
(ns (defadvice suspend-frame (around ns-do-hide-emacs activate)
(ns-do-hide-emacs)))
(mac (defadvice iconify-frame (around mac-do-hide-emacs activate)
(mac-do-hide-emacs))))
Define Mac-like CUA keys.
(case window-system
((ns mac)
(global-set-key (ns-command-key 'c) #'copy-region-as-kill)
(global-set-key (ns-command-key 'v) #'yank)
(global-set-key (ns-command-key 'V) #'yank-pop)))
Fix Emacs 23 local-function-key-map
.
(case window-system
(ns (setq local-function-key-map
'(keymap (M-escape . [134217755])
(M-return . [134217741])
(M-clear . [134217740])
(M-linefeed . [134217738])
(M-tab . [134217737])
(M-delete . [134217855])
(M-backspace . [134217855])
(escape . [27])
(return . [13])
(clear . [12])
(linefeed . [10])
(tab . [9])
(kp-equal . [61])
(kp-divide . [47])
(kp-decimal . [46])
(kp-subtract . [45])
(kp-separator . [44])
(kp-add . [43])
(kp-multiply . [42])
(kp-enter . [13])
(kp-tab . [9])
(kp-space . [32])
(kp-9 . [57])
(kp-8 . [56])
(kp-7 . [55])
(kp-6 . [54])
(kp-5 . [53])
(kp-4 . [52])
(kp-3 . [51])
(kp-2 . [50])
(kp-1 . [49])
(kp-0 . [48])
(24 keymap
(64 keymap
(99 . event-apply-control-modifier)
(83 . event-apply-shift-modifier)
(97 . event-apply-alt-modifier)
(109 . event-apply-meta-modifier)
(115 . event-apply-super-modifier)
(104 . event-apply-hyper-modifier)))
(C-S-kp-9 . [C-S-prior])
(C-S-kp-8 . [C-S-up])
(C-S-kp-7 . [C-S-home])
(C-S-kp-6 . [C-S-right])
(C-S-kp-4 . [C-S-left])
(C-S-kp-3 . [C-S-next])
(C-S-kp-2 . [C-S-down])
(C-S-kp-1 . [C-S-end])
(C-S-kp-prior . [C-S-prior])
(C-S-kp-up . [C-S-up])
(C-S-kp-home . [C-S-home])
(C-S-kp-right . [C-S-right])
(C-S-kp-left . [C-S-left])
(C-S-kp-next . [C-S-next])
(C-S-kp-down . [C-S-down])
(C-S-kp-end . [C-S-end])
(S-kp-prior . [S-prior])
(S-kp-up . [S-up])
(S-kp-home . [S-home])
(S-kp-right . [S-right])
(S-kp-left . [S-left])
(S-kp-next . [S-next])
(S-kp-down . [S-down])
(S-kp-end . [S-end])
(kp-delete . [4])
(delete . [4])
(backspace . [127])
(kp-insert . [insert])
(kp-begin . [begin])
(kp-end . [end])
(M-kp-next . [M-next])
(kp-next . [next])
(kp-prior . [prior])
(kp-down . [down])
(kp-right . [right])
(kp-up . [up])
(kp-left . [left])
(kp-home . [home])))))
We use A4 paper.
(setq ps-paper-type 'a4)
Sane yes-or-no-p
queries.
(defalias 'yes-or-no-p 'y-or-n-p)
Useful query-replace
shortcuts.
(defalias 'qr 'query-replace)
(defalias 'qrr 'query-replace-regexp)
Useful but disabled builtin functions.
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
Rebind execute-extended-command
.
(global-set-key (kbd "C-x C-m") #'execute-extended-command)
…with Shift.
(unless (boundp 'shift-select-mode)
(cua-selection-mode t))
(setq shift-select-mode t)
(delete-selection-mode t)
…with Command.
(global-set-key (kbd "<s-left>") #'move-beginning-of-line)
(global-set-key (kbd "<s-right>") #'move-end-of-line)
(global-set-key (kbd "<s-up>") #'beginning-of-buffer)
(global-set-key (kbd "<s-down>") #'end-of-buffer)
…with Control and Meta.
(global-set-key (kbd "<C-left>") #'backward-word)
(global-set-key (kbd "<C-right>") #'forward-word)
(global-set-key (kbd "<M-up>") #'backward-paragraph)
(global-set-key (kbd "<M-down>") #'forward-paragraph)
(global-set-key (kbd "M-p") #'backward-paragraph)
(global-set-key (kbd "M-n") #'forward-paragraph)
…in Lists.
(global-set-key (kbd "C-M-n") #'up-list)
(global-set-key (kbd "C-M-p") #'backward-down-list)
(global-set-key (kbd "C-M-u") #'backward-up-list)
(global-set-key (kbd "C-M-d") #'down-list)
Make backups.
(setq delete-by-moving-to-trash t)
(setq version-control t)
(setq kept-new-versions 10)
(setq kept-old-versions 2)
(setq delete-old-versions t)
(case system-type
(darwin (setq trash-directory (expand-file-name "~/.Trash"))))
And auto-save files.
(setq auto-save-default t)
(setq auto-save-visited-file-name nil)
But don’t auto-save messages.
(setq message-auto-save-directory nil)
Store backups under user-emacs-directory
.
(setq backup-directory-alist
(list (cons "." (expand-file-name "backup" user-emacs-directory))))
Keep a minibuffer history.
(setq history-length 1024)
(setq history-add-new-input t)
(setq history-delete-duplicates t)
(savehist-mode t)
Unicode!
(prefer-coding-system 'utf-8)
Saner default settings.
(setq-default comment-column 40)
(setq-default fill-column 72)
(setq-default major-mode 'text-mode)
(setq-default indent-tabs-mode nil)
(setq require-final-newline t)
(setq comment-auto-fill-only-comments t)
Display complete emacs-lisp result expressions.
(setq eval-expression-print-length nil)
Truncate lines in some buffers.
(defun do-truncate-lines ()
(setq truncate-lines t))
(defun dont-truncate-lines ()
(setq truncate-lines nil))
(add-hook 'dired-mode-hook 'do-truncate-lines)
(add-hook 'minibuffer-setup-hook 'dont-truncate-lines)
Rebind backward-kill-word
and kill-region
.
(global-set-key (kbd "C-w") 'backward-kill-word)
(global-set-key (kbd "C-x C-k") 'kill-region)
Rebind backward-kill-sexp
.
(global-set-key (kbd "<C-M-backspace>") #'backward-kill-sexp)
(global-set-key (kbd "<C-M-delete>") #'backward-kill-sexp)
Make kill-line
call delete-indentation
when sensible.
(defadvice kill-line (around kill-or-join-line activate)
"At EOL, `delete-indentation', otherwise `kill-line'."
(if (and (eolp) (not (bolp)))
(delete-indentation t)
ad-do-it))
Indent yanked text when sensible.
(defvar indent-region-modes '(emacs-lisp-mode
lisp-interaction-mode
lisp-mode
scheme-mode
clojure-mode
c-mode
c++-mode
objc-mode)
"List of modes that support smart indentation of the region.")
(defun indent-yanked-region ()
(when (member major-mode indent-region-modes)
(let* ((mark-even-if-inactive t))
(indent-region (region-beginning) (region-end)))))
(defadvice yank (after indent-region activate)
"Indent `yank'ed text if `major-mode' supports it."
(indent-yanked-region))
(defadvice yank-pop (after indent-region activate)
"Indent `yank'ed text if `major-mode' supports it."
(indent-yanked-region))
Configure text modes.
(add-hook 'text-mode-hook #'turn-on-visual-line-mode)
…conservatively.
(setq scroll-conservatively most-positive-fixnum)
(setq scroll-preserve-screen-position 'always)
…using the Keyboard.
(global-set-key (kbd "C-v") #'scroll-up)
(global-set-key (kbd "C-S-v") #'scroll-down)
…using the Mouse.
(when (featurep 'mouse)
(setq mouse-yank-at-point t)
(setq mouse-wheel-follow-mouse t)
(setq mouse-wheel-progressive-speed nil)
(setq mouse-avoidance-mode 'exile))
Highlight syntax.
(global-font-lock-mode t)
Highlight parens.
(show-paren-mode t)
(setq show-paren-style 'mixed)
Highlight the current line.
(global-hl-line-mode t)
(set-face-background 'hl-line "lightyellow")
Initial frame settings.
(aput 'initial-frame-alist 'top 88)
(aput 'initial-frame-alist 'left 128)
Default frame settings.
(aput 'default-frame-alist 'cursor-type 'bar)
(aput 'default-frame-alist 'cursor-color "black")
(aput 'default-frame-alist 'weight 80)
(aput 'default-frame-alist 'height 50)
Frame switching.
(global-set-key (ns-command-key ?`) #'next-multiframe-window)
(global-set-key (ns-command-key ?~) #'previous-multiframe-window)
Don’t pop up every new frame.
(setq ns-pop-up-frames nil)
Try to view-echo-area-messages
in view-mode
.
(defadvice view-echo-area-messages
(around view-echo-area-messages-view-mode activate)
(let ((undo-window (list (window-buffer) (window-start) (window-point))))
ad-do-it
(view-mode-enter (cons (selected-window) (cons nil undo-window)))))
Show some but not too much information in the modeline.
(setq column-number-mode t)
(setq line-number-mode t)
(setq size-indication-mode nil)
Don’t show any toolbars.
(when (functionp 'tool-bar-mode) (tool-bar-mode -1))
(when (functionp 'tabbar-mode) (tabbar-mode -1))
Don’t show a splash screen.
(setq inhibit-startup-screen t)
Ask before killing Emacs.
(setq confirm-kill-emacs 'kill-emacs-with-timeout)
Generate unified diffs.
(setq diff-switches "-u")
Use aspell
for spell-checking.
(setq ispell-program-name "aspell")
Set up load-path
so Emacs can find these libraries.
(when (load (expand-file-name "elpa/package" user-emacs-directory) 'noerror)
(package-initialize))
(load (expand-file-name "vendor/autoloads" user-emacs-directory) 'noerror)
(load (expand-file-name "site-lisp/autoloads" user-emacs-directory) 'noerror)
Customization of libraries that come with Emacs.
(setq bs-default-sort-name "by filename")
(global-set-key (kbd "C-x C-b") #'bs-show)
Uniquify buffer names sensibly.
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
(require 'uniquify)
(setq comint-prompt-read-only t)
(eval-after-load 'comint
'(add-hook 'comint-mode-hook 'ansi-color-for-comint-mode-on))
(eval-after-load 'shell
'(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on))
Configure eshell
.
(setq eshell-save-history-on-exit t)
(setq eshell-cmpl-cycle-completions nil)
(setq eshell-cmpl-ignore-case read-file-name-completion-ignore-case)
;; (global-set-key (kbd "C-x C-z") #'eshell)
Hook into eshell-mode
when it starts.
(defun mk/eshell-mode-hook ()
(pushnew 'eshell-handle-ansi-color eshell-output-filter-functions)
(define-key eshell-mode-map (kbd "M-m") #'eshell-bol)
(define-key eshell-mode-map (kbd "C-a") #'eshell-bol)
(define-key eshell-mode-map (kbd "<tab>") #'pcomplete-expand-and-complete))
(eval-after-load 'eshell '(add-hook 'eshell-mode-hook 'mk/eshell-mode-hook))
Configure dired
.
(require 'dired)
(setq dired-listing-switches "-alh")
(define-key dired-mode-map (kbd "-") #'dired-up-directory)
(define-key dired-mode-map (ns-command-key 'up) #'dired-up-directory)
(define-key dired-mode-map (ns-command-key 'down) #'dired-find-file)
(global-set-key (kbd "C-x C-d") #'dired)
Configure dired-x
.
(require 'dired-x)
(setq-default dired-omit-mode t)
(setq dired-omit-files (rx bos (| "#" ".")))
Open files with LaunchServices in dired
.
(defun dired-open-file (&optional arg)
"Open the marked (or next ARG) files with LaunchServices."
(interactive "P")
(dired-map-over-marks
(let ((file-name (dired-get-filename)))
(call-process "/usr/bin/open" nil 0 nil file-name))
arg))
(define-key dired-mode-map (ns-command-key 'shift 'o) #'dired-open-file)
Keep Ediff in a single frame.
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq send-mail-function 'smtpmail-send-it)
(setq smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
Activate SMerge in files with conflict markers.
(defun smerge-mode-maybe ()
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil 'noerror)
(smerge-mode t))))
(add-hook 'find-file-hook 'smerge-mode-maybe)
Make vc
work with symlinks.
(setq-default vc-follow-symlinks t)
(icomplete-mode t)
(setq ido-everywhere t)
(setq ido-enable-prefix t)
(setq ido-enable-flex-matching t)
(setq ido-create-new-buffer 'always)
(setq ido-use-filename-at-point nil)
(setq ido-use-url-at-point t)
(setq ido-save-directory-list-file
(expand-file-name ".ido.last" user-emacs-directory))
(defun isearch-goto-other-end ()
"Jump to the beginning of an `isearch' match after searching forward."
(when (and isearch-forward isearch-other-end)
(goto-char isearch-other-end)))
(global-set-key (kbd "C-s") #'isearch-forward)
(global-set-key (kbd "C-S-s") #'isearch-backward)
(global-set-key (kbd "C-M-s") #'isearch-forward-regexp)
(global-set-key (kbd "C-M-S-s") #'isearch-backward-regexp)
(define-key isearch-mode-map (kbd "C-s") #'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "C-S-s") #'isearch-repeat-backward)
(define-key isearch-mode-map (kbd "C-M-s") #'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "C-M-S-s") #'isearch-repeat-backward)
(add-hook 'isearch-mode-end-hook #'isearch-goto-other-end)
(setq hippie-expand-try-functions-list
'(try-expand-all-abbrevs
try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-complete-lisp-symbol-partially
try-complete-lisp-symbol
try-expand-whole-kill))
(global-set-key (kbd "M-/") #'hippie-expand)
(setq skeleton-pair t)
(dolist (char '(?\( ?\[ ?\{))
(global-set-key (string char) #'skeleton-pair-insert-maybe))
(dolist (char '(?\` ?\"))
(define-key text-mode-map (string char) #'skeleton-pair-insert-maybe))
(dolist (pair '((?\[ . ?\]) (?\{ . ?\})))
(global-set-key (vector (list 'meta (car pair))) #'insert-pair)
(global-set-key (vector (list 'meta (cdr pair))) #'up-list))
(defadvice delete-backward-char (before delete-empty-pair activate)
(when (and (char-before)
(char-after)
(eq (cadr (assq (char-before) insert-pair-alist)) (char-after)))
(delete-char 1)))
Make flymake
support available to additional major modes.
(defmacro* define-flymake-mode-init (mode &body body)
(declare (indent 1))
(let ((function-name (intern (format "flymake-mode-init/%s" mode)))
(regexps (mapcar #'car (remove* mode auto-mode-alist
:test-not 'eq :key 'cdr))))
`(progn (defun ,function-name () ,@body)
(eval-after-load 'flymake
'(dolist (mask (list ,@regexps))
(pushnew (list mask ',function-name)
flymake-allowed-file-name-masks))))))
Enable hs-minor-mode
in supported major modes.
(defun hs-minor-mode-maybe ()
"Turn on `hs-minor-mode' when `major-mode' supports it."
(require 'hideshow)
(when (assoc major-mode hs-special-modes-alist)
(hs-minor-mode +1)))
(defun enable-hs-minor-mode ()
"Turn on `hs-minor-mode'."
(hs-minor-mode +1))
(add-hook 'find-file-hook 'hs-minor-mode-maybe)
Display line counts when hiding code blocks.
(defun hs-display-code-line-counts (overlay)
(case (overlay-get overlay 'hs)
('code (let* ((beg (overlay-start overlay))
(end (overlay-end overlay))
(display (format "... (%d lines)" (count-lines beg end))))
(overlay-put overlay 'face 'font-lock-comment-face)
(overlay-put overlay 'display display)))))
(setq hs-set-up-overlay 'hs-display-code-line-counts)
Enable which-function-mode
.
(setq which-func-modes t)
(which-function-mode t)
Unify server buffers with “normal” buffers.
(defadvice save-buffers-kill-terminal
(around server-done-or-kill-terminal activate)
"If the current buffer has clients, kill those instead."
(unless (server-done)
ad-do-it))
(defadvice server-edit
(around server-edit-or-bury-buffer activate)
"If no server editing buffers exist, call `bury-buffer' instead."
(when ad-do-it
(bury-buffer)))
Bind server-edit
to nicer keys.
(global-set-key (kbd "C-x C-=") #'server-edit)
(global-set-key (kbd "C-x C-#") #'server-edit)
Start the server.
(server-start)
Customization of libraries separate from Emacs.
(when (require 'auto-complete-config nil 'noerror)
(ac-config-default))
(when (functionp 'auto-dictionary-mode)
(unless (functionp 'auto-dictionary-enable)
(defun auto-dictionary-enable ()
(auto-dictionary-mode +1)))
(add-hook 'flyspell-mode-hook 'auto-dictionary-enable))
(setq browse-kill-ring-highlight-current-entry t)
(setq browse-kill-ring-highlight-inserted-item t)
(setq browse-kill-ring-display-duplicates nil)
(setq browse-kill-ring-no-duplicates t)
(when (functionp 'browse-kill-ring-default-keybindings)
(browse-kill-ring-default-keybindings))
(when (functionp 'compilation-recenter-end-enable)
(add-hook 'compilation-mode-hook 'compilation-recenter-end-enable))
(require 'dirvars nil 'noerror)
(setq drag-stuff-modifier '(control meta))
(when (require 'drag-stuff nil 'noerror)
(drag-stuff-global-mode t))
(global-set-key [(control x) (control a)] #'eshell-toggle)
(when (functionp 'folding-install-hooks)
(folding-install-hooks))
(require 'fscroll nil 'noerror)
(setq gist-view-gist t)
(global-set-key [(control x) (g)] #'gitsum)
(when (functionp 'highlight-symbol-mode)
(setq highlight-symbol-on-navigation-p t)
(global-set-key (kbd "C-*") #'highlight-symbol-next)
(global-set-key (kbd "C-#") #'highlight-symbol-prev))
(global-set-key (kbd "C-;") #'iedit-mode)
(when (functionp 'igrep-insinuate)
(igrep-insinuate))
(when (functionp 'indent-tabs-maybe)
(add-hook 'find-file-hook 'indent-tabs-maybe))
(global-set-key [(control x) (shift g)] #'magit-status)
(global-set-key (kbd "C-x C-n") #'nav)
(when (require 'redo nil 'noerror)
(global-set-key (ns-command-key 'z) #'undo)
(global-set-key (ns-command-key 'Z) #'redo)
(global-set-key (kbd "C-z") #'zap-to-char))
(setq smart-tab-using-hippie-expand t)
(setq sudoku-download-method "native-url-lib")
(setq sudoku-level "medium")
Load additional snippets.
(defun init/setup-yasnippet-snippets-dir ()
(let ((snippets-dir (expand-file-name "snippets" user-emacs-directory)))
(when (file-directory-p snippets-dir)
(yas/load-directory snippets-dir))))
Configure Hippie-Exp to use Yasnippet.
(defun init/setup-yasnippet-hippie-expand ()
(eval-after-load 'hippie-exp
'(add-to-list 'hippie-expand-try-functions-list 'yas/hippie-try-expand)))
Configure Yasnippet.
(setq yas/use-menu 'abbreviate)
(when (functionp 'yas/global-mode)
(init/setup-yasnippet-snippets-dir)
;; (init/setup-yasnippet-hippie-expand)
(yas/global-mode t))
Fix Yasnippet in modes locally overriding its trigger key.
(defun yas/fix-trigger-key ()
"Ensure `yasnippet' works in spite of overriding local bindings."
(when (featurep 'yasnippet)
(let ((local-func (local-key-binding (read-kbd-macro yas/trigger-key))))
(when (and yas/minor-mode local-func)
(setq yas/fallback-behavior (list 'apply local-func))
(local-unset-key (read-kbd-macro yas/trigger-key))))))
Enable edit-server
for the Edit with Emacs Chrome extension.
(when (require 'edit-server nil 'noerror)
(edit-server-start))
(when (functionp 'diminish)
(dolist* ((mode sources)
'((eldoc-mode (eldoc))
(hs-minor-mode (hideshow))
(visual-line-mode (simple))
(paredit-mode (paredit paredit-21))
(auto-complete-mode (auto-complete))
(drag-stuff-mode (drag-stuff))
(highlight-parentheses-mode (highlight-parentheses))
(highlight-symbol-mode (highlight-symbol))
(highlight-80+-mode (highlight-80+))
(smart-tab-mode (smart-tab))
(yas/minor-mode (yasnippet yasnippet-bundle))
(autopair-mode (autopair))
))
(dolist (from sources)
(eval-after-load from
`(diminish ',mode)))))
(when (functionp 'color-theme-initialize)
(color-theme-initialize)
(let ((theme 'color-theme-quiet-light))
(when (functionp theme)
(funcall theme))))