diff options
author | Alan Pearce | 2016-11-04 19:18:24 +0100 |
---|---|---|
committer | Alan Pearce | 2016-11-04 19:18:24 +0100 |
commit | c96e914059715e05d6bcef50f53ee048f088bd92 (patch) | |
tree | c624f743c96ca50a66224a7b9180b1bc66ab31ed /tag-emacs/emacs.d | |
parent | c9a5e8b8a412daa6160e0d6d64c40bd978a7259b (diff) | |
parent | d18942af3be0ee634695630e2e0b17a3f12fd815 (diff) | |
download | dotfiles-c96e914059715e05d6bcef50f53ee048f088bd92.tar.lz dotfiles-c96e914059715e05d6bcef50f53ee048f088bd92.tar.zst dotfiles-c96e914059715e05d6bcef50f53ee048f088bd92.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'tag-emacs/emacs.d')
-rw-r--r-- | tag-emacs/emacs.d/init.org | 290 |
1 files changed, 141 insertions, 149 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index a0d3ba9..609f85c 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -322,8 +322,6 @@ configuration with crux.el :init (progn (defalias 'delete-current-buffer-file #'crux-delete-file-and-buffer) (defalias 'rename-current-buffer-file #'crux-rename-file-and-buffer))) - - #+END_SRC * Projects @@ -623,11 +621,12 @@ I like a horizonal diff setup, with everything in one frame. * Indentation Ah, a complicated topic. One day we’ll all be using elastic -tabstops. Until then, I want 4-wide tabs, and make them real tabs! +tabstops. I’ve recently switched to using two spaces, since elastic +tabstops is probably never going to happen. #+BEGIN_SRC emacs-lisp - (setq-default tab-width 4 - indent-tabs-mode t) + (setq-default tab-width 2 + indent-tabs-mode nil) #+END_SRC ** auto-indent-mode @@ -641,7 +640,7 @@ whitespace-sensitive language, of course. (setq auto-indent-key-for-end-of-line-then-newline "<C-return>" auto-indent-key-for-end-of-line-insert-char-then-newline "<C-S-return>" auto-indent-blank-lines-on-move nil - auto-indent-assign-indent-level 4 + auto-indent-assign-indent-level 2 auto-indent-backward-delete-char-behavior nil auto-indent-delete-trailing-whitespace-on-save-file t auto-indent-mode-untabify-on-yank-or-paste nil @@ -667,7 +666,7 @@ with spaces. Perfect! (use-package smart-tabs-mode :defer 1 :config (progn - (smart-tabs-insinuate 'c 'cperl 'javascript 'python) + (smart-tabs-insinuate 'c 'cperl 'python) (add-hook 'php-mode-hook (lambda () (smart-tabs-mode indent-tabs-mode))) (with-eval-after-load "align.el" @@ -820,7 +819,7 @@ point whilst I’m moving about. scroll-preserve-screen-position t mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control))) split-height-threshold 80 - split-width-threshold 130 + split-width-threshold 160 frame-resize-pixelwise nil) (if (boundp 'ns-pop-up-frames) (setq ns-pop-up-frames nil)) @@ -1077,8 +1076,8 @@ helps to make documentation for other languages easier to access A nicer way to browse keybindings for major modes. #+BEGIN_SRC emacs-lisp -(use-package discover-my-major - :bind ("<f1>" . discover-my-major)) + (use-package discover-my-major + :bind ("<f1>" . discover-my-major)) #+END_SRC ** which-key @@ -1175,9 +1174,9 @@ the prompt. I don’t remember what exactly. Occasionally, I exit emacs. I should probably reduce the frequency of this. #+BEGIN_SRC emacs-lisp -(if (daemonp) - (defalias 'exit-emacs #'delete-frame) - (defalias 'exit-emacs #'save-buffers-kill-emacs)) + (if (daemonp) + (defalias 'exit-emacs #'delete-frame) + (defalias 'exit-emacs #'save-buffers-kill-emacs)) #+END_SRC ** swiper/ivy @@ -1283,15 +1282,15 @@ don’t use it directly. Setup some modes for systemd files #+BEGIN_SRC emacs-lisp -(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-mode)) -(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-mode)) -(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-mode)) + (add-to-list 'auto-mode-alist '("\\.service\\'" . conf-mode)) + (add-to-list 'auto-mode-alist '("\\.target\\'" . conf-mode)) + (add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-mode)) #+END_SRC =direnv=’s files are basically shell scripts, it’s a nice way to set environment variables for projects. #+BEGIN_SRC emacs-lisp -(add-to-list 'auto-mode-alist '("\\.envrc\\'" . sh-mode)) + (add-to-list 'auto-mode-alist '("\\.envrc\\'" . sh-mode)) #+END_SRC Some modes that I don’t really customise much, mostly for @@ -1309,10 +1308,7 @@ configuration files. :mode (("Dockerfile\\'" . dockerfile-mode))) (use-package nix-mode - :mode (("\\.nix\\'" . nix-mode)) - :config (progn - (add-hook 'nix-mode-hook (lambda () - (setq-local indent-tabs-mode nil))))) + :mode (("\\.nix\\'" . nix-mode))) (define-derived-mode xmonad-mode haskell-mode "XM") (add-to-list 'auto-mode-alist '("xmobarrc\\'" . xmonad-mode)) @@ -1321,9 +1317,7 @@ configuration files. (use-package nginx-mode :defer t :mode (("/nginx/servers/" . nginx-mode) - ("/nginx/.*\\.d/" . nginx-mode)) - :config (progn - (setq nginx-indent-tabs-mode t))) + ("/nginx/.*\\.d/" . nginx-mode))) (use-package lua-mode :defer t) @@ -1370,9 +1364,6 @@ works really nicely. (find-file (expand-file-name "ledger/my.ledger" (projectile-project-root))) (ledger-report "Budget (Cumulative)" nil))) :config (progn - (defun setup-ledger-mode () - (setq-local indent-tabs-mode nil)) - (add-hook 'ledger-mode-hook #'setup-ledger-mode) (setq ledger-use-iso-dates t ledger-post-use-completion-engine :built-in ledger-reconcile-default-commodity "€" @@ -1399,18 +1390,16 @@ works really nicely. ** Markdown #+BEGIN_SRC emacs-lisp -(use-package markdown-mode - :defer t - :config (progn - (add-hook 'markdown-mode-hook #'turn-on-auto-fill))) + (use-package markdown-mode + :defer t + :config (progn + (add-hook 'markdown-mode-hook #'turn-on-auto-fill))) #+END_SRC ** Org Org is wünderbar. -*** TODO Check whether all this configuration is necessary or helpful. - #+BEGIN_SRC emacs-lisp (use-package org :bind (("C-c C-a" . org-agenda-list) @@ -1428,15 +1417,11 @@ Org is wünderbar. ;; ‘Remember’: new items at top org-reverse-note-order t - org-modules '(org-habit - org-protocol) + org-modules '(org-protocol) ;; Add time done to ‘done’ tasks org-log-done 'time - ;; Allow refiling into any org file - org-refile-targets '((org-agenda-files :maxlevel . 3)) - org-list-allow-alphabetical t org-adapt-indentation nil @@ -1458,15 +1443,7 @@ Org is wünderbar. org-log-into-drawer "LOGBOOK") (set-register ?o `(file . ,(expand-file-name "organiser.org" org-directory))) (add-hook 'org-mode-hook #'turn-on-auto-fill) - (org-load-modules-maybe t) - (defadvice org-clock-in (after wicked activate) - "Mark STARTED when clocked in" - (save-excursion - (catch 'exit - (org-back-to-heading t) - (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) - (if (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) - (org-todo "STARTED"))))) + (org-load-modules-maybe t))) #+END_SRC **** org-babel @@ -1477,13 +1454,13 @@ to have my =ledger= setup in an org file with some graph processing with R or something. #+BEGIN_SRC emacs-lisp -(use-package ob-core - :defer t - :ensure nil - :config (org-babel-do-load-languages - 'org-babel-load-languages - '((ledger . t) - (sh . t)))) + (use-package ob-core + :defer t + :ensure nil + :config (org-babel-do-load-languages + 'org-babel-load-languages + '((ledger . t) + (sh . t)))) #+END_SRC **** org-journal @@ -1542,7 +1519,7 @@ I can use this to keep a journal. I should use it. (file-name-as-directory org-mobile-directory) org-mobile-capture-file)))) (setq org-mobile-watcher - (file-notify-add-watch org-file '(change) #'ap/org-mobile-pull)))))))) + (file-notify-add-watch org-file '(change) #'ap/org-mobile-pull)))))) #+END_SRC **** org-caldav @@ -1565,6 +1542,20 @@ write to the Android calendar, and then for DAVDroid to sync with the server. org-icalendar-alarm-time 60))) #+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. @@ -1638,8 +1629,7 @@ A nice completion backend for programming modes. *** All Lisp modes don’t seem to have a common ancestor. So I made a custom -hook which I trigger in every lispy-mode. Of course, no tabs in -lisps. Even I understand that. +hook which I trigger in every lispy-mode. #+BEGIN_SRC emacs-lisp (defcustom lisp-mode-common-hook nil @@ -1648,8 +1638,7 @@ lisps. Even I understand that. :group 'lisp) (defun ap/lisp-setup () - (run-hooks 'lisp-mode-common-hook) - (setq indent-tabs-mode nil)) + (run-hooks 'lisp-mode-common-hook)) #+END_SRC **** Redshank @@ -1671,8 +1660,8 @@ Customise the modeline-display of =emacs-lisp-mode=. Then make sure it runs the common lisp hooks. #+BEGIN_SRC emacs-lisp -(add-hook 'emacs-lisp-mode-hook #'ap/lisp-setup) -(add-hook 'emacs-lisp-mode-hook #'eldoc-mode) + (add-hook 'emacs-lisp-mode-hook #'ap/lisp-setup) + (add-hook 'emacs-lisp-mode-hook #'eldoc-mode) #+END_SRC Go-to function for elisp. Except it works through the entire Emacs ecosystem. @@ -1688,12 +1677,12 @@ Go-to function for elisp. Except it works through the entire Emacs ecosystem. Interactive elisp #+BEGIN_SRC emacs-lisp -(use-package ielm - :defer t - :ensure nil - :config (progn - (add-hook 'ielm-mode-hook (lambda () - (run-hooks 'lisp-mode-common-hook))))) + (use-package ielm + :defer t + :ensure nil + :config (progn + (add-hook 'ielm-mode-hook (lambda () + (run-hooks 'lisp-mode-common-hook))))) #+END_SRC *** Scheme & Lisp @@ -1715,11 +1704,11 @@ A REPL thing for Scheme. Hopefully I’ll get to use it more in the future. #+BEGIN_SRC emacs-lisp -(use-package geiser - :commands (geiser-mode - geiser - run-geiser - run-racket)) + (use-package geiser + :commands (geiser-mode + geiser + run-geiser + run-racket)) #+END_SRC **** slime @@ -1727,14 +1716,14 @@ future. A REPL thing (and more) for Lisp. #+BEGIN_SRC emacs-lisp -(use-package slime - :commands (slime) - :config (progn - (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")))) + (use-package slime + :commands (slime) + :config (progn + (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")))) #+END_SRC *** Clojure @@ -1762,21 +1751,21 @@ A REPL thing (and more) for Lisp. A REPL thing for Clojure #+BEGIN_SRC emacs-lisp -(use-package cider - :defer t - :config (progn - (setq nrepl-hide-special-buffers t) - (unbind-key "C-c C-f" cider-mode-map) - (add-hook 'cider-mode-hook #'eldoc-mode))) + (use-package cider + :defer t + :config (progn + (setq nrepl-hide-special-buffers t) + (unbind-key "C-c C-f" cider-mode-map) + (add-hook 'cider-mode-hook #'eldoc-mode))) #+END_SRC ** Auto-compile Auto-compile emacs lisp when saving. #+BEGIN_SRC emacs-lisp -(use-package auto-compile - :defer t - :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) + (use-package auto-compile + :defer t + :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) #+END_SRC ** cc-mode @@ -1785,16 +1774,16 @@ Although I don’t use C or C++, setting up the mode is helpful because quite a few other modes are derived from it. #+BEGIN_SRC emacs-lisp -(use-package cc-mode - :defer 5 - :init (progn - (add-hook 'c-mode-common-hook #'electric-indent-mode)) - :config (progn + (use-package cc-mode + :defer 5 + :init (progn + (add-hook 'c-mode-common-hook #'electric-indent-mode)) + :config (progn (setq c-default-style '((java-mode . "java") - (awk-mode . "awk") - (other . "k&r")) - c-basic-offset 4) - (c-set-offset 'case-label '+))) + (awk-mode . "awk") + (other . "k&r")) + c-basic-offset 4) + (c-set-offset 'case-label '+))) #+END_SRC ** quickrun @@ -1802,8 +1791,8 @@ quite a few other modes are derived from it. It’s nice to be able to quickly evaluate some code. Although I don’t really seem to use it. #+BEGIN_SRC emacs-lisp -(use-package quickrun - :bind (("C-c C-e" . quickrun))) + (use-package quickrun + :bind (("C-c C-e" . quickrun))) #+END_SRC ** Scala @@ -1845,7 +1834,6 @@ it though (fboundp #'do-it)) (do-it name))) (advice-add 'imenu-add-to-menubar :around #'js2--imenu-around) - (setq js2-skip-preprocessor-directives t) (defun ap/javascript-setup () (auto-indent-mode -1)) (defun ap/js2-prev-error () @@ -1854,7 +1842,7 @@ it though (bind-key "M-g M-n" #'js2-next-error js2-mode-map) (bind-key "M-g M-p" #'ap/js2-prev-error js2-mode-map) (add-hook 'js2-mode-hook #'ap/javascript-setup) - (setq js2-basic-offset 4 + (setq js2-basic-offset 2 js2-include-node-externs t))) #+END_SRC @@ -1919,9 +1907,9 @@ integration between the two yet. This is for HTML, since old versions of HTML were derived from SGML. #+BEGIN_SRC emacs-lisp -(use-package sgml-mode - :defer t - :config (setq sgml-basic-offset 4)) + (use-package sgml-mode + :defer t + :config (setq sgml-basic-offset 2)) #+END_SRC *** emmet-mode @@ -1949,9 +1937,9 @@ of them as well. ("/templates/.*\\.php\\'" . web-mode) ("\\.ejs\\'" . web-mode)) :config (progn - (setq web-mode-code-indent-offset 4 - web-mode-css-indent-offset 4 - web-mode-markup-indent-offset 4 + (setq web-mode-code-indent-offset 2 + web-mode-css-indent-offset 2 + web-mode-markup-indent-offset 2 web-mode-style-padding 0 web-mode-script-padding 0 web-mode-comment-style 2 @@ -1963,8 +1951,8 @@ of them as well. I derived a mode for twig, in order to use its =mode-hook=. #+BEGIN_SRC emacs-lisp -(define-derived-mode twig-mode web-mode "Twig") -(add-to-list 'auto-mode-alist '("\\.html\\.twig\\'" . twig-mode)) + (define-derived-mode twig-mode web-mode "Twig") + (add-to-list 'auto-mode-alist '("\\.html\\.twig\\'" . twig-mode)) #+END_SRC * Spelling @@ -1982,12 +1970,16 @@ I derived a mode for twig, in order to use its =mode-hook=. Make a shell-script buffer executable after saving it, if it has a shebang. #+BEGIN_SRC emacs-lisp -(add-hook 'after-save-hook - #'executable-make-buffer-file-executable-if-script-p) + (add-hook 'after-save-hook + #'executable-make-buffer-file-executable-if-script-p) -(use-package sh-script - :mode (("\\.zsh\\'" . shell-script-mode)) - :config (setq sh-shell-file "/usr/bin/env zsh")) + (use-package sh-script + :mode (("\\.zsh\\'" . shell-script-mode) + ("zshenv\\'" . shell-script-mode) + ("zshrc\\'" . shell-script-mode)) + :config (setq sh-shell-file "/usr/bin/env zsh" + sh-indentation 2 + sh-basic-offset 2)) #+END_SRC #+BEGIN_SRC emacs-lisp @@ -2081,11 +2073,11 @@ The most important one for me is JSON property alignment. I like to use the clipboard more than the primary selection in X11. #+BEGIN_SRC emacs-lisp -(setq x-select-enable-clipboard t) -(if (functionp 'x-cut-buffer-or-selection-value) - (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)) -(when (boundp 'x-select-request-type) - (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) + (setq x-select-enable-clipboard t) + (if (functionp 'x-cut-buffer-or-selection-value) + (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)) + (when (boundp 'x-select-request-type) + (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) #+END_SRC ** Selection @@ -2168,14 +2160,14 @@ cursors was one of my favourite features, so I was really happy when I 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))) + (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))) #+END_SRC ** paredit @@ -2244,8 +2236,8 @@ Move between instances of a symbol Transposing lines, made easier. #+BEGIN_SRC emacs-lisp -(use-package move-text - :config (move-text-default-bindings)) + (use-package move-text + :config (move-text-default-bindings)) #+END_SRC ** undo-tree @@ -2254,21 +2246,21 @@ Emacs’ default handling of undo is a bit confusing. Undo-tree makes it much clearer. It’s especially helpful for protoyping and refactoring. #+BEGIN_SRC emacs-lisp -(use-package undo-tree - :config (progn - (global-undo-tree-mode) - ;; Keep region when undoing in region - (defadvice undo-tree-undo (around keep-region activate) - (if (use-region-p) - (let ((m (set-marker (make-marker) (mark))) - (p (set-marker (make-marker) (point)))) - ad-do-it - (goto-char p) - (set-mark m) - (set-marker p nil) - (set-marker m nil)) - ad-do-it))) - :diminish undo-tree-mode) + (use-package undo-tree + :config (progn + (global-undo-tree-mode) + ;; Keep region when undoing in region + (defadvice undo-tree-undo (around keep-region activate) + (if (use-region-p) + (let ((m (set-marker (make-marker) (mark))) + (p (set-marker (make-marker) (point)))) + ad-do-it + (goto-char p) + (set-mark m) + (set-marker p nil) + (set-marker m nil)) + ad-do-it))) + :diminish undo-tree-mode) #+END_SRC ** visual-regexp @@ -2278,10 +2270,10 @@ so this package is pretty useful because it highlights everything in the buffer for me. #+BEGIN_SRC emacs-lisp -(use-package visual-regexp - :bind (("C-c r" . vr/replace) - ("C-c q" . vr/query-replace) - ("C-c m" . vc/mc-mark))) + (use-package visual-regexp + :bind (("C-c r" . vr/replace) + ("C-c q" . vr/query-replace) + ("C-c m" . vc/mc-mark))) #+END_SRC * Tangling |