]> code.delx.au - dotemacs/commitdiff
massive config improvements, use git-submodule packaging
authorJames Bunton <jamesbunton@delx.net.au>
Mon, 18 Jul 2016 16:38:11 +0000 (02:38 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Mon, 18 Jul 2016 16:51:14 +0000 (02:51 +1000)
15 files changed:
.gitignore
README.txt
display.el [deleted file]
init.el
keys.el [deleted file]
lisp/my-backups.el [moved from backups.el with 100% similarity]
lisp/my-completion.el [new file with mode: 0644]
lisp/my-defuns.el [new file with mode: 0644]
lisp/my-file-modes.el [new file with mode: 0644]
lisp/my-gui.el [new file with mode: 0644]
lisp/my-keys.el [new file with mode: 0644]
lisp/my-minor-modes.el [new file with mode: 0644]
lisp/my-other-modes.el [new file with mode: 0644]
modes.el [deleted file]
packages.el [deleted file]

index 1f585966bb76e40d0f9ce2aaae96b12eb1d59a1f..b84148ac3a5e306d04e682f5cd16079aba861248 100644 (file)
@@ -1,5 +1,6 @@
 auto-save-list
 games
+lisp/packages
 .mc-lists.el
 recentf
 save-place-file
index 3b8ccce950b96b4e844b828a9480b24ffafa9335..3235e896bff15fe0ab3526f7726c92159f00b8f8 100644 (file)
+# References
+https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf
+https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
+
 # General commands
 C-x C-c                                         Quit Emacs
-C-x C-s                                         Save current buffer
 C-g                                             Cancel command
-M-x                                             Execute command
 C-/                                             Undo
 C-g C-/                                         Undo undo
 C-x z                                           Repeat last command
-M-X 'eval-buffer                                Load current buffer as elisp
+M-x                                             Execute command
 
 # Help
 C-h C-h                                         Help
 C-h k                                           Help about key binding
 C-h v                                           Describe variable
 C-h f                                           Describe function
+C-h m                                           Documentation on active modes
 
 # Search
-C-M-s                                           Regex search
-C-s                                             Search forward
+C-s                                             Search forward (ivy/swiper mode)
 C-r                                             Search backward
 M-s .                                           Search for symbol around point
-M-s w                                           Start word search
 C-s                                             Find next item (while searching)
 Backspace                                       Previous search (while searching)
 M-%                                             Search and replace
+M-x linum-mode                                  Display line numbers
+C-c r                                           Resume ivy search
 
-# Buffers/windows/frames
+# Files/buffers
+C-x C-s                                         Save current buffer
 C-x s                                           Save some buffers
-C-x C-f                                         Find (open) file
+C-x C-w                                         Write buffer to file
+C-x C-f                                         Find file
+C-x f                                           Find file
+C-c f                                           Find files in git repository
+C-c g                                           Grep in git repository
+M-x find-file-at-point                         Find (open) filename at point
+M-x browse-url-at-point                                Browse URL at point
 C-x k                                           Kill buffer
+C-x C-k                                         Kill all buffers that are not visible
 C-x b                                           Select named buffer
 C-x C-b                                         Show all buffers
+C-x C-r                                         Show recent files
+M-x scratch-buffer                              Create new scratch buffer
+
+# Windows/frames
 C-x o                                           Switch to other window
 C-x 0                                           Delete window
 C-x 1                                           Switch to single window
 C-x 2                                           Split vertically
 C-x 3                                           Split horizontally
-M-x 'make-frame                                 New frame (X11 window)
-M-=                                             Display info about region
+C-x -                                           Shrink window
+C-x +                                           Make windows the same height
+C-x ^                                           Make window taller
+C-Up / C-Down / C-Left / C-Right                Switch windows
+M-x make-frame                                  New frame (X11 window)
+
+# Movement
+M-m                                             Jump back to start of indentation
+M-r                                             Jump to window top/bottom/middle
+M-g M-g                                         Jump to line
+M-g Tab                                         Jump to column
+C-a                                             Beginning of line
+C-e                                             End of line
+C-p                                             Back one line
+C-n                                             Forward one line
+C-b                                             Back one character
+C-n                                             Forward one character
+M-b                                             Back a word
+M-f                                             Forward a word
+M-a                                             Backward sentence
+M-e                                             Forward sentence
+M-v                                             Back page
+C-v                                             Forward page
+M-{                                             Back one paragraph
+M-}                                             Forward one paragraph
+M-<                                             Top of file
+M->                                             End of file
+C-M-p                                           Back to start of balanced expression
+C-M-n                                           Forward to end of balanced expression
+C-M-b                                           Back one s-expression / symbol
+C-M-f                                           Forward one s-expression / symbol
+C-M-u                                           Move up one level of parentheses
+C-c c                                           Jump to character
 
 # Text formatting
 M-/                                             Auto-complete
 M-;                                             Comment line or region
+M-i                                             Change inner region
 M-q                                             Reformat paragraph
 M-l                                             Lower case word
 M-u                                             Upper case word
 M-c                                             Capitalise word
 C-x C-l                                         Lower case region
 C-x C-u                                         Upper case region
+C-o                                             Insert a new line above point
+M-o                                            Insert a new line below point
+C-j                                             Newline and maybe indent
+M-^                                             Join to previous line
+M-j                                            New line with comment
+C-q                                            Quoted insert
 
-# Macros
-F3 , F4                                         Start recording macro
-C-u F3                                          Play last macro then append keys
-F4                                              Play back macro
-
-# Selecting/deleting/killing text
+# Marking
 C-Space                                         Set mark (start selection)
 C-Space C-Space                                 Set mark to point
 C-u C-space                                     Return to mark
-C-M-p                                           Back to start of balanced expression
-C-M-n                                           Forward to end of balanced expression
-C-M-k                                           Kill balanced expression
+C-x C-x                                         Exchange point and mark
+C-M-h                                           Highlight expression
 M-@                                             Set mark at end of next word
+C-=                                             Expand region
+C-c l                                           Insert extra cursor on all lines in region
+C-c m                                           Ask to insert extra cursor at locations matching selected region
+M-=                                             Display info about region
+
+# Killing and deleting
+C-M-k                                           Kill s-expression / symbol
 C-w                                             Kill from mark to point
 C-y                                             Yank text (paste)
 M-y                                             Scroll through kill ring (paste buffer)
+M-_                                             Select current line
 M-z <char>                                      Kill until <char>
-C-k                                             Kill rest of line
+C-k                                             Kill to end of line
+M-0 C-k                                         Kill to beginning of line
 C-S-Backspace                                   Delete current line
 C-d                                             Delete next character
 M-d                                             Delete next word
@@ -73,31 +129,49 @@ M-Backspace                                     Delete previous word
 M-Space                                         Collpase to one space around point
 M-\                                             Delete spaces around point
 C-x C-o                                         Collapse blank lines
-M-X delete-trailing-whitespace                  Delete trailing whitespace
+M-x delete-trailing-whitespace                  Delete trailing whitespace
 
-# Lines
-C-o                                             Insert new line at point
-C-j                                             Newline and maybe indent
-M-^                                             Join to previous line
+# Transposing
+C-t                                             Transpose chars
+M-t                                             Transpose words
+C-x C-t                                         Transpose lines
+C-M-t                                           Transpose s-expressions
 
-# Movement
-M-m                                             Jump back to start of indentation
-M-r                                             Jump to window top/bottom/middle
-M-g M-g                                         Jump to line
-M-g Tab                                         Jump to column
-C-a                                             Beginning of line
-C-e                                             End of line
-C-p                                             Back one line
-C-n                                             Forward one line
-C-b                                             Back one character
-C-n                                             Forward one character
-M-b                                             Back a word
-M-f                                             Forward a word
-M-a                                             Backward sentence
-M-e                                             Forward sentence
-M-v                                             Back page
-C-v                                             Forward page
-M-{                                             Back one paragraph
-M-}                                             Forward one paragraph
-M-<                                             Top of file
-M->                                             End of file
+# Rectangle
+C-x Space                                       Toggle mark rectangle mode
+C-x r t                                         Replace rectangle with string
+
+# Macros
+F3 , F4                                         Start recording macro, finish recording macro
+C-u F3                                          Play last macro then append keys
+F4                                              Play back macro
+
+# Lisp
+M-:                                             Evaluate expression as elisp
+M-x eval-buffer                                 Load current buffer as elisp
+M-x eval-region                                 Load current region as elisp
+M-x ielm                                        Run elisp REPL
+
+# Shell
+M-!                                             Execute command
+M-&                                             Execute command asynchronously
+M-|                                             Execute with region
+C-u M-|                                         Filter with region
+M-x shell                                       Start a shell
+
+# Dired
+C-x C-j                                         Open dired at current file
+
+# Flyspell
+F8                                              Toggle flyspell-mode
+M-$                                             Correct word
+C-M-i                                           Automatically correct word
+C-;                                             Automatically correct last word
+<mouse-2>                                       Popup word correction
+
+# Flycheck
+C-c ! v                                         Verify setup
+C-c ! n                                         Next error
+C-c ! p                                         Previous error
+C-c ! l                                         List errors
+C-c ! x                                         Disable checker
diff --git a/display.el b/display.el
deleted file mode 100644 (file)
index 96b94cf..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-(load-theme 'deeper-blue)
-
-(menu-bar-mode -1)
-(tool-bar-mode -1)
-(scroll-bar-mode -1)
-
-(setq frame-title-format
-      '((:eval (if (buffer-file-name)
-                   (abbreviate-file-name (buffer-file-name))
-                 "%b"))
-        (:eval (if (buffer-modified-p)
-                   " (*)"))
-        " - Emacs")
-      )
-(setq icon-title-format frame-title-format)
-
-(setq scroll-conservatively 1)
-(setq scroll-margin 1)
-
-(setq column-number-mode t)
-
-(show-paren-mode t)
-
-(setq show-trailing-whitespace t)
diff --git a/init.el b/init.el
index d06d6589d190530a8f8d0c01d3ad4d8c44140423..4ddfe84d810b4f3bfca6a863de2d7564bb7bcdb8 100644 (file)
--- a/init.el
+++ b/init.el
@@ -1,5 +1,16 @@
-(load "~/.emacs.d/backups.el")
-(load "~/.emacs.d/packages.el")
-(load "~/.emacs.d/display.el")
-(load "~/.emacs.d/keys.el")
-(load "~/.emacs.d/modes.el")
+(add-to-list 'load-path "~/.emacs.d/lisp/")
+
+(dolist (name (directory-files "~/.emacs.d/lisp/packages/"))
+  (let ((dirname (concat "~/.emacs.d/lisp/packages/" name)))
+    (if (not (equal "." (substring name 0 1)))
+        (if (file-accessible-directory-p dirname)
+            (add-to-list 'load-path dirname)))))
+
+(load-library "my-backups")
+(load-library "my-defuns")
+(load-library "my-gui")
+(load-library "my-keys")
+(load-library "my-completion")
+(load-library "my-other-modes")
+(load-library "my-minor-modes")
+(load-library "my-file-modes")
diff --git a/keys.el b/keys.el
deleted file mode 100644 (file)
index a8178f9..0000000
--- a/keys.el
+++ /dev/null
@@ -1,21 +0,0 @@
-(global-set-key (kbd "<C-up>") 'windmove-up)
-(global-set-key (kbd "<C-down>") 'windmove-down)
-(global-set-key (kbd "<C-left>") 'windmove-left)
-(global-set-key (kbd "<C-right>") 'windmove-right)
-
-
-(global-set-key (kbd "M-;") 'toggle-comment-on-line)
-(defun toggle-comment-on-line ()
-  (interactive)
-  (if (and mark-active transient-mark-mode)
-      (comment-or-uncomment-region (region-beginning) (region-end))
-    (comment-or-uncomment-region (line-beginning-position) (line-end-position)))
-  (next-line))
-
-
-(setq mouse-wheel-scroll-amount '(3))
-(setq mouse-wheel-progressive-speed nil)
-
-
-(setq read-file-name-completion-ignore-case t)
-(setq read-buffer-completion-ignore-case t)
similarity index 100%
rename from backups.el
rename to lisp/my-backups.el
diff --git a/lisp/my-completion.el b/lisp/my-completion.el
new file mode 100644 (file)
index 0000000..47b63d5
--- /dev/null
@@ -0,0 +1,7 @@
+(require 'counsel)
+(require 'ivy)
+(require 'swiper)
+(ivy-mode 1)
+(setq counsel-find-file-at-point t)
+(setq counsel-find-file-ignore-regexp "\\(?:\\`[#.]\\)\\|\\(?:[#~]\\'\\)")
+(setq ivy-wrap t)
diff --git a/lisp/my-defuns.el b/lisp/my-defuns.el
new file mode 100644 (file)
index 0000000..7404164
--- /dev/null
@@ -0,0 +1,66 @@
+(defun copy-line (arg)
+  "Copy lines in the kill ring"
+  (interactive "p")
+  (kill-ring-save (line-beginning-position)
+                  (line-beginning-position (+ 1 arg)))
+  (message "%d line%s copied" arg (if (= 1 arg) "" "s")))
+
+(add-to-list 'delete-frame-functions #'kill-buffers-if-deleting-last-frame)
+
+(defun frame-list-ignoring-initial-frame ()
+  (filtered-frame-list
+   (lambda (frame)
+     (not (equal "initial_terminal" (terminal-name frame))))))
+
+(defun kill-buffers-if-deleting-last-frame (frame)
+  (when (equal (list frame) (frame-list-ignoring-initial-frame))
+    (dolist (buffer (buffer-list))
+      (kill-buffer-if-not-modified buffer) buffer)))
+
+(defun kill-buffers-not-in-frame ()
+  "Kill buffers which are not loaded into some a frame"
+  (interactive)
+  (let ((kill-count 0))
+    (dolist (buffer (buffer-list))
+      (if (not (get-buffer-window buffer t))
+          (if (kill-buffer-if-not-modified buffer)
+              (incf kill-count))))
+    (message "Killed %d buffers" kill-count)))
+
+(defun open-line-above ()
+  "Open a new line above point with indentation"
+  (interactive)
+  (beginning-of-line)
+  (newline)
+  (forward-line -1)
+  (indent-for-tab-command))
+
+(defun open-line-below ()
+  "Open a new line below point with indentation"
+  (interactive)
+  (end-of-line)
+  (newline)
+  (indent-for-tab-command))
+
+(defun scratch-buffer ()
+  "Create a new scratch buffer to work in. (could be *scratch* - *scratchX*)"
+  (interactive)
+  (let ((n 0)
+        bufname)
+    (while (progn
+             (setq bufname (concat "*scratch"
+                                   (if (= n 0) "" (int-to-string n))
+                                   "*"))
+             (setq n (1+ n))
+             (get-buffer bufname)))
+    (switch-to-buffer (get-buffer-create bufname))
+    (emacs-lisp-mode)
+    ))
+
+(defun toggle-comment-on-line ()
+  "Toggles the comment on for the active region if present or the current line otherwise."
+  (interactive)
+  (if (and mark-active transient-mark-mode)
+      (comment-or-uncomment-region (region-beginning) (region-end))
+    (comment-or-uncomment-region (line-beginning-position) (line-end-position)))
+  (forward-line))
diff --git a/lisp/my-file-modes.el b/lisp/my-file-modes.el
new file mode 100644 (file)
index 0000000..ea4a7b2
--- /dev/null
@@ -0,0 +1,36 @@
+(setq-default indent-tabs-mode nil)
+(setq-default c-basic-offset 4)
+(setq-default python-indent-offset 4)
+
+(require 'coffee-mode)
+(setq-default coffee-tab-width 4)
+
+(require 'dockerfile-mode)
+
+(require 'git-modes)
+
+(require 'groovy-mode)
+(add-to-list 'auto-mode-alist '("\\.groovy\\'" . groovy-mode))
+
+(require 'haskell-mode)
+
+(require 'json-mode)
+(require 'js)
+(add-hook 'json-mode-hook
+          (lambda ()
+            (make-local-variable 'js-indent-level)
+            (setq js-indent-level 2)))
+
+(require 'js2-mode)
+(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
+(add-to-list 'interpreter-mode-alist '("node" . js2-mode))
+
+(require 'pkgbuild-mode)
+
+(require 'python)
+(add-hook 'python-mode-hook
+          (lambda () (setq forward-sexp-function nil)))
+
+(require 'scala-mode)
+
+(require 'yaml-mode)
diff --git a/lisp/my-gui.el b/lisp/my-gui.el
new file mode 100644 (file)
index 0000000..f97309a
--- /dev/null
@@ -0,0 +1,38 @@
+(load-theme 'deeper-blue)
+
+(menu-bar-mode -1)
+(tool-bar-mode -1)
+(scroll-bar-mode -1)
+
+(setq scroll-conservatively 1)
+(setq scroll-margin 1)
+(setq mouse-wheel-scroll-amount '(3))
+(setq mouse-wheel-progressive-speed nil)
+
+(setq column-number-mode t)
+(setq line-number-mode t)
+
+(show-paren-mode t)
+
+(setq show-trailing-whitespace t)
+
+(require 'uniquify)
+(setq uniquify-strip-common-suffix t)
+(setq uniquify-buffer-name-style 'post-forward)
+
+(setq frame-title-format
+      '((:eval (if (buffer-file-name)
+                   (concat
+                    (file-name-nondirectory (buffer-file-name))
+                    (if (buffer-modified-p)
+                        " +")
+                    " ("
+                    (abbreviate-file-name (substring (file-name-directory (buffer-file-name)) 0 -1))
+                    ") - Emacs"
+                    )
+                 (concat
+                  "%b"
+                  (if (buffer-modified-p)
+                      " +")
+                  " - Emacs")))))
+(setq icon-title-format frame-title-format)
diff --git a/lisp/my-keys.el b/lisp/my-keys.el
new file mode 100644 (file)
index 0000000..dd17040
--- /dev/null
@@ -0,0 +1,43 @@
+;; General commands
+(global-set-key (kbd "M-x") 'counsel-M-x)
+
+;; Search
+(global-set-key (kbd "C-s") 'swiper)
+(global-set-key (kbd "C-c r") 'ivy-resume)
+
+;; Files/buffers
+(global-set-key (kbd "C-x C-f") 'counsel-find-file)
+(global-set-key (kbd "C-c f") 'counsel-git)
+(global-set-key (kbd "C-c g") 'counsel-git-grep)
+(global-set-key (kbd "C-x C-k") 'kill-buffers-not-in-frame)
+(global-set-key (kbd "C-x C-b") 'ibuffer)
+(global-set-key (kbd "C-x C-r") 'ivy-recentf)
+
+;; Windows/frames
+(global-set-key (kbd "<C-up>") 'windmove-up)
+(global-set-key (kbd "<C-down>") 'windmove-down)
+(global-set-key (kbd "<C-left>") 'windmove-left)
+(global-set-key (kbd "<C-right>") 'windmove-right)
+
+;; Movement
+(global-set-key (kbd "C-c c") 'ace-jump-mode)
+
+;; Text formatting
+(global-set-key (kbd "M-/") 'hippie-expand)
+(global-set-key (kbd "M-;") 'toggle-comment-on-line)
+(global-set-key (kbd "M-i") 'change-inner)
+(global-set-key (kbd "C-o") 'open-line-above)
+(global-set-key (kbd "M-o") 'open-line-below)
+
+;; Marking
+(global-set-key (kbd "C-=") 'er/expand-region)
+(global-set-key (kbd "C-c l") 'mc/edit-lines)
+(global-set-key (kbd "C-c m") 'mc/mark-more-like-this-extended)
+
+;; Killing and deleting
+(global-set-key (kbd "M-y") 'counsel-yank-pop)
+(global-set-key (kbd "M-_") 'copy-line)
+(global-set-key (kbd "M-z") 'zap-up-to-char)
+
+;; Flyspell
+(global-set-key (kbd "<f8>") 'flyspell-mode)
diff --git a/lisp/my-minor-modes.el b/lisp/my-minor-modes.el
new file mode 100644 (file)
index 0000000..67e9862
--- /dev/null
@@ -0,0 +1,19 @@
+(require 'ace-jump-mode)
+
+(require 'change-inner)
+
+(require 'expand-region)
+
+(require 'indent-guide)
+(indent-guide-global-mode)
+
+(require 'flyspell)
+
+(require 'flycheck)
+(global-flycheck-mode 1)
+(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
+(setq flycheck-emacs-lisp-load-path 'inherit)
+
+(require 'misc)
+
+(require 'multiple-cursors)
diff --git a/lisp/my-other-modes.el b/lisp/my-other-modes.el
new file mode 100644 (file)
index 0000000..3567aba
--- /dev/null
@@ -0,0 +1,34 @@
+(require 'autorevert)
+(global-auto-revert-mode 1)
+(setq global-auto-revert-non-file-buffers t)
+(setq auto-revert-verbose nil)
+
+(require 'dired-x)
+
+(require 'ibuffer-vc)
+(add-hook 'ibuffer-hook
+          (lambda ()
+            (ibuffer-vc-set-filter-groups-by-vc-root)
+            (unless (eq ibuffer-sorting-mode 'alphabetic)
+              (ibuffer-do-sort-by-alphabetic))))
+
+(require 'recentf)
+(recentf-mode 1)
+(setq recentf-max-saved-items 50)
+(run-at-time nil 600 'recentf-save-list)
+
+(setq require-final-newline t)
+
+(setq save-interprogram-paste-before-kill t)
+
+(setq shift-select-mode nil)
+(delete-selection-mode t)
+
+(require 'saveplace)
+(setq save-place-file "~/.emacs.d/save-place-file")
+(setq-default save-place t)
+
+(require 'vc)
+(setq vc-follow-symlinks t)
+
+(defalias 'yes-or-no-p 'y-or-n-p)
diff --git a/modes.el b/modes.el
deleted file mode 100644 (file)
index f517c85..0000000
--- a/modes.el
+++ /dev/null
@@ -1,37 +0,0 @@
-(setq-default indent-tabs-mode nil)
-(setq-default c-basic-offset 4)
-(setq-default python-basic-offset 4)
-
-(setq vc-follow-symlinks nil)
-
-(add-hook 'text-mode-hook 'flyspell-mode)
-(add-hook 'prog-mode-hook 'flyspell-prog-mode)
-
-(require 'saveplace)
-(setq save-place-file "~/.emacs.d/save-place-file")
-(setq-default save-place t)
-
-(require 'golden-ratio)
-(golden-ratio-mode)
-
-(defadvice ibuffer
-    (around ibuffer-point-to-most-recent) ()
-    "Open ibuffer with cursor pointed to most recent buffer name."
-    (let ((recent-buffer-name (buffer-name)))
-      ad-do-it
-      (ibuffer-jump-to-buffer recent-buffer-name)))
-(ad-activate 'ibuffer)
-(global-set-key (kbd "C-x C-b") 'ibuffer)
-
-(defun frame-list-ignoring-initial-frame ()
-  (filtered-frame-list
-   (lambda (frame)
-     (not (equal "initial_terminal" (terminal-name frame))))))
-
-(defun close-buffers-if-last-frame-deleted (frame)
-  "Close all buffers if the last frame was deleted"
-  (when (equal (list frame) (frame-list-ignoring-initial-frame))
-    (dolist (buffer (buffer-list))
-      (when (and (buffer-file-name buffer) (not (buffer-modified-p buffer)))
-        (kill-buffer buffer)))))
-(add-to-list 'delete-frame-functions #'close-buffers-if-last-frame-deleted)
diff --git a/packages.el b/packages.el
deleted file mode 100644 (file)
index 88ed801..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-(require 'package)
-
-(add-to-list 'package-archives
-             '("melpa-stable" . "https://stable.melpa.org/packages/"))
-
-(package-initialize)
-
-(if (not (file-exists-p package-user-dir))
-    (package-refresh-contents))
-
-(defun ensure-package-installed (package)
-  (if (not (package-installed-p package))
-      (if (y-or-n-p (format "Package %s is missing. Install it? " package))
-          (package-install package))))
-
-(ensure-package-installed 'markdown-mode)
-(ensure-package-installed 'haskell-mode)
-(ensure-package-installed 'golden-ratio)