This is mostly copied from here: http://writequit.org/org/settings.html
This file is used by org-mode to load my personal emacs configuration file. The latest version of this file is always at [[https://github.com/cbilson/.emacs]]. Keep in mind that to use it you will probably have to install a number of packages. Here’s my list of packages: [[https://github.com/cbilson/.emacs/blob/master/packages.el]].
This file was last exported: {{{time(%Y-%m-%d %H:%M)}}}
Put the following in your .emacs.d/init.el:
;; Use this is your .emacs, in your home or start emacs with the below as the
;; startup file.
;; Keep track of loading time
(defconst emacs-start-time (current-time))
(require 'package)
(with-no-warnings (require 'cl))
(setq package-enable-at-startup nil)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package)
(with-no-warnings (require 'cl)))
;; figure out where my stuff is
(defvar cbilson/one-drive
(let* ((candidates
(mapcar #'substitute-in-file-name
'("$HOME\\OneDrive"
"$HOME\\SkyDrive"
"$HOME\\..\\..\\OneDrive"
"$HOME\\..\\..\\SkyDrive"
"/mnt/c/Users/cbilson/OneDrive"))))
(file-name-as-directory
(find-if #'file-exists-p candidates))))
(defvar cbilson/emacs-dir
(file-name-as-directory (concat cbilson/one-drive "Emacs")))
(defvar cbilson/backups-dir (concat user-emacs-directory "backups"))
(defvar cbilson/org-dir
(file-name-as-directory (concat cbilson/one-drive "Documents/org")))
(defvar cbilson/lisp-dir
(file-name-as-directory (concat cbilson/emacs-dir "site-lisp")))
(add-to-list 'load-path cbilson/lisp-dir)
(defvar cbilson/tools-dir
(file-name-as-directory (concat cbilson/one-drive "Tools")))
(defvar cbilson/custom-settings (concat user-emacs-directory "custom-init.el"))
(defun cbilson/reload-settings ()
(interactive)
(message "Regenerating custom-init.el...")
(require 'org)
(org-babel-tangle-file (expand-file-name "settings.org" cbilson/emacs-dir) "custom-init.el")
(rename-file (expand-file-name "custom-init.el" cbilson/emacs-dir) cbilson/custom-settings t)
(message "byte compiling %s..." cbilson/custom-settings)
(byte-compile-file user-init-file t))
;; if settings.org has changed, regenerate custom-init.el
(when (or
(not (file-exists-p cbilson/custom-settings))
(time-less-p
(nth 5 (file-attributes cbilson/custom-settings))
(nth 5 (file-attributes (expand-file-name "settings.org" cbilson/emacs-dir)))))
(cbilson/reload-settings))
(when (file-exists-p cbilson/custom-settings)
(load cbilson/custom-settings))
;; Message how long it took to load everything (minus packages)
(let ((elapsed (float-time (time-subtract (current-time)
emacs-start-time))))
(message "Loading settings...done (%.3fs)" elapsed))
Run the following .reg file to get “Edit in Emacs” for files and folders in Explorer.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\openwemacs] @=”&Edit with Emacs”
[HKEY_CLASSES_ROOT\*\shell\openwemacs\command] @=”C:\ProgramData\Chocolatey\bin\emacsclient.exe -n "%1" –alternate-editor"notepad" –quiet”
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs] @=”Edit &with Emacs”
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs\command] @=”C:\ProgramData\Chocolatey\bin\emacsclient.exe -n "%1" –alternate-editor"notepad" –quiet”
Emacs - Error when calling (server-start)
(when (eq window-system 'w32)
(set-file-modes (expand-file-name "~/.emacs.d/server") #o700))
$serverFolder = Join-Path $env:HOME ".emacs.d\server"
$acl = Get-Acl $serverFolder
$owner = New-Object System.Security.Principal.NTAccount('[email protected]')
$acl.SetOwner($owner)
Set-Acl $serverFolder $acl
(defvar cbilson/omnisharp-path
(file-name-as-directory
(concat cbilson/emacs-dir "OmnisharpServer")))
(defvar cbilson/high-dpi nil)
(setq cbilson/high-dpi
(pcase system-name
("CBILSON-LAPTOP" t)
("CBILSON-LAPTOP3" t)
("CBILSON-DEVVM" t)
("MAKO" t)
(_ nil)))
(defvar cbilson/java-home nil)
(defvar cbilson/java-cmd nil)
(defvar cbilson/graphviz-dot nil)
(defvar cbilson/default-font nil)
(defvar cbilson/base-font-height nil)
(defun cbilson/cleanup-buffer ()
(interactive)
(delete-trailing-whitespace)
(untabify (point-min) (point-max))
(indent-region (point-min) (point-max)))
(defun cbilson/clojure-mode-eldoc-hook ()
(add-hook 'clojure-mode-hook 'turn-on-eldoc-mode))
(defun cbilson/kill-word-key ()
(local-set-key (kbd "C-M-h") 'backward-kill-word))
(defun cbilson/install-packages (packages)
(dolist (p packages)
(when (not (package-installed-p p))
(unwind-protect
(condition-case ex
(package-install p)
('error
(message (format "Failed to install package %s: %s"
p
ex))))))))
;; Duplicate start of line or region,
;; from http://www.emacswiki.org/emacs/DuplicateStartOfLineOrRegion
(defun cbilson/duplicate-start-of-line ()
(if (bolp)
(progn
(end-of-line)
(duplicate-start-of-line)
(beginning-of-line))
(let ((text (buffer-substring (point)
(beginning-of-thing 'line))))
(forward-line)
(push-mark)
(insert text)
(open-line 1))))
(defun cbilson/duplicate-region ()
(let* ((end (region-end))
(text (buffer-substring (region-beginning) end)))
(goto-char end)
(insert text)
(push-mark end)
(setq deactivate-mark nil)
(exchange-point-and-mark)))
(defun cbilson/duplicate-start-of-line-or-region ()
(interactive)
(if mark-active
(cbilson/duplicate-region)
(cbilson/duplicate-start-of-line)))
(defun cbilson/recentf-ido-find-file ()
"Find a recent file using ido."
(interactive)
(let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
(when file
(find-file file))))
(defun cbilson/rename-current-buffer-file ()
"Renames current buffer and file it is visiting."
(interactive)
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name (read-file-name "New name: " filename)))
(if (get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name)
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(message "File '%s' successfully renamed to '%s'"
name (file-name-nondirectory new-name)))))))
(defun cbilson/first-existing-file (files)
(let ((candidates (mapcar #'substitute-in-file-name files)))
(find-if #'file-exists-p candidates)))
(defun cbilson/first-existing-dir (files)
(let ((candidates (mapcar #'substitute-in-file-name files)))
(file-name-as-directory
(find-if #'file-exists-p candidates))))
(defun cbilson/join-line-back ()
(interactive)
(join-line -1))
(defun cbilson/next-line-more ()
(interactive)
(ignore-errors (forward-line 5)))
(defun cbilson/previous-line-more ()
(interactive)
(ignore-errors (forward-line -5)))
(defun cbilson/buildreq-quick ()
(interactive)
(async-shell-command "buildreq -q"))
;; (setq custom-theme-directory (concat cbilson/emacs-dir "themes"))
;; (add-to-list 'load-path (concat cbilson/emacs-dir "themes"))
;; (require 'birds-of-paradise-plus-theme)
;; (load-theme birds-of-paradise-plus t)
;; or: smyx-theme, darktooth-theme, material-theme,
;; anti-zenburn-theme, afternoon-theme
;; (use-package afternoon-theme
;; :if window-system)
(use-package flatui-theme
:if window-system)
(use-package powerline
:config
(powerline-center-theme))
(use-package doom-themes)
(set-cursor-color "darkorange")
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(blink-cursor-mode 1)
(set-cursor-color "darkorange")
(defalias 'yes-or-no-p 'y-or-n-p)
(setq-default inhibit-splash-screen t
initial-scratch-message nil
scroll-step 1
insert-tabs-mode nil
visible-bell t
use-dialog-box nil
cursor-type 'box)
(set-cursor-color "#ffffff")
(setq user-full-name "Chris Bilson")
(setq user-mail-address "[email protected]")
I like having backups, just not in the directory I am working in.
(setq backup-by-copying t
backup-directory-alist
`((".*" . ,(file-name-as-directory cbilson/backups-dir)))
auto-save-file-name-transform
`((".*" ,(file-name-as-directory cbilson/backups-dir) t))
create-lock-files nil
version-control t
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
make-backup-files t)
(setq savehist-file (concat user-emacs-directory "savehist")
history-length t
history-delete-duplicates t
savehist-save-minibuffer-history 1)
(savehist-mode t)
- No tabs, 2-spaces, by default, show column numbers, show
whitespace, no lock files.
(setq c-basic-offset 4 column-number-mode t indent-tabs-mode nil tab-width 4 tab-stop-list (number-sequence 4 120 4) show-trailing-whitespace t global-whitespace-mode t create-lockfiles nil)
- Indicate empty lines, kind of like how vim does, with a symbol
on the left fringe.
(setq indicate-empty-lines t)
- Make sure files have final newline characters when saved.
(setq require-final-newline t)
Make apropos commands search more extensively.
(setq apropos-do-all t)
Echo unfinished commands after 0.1 seconds of pause.
(setq echo-keystrokes 0.1)
Save clipboard strings into kill ring before replacing them. When one selects something in another program to paste it into Emacs, but kills something in Emacs before actually pasting it, this selection is gone unless this variable is non-nil, in which tcase the other program’s selection is saved in the `kill-ring’ before the Emacs kill and one can still paste it using <S-insertchar> M-x yank-pop.
(setq save-interprogram-paste-before-kill t)
(setq
;; I want scratch buffers to be in org-mode
initial-scratch-message nil
initial-major-mode 'org-mode)
(setq use-package-always-ensure t)
- Suppress warning about undo for large files
(add-to-list 'warning-suppress-log-types '(undo discard-info))
(setq whitespace-style '(face trailing lines-tail tabs)
x-select-enable-clipboard t
x-select-enable-primary t)
;; auto-revert
(global-auto-revert-mode +1)
(setq global-auto-revert-non-file-buffers +1
auto-revert-verbose nil)
(setq-default ispell-program-name "aspell" )
(semantic-mode 1)
(add-to-list 'safe-local-variable-values
'((c-set-offset . 2)
(c-set-offset . 4)
(c-basic-offset . 2)
(c-basic-offset . 4)))
When there is a window-system set:
- Use the buffer file name for the window title.
- Make mouse yank commands yank at point, not where the click happened.
- Try to whatever my current favorite GUI theme is.
(when window-system (setq frame-title-format '(buffer-file-name "%f" ("%b")) mouse-yank-at-point t ;; mouse-wheel-scroll-amount '(1 ((shift) . 1)) ;; mouse-wheel-progressive-speed nil ;; mouse-wheel-follow-mouse t ) ;; (when (member cbilson/theme (custom-available-themes)) ;; (load-theme cbilson/theme t)) ;; Fonts ;;(set-face-attribute 'default nil ...) ;; (set-face-attribute 'minibuffer-prompt nil :slant 'oblique) ;; (set-face-attribute 'mode-line nil ;; :foreground "cornsilk" ;; :background "grey30" ;; :slant 'normal ;; :weight 'bold) )
On my high-DPI laptop, I had to:
- Change emacs 24.4 to legacy mode, as described in this SO post.
- Bump up the font size
But now it looks great.
(when (eq window-system 'w32) ;; Chocolatey (defvar cbilson/chocolatey-path (file-name-as-directory (getenv "ChocolateyInstall")) "Path to chocolatey.") (defvar cbilson/chocolatey-bin-path (file-name-as-directory (concat cbilson/chocolatey-path "bin")) "Path to chocolatey bin.") (let* ((graphviz-bin (file-name-as-directory (concat cbilson/tools-dir "graphviz/bin")))) (setenv "GRAPHVIZ_DOT" (concat graphviz-bin "dot.exe"))) (setq cbilson/theme 'darktooth) (setq browse-url-browser-function 'browse-url-default-windows-browser delete-by-moving-to-trash t ispell-personal-dictionary "~/.ispell" projectile-enable-cachinge t) ;; lisp (eval-after-load 'lisp-mode '(progn (when (file-exists-p "~/quicklisp/slime-helper.el") (load "~/quicklisp/slime-helper.el")))) (setq inferior-lisp-program (substitute-in-file-name "$Tools\\sbcl\\sbcl.exe")) (setq slime-lisp-implementations (list (list 'sbcl (list (substitute-in-file-name "$Tools\\sbcl\\sbcl.exe")))) slime-auto-connect 'ask) (setq with-editor-emacsclient-executable (substitute-in-file-name "$Tools\\emacs-25.1.1\\bin\\emacsclient.exe")) ;; java (setq cbilson/java-home (let* ((candidates (mapcar #'substitute-in-file-name '("$ProgramW6432\\Zulu\\zulu-8" "$ProgramW6432\\Java\\JRE" "$Tools\\zulu1.8.0_66-8.11.0.1-win64"))) (java-dir (find-if #'file-exists-p candidates))) (when java-dir (file-name-as-directory (find-if #'file-exists-p candidates))))) (let ((java-bin (file-name-as-directory (concat cbilson/java-home "bin")))) (setenv "PATH" (concat java-bin ";" (getenv "PATH"))) (setq cbilson/java-cmd (concat java-bin "java.exe"))) (setq w32-pass-apps-to-system nil) (setq w32-apps-modifier 'hyper) (defun cbilson/reset-font-size (base-size) (interactive) (setq cbilson/base-font-height base-size) (set-face-attribute 'default nil :font cbilson/default-font :height cbilson/base-font-height) (set-face-attribute 'minibuffer-prompt nil :font cbilson/default-font :height (+ cbilson/base-font-height 20)) (set-face-attribute 'mode-line nil :font cbilson/default-font :height (- cbilson/base-font-height 20)) (set-face-attribute 'mode-line-inactive nil :font cbilson/default-font :height cbilson/base-font-height) ) (setq cbilson/default-font (cond ((member "Source Code Pro Semibold" (font-family-list)) "Source Code Pro Semibold") (t "Consolas"))) ;;(setq cbilson/default-font "InputSansNarrow") ;;(setq cbilson/default-font "Source Code Pro Semibold") ;;(cbilson/reset-font-size 60) ;; Fonts (cbilson/reset-font-size (pcase system-name ("CBILSON-LAPTOP" 100) ("CBILSON-LAPTOP3" 120) ("CBILSON-VM1" 120) ("MAKO" 100) (_ 120))) ;; (cbilson/reset-font-size 150) )
(setenv "JAVA_HOME" cbilson/java-home)
(setenv "JAVA_CMD" cbilson/java-cmd)
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "M-;") 'comment-dwim)
(global-set-key (kbd "M-j") 'cbilson/join-line-back)
(global-set-key (kbd "C-S-n") 'cbilson/next-line-more)
(global-set-key (kbd "C-S-p") 'cbilson/previous-line-more)
(global-set-key (kbd "C-x C-m") 'shell)
(global-set-key (kbd "C-x C-i") 'imenu)
(global-set-key (kbd "C-x C-j") 'dired-jump)
(global-set-key (kbd "C-x C-r") 'helm-recentf)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)
(global-set-key (kbd "C-c d") 'cbilson/duplicate-start-of-line-or-region)
(global-set-key (kbd "C-c f") 'find-file-in-project)
(global-set-key (kbd "C-c g") 'magit-status)
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c n") 'cbilson/cleanup-buffer)
(global-set-key (kbd "C-c y") 'bury-buffer)
(global-set-key (kbd "C-c C-k") 'compile)
(global-set-key (kbd "C-c C-r") 'revert-buffer)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
;; conflicts with sp-mark-defun
;; (global-set-key (kbd "C-M-h") 'backward-kill-word)
(global-set-key (kbd "C-M-x") 'eval-defun)
(global-set-key (kbd "H-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "H-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "H-<up>") 'enlarge-window)
(global-set-key (kbd "H-<down>") 'shrink-window)
Emacs kaizen: ace-isearch combines ace-jump-mode and helm-swoop
(use-package helm-swoop)
(use-package ace-isearch)
(use-package ace-jump-mode)
(use-package ace-jump-buffer)
(use-package ace-window)
;; (use-package acutex)
(use-package ag
:init (setq ag-executable
(cbilson/first-existing-file
(list (concat cbilson/tools-dir "ag.exe")
"/usr/local/bin/ag"))))
Currently disabled - all this gets dumped into custom-init.el, and the setup docs for auto-compile mention specifically disabling compilation of the file that has this stuff in it.
(use-package auto-compile
:disabled t
:init
(setq load-prefer-newer t)
(auto-compile-on-load-mode)
(auto-compile-on-save-mode))
(use-package avy
:bind
("C-:" . avy-goto-char)
("C-\"" . avy-goto-char-2)
("M-g g" . avy-goto-line)
("M-g w" . avy-goto-word-1)
("M-g e" . avy-goto-word-2))
(use-package browse-kill-ring)
(eval-after-load 'c-mode
(progn '(define-key c-mode-map (kbd "C-c C-k") 'compile)))
(use-package cider
:config
(add-hook 'cider-connected-hook 'cbilson/clojure-mode-eldoc-hook)
(if (package-installed-p 'smartparens)
(require 'smartparens))
(if (package-installed-p 'paren-face)
(paren-face-mode)))
- What’s boot?
Key | Function |
---|---|
C-c C-d | cider-doc-map |
M-. | cider-jump-to-var |
M-, | cider-jump-back |
C-c M-. | cider-jump-to-resource |
C-c TAB | complete-symbol |
C-M-x | cider-eval-defun-at-point |
C-c C-c | cider-eval-defun-at-point |
C-x C-e | cider-eval-last-sexp |
C-c C-e | cider-eval-last-sexp |
C-c C-w | cider-eval-last-sexp-and-replace |
C-c M-e | cider-eval-last-sexp-to-repl |
C-c M-p | cider-insert-last-sexp-in-repl |
C-c C-p | cider-pprint-eval-last-sexp |
C-c C-f | cider-pprint-eval-defun-at-point |
C-c C-r | cider-eval-region |
C-c C-n | cider-eval-ns-form |
C-c M-: | cider-read-and-eval |
C-c C-u | cider-undef |
C-c C-m | cider-macroexpand-1 |
C-c M-m | cider-macroexpand-all |
C-c M-n | cider-repl-set-ns |
C-c M-i | cider-inspect |
C-c M-t v | cider-toggle-trace-var |
C-c M-t n | cider-toggle-trace-ns |
C-c C-z | cider-switch-to-repl-buffer |
C-c M-o | cider-find-and-clear-repl-buffer |
C-c C-k | cider-load-buffer |
C-c C-l | cider-load-file |
C-c C-b | cider-interrupt |
C-c , | cider-test-run-tests |
C-c C-, | cider-test-rerun-tests |
C-c M-, | cider-test-run-test |
C-c C-t | cider-test-show-report |
C-c M-s | cider-selector |
C-c M-r | cider-rotate-connection |
C-c M-d | cider-display-current-connection-info |
C-c C-x | cider-refresh |
(use-package clojure-mode)
(use-package cider
:bind
("C-c C-j" . cider-jack-in)
("C-c TAB" . complete-symbol)
:init
(setq cider-lein-command (expand-file-name "~/.lein/lein.bat")))
(use-package cmd-mode
:disabled t
:load-path (lambda () (list (concat cbilson/lisp-dir "cmd")))
:mode "\\.bat$" "\\.cmd$"
:pin manual)
- Hiding compilation buffer
- I got tired of this, since it hides other buffers like ag, and I
usually end up wanting to see compilation buffers anyway.
;; don't prompt for compilation command unless prefixed (setq compilation-read-command nil) ;; hide compilation buffer unless error (defadvice compilation-start (around inhibit-display (command &optional mode name-function highlight-regexp)) (if (not (string-match "^\\(find\\|grep\\)" command)) (cl-flet ((display-buffer) (set-window-point) (goto-char)) (fset 'display-buffer 'ignore) (fset 'goto-char 'ignore) (fset 'set-window-point 'ignore) (save-window-excursion ad-do-it)) ad-do-it)) ;;(ad-activate 'compilation-start) ;;(ad-deactivate 'compilation-start)
- I got tired of this, since it hides other buffers like ag, and I
usually end up wanting to see compilation buffers anyway.
(use-package csharp-mode
:mode "\\.cs$" "\\.csx$"
:init
(c-add-style "Microsoft C#"
'("C#"
(c-basic-offset . 4)
(c-tab-always-indent . 'no-tabs)
(indent-tab . nil)
(indent-tabs-mode . nil)
(c-offsets-alist .
((arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-cont . c-lineup-arglist)))))
(defun cbilson/csharp-mode-hook ()
(interactive)
(setq c-default-style "Microsoft C#")
(setq indent-tabs-mode nil))
(add-hook 'csharp-mode-hook 'cbilson/csharp-mode-hook))
(use-package csv-mode
:disabled t)
(use-package ctags
:disabled t
:config
(setq path-to-ctags "G:\\bin\\ctags.exe"))
(use-package dash)
When Delete Selection mode is enabled, typed text replaces the selection if the selection is active. Otherwise, typed text is just inserted at point regardless of any selection.
(delete-selection-mode +1)
(use-package dired-details)
(use-package dired+)
easy-kill is a drop-in replacement for kill-ring-save.
M-w serves as both a command and a prefix key for other commands. M-w alone saves in the order of active region, url, email and finally current line (See easy-kill-try-things). As a prefix key:
M-w w | save word at point |
M-w s | save sexp at point |
M-w l | save list at point (enclosing sexp) |
M-w d | save defun at point |
M-w D | save current defun name |
M-w f | save file at point |
M-w b | save buffer-file-name or default-directory. - changes the kill to the directory name, + to full name and 0 to basename. |
The following keys modify the selection:
@ | append selection to previous kill and exit. For example, M-w d @ will append current function to last kill. |
C-w | kill selection and exit |
+, - and 1..9 | expand/shrink selection |
0 | shrink the selection to the intitial size i.e. before any expansion |
C-SPC | turn selection into an active region |
C-g | abort |
? | help |
For example, M-w w saves current word, repeat w to expand the kill to include the next word. 5 to include the next 5 words etc. The other commands also follow this pattern.
+/- does expanding/shrinking according to the thing selected. So for word the expansion is word-wise, for line line-wise, for list or sexp, list-wise.
list-wise expanding/shrinking work well in lispy modes (elisp, Common Lisp, Scheme, Clojure etc.), smie-based modes (Prolog, SML, Modula2, Shell, Ruby, Octave, CSS, SQL etc.), Org mode, Nxml mode and Js2 mode.
To copy the enclosing list in lispy modes, I used to do a lot of C-M-u C-M-SPC M-w. Now the key sequence is replaced by M-w l (save list at point)
(use-package easy-kill
:init
(global-set-key [remap kill-ring-save] 'easy-kill)
(global-set-key [remap mark-sexp] 'easy-mark))
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.
Current Emacs plugin coverage for EditorConfig’s properties:
Setting | Supported? |
---|---|
indent_style | |
indent_size | |
tab_width | |
end_of_line | |
charset | not supported |
trim_trailing_whitespace | |
insert_final_newline | “=false” not supported+ |
max_line_length | |
root (only used by EditorConfig core) |
- (as in trailing newlines actually being removed automagically),
we just buffer-locally override any preferences that would
auto-add them to files .editorconfig marks as
trailing-newline-free
Not yet covered properties marked with over-strike – pull requests implementing missing features warmly welcomed! Typically, you will want to tie these to native functionality, or the configuration of existing packages handling the feature.
You also need an executable to use editorconfig. On windows, I installed it with chocolatey, `choco install editorconfig.core’. This creates an exe under lib, and a batch file under %ChocolateyInstall%.
(use-package editorconfig
:disabled
:config
(setq edconf-exec-path
(let ((editorconfig (substitute-in-file-name
"$ChocolateyInstall/bin/editorconfig")))
(if (file-exists-p (concat editorconfig ".exe"))
(concat editorconfig ".exe")
(concat editorconfig ".bat"))))
(add-to-list 'edconf-indentation-alist '(csharp-mode c-basic-offset)))
root = true
[*] end_of_line = lf insert_final_newline = true
[*.{js,py}] charset = utf-8
[*.py] indent_style = space indent_size = 4
[*.js] indent_style = tab
[lib/**.js] indent_style = space indent_size = 2
[{package.json,.travis.yml}] indent_style = space indent_size = 2
(use-package elisp-slime-nav
:ensure t
:commands (elisp-slime-name-mode)
:init
(add-hook 'emacs-lisp-mode-hook 'elisp-slime-nav-mode))
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(define-key emacs-lisp-mode-map "C-c v" 'eval-buffer)
(use-package emmet-mode)
(use-package eshell
:bind ("C-c t" . eshell)
:init
(defun eshell/rgrep (&rest args)
"Use Emacs grep facility instead of calling external grep."
(eshell-grep "rgrep" args t))
(defun eshell/cdg ()
"Change directory to the project's root."
(eshell/cd (locate-dominating-file default-directory ".git"))))
(use-package expand-region
:bind ("C-=" . er/expand-region))
(use-package feature-mode)
(use-package find-file-in-project)
Use the flx matching engine with ido. flx is the thing that enables matching like reshaper (“_A_thing_B_whatever” matched by “AB”) along with even more powerful matching.
(use-package flx
:init
(use-package flx-ido)
:config
(flx-ido-mode 1)
(setq ido-enable-flex-matching t
ido-use-faces nil))
(use-package flymake)
(use-package fsharp-mode)
(use-package gist)
(use-package gitconfig :ensure t)
(use-package gitignore-mode)
(use-package git-timemachine)
(use-package go-mode)
(use-package helm)
(use-package helm-ag)
(use-package helm-projectile)
(use-package helm-org-rifle)
(use-package helm-swoop)
(use-package helm
:diminish helm-mode
:config
(require 'helm-ag)
(require 'helm-config)
(require 'helm-projectile)
(helm-autoresize-mode 1)
(setq recentf-max-saved-items 500)
(setq helm-ag-base-command
(format "%s %s"
ag-executable
"--vimgrep"
;; (if (helm-ag--windows-p)
;; "--vimgrep"
;; "--nocolor --nogroup")
))
(setq helm-ff-file-name-history-use-recentf nil
helm-ff-search-library-in-sexp t
helm-ff-guess-ffap-filenames t
helm-mode-fuzzy-match t
helm-move-to-line-cycle-in-source t
helm-scroll-amount 8
helm-semantic-fuzzy-match t
projectile-completion-system 'helm
;; helm-boring-file-regexp-list '(".o$" ...)
)
:bind
("M-x" . helm-M-x)
("M-C-h" . backward-kill-word)
("M-y" . helm-show-kill-ring)
("C-x C-f" . helm-find-files)
("C-x C-b" . helm-buffers-list)
("C-c h o" . helm-occur)
("C-c h a" . helm-apropos)
("C-c h h i" . helm-info-at-point)
("C-c h h r" . helm-info-emacs)
("C-c h x" . helm-register))
(use-package helm-descbinds
:defer t
:bind
("C-c b" . helm-descbinds))
(helm-mode +1)
(add-to-list 'auto-mode-alist '("\\.aspx$" . html-mode))
(add-to-list 'auto-mode-alist '("\\.asax$" . html-mode))
(add-to-list 'auto-mode-alist '("\\.asmx$" . html-mode))
(add-to-list 'auto-mode-alist '("\\.cshtml$" . html-mode))
(add-to-list 'auto-mode-alist '("\\.spark$" . html-mode))
(use-package htmlize)
TODO: Maybe not needed anymore?
(use-package ido
:config
(use-package ido-completing-read)
:init
(setq ido-enable-flex-matching t))
;;(use-package idle-highlight)
(use-package iedit
:demand
:bind
("C-c ;" . iedit-mode)
("C-c C-;" . iedit-mode-from-isearch))
(use-package ispell
:ensure flyspell
:config
(setq
aspell-dir (file-name-as-directory (concat cbilson/emacs-dir "aspell"))
aspell-bin-dir (file-name-as-directory (concat aspell-dir "bin"))
ispell-program-name (concat aspell-bin-dir "aspell.exe")
ispell-aspell-data-dir (file-name-as-directory (concat aspell-dir "data"))
ispell-aspell-dict-dir (file-name-as-directory (concat aspell-dir "dict")))
(add-to-list 'ispell-local-dictionary-alist
'("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']"
nil
("-B")
nil iso-8859-1)))
(use-package js-comint)
(use-package kurecolor)
loccur lets you quickly see occurrences of a word in the current buffer.
(use-package loccur
:bind ("C-o" . loccur-current))
(use-package magit
:init
(setq magit-last-seen-setup-instructions "1.4.0"
magit-git-executable (substitute-in-file-name "$Tools\\PortableGit\\bin\\git.exe")))
(file-exists-p magit-git-executable)
(use-package markdown-mode
:init
(add-hook 'markdown-mode-hook 'writegood-mode))
(use-package multiple-cursors
:bind
("C-S-c a" . mc/edit-beginnings-of-lines)
("C-S-c c" . mc/add-cursor-on-click)
("C-S-c e" . mc/edit-ends-of-lines)
("C-S-c f" . mc/mark-all-like-this-in-defun)
("C-S-c C-S-c" . mc/edit-lines)
("C-S-c d" . mc/mark-all-dwim))
;; (use-package omnisharp
;; :config
;; (add-hook 'csharp-mode-hook 'omnisharp-mode)
;; :init
;; (setq omnisharp--curl-executable-path
;; (if (eq window-system 'w32)
;; (concat cbilson/tools-dir "curl.exe")
;; "curl")
;; omnisharp-eldoc-support t
;; omnisharp-server-executable-path
;; (concat cbilson/omnisharp-path "OmniSharp.exe")))
- C-c C-j: org-goto
- C-c r: org-refile
- Learn how to take notes more efficiently in Org Mode
- Org-Hacks
(use-package ob-http) (use-package org :bind ("C-c C-j" . org-goto) ;; ("C-c C-w" . org-refile) :config (unbind-key "C-c ;" org-mode-map) (unbind-key "C-c C-r" org-mode-map) (unbind-key "C-c r" org-mode-map) (require 'ob) (require 'ob-clojure) ;; (require 'ob-ipython) (add-hook 'org-mode-hook 'flyspell-mode) (add-hook 'org-mode-hook 'auto-fill-mode) (add-hook 'org-mode-hook 'writegood-mode) (add-hook 'org-mode-hook 'abbrev-mode) (set-register ?o (cons 'file (concat cbilson/org-dir "Capture.org"))) (add-hook 'org-agenda-finalize-hook (lambda () (delete-other-windows) (hl-line-mode))) ;; Agenda, notes (setq org-agenda-show-log t ;; org-archive-location "::* Archive" org-default-notes-file (concat cbilson/org-dir "Capture.org") org-refile-targets '((org-agenda-files . (:maxlevel . 3))) org-todo-keywords '((sequence "BACKLOG" "TODO" "WIP" "BLOCKED" "|" "DONE" "DELEGATED" "CANCELLED")) ;;org-todo-keyword-faces ;;'(("WIP" . (:foreground "light-blue" :weight bold))) ;; use helm for completion org-completion-use-ido nil org-outline-path-complete-in-steps nil ) ;; capture (setq org-capture-templates '(("c" "Chinese" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* %? :chinese:\n %i\n") ("h" "Hindi" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* %? :hindi:\n %i\n") ("I" "Incident" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* RDIncident %? :incident:\nEntered on %U\n %i") ("i" "Interesting" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* %? :interesting:\n %i\n %a") ("k" "Knowledge Base" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* KB %? :kb:\n %i\n %a") ("l" "Log" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* %? :log:\nEntered: %U\n %i\n %a") ("m" "Meeting" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* Meeting %? :meeting:\nEntered: %U\n %i\n %a") ("t" "TODO" entry (file+datetree (concat cbilson/org-dir "Capture.org")) "* BACKLOG %?\nEntered: %U\n %i\n %a"))) (org-babel-do-load-languages 'org-babel-load-languages '((clojure . t) (C . t) (ditaa . t) (dot . t) ;; (ipython . t) (http . t) (plantuml . t) ;; (python . t) (ruby . t) (sh . t))) ;; babel (setq org-confirm-babel-evaluate nil org-ditaa-jar-path (concat cbilson/emacs-dir "ditaa0_9.jar") org-plantuml-jar-path (concat cbilson/emacs-dir "plantuml.jar") org-source-fontify-natively t) (add-to-list 'org-src-lang-modes (quote ("dot" . graphviz-dot))) (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental))) (add-to-list 'org-src-lang-modes (quote ("clojure" . "clj"))) (let* ((miktex-bin (file-name-as-directory (concat cbilson/tools-dir "MiKTeX\\miktex\\bin"))) (xelatex-exe (concat miktex-bin "xelatex.exe"))) (setq org-agenda-show-log t org-agenda-span 14 org-hide-leading-stars t org-startup-indented t org-startup-folded "fold" org-src-window-setup 'current-window org-directory cbilson/org-dir org-agenda-files (list cbilson/org-dir) ;; log when something changes to done. org-log-done t org-latex-pdf-process (list (concat xelatex-exe " -interaction nonstopmode %f") (concat xelatex-exe " -interaction nonstopmode %f")))) (define-skeleton skel-header-block "Creates my default header" "" "#+TITLE: " str "\n" "#+Author: Chris Bilson\n" "#+Email: [email protected]\n" "#+Options: toc:3 num:nil html-postamble:nil\n" "#+Style: <link rel=\"stylesheet\" type=\"text/css\" " "href=\"http://thomasf.github.io/solarized-css/solarized-light.min.css\"" " />\n" "#+LaTeX_Header: \\usepackage{fontspec}\n" "#+LaTeX_Header: \\setmonofont[Scale=0.9]{Consolas}\n" "#+LaTeX_Header: \\setromanfont{Cambria}\n" "#+LaTeX_Header: \\linespread{1.5}\n" "#+LaTeX_Header: \\usepackage[margin=1.25in]{geometry}\n") (define-abbrev org-mode-abbrev-table "sheader" "" 'skel-header-block) (define-skeleton skel-org-block-elisp "Insert an emacs-lisp block" "" "#+begin_src emacs-lisp\n" _ - \n "#+end_src\n") (define-abbrev org-mode-abbrev-table "selisp" "" 'skel-org-block-elisp) (define-skeleton skel-org-block-powershell "Insert a powershell block" "" "#+begin_src powershell\n" _ - \n "#+end_src\n") (define-abbrev org-mode-abbrev-table "sposh" "" 'skel-org-block-powershell) (define-skeleton skel-org-block-uml "Insert a UML block" "" "#+name: Some UML stuff\n" "#+begin_src plantuml :file figure.png\n" _ - \n "#+end_src\n") (define-abbrev org-mode-abbrev-table "suml" "" 'skel-org-block-uml) (defun cbilson/archive-done-tasks () (interactive) (org-map-entries (lambda () (org-archive-subtree) (setq org-map-continue-from (outline-previous-heading))) "/DONE" 'tree)))
(use-package page-break-lines)
(use-package paren-face)
(use-package plantuml-mode
:disabled t
:config
(setq plantuml-jar-path org-plantuml-jar-path
plantuml-run-command (format "%s -jar %%s" cbilson/java-cmd)))
This mode lets you run powershell as an inferior shell.
I’m using my own fork in my settings directory.
(use-package powershell
:config (setq powershell-indent 2))
Pretty prints C-l
(use-package pp-c-l)
(add-hook 'prog-mode-hook 'cbilson/kill-word-key)
(if (package-installed-p 'whitespace)
(add-hook 'prog-mode-hook 'whitespace-mode))
(if (package-installed-p 'flyspell)
(add-hook 'prog-mode-hook 'flyspell-prog-mode))
(if (package-installed-p 'hl-line)
(add-hook 'prog-mode-hook 'hl-line-mode))
(if (package-installed-p 'idle-highlight)
(add-hook 'prog-mode-hook 'idle-highlight-mode))
- If you’re going to use the default ido completion it’s extremely
highly recommended that you install the optional flx-ido package,
which provides a much more powerful alternative to ido’s built-in
flex matching.
(use-package projectile :init (projectile-mode +1) :config (setq projectile-enable-caching t projectile-completion-system 'helm projectile-indexing-method 'alien) :bind ("C-c C-k" . projectile-compile-project))
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "-i"
python-indent-offset 2
ob-ipython-command (substitute-in-file-name "$Tools/python/Scripts/jupyter.exe"))
;; (add-to-list 'exec-path (substitute-in-file-name "$Tools/python"))
;; (add-to-list 'exec-path (substitute-in-file-name "$Tools/python/scripts"))
;; (use-package ob-ipython)
(use-package rainbow-mode)
(defun cbilson/rust-mode-hook ()
(interactive)
(racer-mode)
(eldoc-mode)
(company-mode))
(use-package rust-mode
:config
(add-hook 'rust-mode-hook #'cbilson/rust-mode-hook)
:init
(use-package racer))
A string library
(use-package s)
Remember where I was last time I visited a file.
(require 'saveplace)
(setq-default save-place t
save-place-file (concat user-emacs-directory "places"))
(use-package geiser)
(use-package smartparens
:init (smartparens-global-mode +1)
:bind
("C-M-f" . sp-forward-sexp)
("C-M-b" . sp-backward-sexp)
("C-M-d" . sp-down-sexp)
("C-M-a" . sp-backward-down-sexp)
("C-S-a" . sp-beginning-of-sexp)
("C-S-d" . sp-end-of-sexp)
("C-M-e" . sp-up-sexp)
("C-M-u" . sp-backward-up-sexp)
("C-M-t" . sp-transpose-sexp)
("C-M-n" . sp-next-sexp)
("C-M-p" . sp-previous-sexp)
("C-M-k" . sp-kill-sexp)
("C-M-w" . sp-copy-sexp)
("M-<delete>" . sp-unwrap-sexp)
("M-<backspace>" . sp-backward-unwrap-sexp)
("C-<right>" . sp-forward-slurp-sexp)
("C-<left>" . sp-forward-barf-sexp)
("C-M-<left>" . sp-backward-slurp-sexp)
("C-M-<right>" . sp-backward-barf-sexp)
("M-D" . sp-splice-sexp)
("C-M-<delete>" . sp-splice-sexp-killing-forward)
("C-M-<backspace>" . sp-splice-sexp-killing-backward)
("C-S-<backspace>" . sp-splice-sexp-killing-around)
("C-]" . sp-select-next-thing-exchange)
("C-<left_bracket>" . sp-select-previous-thing)
("C-M-]" . sp-select-next-thing)
("M-F" . sp-forward-symbol))
(use-package smooth-scrolling
:init (smooth-scrolling-mode +1)
:config
(setq smooth-scrolling/vscroll-step-size 5))
(use-package tex-mode
:config
(add-hook 'LaTeX-mode-hook
(lambda ()
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(reftex-mode t)
(TeX-fold-mode t)))
(add-hook 'latex-mode-hook 'writegood-mode))
Transient Mark mode is a global minor mode. When enabled, the region is highlighted whenever the mark is active. The mark is “deactivated” by changing the buffer, and after certain other operations that set the mark but whose main purpose is something else–for example, incremental search, <, and >.
You can also deactivate the mark by typing C-g or M-ESC ESC.
Many commands change their behavior when Transient Mark mode is in effect and the mark is active, by acting on the region instead of their usual default part of the buffer’s text. Examples of such commands include M-;, M-x flush-lines, M-x keep-lines, M-%, C-M-%, M-x ispell, and <undo>.
To see the documentation of commands which are sensitive to the Transient Mark mode, invoke C-h d and type “transient” or “mark.*active” at the prompt.
(transient-mark-mode +1)
(use-package transmission
:config
(setq transmission-host "192.168.10.3"
transmission-service 9091))
(use-package undo-tree
:bind
("C-_" . undo-tree-undo)
("M-_" . undo-tree-redo)
("C-x u" . undo-tree-visualize)
:init
(global-undo-tree-mode +1))
(use-package whitespace
:bind ("C-c T w" . whitespace-mode)
:init
(dolist (hook '(prog-mode-hook text-mode-hook conf-mode-hook))
(add-hook hook #'whitespace-mode))
:config (setq whitespace-line-column nil)
:diminish whitespace-mode)
Winner mode is a global minor mode that records the changes in the window configuration (i.e., how the frames are partitioned into windows), so that you can “undo” them. You can toggle Winner mode with `M-x winner-mode’, or by customizing the variable `winner-mode’. When the mode is enabled, `C-c left’ (`winner-undo’) undoes the last window configuration change. If you change your mind while undoing, you can redo the changes you had undone using `C-c right’ (`M-x winner-redo’).
(winner-mode +1)
(use-package wrap-region)
(use-package yaml-mode)
(use-package yasnippet
:init
(yas-global-mode +1)
:config
(setq yas-snippet-dirs
(file-name-as-directory
(concat cbilson/emacs-dir "snippets"))))
The library uniquify overrides Emacs’ default mechanism for making buffer names unique (using suffixes like <2>, <3> etc.) with a more sensible behaviour which use parts of the file names to make the buffer names distinguishable.
For instance, buffers visiting “/u/mernst/tmp/Makefile” and “/usr/projects/zaphod/Makefile” would be named “Makefile|tmp” and “Makefile|zaphod”, respectively (instead of “Makefile” and “Makefile<2>”). Other buffer name styles are also available. To enable this, (require ‘uniquify) then customize uniquify-buffer-name-style. (Run M-x customize-option)
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(use-package web-mode
:ensure t
:mode (("\\.html?\\'" . web-mode)
("\\.aspx?\\'" . web-mode)
("\\.js\\'" . web-mode))
:config (progn
(setq web-mode-markup-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2)))
Highlights bad grammar and writing anti-patterns
(use-package writegood-mode
:config
(set-face-attribute 'writegood-passive-voice-face nil :background "gray22")
(set-face-attribute 'writegood-duplicates-face nil :background "gray22"))
For XML modes, I want emmet-mode active.
(add-hook 'nxml-mode-hook 'emmet-mode)
(add-to-list 'auto-mode-alist '("\\.config$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.csman$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.csproj" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.fsproj" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.proj" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.pssproj" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.targets$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.ps1xml$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.props$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.rd$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.rdsc$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.rels$" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.t4$" . nxml-mode))
;; maximize the window
(when (eq window-system 'w32)
(w32-send-sys-command 61488))
- helm-backup
- flx-isearch
- exercism.io
- marmalade everything (interface to windows desktop search)
- helm-dictionary
- helm-emmet
- helm-flycheck
- helm-flymake
- helm-google
- helm-gtags
- helm-lobsters
- helm-open-github