summary refs log tree commit diff stats
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/ap-spotcap.local.el.gpgbin2447 -> 2136 bytes
-rw-r--r--emacs/.emacs.d/init.org190
2 files changed, 140 insertions, 50 deletions
diff --git a/emacs/.emacs.d/ap-spotcap.local.el.gpg b/emacs/.emacs.d/ap-spotcap.local.el.gpg
index c17384c..e8c7590 100644
--- a/emacs/.emacs.d/ap-spotcap.local.el.gpg
+++ b/emacs/.emacs.d/ap-spotcap.local.el.gpg
Binary files differdiff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org
index 305787e..034ac0b 100644
--- a/emacs/.emacs.d/init.org
+++ b/emacs/.emacs.d/init.org
@@ -120,10 +120,6 @@ Ring the bell sometimes, but not so often
           (ding))))
 #+END_SRC
 
-#+BEGIN_SRC emacs-lisp
-(use-package dash)
-#+END_SRC
-
 ** Colours
 
 Let’s try a more minimal theme.
@@ -329,7 +325,7 @@ modes.
               (setq cyphejor-rules `(("emacs"       "ε")
                                      ("diff"        "Δ")
                                      ("js2"         "js")
-                                     ("magit-status" ,(char-to-string (-find #'char-displayable-p '(11942 5848 177))))
+                                     ("magit-status" ,(char-to-string (seq-find #'char-displayable-p '(11942 5848 177))))
                                      ("inferior"    "i" :prefix)
                                      ("interaction" "i" :prefix)
                                      ("interactive" "i" :prefix)
@@ -430,14 +426,9 @@ configuration with crux.el
 * Projects
 
 #+BEGIN_SRC emacs-lisp
-(defvar work-project-directory "~/work")
-(defvar home-project-directory "~/projects")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
 (defun switch-to-dotfiles ()
   (interactive)
-  (projectile-switch-project-by-name (expand-file-name "~/dotfiles")))
+  (projectile-switch-project-by-name (car (split-string (shell-command-to-string "ghq list --full-path dotfiles")))))
 #+END_SRC
 
 ** The Silver Searcher
@@ -483,17 +474,6 @@ based upon some folder conventions I use.
   :config (progn
             (projectile-global-mode)
             (add-to-list 'projectile-globally-ignored-directories ".stversions")
-            (defun ap/subfolder-projects (dir)
-              (--map (file-relative-name it dir)
-                     (-filter (lambda (subdir)
-                                (--reduce-from (or acc (funcall it subdir)) nil
-                                               projectile-project-root-files-functions))
-                              (-filter #'file-directory-p (directory-files dir t "\\<")))))
-
-            (defun ap/open-subfolder-project (from-dir &optional arg)
-              (let ((project-dir (projectile-completing-read "Open project: "
-                                                             (ap/subfolder-projects from-dir))))
-                (projectile-switch-project-by-name (expand-file-name project-dir from-dir) arg)))
 
             (defun yarn-install (&optional arg)
               (interactive "P")
@@ -510,16 +490,24 @@ based upon some folder conventions I use.
               (projectile-with-default-dir (projectile-project-root)
                 (cmd-to-echo "yarn" (concat "add " package))))
 
-            (defun ap/open-work-project (&optional arg)
-              (interactive "P")
-              (ap/open-subfolder-project work-project-directory arg))
+            (defun yarn-run (cmd)
+              (interactive "scommand: ")
+              (projectile-with-default-dir (projectile-project-root)
+                (cmd-to-echo "yarn" (concat "run " cmd))))
 
-            (defun ap/open-home-project (&optional arg)
+            (defun ap/open-project (&optional arg)
               (interactive "P")
-              (ap/open-subfolder-project home-project-directory arg))
+              (let ((project-dir (projectile-completing-read
+                                  "Open project: "
+                                  (ghq--find-projects))))
+                (projectile-switch-project-by-name
+                 (expand-file-name project-dir (ghq--find-root)) arg)))
 
             (setq projectile-switch-project-action #'projectile-commander
                   projectile-completion-system 'ivy)))
+
+(use-package counsel-projectile
+  :config (counsel-projectile-on))
 #+END_SRC
 
 ** vc
@@ -583,6 +571,17 @@ a particular way, but it changed later.
   :commands git-timemachine)
 #+END_SRC
 
+** ghq
+
+[[https://github.com/motemen/ghq][=ghq=]] clones VCS-backed projects to a common directory.  It should
+seem familiar to anyone who's used =go get= before.  [[https://github.com/rcoedo/emacs-ghq][=emacs-ghq=]] is a
+simple wrapper for it.
+
+#+BEGIN_SRC emacs-lisp
+(use-package ghq
+  :if (executable-find "ghq"))
+#+END_SRC
+
 * Files
 
 ** Auto-saving
@@ -718,13 +717,6 @@ that I can sudo on remote machines
             (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" (concat "/" tramp-default-method ":%h:")))
             (add-to-list 'tramp-default-proxies-alist `(,(regexp-quote (system-name)) nil nil))
             (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))))
-
-(use-package tramp-sh
-  :ensure nil
-  :defer t
-  :config (progn
-            (add-to-list 'tramp-remote-path "/usr/local/sbin")
-            (add-to-list 'tramp-remote-path "~/bin")))
 #+END_SRC
 
 ** ediff
@@ -965,7 +957,6 @@ seems to work perfectly well for me.
 
 #+BEGIN_SRC emacs-lisp
 (use-package company-nixos-options
-  :if (eq system-type 'gnu/linux)
   :config (progn
             (add-to-list 'company-backends 'company-nixos-options)))
 #+END_SRC
@@ -1120,9 +1111,9 @@ helps to make documentation for other languages easier to access
     `(progn
        (defun ,fun ()
          (when (require 'counsel-dash nil :noerror)
-           (-each (-difference ',docsets
-                               (helm-dash-installed-docsets))
-             #'counsel-dash-install-docset)
+           (seq-map #'counsel-dash-install-docset
+             (seq-difference ',docsets
+                                  (helm-dash-installed-docsets)))
            (setq-local counsel-dash-docsets ',docsets)))
        (add-hook (quote ,hook) (function ,fun)))))
 
@@ -1176,6 +1167,52 @@ rather useful.
             (setq eldoc-idle-delay 0.1)
             (eldoc-add-command 'paredit-backward-delete 'paredit-close-round)))
 #+END_SRC
+* Mail
+
+** Gnus
+
+At work, I use gnus for email.  Some of the setup is specific to my
+workplace, so I keep it in a host-specific, GPG-encrypted file.
+
+#+BEGIN_SRC emacs-lisp
+(use-package gnus
+  :config (progn
+            (setq gnus-gcc-mark-as-read t
+                  mml-secure-openpgp-encrypt-to-self t
+                  send-mail-function #'smtpmail-send-it
+                  message-send-mail-function #'smtpmail-send-it)))
+
+(with-eval-after-load 'gnus-mime
+  (define-key gnus-mime-button-map " " #'gnus-mime-view-part-externally))
+
+(with-eval-after-load "mailcap"
+  (when (eq system-type 'darwin)
+    (mailcap-add-mailcap-entry "application" "pdf" '((viewer . "/usr/bin/qlmanage -p %s") (type . "application/pdf")))))
+
+(with-eval-after-load "mm-decode"
+  (add-to-list 'mm-discouraged-alternatives "text/html")
+  (add-to-list 'mm-discouraged-alternatives "text/richtext"))
+#+END_SRC
+
+** BBDB
+
+As I'm using Emacs for email, it makes sense to have contact
+information here as well.
+
+#+BEGIN_SRC emacs-lisp
+(use-package bbdb
+  :config (progn
+            (bbdb-initialize 'gnus 'mail 'message 'pgp)
+            (bbdb-mua-auto-update-init 'gnus 'message)
+            (setq bbdb-send-mail-style 'gnus
+                  bbdb-complete-mail-allow-cycling t
+                  bbdb-mua-auto-update t
+                  bbdb-mua-update-interactive-p '(query . create)
+                  bbdb-message-all-addresses t
+                  bbdb-offer-save t
+                  bbdb-offer-to-create 1)))
+#+END_SRC
+
 * Misc
 
 #+BEGIN_SRC emacs-lisp
@@ -1320,8 +1357,8 @@ replacement for helm so far.
   :demand t
   :config (progn
             (ivy-mode 1)
-            (setq ivy-re-builders-alist '((internal-complete-buffer . ivy--regex-fuzzy)
-                                          (t . ivy--regex-plus)))
+            (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)
@@ -1848,6 +1885,14 @@ I don’t work with these as often as I would like
 (add-hook 'lisp-mode-hook #'set-common-lisp-indentation)
 #+END_SRC
 
+**** hyperspec
+
+#+BEGIN_SRC emacs-lisp
+(use-package hyperspec
+  :config (progn
+            (setq common-lisp-hyperspec-root "file://opt/local/share/doc/lisp/HyperSpec-7-0/")))
+#+END_SRC
+
 **** geiser
 
 A REPL thing for Scheme.  Hopefully I’ll get to use it more in the
@@ -1872,8 +1917,9 @@ A REPL thing (and more) for Lisp.
             (let ((ql-slime-helper (expand-file-name "~/quicklisp/slime-helper.el")))
               (if (file-exists-p ql-slime-helper)
                   (load ql-slime-helper))
-              (slime-setup))
-            (setq inferior-lisp-program (executable-find "sbcl"))))
+              (slime-setup '(slime-fancy slime-asdf)))
+            (setq inferior-lisp-program (or (executable-find "sbcl")
+                                            (executable-find "ccl64")))))
 #+END_SRC
 
 *** Clojure
@@ -2138,6 +2184,53 @@ I derived a mode for twig, in order to use its =mode-hook=.
                                                  ispell-really-hunspell t)))))
 #+END_SRC
 
+#+BEGIN_SRC emacs-lisp
+(use-package flyspell
+  :config (progn
+            (defun flyspell-detect-ispell-args (&optional run-together)
+              "If RUN-TOGETHER is true, spell check the CamelCase words.
+ Please note RUN-TOGETHER will make aspell less capable. So it should only be used in prog-mode-hook."
+              (let (args)
+                (when ispell-program-name
+                  (cond
+                   ((string-match "aspell$" ispell-program-name)
+                    (setq args (list "--sug-mode=ultra"))
+                    (if run-together
+                        (setq args (append args '("--run-together" "--run-together-limit=16" "--run-together-min=2")))))
+                   ((string-match "hunspell$" ispell-program-name)
+                    (setq args nil))))
+                args))
+            ;; `ispell-extra-args' is *always* used when start CLI aspell process
+            (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
+            ;; (setq ispell-cmd-args (flyspell-detect-ispell-args))
+            (defadvice ispell-word (around my-ispell-word activate)
+              (let ((old-ispell-extra-args ispell-extra-args))
+                (ispell-kill-ispell t)
+                ;; use emacs original arguments
+                (setq ispell-extra-args (flyspell-detect-ispell-args))
+                ad-do-it
+                ;; restore our own ispell arguments
+                (setq ispell-extra-args old-ispell-extra-args)
+                (ispell-kill-ispell t)))
+
+            (defadvice flyspell-auto-correct-word (around my-flyspell-auto-correct-word activate)
+              (let* ((old-ispell-extra-args ispell-extra-args))
+                (ispell-kill-ispell t)
+                ;; use emacs original arguments
+                (setq ispell-extra-args (flyspell-detect-ispell-args))
+                ad-do-it
+                ;; restore our own ispell arguments
+                (setq ispell-extra-args old-ispell-extra-args)
+                (ispell-kill-ispell t)))
+            (setq flyspell-issue-message-flag nil)
+
+            (defun fly-text-mode-hook-setup ()
+              ;; Turn off RUN-TOGETHER option when spell check text-mode
+              (setq-local ispell-extra-args (flyspell-detect-ispell-args)))
+            (add-hook 'text-mode-hook 'fly-text-mode-hook-setup)
+            (add-hook 'prog-mode-hook #'flyspell-prog-mode)))
+#+END_SRC
+
 * Scripting
 
 Make a shell-script buffer executable after saving it, if it has a shebang.
@@ -2274,8 +2367,6 @@ I like to use the clipboard more than the primary selection in X11.
          ("s" . copy-as-format-slack)))
 #+END_SRC
 
-**
-
 ** Selection
 
 I’m quite used to deleting text by selecting it and typing.  Emacs has
@@ -2363,12 +2454,11 @@ saw that multiple-cursors was released for Emacs.
 #+BEGIN_SRC emacs-lisp
 (use-package multiple-cursors
   :defer 1
-  :config (progn
-            (bind-key "C-." #'mc/mark-next-like-this)
-            (bind-key "C-," #'mc/mark-previous-like-this)
-            (bind-key "M-<f3>" #'mc/mark-all-like-this-dwim)
-            (bind-key "C-<f3>" #'mc/mark-more-like-this-extended)
-            (bind-key "C-S-L" #'mc/edit-lines)))
+  :bind* (("C-." . mc/mark-next-like-this)
+          ("C-," . mc/mark-previous-like-this)
+          ("M-<f3>" . mc/mark-all-like-this-dwim)
+          ("C-<f3>" . mc/mark-more-like-this-extended)
+          ("C-S-L" . mc/edit-lines)))
 #+END_SRC
 
 ** paredit