diff options
Diffstat (limited to 'emacs/.emacs.d/init.org')
-rw-r--r-- | emacs/.emacs.d/init.org | 369 |
1 files changed, 167 insertions, 202 deletions
diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index d15dcd65..d428bd89 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -1,12 +1,14 @@ +# # emacs-config --- Summary #+TITLE: Emacs Configuration for Alan Pearce #+OPTIONS: ^:nil #+PROPERTY: results silent #+PROPERTY: eval no-export #+PROPERTY: header-args :comments link -* Introduction +* Header This is a living document, detailing my Emacs configuration using org-mode -* Basics -** Startup +* Code +** Basics +*** Startup Open Emacs with just a plain window. No graphics or messages, please! #+BEGIN_SRC emacs-lisp (put 'inhibit-startup-echo-area-message 'saved-value @@ -29,7 +31,7 @@ Are we running on Windows via the WSL? (setq system-type 'gnu/linux/windows)))) #+END_SRC -** Compatibility +*** Compatibility #+BEGIN_SRC emacs-lisp (if (version< emacs-version "25.0") @@ -37,7 +39,7 @@ Are we running on Windows via the WSL? `(eval-after-load ,file (lambda () ,@body)))) #+END_SRC -** Scratch buffers +*** Scratch buffers I usually use scratch buffers for any sort of text. If I need a programming mode in one, then I’ll just call it manually. I also like the buffer to be empty. @@ -46,15 +48,15 @@ the buffer to be empty. initial-major-mode 'text-mode) #+END_SRC -** Personal Information +*** Personal Information #+BEGIN_SRC emacs-lisp (setq user-mail-address "alan@alanpearce.eu" user-full-name "Alan Pearce") #+end_src -* Packaging +** Packaging -** Use-package +*** Use-package #+BEGIN_SRC emacs-lisp (eval-and-compile @@ -100,9 +102,9 @@ the buffer to be empty. package-enable-at-startup nil) #+END_SRC -** Helpers +*** Helpers -*** Hook Helpers +**** Hook Helpers An improvement over add-hook with lamda functions that allows modification and removal, without the boilerplate of an extra function @@ -113,7 +115,7 @@ definition. (use-package hook-helpers)) #+END_SRC -* Customize +** Customize I don’t really like using customize for normal configuration. Instead, I use it for things that get saved automatically. That’s why I use a different file, which is ignored by the VCS. It also means @@ -125,7 +127,7 @@ pass =:noerror= to =load= (load custom-file :noerror :nomessage) #+END_SRC -* Styles +** Styles I prefer an always-visible cursor. Feels less distracting. #+BEGIN_SRC emacs-lisp @@ -155,7 +157,7 @@ Ring the bell sometimes, but not so often (ding)))) #+END_SRC -** Colours +*** Colours Eziam looks nice, too, except for the non-white background. I prefer white because most other application backgrounds are that colour. @@ -212,7 +214,7 @@ can enable it if needed. :diminish highlight-stages-mode) #+END_SRC -** Fonts +*** Fonts When possible, set up fonts. I don’t have any settings here for X11, because I manage those in my [[file:~/projects/dotfiles/tag-xresources/xresources/main][XResources file]]. @@ -277,7 +279,7 @@ it has it's own, more extensive version. (global-prettify-symbols-mode +1)) #+END_SRC -** Page Breaks +*** Page Breaks By default, Emacs displays page breaks as ^L. Lines look much nicer. On Windows, Emacs incorrectly detects that U+2500 (Box Drawings Light @@ -295,7 +297,7 @@ correct, at least for Liberation Mono. (cons page-break-lines-char page-break-lines-char) (face-attribute 'default :family))))) #+END_SRC -** Modeline +*** Modeline #+BEGIN_SRC emacs-lisp (column-number-mode -1) @@ -325,7 +327,7 @@ correct, at least for Liberation Mono. '(dired-directory (" — " dired-directory)))) #+END_SRC -** Chrome +*** Chrome Sometimes I like to hide clutter. Other times, it's useful. @@ -383,7 +385,7 @@ Sometimes I like to hide clutter. Other times, it's useful. (add-hook 'minibuffer-exit-hook #'hide-mode-line) #+END_SRC -** Highlight Changes +*** Highlight Changes Highlight what just changed when I undo, yank, and so on. @@ -394,7 +396,7 @@ Highlight what just changed when I undo, yank, and so on. (volatile-highlights-mode t))) #+END_SRC -** Beacon +*** Beacon I was against the idea of having flashy animations inside Emacs, but this one is useful. It highlights the cursor when scrolling or @@ -411,7 +413,7 @@ switching windows. beacon-color "#a1b56c"))) #+END_SRC -** Renaming major modes +*** Renaming major modes Diminishing major modes does not happen in the same manner as minor modes. @@ -436,7 +438,7 @@ modes. #+END_SRC -* Environment Variables +** Environment Variables MacOS doesn’t have a reasonable way to set environment variables and read them automatically any more. So, let’s use the @@ -457,7 +459,7 @@ It starts up without an environment in this case as well. (exec-path-from-shell-initialize))) #+END_SRC -** NixOS sandboxes +*** NixOS sandboxes I'm currently exploring using nix to create sandboxes for development. This package allows using tools from inside sandboxes, @@ -479,7 +481,7 @@ and some convenience commands for building packages and launching shells. (executable-find cmd))))))) #+END_SRC -* Keybindings +** Keybindings I think =set-keyboard-coding-system= stops OS X from doing something annoying to add accents. The modifier setup is to match my @@ -533,7 +535,7 @@ Option/alt, then Control. (set-register ?z `(file . ,(expand-file-name ".config/zsh/zshrc" "~"))) #+END_SRC -** Crux +*** Crux I can replace most of the simple helper/wrapper functions in my configuration with crux.el @@ -554,7 +556,7 @@ configuration with crux.el (defalias 'rename-current-buffer-file #'crux-rename-file-and-buffer))) #+END_SRC -* Projects +** Projects #+BEGIN_SRC emacs-lisp (defun switch-to-dotfiles () @@ -562,7 +564,7 @@ configuration with crux.el (projectile-switch-project-by-name (car (split-string (shell-command-to-string "ghq list --full-path dotfiles"))))) #+END_SRC -** The Silver Searcher +*** The Silver Searcher #+BEGIN_SRC emacs-lisp (use-package ag @@ -573,7 +575,7 @@ configuration with crux.el :after ag) #+END_SRC -** Ripgrep +*** Ripgrep Step over Silver Search, here comes a new challenger. @@ -587,7 +589,7 @@ Step over Silver Search, here comes a new challenger. :bind (("C-c p s r" . projectile-ripgrep))) #+END_SRC -** Projectile +*** Projectile Projectile is awesome for working in projects, especially VCS-backed ones. @@ -657,7 +659,7 @@ ones. (define-key projectile-mode-map [remap counsel-projectile-ag] #'counsel-projectile-rg))) #+END_SRC -** vc +*** vc This is nice for some things that magit doesn’t do, and for those rare occasions that I’m working with something other than git. @@ -673,7 +675,7 @@ occasions that I’m working with something other than git. tramp-file-name-regexp)))) #+END_SRC -** git-gutter-fringe +*** git-gutter-fringe It’s nice to be able to see at a glance which lines of a file have changed. This package colours the fringe. I have it set to the right @@ -701,7 +703,7 @@ fringe so it doesn’t interfere with flycheck. (setq git-gutter-fr:side 'right-fringe))) #+END_SRC -** magit +*** magit Magit is my favourite way to use git. I use selective staging all the time. Make sure to set it up with a nice =completing-read-function= @@ -718,7 +720,7 @@ time. Make sure to set it up with a nice =completing-read-function= :init (add-hook 'magit-mode-hook #'magit-load-config-extensions)) #+END_SRC -** git-messenger +*** git-messenger Popup the last commit that changed the line at point. @@ -729,7 +731,7 @@ Popup the last commit that changed the line at point. (setq git-messenger:use-magit-popup t))) #+END_SRC -** git-timemachine +*** git-timemachine This package allow me to go through a file’s history with just a few keys. It makes it very easy to figure what what exactly was in a file @@ -741,7 +743,7 @@ a particular way, but it changed later. :commands git-timemachine) #+END_SRC -** ghq +*** 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 @@ -752,9 +754,9 @@ simple wrapper for it. :if (executable-find "ghq")) #+END_SRC -* Files +** Files -** Auto-saving +*** Auto-saving Auto-save everything to a temporary directory, instead of cluttering the filesystem. I don’t want emacs-specific lockfiles, either. @@ -763,7 +765,7 @@ the filesystem. I don’t want emacs-specific lockfiles, either. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)) create-lockfiles nil) #+END_SRC -** Backups +*** Backups I like to keep my backups out of regular folders. I tell emacs to use a subfolder of its configuration directory for that. Also, use the @@ -784,7 +786,7 @@ trash for deleting on OS X. file)))) #+END_SRC -** autorevert +*** autorevert #+BEGIN_SRC emacs-lisp (use-package autorevert @@ -795,7 +797,7 @@ trash for deleting on OS X. auto-revert-use-notify (not (eq system-type 'darwin))))) #+END_SRC -** Encoding +*** Encoding UTF-8 is usually appropriate. Note that =prefer-coding-system= expects only a coding system, not a coding system and line ending combination. @@ -805,7 +807,7 @@ only a coding system, not a coding system and line ending combination. (setq-default buffer-file-coding-system 'utf-8-auto-unix) #+END_SRC -** Buffer-file management +*** Buffer-file management Ask if I want to create a directory when it doesn’t exist. This is especially nice when starting new projects. @@ -836,7 +838,7 @@ with a buffer. (kill-buffer buf))))) #+END_SRC -** Whitespace +*** Whitespace Show bad whitespace, so that I can fix it. @@ -851,7 +853,7 @@ Show bad whitespace, so that I can fix it. (add-hook 'text-mode-hook #'show-trailing-whitespace-on) #+END_SRC -** shrink-whitespace +*** shrink-whitespace DWIM whitespace removal. So I don’t need =M-SPC=, =M-\= and =C-x o= for similar things any more. @@ -861,7 +863,7 @@ for similar things any more. :bind ("M-SPC" . shrink-whitespace)) #+END_SRC -** Tramp +*** Tramp Tramp is awesome. It makes SSH feel Unix-y. The proxy setup is so that I can sudo on remote machines @@ -888,7 +890,7 @@ that I can sudo on remote machines (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)))) #+END_SRC -** ediff +*** ediff I like a horizonal diff setup, with everything in one frame. @@ -900,7 +902,7 @@ I like a horizonal diff setup, with everything in one frame. ediff-window-setup-function 'ediff-setup-windows-plain))) #+END_SRC -* Indentation +** Indentation Ah, a complicated topic. One day we’ll all be using elastic tabstops. I’ve recently switched to using two spaces, since elastic @@ -913,7 +915,7 @@ tabstops is probably never going to happen. #+END_SRC -** smart-tabs-mode +*** smart-tabs-mode Not related to [[smart-tab][=smart-tab=]], this mode indents with tabs and aligns with spaces. Perfect! @@ -927,7 +929,7 @@ with spaces. Perfect! (smart-tabs-mode indent-tabs-mode)))) #+END_SRC -** editorconfig +*** editorconfig #+BEGIN_SRC emacs-lisp (use-package editorconfig @@ -935,7 +937,7 @@ with spaces. Perfect! :config (editorconfig-mode 1)) #+END_SRC -** dtrt-indent-mode +*** dtrt-indent-mode Sometimes people use different indentation settings. [[https://github.com/jscheid/dtrt-indent][dtrt-indent]] guesses the correct settings for me. @@ -951,9 +953,9 @@ guesses the correct settings for me. (smart-tabs-mode (or indent-tabs-mode -1))))) #+END_SRC -* Security +** Security -** password-store +*** password-store This is a frontend to the GPG-powered =pass= program. #+BEGIN_SRC emacs-lisp @@ -962,9 +964,9 @@ This is a frontend to the GPG-powered =pass= program. :config (progn (setq password-store-password-length 16))) #+END_SRC -* Buffers +** Buffers -** Ibuffer +*** Ibuffer Ibuffer is quite nice for listing all buffers. #+BEGIN_SRC emacs-lisp @@ -1000,7 +1002,7 @@ Ibuffer is quite nice for listing all buffers. filename-and-process))))) #+END_SRC -** Relative Buffer names +*** Relative Buffer names #+BEGIN_SRC emacs-lisp (use-package relative-buffers @@ -1008,7 +1010,7 @@ Ibuffer is quite nice for listing all buffers. :config (progn (global-relative-buffers-mode))) #+END_SRC -** Narrowing +*** Narrowing Enable it without prompting @@ -1018,7 +1020,7 @@ Enable it without prompting (put 'narrow-to-region 'disabled nil) #+END_SRC -** ace-window +*** ace-window I don’t often have many windows open at once, but when I do, =ace-window= is really nice to jump around them in the same way that @@ -1041,7 +1043,7 @@ I don’t often have many windows open at once, but when I do, aw-keys '(?a ?r ?s ?t ?n ?e ?i ?o)))) #+END_SRC -* Windows +** Windows Scrolling is tricky. I use this setup to help me keep track of the point whilst I’m moving about. @@ -1058,7 +1060,7 @@ point whilst I’m moving about. (setq ns-pop-up-frames nil)) #+END_SRC -** eyebrowse +*** eyebrowse Workspaces, a bit like dwm. On Windows and Linux (at least the WMs I'm likely to use), super+{0-9} are taken from the OS, so use meta @@ -1095,9 +1097,9 @@ programs to switch between program windows or views. (eyebrowse-mode +1))) #+END_SRC -* Sessions +** Sessions -** Desktop +*** Desktop Save my Emacs session and restore it on startup. #+BEGIN_SRC emacs-lisp @@ -1116,7 +1118,7 @@ Save my Emacs session and restore it on startup. (desktop-save-mode 1))) #+END_SRC -** winner +*** winner Undo, for window-based commands. @@ -1127,7 +1129,7 @@ Undo, for window-based commands. (winner-mode 1))) #+END_SRC -** windmove +*** windmove Directional window movement @@ -1138,7 +1140,7 @@ Directional window movement ("S-<up>" . windmove-up) ("S-<down>" . windmove-down))) #+END_SRC -* Blogging +** Blogging I have a [[https://alanpearce.uk][blog]] that I publish with hugo. @@ -1149,7 +1151,7 @@ I have a [[https://alanpearce.uk][blog]] that I publish with hugo. easy-hugo-default-ext ".md")) #+END_SRC -* Completion +** Completion Make built-in completion a bit more intelligent, by adding substring and initial-based completion and ignoring case. @@ -1160,7 +1162,7 @@ and initial-based completion and ignoring case. tab-always-indent 'complete) #+END_SRC -** Company +*** Company The main choices for automatic completion in Emacs are company and auto-complete-mode. I’ve not tried auto-complete-mode as company @@ -1194,9 +1196,9 @@ seems to work perfectly well for me. :after company) #+END_SRC -* Dates & Times +;;; * Dates: & Times -** Calendar +*** Calendar Weeks start on Monday for me and I prefer ISO-style dates. #+BEGIN_SRC emacs-lisp @@ -1234,7 +1236,7 @@ Sometimes I want to insert a date or time into a buffer. (timer-relative-time (current-time) -86400)) #+END_SRC -* Directories +** Directories Dired works quite nicely, but not always in the way I want. I don’t like having so many prompts for recursive operations. Also, when I @@ -1300,7 +1302,7 @@ Expand subfolders like a tree inside the parent (bind-key "i" #'dired-subtree-toggle dired-mode-map)))) #+END_SRC -** Disk usage +*** Disk usage Combine dired and du (disk usage). @@ -1311,7 +1313,7 @@ Combine dired and du (disk usage). (setq dired-du-size-format t))) #+END_SRC -** Dired-narrow +*** Dired-narrow One can already use dired with wildcards to browse a filtered directory listing, but it opens a new buffer. Dired-narrow is a slightly nicer interface: with a currently-open dired buffer, use =/= @@ -1325,9 +1327,9 @@ the buffer, removing the filter. ("/" . dired-narrow)))) #+END_SRC -* Documentation +** Documentation -** ehelp +*** ehelp ehelp is a less well-known package that’s part of Emacs and slightly improves the normal help commands, mostly by making quitting them easier. @@ -1336,7 +1338,7 @@ improves the normal help commands, mostly by making quitting them easier. (use-package ehelp :bind-keymap ("C-h" . ehelp-map)) #+END_SRC -** counsel-dash +*** counsel-dash Emacs’ documentation is great to read from inside Emacs. Counsel-dash helps to make documentation for other languages easier to access @@ -1371,7 +1373,7 @@ helps to make documentation for other languages easier to access (ap/create-counsel-dash-hook sql ("PostgreSQL" "MySQL")))) #+END_SRC -** discover-my-major +*** discover-my-major A nicer way to browse keybindings for major modes. @@ -1380,7 +1382,7 @@ A nicer way to browse keybindings for major modes. :bind ("<f1>" . discover-my-major)) #+END_SRC -** which-key +*** which-key Popup keybindings following a prefix automatically. @@ -1392,7 +1394,7 @@ Popup keybindings following a prefix automatically. (which-key-setup-side-window-right-bottom))) #+END_SRC -** eldoc +*** eldoc Documentation in the echo-area (where the minibuffer is displayed) is rather useful. @@ -1405,9 +1407,9 @@ rather useful. (setq eldoc-idle-delay 0.1) (eldoc-add-command 'paredit-backward-delete 'paredit-close-round))) #+END_SRC -* Mail +** Mail -** Gnus +*** 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. @@ -1432,7 +1434,7 @@ workplace, so I keep it in a host-specific, GPG-encrypted file. (add-to-list 'mm-discouraged-alternatives "text/richtext")) #+END_SRC -** BBDB +*** BBDB As I'm using Emacs for email, it makes sense to have contact information here as well. @@ -1451,7 +1453,7 @@ information here as well. bbdb-offer-to-create 1))) #+END_SRC -* Misc +** Misc #+BEGIN_SRC emacs-lisp (defvar *init-file* @@ -1503,7 +1505,7 @@ information here as well. (bind-key* "C-x r M-w" #'copy-rectangle) #+END_SRC -** Auxillary Configuration +*** Auxillary Configuration #+BEGIN_SRC emacs-lisp (require 'pinentry) @@ -1556,7 +1558,7 @@ information here as well. (add-hook 'after-make-frame-functions #'first-frame-hook)) #+END_SRC -* Minibuffer +** Minibuffer Sometimes I want to use the minibuffer, but I’m already inside it. Fortunately, this is possible. Of course, I need to know how many @@ -1580,7 +1582,7 @@ Occasionally, I exit emacs. I should probably reduce the frequency of this. (defalias 'exit-emacs #'save-buffers-kill-emacs)) #+END_SRC -** swiper/ivy +*** swiper/ivy Ivy is the new kid on the completion block. It seems to be a strong replacement for helm so far. @@ -1603,7 +1605,7 @@ replacement for helm so far. (add-to-list 'ivy-initial-inputs-alist '(counsel-M-x . "")))) #+END_SRC -** counsel +*** counsel #+BEGIN_SRC emacs-lisp (use-package counsel @@ -1626,7 +1628,7 @@ replacement for helm so far. #+END_SRC -** smex +*** smex Smex is my favourite way to use =M-x=. Counsel’s =counsel-M-x= function uses it internally, so I’m keeping it around, even though I @@ -1650,7 +1652,7 @@ don’t use it directly. "smex-items")))) #+END_SRC -** cmd-to-echo +*** cmd-to-echo I’ve been looking for some way to run programming projects (mostly node.js) inside emacs. =cmd-to-echo= seems great for this, as new @@ -1661,7 +1663,7 @@ output pops up in the echo area. :commands (cmd-to-echo) :config (setq cmd-to-echo-add-output-to-process-buffers t)) #+END_SRC -* Modes +** Modes Setup some modes for systemd files #+BEGIN_SRC emacs-lisp @@ -1730,7 +1732,7 @@ configuration files. (add-to-list 'auto-mode-alist '("\\.sls\\'" . saltstack-mode)) #+END_SRC -** ledger +*** ledger I use [[http://ledger-cli.org/][=ledger=]] to manage my finances. It has an Emacs mode, which works really nicely. @@ -1770,7 +1772,7 @@ works really nicely. ("account" "ledger -f %(ledger-file) reg %(account)"))))) #+END_SRC -** Markdown +*** Markdown #+BEGIN_SRC emacs-lisp (use-package markdown-mode @@ -1779,7 +1781,17 @@ works really nicely. (add-hook 'markdown-mode-hook #'turn-on-auto-fill))) #+END_SRC -** Org +*** Lentic + +Multiple different views of the same file. Can be used for a kind of +inverse literate programming. + +#+BEGIN_SRC emacs-lisp +(use-package lentic + :config (global-lentic-mode)) +#+END_SRC + +*** Org Org is wünderbar. @@ -1839,7 +1851,7 @@ Org is wünderbar. (bind-key "C-x C-s" #'org-edit-src-exit org-src-mode-map))) #+END_SRC -**** org-babel +***** org-babel Org’s babel feature is really nice. I use it for this file, and I can use it to communicate between programming languages. Sometime I hope @@ -1859,7 +1871,7 @@ with R or something. org-src-preserve-indentation t))) #+END_SRC -**** org-journal +***** org-journal I can use this to keep a journal. I should use it. @@ -1885,8 +1897,8 @@ I can use this to keep a journal. I should use it. #+END_SRC -* Programming -** flycheck +** Programming +*** flycheck On-the-fly error checking in programming modes? Yes please. @@ -1905,7 +1917,7 @@ On-the-fly error checking in programming modes? Yes please. (setq flycheck-javascript-eslint-executable "eslint_d")))) #+END_SRC -*** flycheck-pos-tip +**** flycheck-pos-tip Show flycheck errors in a little popup, so I don't lose my place @@ -1917,7 +1929,7 @@ Show flycheck errors in a little popup, so I don't lose my place (flycheck-pos-tip-mode 1))) #+END_SRC -*** flycheck-flow +**** flycheck-flow #+BEGIN_SRC emacs-lisp (use-package flycheck-flow @@ -1927,7 +1939,7 @@ Show flycheck errors in a little popup, so I don't lose my place (flycheck-add-next-checker 'javascript-eslint 'javascript-flow))) #+END_SRC -** golang +*** golang Go has a few packages to inter-operate with other emacs packages. @@ -1954,7 +1966,7 @@ Go has a few packages to inter-operate with other emacs packages. #+END_SRC -** ggtags +*** ggtags A nice completion backend for programming modes. @@ -1972,7 +1984,7 @@ A nice completion backend for programming modes. (add-hook 'c-mode-common-hook #'turn-on-ggtags-mode))) #+END_SRC -** dumb-jump +*** dumb-jump A "clever" way of implementing go-to-definition across languages: use a project-wide text search and apply heuristics to the results to @@ -1987,7 +1999,7 @@ guess a definition. :config (setq dumb-jump-selector 'ivy)) #+END_SRC -** imenu-anywhere +*** imenu-anywhere This is like imenu, but shows functions (or similar top-level entities) across buffers in the same project. Neat! @@ -1996,9 +2008,9 @@ entities) across buffers in the same project. Neat! (use-package imenu-anywhere :bind ("C-x C-." . ivy-imenu-anywhere)) #+END_SRC -** Lisps +*** Lisps -*** All +**** All Lisp modes don’t seem to have a common ancestor. So I made a custom hook which I trigger in every lispy-mode. @@ -2017,7 +2029,7 @@ hook which I trigger in every lispy-mode. (run-hooks 'lisp-mode-common-hook)) #+END_SRC -**** Redshank +***** Redshank Lisp syntax allows for really easy refactoring. Redshank gives some operations that aren’t part of paredit, like extracting variables into @@ -2030,7 +2042,7 @@ let bindings. (add-hook 'lisp-mode-common-hook #'turn-on-redshank-mode))) #+END_SRC -*** Emacs Lisp +**** Emacs Lisp Customise the modeline-display of =emacs-lisp-mode=. Then make sure it runs the common lisp hooks. @@ -2060,7 +2072,7 @@ Interactive elisp (run-hooks 'lisp-mode-common-hook)))) #+END_SRC -*** Scheme & Lisp +**** Scheme & Lisp I don’t work with these as often as I would like @@ -2070,7 +2082,7 @@ I don’t work with these as often as I would like #'common-lisp-indent-function)) #+END_SRC -**** geiser +***** geiser A REPL thing for Scheme. Hopefully I’ll get to use it more in the future. @@ -2083,7 +2095,7 @@ future. run-racket)) #+END_SRC -**** slime +***** slime A REPL thing (and more) for Lisp. @@ -2100,7 +2112,7 @@ A REPL thing (and more) for Lisp. (executable-find "ccl64"))))) #+END_SRC -*** Clojure +**** Clojure #+BEGIN_SRC emacs-lisp (use-package clojure-mode @@ -2119,7 +2131,7 @@ A REPL thing (and more) for Lisp. (clj-refactor-mode 1)))) #+END_SRC -**** cider +***** cider A REPL thing for Clojure @@ -2132,7 +2144,7 @@ A REPL thing for Clojure (add-hook 'cider-mode-hook #'eldoc-mode))) #+END_SRC -** Auto-compile +*** Auto-compile Auto-compile emacs lisp when saving. #+BEGIN_SRC emacs-lisp @@ -2141,7 +2153,7 @@ Auto-compile emacs lisp when saving. :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) #+END_SRC -** cc-mode +*** cc-mode Although I don’t use C or C++, setting up the mode is helpful because quite a few other modes are derived from it. @@ -2157,7 +2169,7 @@ quite a few other modes are derived from it. (c-set-offset 'case-label '+))) #+END_SRC -** quickrun +*** quickrun It’s nice to be able to quickly evaluate some code. Although I don’t really seem to use it. @@ -2166,7 +2178,7 @@ really seem to use it. :bind (("C-c C-e" . quickrun))) #+END_SRC -** Scala +*** Scala Let’s try using Scala. @@ -2180,9 +2192,9 @@ And add ensime, an IDE-style environment. (use-package ensime) #+END_SRC -** Web development +*** Web development -*** js2-mode +**** js2-mode This mode is really great for editing Javascript. It turns code into an AST internally, so it can work with it almost like a lisp. @@ -2213,16 +2225,18 @@ an AST internally, so it can work with it almost like a lisp. js2-strict-missing-semi-warning nil))) #+END_SRC -**** rjsx-mode +***** rjsx-mode A set of advice for js2-jsx-mode to work better with React. #+BEGIN_SRC emacs-lisp (use-package rjsx-mode + :after js2-mode + :if (fboundp #'js2--struct-put) :mode (("\\.jsx\\'" . rjsx-mode))) #+END_SRC -**** js2-refactor +***** js2-refactor Thanks to the AST provided by js2-mode, refactoring is possible. This library implements some refactorings. @@ -2236,7 +2250,7 @@ library implements some refactorings. (js2r-add-keybindings-with-prefix "C-c C-m"))) #+END_SRC -**** add-node-modules-path +***** 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. @@ -2247,7 +2261,7 @@ the project. This will allows emacs to find their executables. (add-hook 'js2-mode-hook #'add-node-modules-path))) #+END_SRC -**** Flow +***** Flow #+BEGIN_SRC emacs-lisp (use-package flow-minor-mode @@ -2256,7 +2270,7 @@ the project. This will allows emacs to find their executables. (add-hook 'js2-mode-hook #'flow-minor-enable-automatically))) #+END_SRC -**** Indium +***** Indium Javascript with an inferior node.js process and a debugger? Awesome. @@ -2281,7 +2295,7 @@ Instead, do this: (add-hook 'js2-mode-hook #'indium-interaction-mode))) #+END_SRC -*** coffee-mode +**** coffee-mode #+BEGIN_SRC emacs-lisp (use-package coffee-mode @@ -2290,7 +2304,7 @@ Instead, do this: (setq coffee-indent-like-python-mode t))) #+END_SRC -*** tern +**** tern Tern understands javascript. It adds really clever documented completions, besides other IDE-like things. @@ -2311,7 +2325,7 @@ completions, besides other IDE-like things. (use-package company-tern)) #+END_SRC -*** json-mode +**** json-mode #+BEGIN_SRC emacs-lisp (use-package json-mode @@ -2321,7 +2335,7 @@ completions, besides other IDE-like things. ("\\.tern-project\\'" . json-mode))) #+END_SRC -*** restclient +**** restclient Restclient is really nice. It’s like a scratchpad for HTTP api calls. Feels a bit like using =org-babel=. I wonder if there’s an @@ -2342,7 +2356,7 @@ integration between the two yet. :init (add-to-list 'company-backends #'company-restclient t)) #+END_SRC -*** sgml-mode +**** sgml-mode This is for HTML, since old versions of HTML were derived from SGML. #+BEGIN_SRC emacs-lisp @@ -2351,7 +2365,7 @@ This is for HTML, since old versions of HTML were derived from SGML. :config (setq sgml-basic-offset 2)) #+END_SRC -*** emmet-mode +**** emmet-mode Emmet is really nice to write HTML quickly. Especially with frameworks that require multiple nested elements to do anything useful. @@ -2367,7 +2381,7 @@ frameworks that require multiple nested elements to do anything useful. (add-hook 'css-mode-hook #'emmet-mode))) #+END_SRC -*** web-mode +**** web-mode This mode handles just about every templating language out ther, which is really nice, because it handles the HTML part the same way in all @@ -2399,7 +2413,7 @@ I derived a mode for twig, in order to use its =mode-hook=. (add-to-list 'auto-mode-alist '("\\.html\\.twig\\'" . twig-mode)) #+END_SRC -** Live coding +*** Live coding Sometimes I might want to show off my emacs usage. @@ -2415,7 +2429,7 @@ Sometimes I might want to show off my emacs usage. (global-command-log-mode -1)) #+END_SRC -*** command-log-mode +**** command-log-mode #+BEGIN_SRC emacs-lisp (use-package command-log-mode @@ -2426,7 +2440,7 @@ Sometimes I might want to show off my emacs usage. command-log-mode-is-global t))) #+END_SRC -* Spelling +** Spelling #+BEGIN_SRC emacs-lisp (use-package ispell @@ -2490,7 +2504,7 @@ Sometimes I might want to show off my emacs usage. (add-hook 'prog-mode-hook #'flyspell-prog-mode))) #+END_SRC -** Style checking +*** Style checking [[https://github.com/ValeLint/vale][Vale]] is a linter, but for prose. Neat idea! Salesman is a bad term. @@ -2503,7 +2517,7 @@ Sometimes I might want to show off my emacs usage. (flycheck-vale-setup))) #+END_SRC -* Scripting +** Scripting Make a shell-script buffer executable after saving it, if it has a shebang. @@ -2524,7 +2538,7 @@ Make a shell-script buffer executable after saving it, if it has a shebang. (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) #+END_SRC -** eshell +*** eshell I should try to get into the habit of using this more. It’s really nice, when I remember to use it. @@ -2564,7 +2578,7 @@ nice, when I remember to use it. #+END_SRC -*** Shells +**** Shells #+BEGIN_SRC emacs-lisp (use-package shell @@ -2585,7 +2599,7 @@ nice, when I remember to use it. (comint-delchar-or-maybe-eof arg))) #+END_SRC -* Text editing +** Text editing Emacs has an editor within. @@ -2597,7 +2611,7 @@ Emacs has an editor within. (setq-default truncate-lines t) #+END_SRC -** align +*** align =Align= is a useful command to line things up, once given some rules. The most important one for me is JSON property alignment. @@ -2613,7 +2627,7 @@ The most important one for me is JSON property alignment. (modes . '(js2-mode)))))) #+END_SRC -** Clipboard +*** Clipboard I like to use the clipboard more than the primary selection in X11. @@ -2626,7 +2640,7 @@ I like to use the clipboard more than the primary selection in X11. (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) #+END_SRC -** Selection +*** Selection I’m quite used to deleting text by selecting it and typing. Emacs has a mode for that. @@ -2663,7 +2677,7 @@ from Sublime Text. As always, there’s a mode for that. :config (setq expand-region-fast-keys-enabled nil)) #+END_SRC -** avy +*** avy Avy is a really nice way to move around files, like ace-jump-mode, but somehow I prefer it. @@ -2682,7 +2696,7 @@ somehow I prefer it. avy-keys '(?a ?r ?s ?t ?d ?h ?n ?e ?i ?\;)))) #+END_SRC -*** ace-link +**** ace-link Visit any link. Despite the name, this works with avy. @@ -2696,7 +2710,7 @@ Visit any link. Despite the name, this works with avy. (bind-key "M-o" #'ace-link-gnus gnus-article-mode-map)))) #+END_SRC -** goto-chg +*** goto-chg This is like popping the mark, only it filters to only change areas and doesn’t go back to the same place more than once. @@ -2706,7 +2720,7 @@ and doesn’t go back to the same place more than once. :bind ("C-c C-SPC" . goto-last-change)) #+END_SRC -** beginend +*** beginend In special buffers, I would rather have =M->= and =M-<= goto the logical beginning/end rather than the physical ones. @@ -2717,7 +2731,7 @@ logical beginning/end rather than the physical ones. (beginend-setup-all))) #+END_SRC -** multiple-cursors +*** multiple-cursors I mentioned before that I’d used Sublime Text before. Multiple cursors was one of my favourite features, so I was really happy when I @@ -2733,7 +2747,7 @@ saw that multiple-cursors was released for Emacs. ("C-S-L" . mc/edit-lines))) #+END_SRC -** paredit +*** paredit Balanced parentheses in lisps are nice, but all the refactoring and movement commands are much more interesting. @@ -2748,7 +2762,7 @@ movement commands are much more interesting. (add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode))) #+END_SRC -** smartparens +*** smartparens I like to use smartparens where paredit isn’t already useful. Somehow I didn’t find smartparens’ implementation of paredit style to be as @@ -2785,7 +2799,7 @@ nice as the real version #+END_SRC -** move-text +*** move-text Transposing lines, made easier. @@ -2794,7 +2808,7 @@ Transposing lines, made easier. :config (move-text-default-bindings)) #+END_SRC -** undo-tree +*** undo-tree Emacs’ default handling of undo is a bit confusing. Undo-tree makes it much clearer. It’s especially helpful for protoyping and refactoring. @@ -2817,14 +2831,14 @@ it much clearer. It’s especially helpful for protoyping and refactoring. :diminish undo-tree-mode) #+END_SRC -** replace +*** replace #+BEGIN_SRC emacs-lisp (with-eval-after-load "replace.el" (setq case-replace nil)) #+END_SRC -** visual-regexp +*** visual-regexp I don’t always remember exactly how Emacs’ regular expressions work, so this package is pretty useful because it highlights everything in @@ -2836,61 +2850,8 @@ the buffer for me. ("C-c q" . vr/query-replace) ("C-c m" . vc/mc-mark))) #+END_SRC -* Tangling - -Taken from [[https://github.com/larstvei/dot-emacs/blob/master/init.org][larstvei/dot-emacs]]. I changed it so that it would work with -my current dotfiles repository structure and work asynchronously, -thanks to [[https://github.com/jwiegley/emacs-async][jwiegley/emacs-async]]. - -We can use =C-c C-v t= to run =org-babel-tangle=, which extracts the -code blocks from the current file into a source-specific file (in this -case a =.el=-file). -To avoid doing this each time a change is made we can add a function -to the =after-save-hook= ensuring to always tangle and byte-compile -the =org=-document after changes. - -#+BEGIN_SRC emacs-lisp -(use-package async - :commands (async-start) - :defer 2) - -(defun tangle-if-init () - "If the current buffer is 'init.org' the code-blocks are - tangled, and the tangled file is compiled." - - (when (string-suffix-p "init.org" (buffer-file-name)) - (tangle-init))) - -(defun tangle-init-sync () - (interactive) - (message "Tangling init") - ;; Avoid running hooks when tangling. - (let ((prog-mode-hook nil) - (src (expand-file-name "init.org" user-emacs-directory)) - (dest (expand-file-name "init.el" user-emacs-directory))) - (require 'ob-tangle) - (org-babel-tangle-file src dest) - (if (byte-compile-file dest) - (byte-compile-dest-file dest) - (with-current-buffer byte-compile-log-buffer - (buffer-string))))) - -(defun tangle-init () - "Tangle init.org asynchronously." - - (interactive) - (message "Tangling init") - (async-start - (symbol-function #'tangle-init-sync) - (lambda (result) - (message "Init tangling completed: %s" result)))) -#+END_SRC - -# Local Variables: -# eval: (when (fboundp #'tangle-if-init) (add-hook 'after-save-hook #'tangle-if-init)) -# End: -* End +** End Start a server if possible. A daemon is already a server. #+BEGIN_SRC emacs-lisp @@ -2902,3 +2863,7 @@ Start a server if possible. A daemon is already a server. (setq gc-cons-threshold 800000 file-name-handler-alist file-name-handler-alist-backup) #+END_SRC + +Local Variables: +lentic-init: lentic-orgel-org-init +End: |