summary refs log tree commit diff stats
path: root/emacs
diff options
context:
space:
mode:
authorAlan Pearce2017-05-13 10:03:30 +0200
committerAlan Pearce2017-05-13 10:03:30 +0200
commit3dd9fad897305f1ed6edc2a880ffad2c888ae9d9 (patch)
tree9d897ab39ef995808de04461e337a5d566917745 /emacs
parentf28fe7ef1170a5049f294974b57a6dc7292986b0 (diff)
parent3b8e49259080ac24eb4015d9a8ce94aba753e123 (diff)
downloaddotfiles-3dd9fad897305f1ed6edc2a880ffad2c888ae9d9.tar.lz
dotfiles-3dd9fad897305f1ed6edc2a880ffad2c888ae9d9.tar.zst
dotfiles-3dd9fad897305f1ed6edc2a880ffad2c888ae9d9.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init.org299
1 files changed, 177 insertions, 122 deletions
diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org
index af8b5a6..628c90e 100644
--- a/emacs/.emacs.d/init.org
+++ b/emacs/.emacs.d/init.org
@@ -37,7 +37,7 @@ the buffer to be empty.
 
 ** Personal Information
 #+BEGIN_SRC emacs-lisp
-(setq user-mail-address "alan@alanpearce.co.uk"
+(setq user-mail-address "alan@alanpearce.eu"
       user-full-name "Alan Pearce")
 #+end_src
 
@@ -56,10 +56,10 @@ the buffer to be empty.
         package-pinned-packages '(("use-package" . melpa-stable)
                                   ("diminish" . melpa-stable)
                                   ("bind-key" . melpa-stable))
-        package-archive-priorities '(("melpa-stable" . 10)
+        package-archive-priorities '(("melpa" . 10)
                                      ("gnu" . 10)
-                                     ("marmalade" . 5)
-                                     ("melpa" . 0))
+                                     ("melpa-stable" . 5)
+                                     ("marmalade" . 0))
         package-menu-async t
         package-menu-hide-low-priority t)
   (when (eq system-type 'darwin)
@@ -90,7 +90,8 @@ modification and removal, without the boilerplate of an extra function
 definition.
 
 #+BEGIN_SRC emacs-lisp
-(use-package hook-helpers)
+(eval-and-compile
+  (use-package hook-helpers))
 #+END_SRC
 
 * Customize
@@ -151,6 +152,7 @@ Let’s try a basic theme.
 #+BEGIN_SRC emacs-lisp
 (use-package basic-theme
   :if (display-graphic-p)
+  :disabled t
   :config (progn
             (load-theme 'basic t)
 
@@ -160,62 +162,18 @@ Let’s try a basic theme.
             (set-face-background 'vertical-border "#a1b56c")
             (set-face-foreground 'vertical-border "#a1b56c")
             (set-face-background 'window-divider "#a1b56c")
-            (set-face-foreground 'window-divider "#a1b56c")
-
-            (defvar mode-line-default-format mode-line-format)
-            (defvar mode-line-default-hidden nil
-              "Whether to hide the mode line by default")
-
-            (defun show-mode-line ()
-              (interactive)
-              (setq mode-line-format mode-line-default-format)
-              (when (called-interactively-p 'interactive)
-                (setq-default mode-line-format mode-line-default-format)
-                (setq mode-line-default-hidden nil)))
-            (defun hide-mode-line ()
-              (interactive)
-              (setq mode-line-format nil)
-              (when (called-interactively-p 'interactive)
-                (setq-default mode-line-format nil)
-                (setq mode-line-default-hidden t)))
-
-            (setq-default cursor-type '(bar . 1))
-            (setq-default cursor-in-non-selected-windows nil)
-
-            (defun hide-clutter ()
-              (interactive)
-              (fringe-mode '(4 . 8))
-              (hide-mode-line))
-
-            (defun show-clutter ()
-              (interactive)
-              (fringe-mode '(8 . 8))
-              (show-mode-line))
-            (hide-clutter)
-
-            (when mode-line-default-hidden
-              (call-interactively #'hide-mode-line))
-
-            (setq-default indicate-buffer-boundaries 'left)
-
-            (defun hide-mode-line-if-default-hidden ()
-              (if mode-line-default-hidden
-                  (hide-mode-line)
-                (show-mode-line)))
-
-            (add-to-list 'default-frame-alist '(border-width . 0))
-            (add-to-list 'default-frame-alist '(internal-border-width . 0))
-            (when (eq window-system 'x)
-              (setq window-divider-default-bottom-width 1
-                    window-divider-default-right-width 1
-                    window-divider-default-places t)
-              (setq mode-line-default-hidden t)
-              (window-divider-mode +1))
+            (set-face-foreground 'window-divider "#a1b56c")))
+#+END_SRC
 
-            (add-hook 'after-change-major-mode-hook #'hide-mode-line-if-default-hidden)
+Eziam looks nice, too
 
-            (add-hook 'minibuffer-setup-hook #'show-mode-line)
-            (add-hook 'minibuffer-exit-hook #'hide-mode-line)))
+#+BEGIN_SRC emacs-lisp
+(use-package eziam-light-theme
+  :ensure eziam-theme
+  :defines (eziam-scale-headings)
+  :config (progn
+            (setq eziam-scale-headings nil)
+            (load-theme 'eziam-light t)))
 #+END_SRC
 
 Highlighting quasi-quoted expressions in lisps is quite useful, but I
@@ -261,7 +219,7 @@ because I manage those in my [[file:~/projects/dotfiles/tag-xresources/xresource
       (let ((displays (string-to-number (shell-command-to-string "system_profiler SPDisplaysDataType | grep \"Online: Yes\" | wc -l"))))
         (if (eq displays 1)
             (ap/set-fonts "Lekton" 20 "Lucida Grande" 16 t)
-          (ap/set-fonts "Monaco" 10 "Lucida Grande" 12 nil 0.1))))
+          (ap/set-fonts "Monaco" 14 "Lucida Grande" 14 nil 0.1))))
      ((eq window-system 'x)
       (set-fontset-font "fontset-default" 'unicode (font-spec :name "Terminus" :size 14))
       (ap/set-fonts "Fixed" 14 "Lucida" 14 nil))))
@@ -303,6 +261,66 @@ correct, at least for Liberation Mono.
 (setq frame-title-format '("%f" (dired-directory dired-directory)))
 #+END_SRC
 
+** Chrome
+
+Sometimes I like to hide clutter.  Other times, it's useful.
+
+#+BEGIN_SRC emacs-lisp
+(defvar mode-line-default-format mode-line-format)
+(defvar mode-line-default-hidden nil
+  "Whether to hide the mode line by default")
+
+(defun show-mode-line ()
+  (interactive)
+  (setq mode-line-format mode-line-default-format)
+  (when (called-interactively-p 'interactive)
+    (setq-default mode-line-format mode-line-default-format)
+    (setq mode-line-default-hidden nil)))
+(defun hide-mode-line ()
+  (interactive)
+  (setq mode-line-format nil)
+  (when (called-interactively-p 'interactive)
+    (setq-default mode-line-format nil)
+    (setq mode-line-default-hidden t)))
+
+(setq-default cursor-in-non-selected-windows nil)
+
+(defun hide-clutter ()
+  (interactive)
+  (fringe-mode '(4 . 8))
+  (hide-mode-line))
+
+(defun show-clutter ()
+  (interactive)
+  (fringe-mode '(8 . 8))
+  (show-mode-line))
+(hide-clutter)
+
+(when mode-line-default-hidden
+  (call-interactively #'hide-mode-line))
+
+(setq-default indicate-buffer-boundaries 'left)
+
+(defun hide-mode-line-if-default-hidden ()
+  (if mode-line-default-hidden
+      (hide-mode-line)
+    (show-mode-line)))
+
+(add-to-list 'default-frame-alist '(border-width . 0))
+(add-to-list 'default-frame-alist '(internal-border-width . 0))
+(when (eq window-system 'x)
+  (setq window-divider-default-bottom-width 1
+        window-divider-default-right-width 1
+        window-divider-default-places t)
+  (setq mode-line-default-hidden t)
+  (window-divider-mode +1))
+
+(add-hook 'after-change-major-mode-hook #'hide-mode-line-if-default-hidden)
+
+(add-hook 'minibuffer-setup-hook #'show-mode-line)
+(add-hook 'minibuffer-exit-hook #'hide-mode-line)
+#+END_SRC
+
 ** Highlight Changes
 
 Highlight what just changed when I undo, yank, and so on.
@@ -419,7 +437,7 @@ Option/alt, then Control.
 
 (bind-key* "s-x" (define-prefix-command 'super-x-map))
 (bind-key* "s-," #'switch-to-dotfiles)
-(bind-key* "C-M-x" #'execute-extended-command)
+(bind-key* "C-x M-x" #'execute-extended-command)
 (set-register ?z `(file . ,(expand-file-name ".config/zsh/zshrc" "~")))
 #+END_SRC
 
@@ -905,6 +923,48 @@ point whilst I’m moving about.
     (setq ns-pop-up-frames nil))
 #+END_SRC
 
+** eyebrowse
+
+Workspaces, a bit like dwm.
+
+#+BEGIN_SRC emacs-lisp
+(use-package eyebrowse
+  :bind (("s-0" . eyebrowse-switch-to-window-config-0)
+         ("s-1" . eyebrowse-switch-to-window-config-1)
+         ("s-2" . eyebrowse-switch-to-window-config-2)
+         ("s-3" . eyebrowse-switch-to-window-config-3)
+         ("s-4" . eyebrowse-switch-to-window-config-4)
+         ("s-5" . eyebrowse-switch-to-window-config-5)
+         ("s-6" . eyebrowse-switch-to-window-config-6)
+         ("s-7" . eyebrowse-switch-to-window-config-7)
+         ("s-8" . eyebrowse-switch-to-window-config-8)
+         ("s-9" . eyebrowse-switch-to-window-config-9))
+  :config (progn
+            (setq eyebrowse-new-workspace t)
+            (eyebrowse-mode +1)))
+#+END_SRC
+
+* Sessions
+
+** Desktop
+Save my Emacs session and restore it on startup.
+
+#+BEGIN_SRC emacs-lisp
+(use-package desktop
+  :ensure nil
+  :config (progn
+            (setq desktop-dirname (expand-file-name "desktop/" user-emacs-directory)
+                  desktop-base-file-name "emacs.desktop"
+                  desktop-base-lock-name "lock"
+                  desktop-path (list desktop-dirname)
+                  desktop-save 'if-exists
+                  desktop-files-not-to-save "^$"
+                  desktop-load-locked-desktop nil)
+            (unless (file-directory-p desktop-dirname)
+              (make-directory desktop-dirname))
+            (desktop-save-mode 1)))
+#+END_SRC
+
 ** winner
 
 Undo, for window-based commands.
@@ -1313,8 +1373,8 @@ information here as well.
 ; startup and caches it. Don't want emacs daemon to hang because of gpg-agent.
 (defun load-private-data ()
   (interactive)
-  (if (not (file-exists-p (expand-file-name (concat system-name ".el.gpg") user-emacs-directory)))
-      (message "No encrypted configuration matches system name `%s'" system-name)
+  (if (not (file-exists-p (expand-file-name (concat (system-name) ".el.gpg") user-emacs-directory)))
+      (message "No encrypted configuration matches system name `%s'" (system-name))
     (if (not have-private-key)
         (message "ERROR: Private GPG key not found")
       (unless (or (getenv "GPG_AGENT_INFO")
@@ -1326,7 +1386,7 @@ information here as well.
         (pinentry-start)
         (add-hook 'kill-emacs-hook 'pinentry-stop))
       (add-to-list 'load-suffixes ".el.gpg")
-      (load-gpg (expand-file-name system-name user-emacs-directory)))))
+      (load-gpg (expand-file-name (system-name) user-emacs-directory)))))
 
 (defun first-frame-hook (frame)
   (remove-hook 'after-make-frame-functions #'first-frame-hook)
@@ -1370,7 +1430,6 @@ replacement for helm so far.
 (use-package swiper
   :bind (("C-s" . swiper)
          ("C-r" . swiper)
-         ("C-x i" . ivy-imenu-goto)
          ("C-=" . swiper))
   :diminish ivy-mode
   :demand t
@@ -1378,28 +1437,6 @@ replacement for helm so far.
             (ivy-mode 1)
             (setq ivy-re-builders-alist '((t . ivy--regex-plus))
                   ivy-extra-directories '("./"))
-            (defun ivy-imenu-get-candidates-from (alist  &optional prefix)
-              (cl-loop for elm in alist
-                       nconc (if (imenu--subalist-p elm)
-                                 (ivy-imenu-get-candidates-from
-                                  (cl-loop for (e . v) in (cdr elm) collect
-                                           (cons e (if (integerp v) (copy-marker v) v)))
-                                  (concat prefix (if prefix ".") (car elm)))
-                               (and (cdr elm) ; bug in imenu, should not be needed.
-                                    (setcdr elm (copy-marker (cdr elm))) ; Same as [1].
-                                    (list (cons (concat prefix (if prefix ".") (car elm))
-                                                (copy-marker (cdr elm))))))))
-
-            (defun ivy-imenu-goto ()
-              "Go to buffer position"
-              (interactive)
-              (let ((imenu-auto-rescan t) items)
-                (unless (featurep 'imenu)
-                  (require 'imenu nil t))
-                (setq items (imenu--make-index-alist t))
-                (ivy-read "imenu items:"
-                          (ivy-imenu-get-candidates-from (delete (assoc "*Rescan*" items) items))
-                          :action (lambda (k) (goto-char k)))))
             (ivy-set-actions 'ivy-switch-buffer '(("k" (lambda (x)
                                                          (kill-buffer x)
                                                          (ivy--reset-state ivy-last))
@@ -1418,6 +1455,7 @@ replacement for helm so far.
             (bind-key "C-c M-x" #'execute-extended-command)
             (bind-key "C-x C-f" #'counsel-find-file)
             (bind-key "M-y" #'counsel-yank-pop)
+            (bind-key "C-x i" #'counsel-imenu)
             (bind-key "M-y" #'ivy-next-line ivy-minibuffer-map)
             (defadvice counsel-find-file (after find-file-sudo activate)
               "Find file as root if necessary."
@@ -1481,11 +1519,6 @@ set environment variables for projects.
 Some modes that I don’t really customise much, mostly for
 configuration files.
 #+BEGIN_SRC emacs-lisp
-(use-package xrdb-mode
-  :ensure nil
-  :mode (("\\.Xdefaults\\'" . xrdb-mode)
-         ("\\.Xresources\\'" . xrdb-mode)))
-
 (use-package haskell-mode
   :mode (("\\.hs\\'" . haskell-mode)))
 
@@ -1623,6 +1656,10 @@ Org is wünderbar.
                                                (plain-list-item . auto))
                   org-fontify-done-headline t
 
+                  org-goto-interface 'outline-path-completion
+
+                  org-outline-path-complete-in-steps nil
+
                   org-todo-keywords '((sequence "BACKLOG(b)" "TODO(t)" "WAIT(w@/!)" "STARTED(s!)" "|" "DONE(d!)")
                                       (sequence "|" "CANCELLED(c@)"))
                   org-log-into-drawer "LOGBOOK")
@@ -1667,19 +1704,6 @@ I can use this to keep a journal.  I should use it.
               (org-journal-read-or-display-entry (yesterday-time)))))
 #+END_SRC
 
-**** org-page
-
-I would like to convert my website from using hugo to something else
-that I can work with nicely from inside Emacs.  I wonder if org-page
-will do the trick.
-
-#+BEGIN_SRC emacs-lisp
-(use-package org-page
-  :config (progn
-            (setq op/site-domain "https://alanpearce.uk/"
-                  op/repository-directory "~/projects/alanpearce/"
-                  op/personal-github-link "https://github.com/alanpearce")))
-#+END_SRC
 
 * Music
 Emacs actually supports playing music via mpd.
@@ -1703,7 +1727,15 @@ On-the-fly error checking in programming modes?  Yes please.
             (global-flycheck-mode)
             (setq flycheck-check-syntax-automatically '(save new-line mode-enabled))
             (if (executable-find "eslint_d")
-                (setq flycheck-javascript-eslint-executable (executable-find "eslint_d")))))
+                (setq flycheck-javascript-eslint-executable "eslint_d"))))
+#+END_SRC
+
+*** flycheck-flow
+
+#+BEGIN_SRC emacs-lisp
+(use-package flycheck-flow
+  :config (progn
+            (flycheck-add-next-checker 'javascript-eslint 'javascript-flow)))
 #+END_SRC
 
 ** golang
@@ -2000,19 +2032,39 @@ library implements some refactorings.
             (js2r-add-keybindings-with-prefix "C-c C-m")))
 #+END_SRC
 
-**** jade (not pug)
+**** add-node-modules-path
+
+Inside a javascript project, it's common to install tools locally to
+the project.  This will allows emacs to find their executables.
+
+#+BEGIN_SRC emacs-lisp
+(use-package add-node-modules-path
+  :config (progn
+            (add-hook 'js2-mode-hook #'add-node-modules-path)))
+#+END_SRC
+
+**** Indium
 
 Javascript with an inferior node.js process and a debugger?  Awesome.
 
 To debug with node, use version 6.9.1 or later of node and run it with
 ~--inspect~ and, to break on the first line, ~--debug-brk~.
 
-For Chrom*, it needs to be launched with ~--remote-debugging-port=9222~
+For Chrom*, it needs to be launched with
+~--remote-debugging-port=9222~
+
+Node will tell you to open an URL in Chrome:
+
+~chrome-devtools://inspector.html?...&ws=127.0.0.1:PORT/PATH~
+
+Instead, do this:
+
+~M-x indium-connect-to-nodejs RET 127.0.0.1 RET PORT RET~
 
 #+BEGIN_SRC emacs-lisp
-(use-package jade
+(use-package indium
   :config (progn
-            (add-hook 'js2-mode-hook #'jade-interaction-mode)))
+            (add-hook 'js2-mode-hook #'indium-interaction-mode)))
 #+END_SRC
 
 *** coffee-mode
@@ -2036,8 +2088,10 @@ completions, besides other IDE-like things.
   :defer 5
   :config (progn
             (setq tern-command (list (executable-find "tern")))
-            (add-hook 'js2-mode-hook #'tern-mode-enable)
-            (add-hook 'web-mode-hook #'tern-mode-enable)))
+            (create-hook-helper tern-mode-on ()
+              :hooks (web-mode-hook
+                      js2-mode-hook)
+              (tern-mode +1))))
 
 (with-eval-after-load 'tern
   (use-package company-tern))
@@ -2405,6 +2459,17 @@ and doesn’t go back to the same place more than once.
   :bind ("C-c C-SPC" . goto-last-change))
 #+END_SRC
 
+** beginend
+
+In special buffers, I would rather have =M->= and =M-<= goto the
+logical beginning/end rather than the physical ones.
+
+#+BEGIN_SRC emacs-lisp
+(use-package beginend
+  :config (progn
+            (beginend-setup-all)))
+#+END_SRC
+
 ** multiple-cursors
 
 I mentioned before that I’d used Sublime Text before.  Multiple
@@ -2472,16 +2537,6 @@ nice as the real version
             (add-hook 'coffee-mode-hook #'turn-off-smartparens-mode)))
 #+END_SRC
 
-** smart-scan
-
-Move between instances of a symbol
-
-#+BEGIN_SRC emacs-lisp
-(use-package smartscan
-  :config (progn
-            (global-smartscan-mode 1)
-            (setq smartscan-symbol-selector "symbol")))
-#+END_SRC
 
 ** move-text