From a3b9393fc3fed15c790d4ef315ab6d53a6e24b59 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 10:31:19 +1200 Subject: [PATCH 01/95] Tidy up init-elpa --- lisp/init-elpa.el | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el index 13c91ff2ed..b479bcd5db 100644 --- a/lisp/init-elpa.el +++ b/lisp/init-elpa.el @@ -3,13 +3,13 @@ ;;; Code: (require 'package) +(require 'cl-lib) ;;; Install into separate package dirs for each Emacs version, to prevent bytecode incompatibility -(let ((versioned-package-dir - (expand-file-name (format "elpa-%s.%s" emacs-major-version emacs-minor-version) - user-emacs-directory))) - (setq package-user-dir versioned-package-dir)) +(setq package-user-dir + (expand-file-name (format "elpa-%s.%s" emacs-major-version emacs-minor-version) + user-emacs-directory)) @@ -28,8 +28,6 @@ ;;; On-demand installation of packages -(require 'cl-lib) - (defun require-package (package &optional min-version no-refresh) "Install given PACKAGE, optionally requiring MIN-VERSION. If NO-REFRESH is non-nil, the available package lists will not be @@ -37,7 +35,7 @@ re-downloaded in order to locate PACKAGE." (or (package-installed-p package min-version) (let* ((known (cdr (assoc package package-archive-contents))) (versions (mapcar #'package-desc-version known))) - (if (cl-find-if (lambda (v) (version-list-<= min-version v)) versions) + (if (cl-some (lambda (v) (version-list-<= min-version v)) versions) (package-install package) (if no-refresh (error "No version of %s >= %S is available" package min-version) @@ -50,11 +48,9 @@ In the event of failure, return nil and print a warning message. Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the available package lists will not be re-downloaded in order to locate PACKAGE." - (condition-case err - (require-package package min-version no-refresh) - (error - (message "Couldn't install optional package `%s': %S" package err) - nil))) + (with-demoted-errors + (concat "Couldn't install optional package `" (symbol-name package) "': %S") + (require-package package min-version no-refresh))) ;;; Fire up package.el @@ -70,10 +66,14 @@ locate PACKAGE." (defvar sanityinc/required-packages nil) (defun sanityinc/note-selected-package (oldfun package &rest args) - "If OLDFUN reports PACKAGE was successfully installed, note it in `sanityinc/required-packages'." + "If OLDFUN reports PACKAGE was successfully installed, note that fact. +The package name is noted by adding it to +`sanityinc/required-packages'. This function is used as an +advice for `require-package', to which ARGS are passed." (let ((available (apply oldfun package args))) - (prog1 available - (when (and available (boundp 'package-selected-packages)) + (prog1 + available + (when available (add-to-list 'sanityinc/required-packages package))))) (advice-add 'require-package :around 'sanityinc/note-selected-package) @@ -81,8 +81,9 @@ locate PACKAGE." (when (fboundp 'package--save-selected-packages) (require-package 'seq) (add-hook 'after-init-hook - (lambda () (package--save-selected-packages - (seq-uniq (append sanityinc/required-packages package-selected-packages)))))) + (lambda () + (package--save-selected-packages + (seq-uniq (append sanityinc/required-packages package-selected-packages)))))) (require-package 'fullframe) From ea6b2badad3554ff3eb34e8417379e61691b3d02 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 10:37:04 +1200 Subject: [PATCH 02/95] Disable counsel-yank-pop --- lisp/init-ivy.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/init-ivy.el b/lisp/init-ivy.el index 007cea543c..a87fa9a63c 100644 --- a/lisp/init-ivy.el +++ b/lisp/init-ivy.el @@ -38,7 +38,10 @@ (with-eval-after-load 'counsel (setq-default ivy-initial-inputs-alist '((Man-completion-table . "^") - (woman . "^")))) + (woman . "^"))) + ;; I prefer the default behaviour or cycling in place, or + ;; explicit use of browse-kill-ring + (define-key counsel-mode-map [remap yank-pop] nil)) (when (maybe-require-package 'diminish) (with-eval-after-load 'counsel (diminish 'counsel-mode))) From bcba8945e98ac52aee2116f799fe6a577ac49a3e Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 10:40:00 +1200 Subject: [PATCH 03/95] Stop using cua-selection-mode --- lisp/init-editing-utils.el | 31 ------------------------------- lisp/init-paredit.el | 4 ---- 2 files changed, 35 deletions(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 65e91f0be4..1b9d90b35c 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -169,12 +169,6 @@ (put 'downcase-region 'disabled nil) -;;---------------------------------------------------------------------------- -;; Rectangle selections, and overwrite text when the selection is active -;;---------------------------------------------------------------------------- -(cua-selection-mode t) ; for rectangles, CUA is nice - - ;;---------------------------------------------------------------------------- ;; Handy key bindings ;;---------------------------------------------------------------------------- @@ -258,31 +252,6 @@ (with-eval-after-load 'whole-line-or-region (diminish 'whole-line-or-region-local-mode)) - -;; Some local minor modes clash with CUA rectangle selection - -(defvar-local sanityinc/suspended-modes-during-cua-rect nil - "Modes that should be re-activated when cua-rect selection is done.") - -(eval-after-load 'cua-rect - (advice-add 'cua--deactivate-rectangle :after - (lambda (&rest _) - (dolist (m sanityinc/suspended-modes-during-cua-rect) - (funcall m 1) - (setq sanityinc/suspended-modes-during-cua-rect nil))))) - -(defun sanityinc/suspend-mode-during-cua-rect-selection (mode-name) - "Add an advice to suspend `MODE-NAME' while selecting a CUA rectangle." - (eval-after-load 'cua-rect - (advice-add 'cua--activate-rectangle :after - (lambda (&rest _) - (when (bound-and-true-p mode-name) - (add-to-list 'sanityinc/suspended-modes-during-cua-rect mode-name) - (funcall mode-name 0)))))) - -(sanityinc/suspend-mode-during-cua-rect-selection 'whole-line-or-region-local-mode) - - (defun sanityinc/open-line-with-reindent (n) diff --git a/lisp/init-paredit.el b/lisp/init-paredit.el index da228851c3..b0364326f0 100644 --- a/lisp/init-paredit.el +++ b/lisp/init-paredit.el @@ -19,10 +19,6 @@ (define-key paredit-mode-map (read-kbd-macro binding) nil))) -;; Compatibility with other modes - -(sanityinc/suspend-mode-during-cua-rect-selection 'paredit-mode) - ;; Use paredit in the minibuffer ;; TODO: break out into separate package From 02db6b1ca458d26cf4a04f95acdb343bc0a9aa5e Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 10:45:17 +1200 Subject: [PATCH 04/95] Reformat init-editing-utils --- lisp/init-editing-utils.el | 63 ++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 1b9d90b35c..67ab062967 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -10,9 +10,9 @@ (maybe-require-package 'list-unicode-display) -;;---------------------------------------------------------------------------- -;; Some basic preferences -;;---------------------------------------------------------------------------- + +;;; Some basic preferences + (setq-default blink-cursor-interval 0.4 bookmark-default-file (expand-file-name ".bookmarks.el" user-emacs-directory) @@ -124,9 +124,9 @@ (define-key symbol-overlay-mode-map (kbd "M-n") 'symbol-overlay-jump-next) (define-key symbol-overlay-mode-map (kbd "M-p") 'symbol-overlay-jump-prev))) -;;---------------------------------------------------------------------------- -;; Zap *up* to char is a handy pair for zap-to-char -;;---------------------------------------------------------------------------- + +;;; Zap *up* to char is a handy pair for zap-to-char + (autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.") (global-set-key (kbd "M-Z") 'zap-up-to-char) @@ -143,35 +143,28 @@ (add-to-list 'page-break-lines-modes 'browse-kill-ring-mode)) -;;---------------------------------------------------------------------------- ;; Don't disable narrowing commands -;;---------------------------------------------------------------------------- (put 'narrow-to-region 'disabled nil) (put 'narrow-to-page 'disabled nil) (put 'narrow-to-defun 'disabled nil) +;; Don't disable case-change functions +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) + -;;---------------------------------------------------------------------------- ;; Show matching parens -;;---------------------------------------------------------------------------- (add-hook 'after-init-hook 'show-paren-mode) -;;---------------------------------------------------------------------------- -;; Expand region -;;---------------------------------------------------------------------------- + +;;; Expand region + (require-package 'expand-region) (global-set-key (kbd "C-=") 'er/expand-region) -;;---------------------------------------------------------------------------- -;; Don't disable case-change functions -;;---------------------------------------------------------------------------- -(put 'upcase-region 'disabled nil) -(put 'downcase-region 'disabled nil) - + +;;; Handy key bindings -;;---------------------------------------------------------------------------- -;; Handy key bindings -;;---------------------------------------------------------------------------- (global-set-key (kbd "C-.") 'set-mark-command) (global-set-key (kbd "C-x C-.") 'pop-global-mark) @@ -190,13 +183,10 @@ (global-set-key (kbd "C-c m e") 'mc/edit-ends-of-lines) (global-set-key (kbd "C-c m a") 'mc/edit-beginnings-of-lines) - ;; Train myself to use M-f and M-b instead (global-unset-key [M-left]) (global-unset-key [M-right]) - - (defun kill-back-to-indentation () "Kill from point back to the first non-whitespace character on the line." (interactive) @@ -207,19 +197,20 @@ (global-set-key (kbd "C-M-") 'kill-back-to-indentation) -;;---------------------------------------------------------------------------- -;; Page break lines -;;---------------------------------------------------------------------------- + +;;; Page break lines + (when (maybe-require-package 'page-break-lines) (add-hook 'after-init-hook 'global-page-break-lines-mode) (with-eval-after-load 'page-break-lines (diminish 'page-break-lines-mode))) -;;---------------------------------------------------------------------------- + + ;; Shift lines up and down with M-up and M-down. When paredit is enabled, ;; it will use those keybindings. For this reason, you might prefer to ;; use M-S-up and M-S-down, which will work even in lisp modes. -;;---------------------------------------------------------------------------- + (require-package 'move-dup) (global-set-key [M-up] 'md-move-lines-up) (global-set-key [M-down] 'md-move-lines-down) @@ -229,9 +220,9 @@ (global-set-key (kbd "C-c d") 'md-duplicate-down) (global-set-key (kbd "C-c u") 'md-duplicate-up) -;;---------------------------------------------------------------------------- -;; Fix backward-up-list to understand quotes, see http://bit.ly/h7mdIL -;;---------------------------------------------------------------------------- + +;;; Fix backward-up-list to understand quotes, see http://bit.ly/h7mdIL + (defun sanityinc/backward-up-sexp (arg) "Jump up to the start of the ARG'th enclosing sexp." (interactive "p") @@ -244,9 +235,8 @@ (global-set-key [remap backward-up-list] 'sanityinc/backward-up-sexp) ; C-M-u, C-M-up -;;---------------------------------------------------------------------------- -;; Cut/copy the current line if no region is active -;;---------------------------------------------------------------------------- + +;;; Cut/copy the current line if no region is active (require-package 'whole-line-or-region) (add-hook 'after-init-hook 'whole-line-or-region-global-mode) (with-eval-after-load 'whole-line-or-region @@ -302,7 +292,6 @@ With arg N, insert N newlines." (sort-subr nil 'forward-line 'end-of-line nil nil (lambda (s1 s2) (eq (random 2) 0))))))) - (require-package 'highlight-escape-sequences) From edd084a9ca0315a638309b3c8d285a8488faae8f Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 10:45:49 +1200 Subject: [PATCH 05/95] I just don't use expand-region --- lisp/init-editing-utils.el | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 67ab062967..5767c0a96d 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -155,12 +155,6 @@ ;; Show matching parens (add-hook 'after-init-hook 'show-paren-mode) - -;;; Expand region - -(require-package 'expand-region) -(global-set-key (kbd "C-=") 'er/expand-region) - ;;; Handy key bindings From 754a3ce1871f44c0c235887c18a32ac5dc799eb7 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 10:50:51 +1200 Subject: [PATCH 06/95] Previous formulation of maybe-require-package was better --- lisp/init-elpa.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el index b479bcd5db..f0b1ae6751 100644 --- a/lisp/init-elpa.el +++ b/lisp/init-elpa.el @@ -48,9 +48,11 @@ In the event of failure, return nil and print a warning message. Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the available package lists will not be re-downloaded in order to locate PACKAGE." - (with-demoted-errors - (concat "Couldn't install optional package `" (symbol-name package) "': %S") - (require-package package min-version no-refresh))) + (condition-case err + (require-package package min-version no-refresh) + (error + (message "Couldn't install optional package `%s': %S" package err) + nil))) ;;; Fire up package.el From 42f270cf2c310803c7a4ba538ab2c4613e6d83d5 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 11:06:36 +1200 Subject: [PATCH 07/95] Don't test so many version on MacOS --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab0ee2be10..a9574277aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] emacs_version: - 24.5 - 25.1 @@ -22,6 +22,10 @@ jobs: - 26.3 - 27.1 - snapshot + include: + - os: macos-latest + emacs_version: 24.5 + emacs_version: 27.1 steps: - uses: purcell/setup-emacs@master with: From b5b1503c1520ee52a42052d77a521ce96d3fb296 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Sep 2020 11:08:10 +1200 Subject: [PATCH 08/95] Fix broken matrix spec --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9574277aa..cf41c67d7e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,6 @@ jobs: - snapshot include: - os: macos-latest - emacs_version: 24.5 emacs_version: 27.1 steps: - uses: purcell/setup-emacs@master From ce57d8bb302ca3faf0a4374ca8480bc340407e1b Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 26 Sep 2020 13:54:50 +1200 Subject: [PATCH 09/95] Make tab completion bring up company --- lisp/init-company.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/init-company.el b/lisp/init-company.el index b48d60ae18..84c0a74997 100644 --- a/lisp/init-company.el +++ b/lisp/init-company.el @@ -15,6 +15,8 @@ (delq backend company-backends)) (diminish 'company-mode) (define-key company-mode-map (kbd "M-/") 'company-complete) + (define-key company-mode-map [remap completion-at-point] 'company-complete) + (define-key company-mode-map [remap indent-for-tab-command] 'company-indent-or-complete-common) (define-key company-active-map (kbd "M-/") 'company-other-backend) (define-key company-active-map (kbd "C-n") 'company-select-next) (define-key company-active-map (kbd "C-p") 'company-select-previous) From bf65ab24cb31a32add371a7bad5d391d02b5391d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Thu, 15 Oct 2020 09:57:53 +1300 Subject: [PATCH 10/95] Add ocaml support --- README.md | 2 +- init.el | 1 + lisp/init-ocaml.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 lisp/init-ocaml.el diff --git a/README.md b/README.md index c8ba737d23..858834d5b3 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Emacs itself comes with support for many programming languages. This config adds improved defaults and extended support for the following, listed in the approximate order of how much I use them, from most to least: -* Haskell / Purescript / Elm +* Haskell / Purescript / Elm / OCaml * Ruby / Ruby on Rails * SQL * CSS / LESS / SASS / SCSS diff --git a/init.el b/init.el index 4c4258ca2b..51ff695f1f 100644 --- a/init.el +++ b/init.el @@ -105,6 +105,7 @@ (require 'init-ruby) (require 'init-rails) (require 'init-sql) +(require 'init-ocaml) (require 'init-nim) (require 'init-rust) (require 'init-toml) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el new file mode 100644 index 0000000000..6b65a01add --- /dev/null +++ b/lisp/init-ocaml.el @@ -0,0 +1,54 @@ +;;; init-ocaml.el --- Support the OCaml language -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(when (maybe-require-package 'tuareg) + (when (maybe-require-package 'merlin) + (autoload 'merlin-mode "merlin" "Merlin mode" t) + (add-hook 'tuareg-mode-hook 'merlin-mode) + + (with-eval-after-load 'merlin + (with-eval-after-load 'company + (push 'merlin-company-backend company-backends))) + + (when (maybe-require-package 'merlin-eldoc) + (with-eval-after-load 'merlin + (autoload 'merlin-eldoc--gather-info "merlin-eldoc") + (add-hook 'merlin-mode-hook + (lambda () + (setq-local eldoc-documentation-function + #'merlin-eldoc--gather-info)))))) + + (with-eval-after-load 'tuareg + (defvar-local tuareg-previous-tuareg-buffer nil + "Buffer from which we jumped to the REPL.") + + (defun sanityinc/tuareg-repl-switch () + (interactive) + (let ((last-tuareg-buf (when (derived-mode-p 'tuareg-mode) + (current-buffer)))) + (tuareg-run-ocaml) + (pop-to-buffer tuareg-interactive-buffer-name) + (when last-tuareg-buf + (setq-local tuareg-previous-tuareg-buffer last-tuareg-buf)))) + + (defun sanityinc/tuareg-repl-switch-back () + (interactive) + (when tuareg-previous-tuareg-buffer + (pop-to-buffer tuareg-previous-tuareg-buffer))) + + (define-key tuareg-mode-map (kbd "C-c C-z") 'sanityinc/tuareg-repl-switch) + (define-key tuareg-interactive-mode-map (kbd "C-c C-z") 'sanityinc/tuareg-repl-switch-back))) + +(when (maybe-require-package 'reformatter) + (defcustom ocp-indent-args nil + "Arguments for \"ocp-indent\" invocation.") + + (reformatter-define ocp-indent + :program "ocp-indent" + :args ocp-indent-args + :lighter " OCP")) + + +(provide 'init-ocaml) +;;; init-ocaml.el ends here From 5dd4bce164ee7aef5045feb19c2711bc18b6b21f Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:16:33 +1300 Subject: [PATCH 11/95] Ignore gccemacs native compilation cache dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 474afb6d74..87b89afb3b 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ site-lisp/package/ /transient /.lsp-session-v1 /smex-items +/eln-cache/ From 63cd121dac46a7619f3bc33bca05a75f043c8704 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:17:01 +1300 Subject: [PATCH 12/95] Change C-c C-l in ruby-mode to work more like in other langs --- lisp/init-ruby.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/init-ruby.el b/lisp/init-ruby.el index 00a189ea8c..12c879eca1 100644 --- a/lisp/init-ruby.el +++ b/lisp/init-ruby.el @@ -31,6 +31,14 @@ ;;; Inferior ruby (require-package 'inf-ruby) +(with-eval-after-load 'inf-ruby + (defun sanityinc/ruby-load-file (&optional choose-file) + (interactive "P") + (if (or choose-file (not buffer-file-name)) + (call-interactively 'ruby-load-file) + (save-some-buffers) + (ruby-load-file buffer-file-name))) + (define-key inf-ruby-minor-mode-map [remap ruby-load-file] 'sanityinc/ruby-load-file)) From 0fc6ff73a4ccefcc7e0d99e648161f9cf20c95af Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:19:18 +1300 Subject: [PATCH 13/95] Prefix more personal functions with "sanityinc/" --- lisp/init-paredit.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/init-paredit.el b/lisp/init-paredit.el index b0364326f0..bd976e2c8e 100644 --- a/lisp/init-paredit.el +++ b/lisp/init-paredit.el @@ -4,12 +4,12 @@ (require-package 'paredit) -(defun maybe-map-paredit-newline () +(defun sanityinc/maybe-map-paredit-newline () (unless (or (memq major-mode '(inferior-emacs-lisp-mode cider-repl-mode)) (minibufferp)) (local-set-key (kbd "RET") 'paredit-newline))) -(add-hook 'paredit-mode-hook 'maybe-map-paredit-newline) +(add-hook 'paredit-mode-hook 'sanityinc/maybe-map-paredit-newline) (with-eval-after-load 'paredit (diminish 'paredit-mode " Par") @@ -23,7 +23,7 @@ ;; Use paredit in the minibuffer ;; TODO: break out into separate package ;; http://emacsredux.com/blog/2013/04/18/evaluate-emacs-lisp-in-the-minibuffer/ -(add-hook 'minibuffer-setup-hook 'conditionally-enable-paredit-mode) +(add-hook 'minibuffer-setup-hook 'sanityinc/conditionally-enable-paredit-mode) (defvar paredit-minibuffer-commands '(eval-expression pp-eval-expression @@ -32,7 +32,7 @@ ibuffer-do-view-and-eval) "Interactive commands for which paredit should be enabled in the minibuffer.") -(defun conditionally-enable-paredit-mode () +(defun sanityinc/conditionally-enable-paredit-mode () "Enable paredit during lisp-related minibuffer commands." (if (memq this-command paredit-minibuffer-commands) (enable-paredit-mode))) From b47e7efc8553225a17ab3b907e7de2e79f77408c Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:19:43 +1300 Subject: [PATCH 14/95] Add docstring --- lisp/init-http.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/init-http.el b/lisp/init-http.el index c2a854f6c1..d058a4f8c2 100644 --- a/lisp/init-http.el +++ b/lisp/init-http.el @@ -7,6 +7,7 @@ (add-auto-mode 'restclient-mode "\\.rest\\'") (defun sanityinc/restclient () + "Work with `rest' in the *restclient* buffer." (interactive) (with-current-buffer (get-buffer-create "*restclient*") (restclient-mode) From 69a47ae58446021e831a2899b2b472a0a260abc3 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:19:50 +1300 Subject: [PATCH 15/95] Make httprepl understand images --- lisp/init-http.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/init-http.el b/lisp/init-http.el index d058a4f8c2..bacc852a67 100644 --- a/lisp/init-http.el +++ b/lisp/init-http.el @@ -3,6 +3,14 @@ ;;; Code: (maybe-require-package 'httprepl) +(with-eval-after-load 'httprepl + (push '("image" . image) httprepl-content-type-alist) + (push '(image . ((lambda (b) (with-current-buffer b + (image-mode) + b)))) + httprepl-content-type-middleware-alist)) + + (when (maybe-require-package 'restclient) (add-auto-mode 'restclient-mode "\\.rest\\'") From 60a0adbd83b8a87e0b12f3d5adca494db2f81a51 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:20:20 +1300 Subject: [PATCH 16/95] Resize windows and frames pixelwise if possible --- lisp/init-gui-frames.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/init-gui-frames.el b/lisp/init-gui-frames.el index 1d18204725..e86e80a09b 100644 --- a/lisp/init-gui-frames.el +++ b/lisp/init-gui-frames.el @@ -24,6 +24,10 @@ ;;---------------------------------------------------------------------------- ;; Window size and features ;;---------------------------------------------------------------------------- +(setq-default + window-resize-pixelwise t + frame-resize-pixelwise t) + (when (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (when (fboundp 'set-scroll-bar-mode) From 82de7b9912dfd133bc41d65764d590a3944d9057 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:20:46 +1300 Subject: [PATCH 17/95] Use so-long for very large files when available --- lisp/init-editing-utils.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 5767c0a96d..16bd148d3e 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -46,6 +46,9 @@ ;; Huge files +(when (fboundp 'so-long-enable) + (add-hook 'after-init-hook 'so-long-enable)) + (require-package 'vlf) (defun ffap-vlf () From 1d211322c78b22d9a4540a5b7a0ebb97b6746cfb Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:21:09 +1300 Subject: [PATCH 18/95] Remove some multiple-cursors bindings I don't use --- lisp/init-editing-utils.el | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 16bd148d3e..4f18687e1d 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -174,11 +174,6 @@ (global-set-key (kbd "C->") 'mc/mark-next-like-this) (global-set-key (kbd "C-+") 'mc/mark-next-like-this) (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) -;; From active region to multiple cursors: -(global-set-key (kbd "C-c m r") 'set-rectangular-region-anchor) -(global-set-key (kbd "C-c m c") 'mc/edit-lines) -(global-set-key (kbd "C-c m e") 'mc/edit-ends-of-lines) -(global-set-key (kbd "C-c m a") 'mc/edit-beginnings-of-lines) ;; Train myself to use M-f and M-b instead (global-unset-key [M-left]) From b8948ae6ea8ac63a090682cc89049d3eb900157d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Oct 2020 10:22:12 +1300 Subject: [PATCH 19/95] Make "q" kill the debugger, not bury it --- lisp/init-lisp.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/init-lisp.el b/lisp/init-lisp.el index 7f2cb9c1e5..b8f8adfe70 100644 --- a/lisp/init-lisp.el +++ b/lisp/init-lisp.el @@ -2,6 +2,8 @@ ;;; Commentary: ;;; Code: +(setq-default debugger-bury-or-kill 'kill) + (require-package 'elisp-slime-nav) (dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook)) (add-hook hook 'turn-on-elisp-slime-nav-mode)) From cdb7f8ab2e63e02d31217852b57c8499ba769f79 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 27 Oct 2020 11:32:43 +1300 Subject: [PATCH 20/95] Enable merlin xref backend in ocaml buffers --- lisp/init-ocaml.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index 6b65a01add..7c616094a3 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -8,6 +8,11 @@ (add-hook 'tuareg-mode-hook 'merlin-mode) (with-eval-after-load 'merlin + (add-hook 'merlin-mode-hook + (lambda () + (if merlin-mode + (add-hook 'xref-backend-functions 'merlin-xref-backend nil t) + (remove-hook 'xref-backend-functions 'merlin-xref-backend t)))) (with-eval-after-load 'company (push 'merlin-company-backend company-backends))) From 75b3c24fc2f6d10db90234d06f0e31ba7106548b Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 17 Nov 2020 10:59:10 +1300 Subject: [PATCH 21/95] Ensure ~/.emacs.d/site-lisp is in load-path Fixes #756 --- lisp/init-site-lisp.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/init-site-lisp.el b/lisp/init-site-lisp.el index 6dab3b4e32..b10aae680e 100644 --- a/lisp/init-site-lisp.el +++ b/lisp/init-site-lisp.el @@ -4,20 +4,22 @@ ;;; Set load path -(eval-when-compile (require 'cl)) +(require 'cl-lib) + (defun sanityinc/add-subdirs-to-load-path (parent-dir) "Adds every non-hidden subdir of PARENT-DIR to `load-path'." (let* ((default-directory parent-dir)) (progn (setq load-path (append - (remove-if-not - (lambda (dir) (file-directory-p dir)) + (cl-remove-if-not + #'file-directory-p (directory-files (expand-file-name parent-dir) t "^[^\\.]")) load-path))))) -(sanityinc/add-subdirs-to-load-path - (expand-file-name "site-lisp/" user-emacs-directory)) +(let ((site-lisp-dir (expand-file-name "site-lisp/" user-emacs-directory))) + (push site-lisp-dir load-path) + (sanityinc/add-subdirs-to-load-path site-lisp-dir)) ;;; Utilities for grabbing upstream libs From 4c81c50ba77d165df8008dd5905f8c49102793d4 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 17 Nov 2020 16:32:53 +1300 Subject: [PATCH 22/95] Small tidy-up of init-site-lisp --- lisp/init-site-lisp.el | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lisp/init-site-lisp.el b/lisp/init-site-lisp.el index b10aae680e..8b190abbe4 100644 --- a/lisp/init-site-lisp.el +++ b/lisp/init-site-lisp.el @@ -7,16 +7,16 @@ (require 'cl-lib) (defun sanityinc/add-subdirs-to-load-path (parent-dir) - "Adds every non-hidden subdir of PARENT-DIR to `load-path'." - (let* ((default-directory parent-dir)) - (progn - (setq load-path - (append - (cl-remove-if-not - #'file-directory-p - (directory-files (expand-file-name parent-dir) t "^[^\\.]")) - load-path))))) - + "Add every non-hidden subdir of PARENT-DIR to `load-path'." + (let ((default-directory parent-dir)) + (setq load-path + (append + (cl-remove-if-not + #'file-directory-p + (directory-files (expand-file-name parent-dir) t "^[^\\.]")) + load-path)))) + +;; Add both site-lisp and its immediate subdirs to `load-path' (let ((site-lisp-dir (expand-file-name "site-lisp/" user-emacs-directory))) (push site-lisp-dir load-path) (sanityinc/add-subdirs-to-load-path site-lisp-dir)) From 834479600a3b130835cf838be96736281e4f4edb Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 5 Jan 2021 15:06:33 +1300 Subject: [PATCH 23/95] Fix incorrect org command bindings Fixes #763 and #762, thanks @Eason0210 --- lisp/init-org.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/init-org.el b/lisp/init-org.el index e3dbe280af..a90b89d96a 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -33,7 +33,7 @@ (defvar sanityinc/org-global-prefix-map (make-sparse-keymap) "A keymap for handy global access to org helpers, particularly clocking.") -(define-key sanityinc/org-global-prefix-map (kbd "j") 'org-clock-jump-to-current-clock) +(define-key sanityinc/org-global-prefix-map (kbd "j") 'org-clock-goto) (define-key sanityinc/org-global-prefix-map (kbd "l") 'org-clock-in-last) (define-key sanityinc/org-global-prefix-map (kbd "i") 'org-clock-in) (define-key sanityinc/org-global-prefix-map (kbd "o") 'org-clock-out) @@ -357,7 +357,7 @@ typical word processor." (define-key org-mode-map (kbd "C-M-") 'org-up-element) (when *is-a-mac* (define-key org-mode-map (kbd "M-h") nil) - (define-key org-mode-map (kbd "C-c g") 'org-mac-grab-link))) + (define-key org-mode-map (kbd "C-c g") 'grab-mac-link))) (with-eval-after-load 'org (org-babel-do-load-languages From e3b067a28501f4356a9901c1d669c3c5066dffac Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 11 Jan 2021 11:30:03 +1300 Subject: [PATCH 24/95] More reliably enable delete-selection-mode --- lisp/init-editing-utils.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 4f18687e1d..0cc9bd3717 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -19,7 +19,6 @@ buffers-menu-max-size 30 case-fold-search t column-number-mode t - delete-selection-mode t ediff-split-window-function 'split-window-horizontally ediff-window-setup-function 'ediff-setup-windows-plain indent-tabs-mode nil @@ -34,6 +33,8 @@ truncate-lines nil truncate-partial-width-windows nil) +(add-hook 'after-init-hook 'delete-selection-mode) + (add-hook 'after-init-hook 'global-auto-revert-mode) (setq global-auto-revert-non-file-buffers t auto-revert-verbose nil) From 90b8fd24756e9953d47dce7217b379038a623740 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 13 Jan 2021 16:36:26 +1300 Subject: [PATCH 25/95] Switch from ivy/counsel to selectrum/consult/embark --- init.el | 3 +- lisp/init-ivy.el | 88 ------------------------------------------ lisp/init-selectrum.el | 45 +++++++++++++++++++++ lisp/init-smex.el | 12 ------ 4 files changed, 46 insertions(+), 102 deletions(-) delete mode 100644 lisp/init-ivy.el create mode 100644 lisp/init-selectrum.el delete mode 100644 lisp/init-smex.el diff --git a/init.el b/init.el index 51ff695f1f..3b4750bc90 100644 --- a/init.el +++ b/init.el @@ -66,8 +66,7 @@ (require 'init-flycheck) (require 'init-recentf) -(require 'init-smex) -(require 'init-ivy) +(require 'init-selectrum) (require 'init-hippie-expand) (require 'init-company) (require 'init-windows) diff --git a/lisp/init-ivy.el b/lisp/init-ivy.el deleted file mode 100644 index a87fa9a63c..0000000000 --- a/lisp/init-ivy.el +++ /dev/null @@ -1,88 +0,0 @@ -;;; init-ivy.el --- Use ivy for minibuffer completion and more -*- lexical-binding: t -*- -;;; Commentary: -;;; Code: - -(when (maybe-require-package 'ivy) - (add-hook 'after-init-hook 'ivy-mode) - (with-eval-after-load 'ivy - (setq-default ivy-use-virtual-buffers t - ivy-virtual-abbreviate 'fullpath - ivy-count-format "" - projectile-completion-system 'ivy - ivy-magic-tilde nil - ivy-dynamic-exhibit-delay-ms 150 - ivy-use-selectable-prompt t) - - ;; IDO-style directory navigation - (define-key ivy-minibuffer-map (kbd "RET") #'ivy-alt-done) - (dolist (k '("C-j" "C-RET")) - (define-key ivy-minibuffer-map (kbd k) #'ivy-immediate-done)) - - (define-key ivy-minibuffer-map (kbd "") #'ivy-previous-line-or-history) - (define-key ivy-minibuffer-map (kbd "") #'ivy-next-line-or-history) - - (define-key ivy-occur-mode-map (kbd "C-c C-q") #'ivy-wgrep-change-to-wgrep-mode) - - (when (maybe-require-package 'diminish) - (diminish 'ivy-mode))) - (when (maybe-require-package 'ivy-rich) - (setq ivy-virtual-abbreviate 'abbreviate - ivy-rich-switch-buffer-align-virtual-buffer nil - ivy-rich-path-style 'abbrev) - (with-eval-after-load 'ivy - (setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line)) - (add-hook 'ivy-mode-hook (lambda () (ivy-rich-mode ivy-mode))))) - -(when (maybe-require-package 'counsel) - (setq-default counsel-mode-override-describe-bindings t) - (with-eval-after-load 'counsel - (setq-default ivy-initial-inputs-alist - '((Man-completion-table . "^") - (woman . "^"))) - ;; I prefer the default behaviour or cycling in place, or - ;; explicit use of browse-kill-ring - (define-key counsel-mode-map [remap yank-pop] nil)) - (when (maybe-require-package 'diminish) - (with-eval-after-load 'counsel - (diminish 'counsel-mode))) - (add-hook 'after-init-hook 'counsel-mode) - - (when (maybe-require-package 'projectile) - (let ((search-function - (cond - ((executable-find "rg") 'counsel-rg) - ((executable-find "ag") 'counsel-ag) - ((executable-find "pt") 'counsel-pt) - ((executable-find "ack") 'counsel-ack)))) - (when search-function - (defun sanityinc/counsel-search-project (initial-input &optional use-current-dir) - "Search using `counsel-rg' or similar from the project root for INITIAL-INPUT. -If there is no project root, or if the prefix argument -USE-CURRENT-DIR is set, then search from the current directory -instead." - (interactive (list (let ((sym (thing-at-point 'symbol))) - (when sym (regexp-quote sym))) - current-prefix-arg)) - (let ((current-prefix-arg) - (dir (if use-current-dir - default-directory - (condition-case err - (projectile-project-root) - (error default-directory))))) - (funcall search-function initial-input dir))))) - (with-eval-after-load 'ivy - (add-to-list 'ivy-height-alist (cons 'counsel-ag 20))) - (global-set-key (kbd "M-?") 'sanityinc/counsel-search-project))) - - -(when (maybe-require-package 'swiper) - (with-eval-after-load 'ivy - (define-key ivy-mode-map (kbd "M-s /") 'swiper-thing-at-point))) - - -(when (maybe-require-package 'ivy-xref) - (setq xref-show-xrefs-function 'ivy-xref-show-xrefs)) - - -(provide 'init-ivy) -;;; init-ivy.el ends here diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el new file mode 100644 index 0000000000..e5f4470148 --- /dev/null +++ b/lisp/init-selectrum.el @@ -0,0 +1,45 @@ +;;; init-selectrum.el --- Config for selectrum -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(when (maybe-require-package 'orderless) + (setq completion-styles '(orderless))) + +(when (require-package 'selectrum) + (add-hook 'after-init-hook (lambda () (selectrum-mode 1))) + + (when (maybe-require-package 'selectrum-prescient) + (require 'prescient) + (prescient-persist-mode 1) + (selectrum-prescient-mode 1) + (global-set-key [remap execute-extended-command] nil) + (global-set-key [remap execute-extended-command] 'execute-extended-command)) + + ;;(defun sanityinc/read-buffer-function (prompt &optional def require-match predicate)) + + (when (maybe-require-package 'embark) + (define-key selectrum-minibuffer-map (kbd "C-c C-o") 'embark-export) + (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act)) + + (when (maybe-require-package 'consult) + (when (maybe-require-package 'projectile) + (setq-default consult-project-root-function 'projectile-project-root)) + + (when (executable-find "rg") + (global-set-key (kbd "M-?") 'consult-ripgrep)) + (global-set-key [remap switch-to-buffer] 'consult-buffer) + (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) + (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) + (maybe-require-package 'embark-consult) ) + + (maybe-require-package 'consult-flycheck) + + (when (maybe-require-package 'marginalia) + (add-hook 'after-init-hook (lambda () (marginalia-mode 1))) + (setq-default marginalia-annotators '(marginalia-annotators-heavy))) + ) + + + +(provide 'init-selectrum) +;;; init-selectrum.el ends here diff --git a/lisp/init-smex.el b/lisp/init-smex.el deleted file mode 100644 index 640f342dae..0000000000 --- a/lisp/init-smex.el +++ /dev/null @@ -1,12 +0,0 @@ -;;; init-smex.el --- Use smex to improve M-x -*- lexical-binding: t -*- -;;; Commentary: -;;; Code: - -;; Use smex to handle M-x -(when (maybe-require-package 'smex) - ;; Change path for ~/.smex-items - (setq-default smex-save-file (expand-file-name ".smex-items" user-emacs-directory)) - (global-set-key [remap execute-extended-command] 'smex)) - -(provide 'init-smex) -;;; init-smex.el ends here From 1392c8c6ea8dda6cdb411bea887f364f7fc66027 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 13 Jan 2021 16:38:12 +1300 Subject: [PATCH 26/95] Add basic support for the J programming language --- init.el | 1 + lisp/init-j.el | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 lisp/init-j.el diff --git a/init.el b/init.el index 3b4750bc90..4a80b0289a 100644 --- a/init.el +++ b/init.el @@ -105,6 +105,7 @@ (require 'init-rails) (require 'init-sql) (require 'init-ocaml) +(require 'init-j) (require 'init-nim) (require 'init-rust) (require 'init-toml) diff --git a/lisp/init-j.el b/lisp/init-j.el new file mode 100644 index 0000000000..68e2c49bdd --- /dev/null +++ b/lisp/init-j.el @@ -0,0 +1,12 @@ +;;; init-j.el --- Basic support for programming in J -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(require-package 'j-mode) + +(setq-default j-console-cmd "jconsole") +(add-hook 'inferior-j-mode-hook (lambda () (electric-pair-mode -1))) + + +(provide 'init-j) +;;; init-j.el ends here From 0c23b05dbccc698e76eb7fa1422864bcb1abc5a7 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 13 Jan 2021 21:02:26 +1300 Subject: [PATCH 27/95] Require Emacs 25.1 --- .github/workflows/test.yml | 1 - README.md | 2 +- init.el | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf41c67d7e..6fba3d4ffa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,6 @@ jobs: matrix: os: [ubuntu-latest] emacs_version: - - 24.5 - 25.1 - 25.2 - 25.3 diff --git a/README.md b/README.md index 858834d5b3..a185db76b6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ other languages. ## Supported Emacs versions -The config should run on Emacs 24.5 or greater and is designed to +The config should run on Emacs 25.1 or greater and is designed to degrade smoothly - see the CI build - but note that much newer versions are required for an increasing number of key packages, so to get full functionality you should use the latest Emacs version diff --git a/init.el b/init.el index 4a80b0289a..98f3f86501 100644 --- a/init.el +++ b/init.el @@ -9,10 +9,10 @@ ;; Produce backtraces when errors occur: can be helpful to diagnose startup issues ;;(setq debug-on-error t) -(let ((minver "24.5")) +(let ((minver "25.1")) (when (version< emacs-version minver) (error "Your Emacs is too old -- this config requires v%s or higher" minver))) -(when (version< emacs-version "25.1") +(when (version< emacs-version "26.1") (message "Your Emacs is old, and some functionality in this config will be disabled. Please upgrade if possible.")) (add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) From 965e59242f9ca6662435892a657cd3fafcac1c09 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 13 Jan 2021 21:02:54 +1300 Subject: [PATCH 28/95] Bump version of github action --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fba3d4ffa..850bbbfc70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,6 @@ jobs: with: version: ${{ matrix.emacs_version }} - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Check startup run: ./test-startup.sh From a4115c2abd5c3a41ffc77b194ca8fb834918198d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 13 Jan 2021 21:16:19 +1300 Subject: [PATCH 29/95] Don't fail fast in CI build --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 850bbbfc70..17072d257b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,7 @@ jobs: build: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest] emacs_version: From 89f335412c6aeee2ae0d13ad294c657317aa4dd1 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 13 Jan 2021 21:20:05 +1300 Subject: [PATCH 30/95] Revert "Switch from ivy/counsel to selectrum/consult/embark" for now See https://github.com/oantolin/embark/issues/108 This reverts commit 90b8fd24756e9953d47dce7217b379038a623740. --- init.el | 3 +- lisp/init-ivy.el | 88 ++++++++++++++++++++++++++++++++++++++++++ lisp/init-selectrum.el | 45 --------------------- lisp/init-smex.el | 12 ++++++ 4 files changed, 102 insertions(+), 46 deletions(-) create mode 100644 lisp/init-ivy.el delete mode 100644 lisp/init-selectrum.el create mode 100644 lisp/init-smex.el diff --git a/init.el b/init.el index 98f3f86501..048d47f430 100644 --- a/init.el +++ b/init.el @@ -66,7 +66,8 @@ (require 'init-flycheck) (require 'init-recentf) -(require 'init-selectrum) +(require 'init-smex) +(require 'init-ivy) (require 'init-hippie-expand) (require 'init-company) (require 'init-windows) diff --git a/lisp/init-ivy.el b/lisp/init-ivy.el new file mode 100644 index 0000000000..a87fa9a63c --- /dev/null +++ b/lisp/init-ivy.el @@ -0,0 +1,88 @@ +;;; init-ivy.el --- Use ivy for minibuffer completion and more -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(when (maybe-require-package 'ivy) + (add-hook 'after-init-hook 'ivy-mode) + (with-eval-after-load 'ivy + (setq-default ivy-use-virtual-buffers t + ivy-virtual-abbreviate 'fullpath + ivy-count-format "" + projectile-completion-system 'ivy + ivy-magic-tilde nil + ivy-dynamic-exhibit-delay-ms 150 + ivy-use-selectable-prompt t) + + ;; IDO-style directory navigation + (define-key ivy-minibuffer-map (kbd "RET") #'ivy-alt-done) + (dolist (k '("C-j" "C-RET")) + (define-key ivy-minibuffer-map (kbd k) #'ivy-immediate-done)) + + (define-key ivy-minibuffer-map (kbd "") #'ivy-previous-line-or-history) + (define-key ivy-minibuffer-map (kbd "") #'ivy-next-line-or-history) + + (define-key ivy-occur-mode-map (kbd "C-c C-q") #'ivy-wgrep-change-to-wgrep-mode) + + (when (maybe-require-package 'diminish) + (diminish 'ivy-mode))) + (when (maybe-require-package 'ivy-rich) + (setq ivy-virtual-abbreviate 'abbreviate + ivy-rich-switch-buffer-align-virtual-buffer nil + ivy-rich-path-style 'abbrev) + (with-eval-after-load 'ivy + (setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line)) + (add-hook 'ivy-mode-hook (lambda () (ivy-rich-mode ivy-mode))))) + +(when (maybe-require-package 'counsel) + (setq-default counsel-mode-override-describe-bindings t) + (with-eval-after-load 'counsel + (setq-default ivy-initial-inputs-alist + '((Man-completion-table . "^") + (woman . "^"))) + ;; I prefer the default behaviour or cycling in place, or + ;; explicit use of browse-kill-ring + (define-key counsel-mode-map [remap yank-pop] nil)) + (when (maybe-require-package 'diminish) + (with-eval-after-load 'counsel + (diminish 'counsel-mode))) + (add-hook 'after-init-hook 'counsel-mode) + + (when (maybe-require-package 'projectile) + (let ((search-function + (cond + ((executable-find "rg") 'counsel-rg) + ((executable-find "ag") 'counsel-ag) + ((executable-find "pt") 'counsel-pt) + ((executable-find "ack") 'counsel-ack)))) + (when search-function + (defun sanityinc/counsel-search-project (initial-input &optional use-current-dir) + "Search using `counsel-rg' or similar from the project root for INITIAL-INPUT. +If there is no project root, or if the prefix argument +USE-CURRENT-DIR is set, then search from the current directory +instead." + (interactive (list (let ((sym (thing-at-point 'symbol))) + (when sym (regexp-quote sym))) + current-prefix-arg)) + (let ((current-prefix-arg) + (dir (if use-current-dir + default-directory + (condition-case err + (projectile-project-root) + (error default-directory))))) + (funcall search-function initial-input dir))))) + (with-eval-after-load 'ivy + (add-to-list 'ivy-height-alist (cons 'counsel-ag 20))) + (global-set-key (kbd "M-?") 'sanityinc/counsel-search-project))) + + +(when (maybe-require-package 'swiper) + (with-eval-after-load 'ivy + (define-key ivy-mode-map (kbd "M-s /") 'swiper-thing-at-point))) + + +(when (maybe-require-package 'ivy-xref) + (setq xref-show-xrefs-function 'ivy-xref-show-xrefs)) + + +(provide 'init-ivy) +;;; init-ivy.el ends here diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el deleted file mode 100644 index e5f4470148..0000000000 --- a/lisp/init-selectrum.el +++ /dev/null @@ -1,45 +0,0 @@ -;;; init-selectrum.el --- Config for selectrum -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - -(when (maybe-require-package 'orderless) - (setq completion-styles '(orderless))) - -(when (require-package 'selectrum) - (add-hook 'after-init-hook (lambda () (selectrum-mode 1))) - - (when (maybe-require-package 'selectrum-prescient) - (require 'prescient) - (prescient-persist-mode 1) - (selectrum-prescient-mode 1) - (global-set-key [remap execute-extended-command] nil) - (global-set-key [remap execute-extended-command] 'execute-extended-command)) - - ;;(defun sanityinc/read-buffer-function (prompt &optional def require-match predicate)) - - (when (maybe-require-package 'embark) - (define-key selectrum-minibuffer-map (kbd "C-c C-o") 'embark-export) - (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act)) - - (when (maybe-require-package 'consult) - (when (maybe-require-package 'projectile) - (setq-default consult-project-root-function 'projectile-project-root)) - - (when (executable-find "rg") - (global-set-key (kbd "M-?") 'consult-ripgrep)) - (global-set-key [remap switch-to-buffer] 'consult-buffer) - (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) - (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) - (maybe-require-package 'embark-consult) ) - - (maybe-require-package 'consult-flycheck) - - (when (maybe-require-package 'marginalia) - (add-hook 'after-init-hook (lambda () (marginalia-mode 1))) - (setq-default marginalia-annotators '(marginalia-annotators-heavy))) - ) - - - -(provide 'init-selectrum) -;;; init-selectrum.el ends here diff --git a/lisp/init-smex.el b/lisp/init-smex.el new file mode 100644 index 0000000000..640f342dae --- /dev/null +++ b/lisp/init-smex.el @@ -0,0 +1,12 @@ +;;; init-smex.el --- Use smex to improve M-x -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +;; Use smex to handle M-x +(when (maybe-require-package 'smex) + ;; Change path for ~/.smex-items + (setq-default smex-save-file (expand-file-name ".smex-items" user-emacs-directory)) + (global-set-key [remap execute-extended-command] 'smex)) + +(provide 'init-smex) +;;; init-smex.el ends here From cd2be4d6a663cb0410b8206ea23594d04981da44 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 15 Jan 2021 11:40:04 +1300 Subject: [PATCH 31/95] Switch from ivy+counsel+smex to selectrum+consult+embark+prescient This is a relatively big change in terms of user experience, but should be largely familiar to counsel/ivy users. Existing users may find that counsel-mode and ivy-mode stay activated due to desktop-save-mode, which could lead to confusion: these modes should be deactivated and can, ultimately, be uninstalled. --- init.el | 3 +- lisp/init-ivy.el | 88 ------------------------------------------ lisp/init-selectrum.el | 48 +++++++++++++++++++++++ lisp/init-smex.el | 12 ------ 4 files changed, 49 insertions(+), 102 deletions(-) delete mode 100644 lisp/init-ivy.el create mode 100644 lisp/init-selectrum.el delete mode 100644 lisp/init-smex.el diff --git a/init.el b/init.el index 048d47f430..98f3f86501 100644 --- a/init.el +++ b/init.el @@ -66,8 +66,7 @@ (require 'init-flycheck) (require 'init-recentf) -(require 'init-smex) -(require 'init-ivy) +(require 'init-selectrum) (require 'init-hippie-expand) (require 'init-company) (require 'init-windows) diff --git a/lisp/init-ivy.el b/lisp/init-ivy.el deleted file mode 100644 index a87fa9a63c..0000000000 --- a/lisp/init-ivy.el +++ /dev/null @@ -1,88 +0,0 @@ -;;; init-ivy.el --- Use ivy for minibuffer completion and more -*- lexical-binding: t -*- -;;; Commentary: -;;; Code: - -(when (maybe-require-package 'ivy) - (add-hook 'after-init-hook 'ivy-mode) - (with-eval-after-load 'ivy - (setq-default ivy-use-virtual-buffers t - ivy-virtual-abbreviate 'fullpath - ivy-count-format "" - projectile-completion-system 'ivy - ivy-magic-tilde nil - ivy-dynamic-exhibit-delay-ms 150 - ivy-use-selectable-prompt t) - - ;; IDO-style directory navigation - (define-key ivy-minibuffer-map (kbd "RET") #'ivy-alt-done) - (dolist (k '("C-j" "C-RET")) - (define-key ivy-minibuffer-map (kbd k) #'ivy-immediate-done)) - - (define-key ivy-minibuffer-map (kbd "") #'ivy-previous-line-or-history) - (define-key ivy-minibuffer-map (kbd "") #'ivy-next-line-or-history) - - (define-key ivy-occur-mode-map (kbd "C-c C-q") #'ivy-wgrep-change-to-wgrep-mode) - - (when (maybe-require-package 'diminish) - (diminish 'ivy-mode))) - (when (maybe-require-package 'ivy-rich) - (setq ivy-virtual-abbreviate 'abbreviate - ivy-rich-switch-buffer-align-virtual-buffer nil - ivy-rich-path-style 'abbrev) - (with-eval-after-load 'ivy - (setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line)) - (add-hook 'ivy-mode-hook (lambda () (ivy-rich-mode ivy-mode))))) - -(when (maybe-require-package 'counsel) - (setq-default counsel-mode-override-describe-bindings t) - (with-eval-after-load 'counsel - (setq-default ivy-initial-inputs-alist - '((Man-completion-table . "^") - (woman . "^"))) - ;; I prefer the default behaviour or cycling in place, or - ;; explicit use of browse-kill-ring - (define-key counsel-mode-map [remap yank-pop] nil)) - (when (maybe-require-package 'diminish) - (with-eval-after-load 'counsel - (diminish 'counsel-mode))) - (add-hook 'after-init-hook 'counsel-mode) - - (when (maybe-require-package 'projectile) - (let ((search-function - (cond - ((executable-find "rg") 'counsel-rg) - ((executable-find "ag") 'counsel-ag) - ((executable-find "pt") 'counsel-pt) - ((executable-find "ack") 'counsel-ack)))) - (when search-function - (defun sanityinc/counsel-search-project (initial-input &optional use-current-dir) - "Search using `counsel-rg' or similar from the project root for INITIAL-INPUT. -If there is no project root, or if the prefix argument -USE-CURRENT-DIR is set, then search from the current directory -instead." - (interactive (list (let ((sym (thing-at-point 'symbol))) - (when sym (regexp-quote sym))) - current-prefix-arg)) - (let ((current-prefix-arg) - (dir (if use-current-dir - default-directory - (condition-case err - (projectile-project-root) - (error default-directory))))) - (funcall search-function initial-input dir))))) - (with-eval-after-load 'ivy - (add-to-list 'ivy-height-alist (cons 'counsel-ag 20))) - (global-set-key (kbd "M-?") 'sanityinc/counsel-search-project))) - - -(when (maybe-require-package 'swiper) - (with-eval-after-load 'ivy - (define-key ivy-mode-map (kbd "M-s /") 'swiper-thing-at-point))) - - -(when (maybe-require-package 'ivy-xref) - (setq xref-show-xrefs-function 'ivy-xref-show-xrefs)) - - -(provide 'init-ivy) -;;; init-ivy.el ends here diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el new file mode 100644 index 0000000000..12be908730 --- /dev/null +++ b/lisp/init-selectrum.el @@ -0,0 +1,48 @@ +;;; init-selectrum.el --- Config for selectrum -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(when (maybe-require-package 'orderless) + (setq completion-styles '(orderless))) + +(when (require-package 'selectrum) + (add-hook 'after-init-hook 'selectrum-mode) + + (when (maybe-require-package 'selectrum-prescient) + (require 'prescient) + (prescient-persist-mode 1) + (selectrum-prescient-mode 1) + (global-set-key [remap execute-extended-command] nil) + (global-set-key [remap execute-extended-command] 'execute-extended-command)) + + ;;(defun sanityinc/read-buffer-function (prompt &optional def require-match predicate)) + + (when (maybe-require-package 'embark) + (define-key selectrum-minibuffer-map (kbd "C-c C-o") 'embark-export) + (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act)) + + (when (maybe-require-package 'consult) + (when (maybe-require-package 'projectile) + (setq-default consult-project-root-function 'projectile-project-root)) + + (when (executable-find "rg") + (global-set-key (kbd "M-?") 'consult-ripgrep)) + (global-set-key [remap switch-to-buffer] 'consult-buffer) + (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) + (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) + (when (maybe-require-package 'embark-consult) + (with-eval-after-load 'embark + (add-hook 'embark-collect-mode-hook 'embark-consult-preview-minor-mode) + (with-eval-after-load 'consult + (require 'embark-consult))))) + + (maybe-require-package 'consult-flycheck) + + (when (maybe-require-package 'marginalia) + (add-hook 'after-init-hook 'marginalia-mode) + (setq-default marginalia-annotators '(marginalia-annotators-heavy)))) + + + +(provide 'init-selectrum) +;;; init-selectrum.el ends here diff --git a/lisp/init-smex.el b/lisp/init-smex.el deleted file mode 100644 index 640f342dae..0000000000 --- a/lisp/init-smex.el +++ /dev/null @@ -1,12 +0,0 @@ -;;; init-smex.el --- Use smex to improve M-x -*- lexical-binding: t -*- -;;; Commentary: -;;; Code: - -;; Use smex to handle M-x -(when (maybe-require-package 'smex) - ;; Change path for ~/.smex-items - (setq-default smex-save-file (expand-file-name ".smex-items" user-emacs-directory)) - (global-set-key [remap execute-extended-command] 'smex)) - -(provide 'init-smex) -;;; init-smex.el ends here From 99961e1170eb84b19a896753102c3d7179dff6ce Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 15 Jan 2021 11:56:06 +1300 Subject: [PATCH 32/95] Don't restore counsel-mode or ivy-mode via desktop.el --- lisp/init-selectrum.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index 12be908730..cc2239646b 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -42,7 +42,11 @@ (add-hook 'after-init-hook 'marginalia-mode) (setq-default marginalia-annotators '(marginalia-annotators-heavy)))) - +(with-eval-after-load 'desktop + ;; Try to prevent old minibuffer completion system being reactivated in + ;; buffers restored via desktop.el + (push (cons 'counsel-mode nil) desktop-minor-mode-table) + (push (cons 'ivy-mode nil) desktop-minor-mode-table)) (provide 'init-selectrum) ;;; init-selectrum.el ends here From c59be0ab729341b7d3b5a3e99552d3d6a55c722d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 15 Jan 2021 13:21:51 +1300 Subject: [PATCH 33/95] Remove commented-out cruft --- lisp/init-selectrum.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index cc2239646b..ec0104edd1 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -15,8 +15,6 @@ (global-set-key [remap execute-extended-command] nil) (global-set-key [remap execute-extended-command] 'execute-extended-command)) - ;;(defun sanityinc/read-buffer-function (prompt &optional def require-match predicate)) - (when (maybe-require-package 'embark) (define-key selectrum-minibuffer-map (kbd "C-c C-o") 'embark-export) (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act)) From a2d8d6e9160fa2f47b6388d56916cc81df5064bb Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 15 Jan 2021 14:55:38 +1300 Subject: [PATCH 34/95] Trim unnecessary parts out of selectrum config Thanks @minad, @oantolin --- lisp/init-selectrum.el | 3 --- 1 file changed, 3 deletions(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index ec0104edd1..fc6b246302 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -2,8 +2,6 @@ ;;; Commentary: ;;; Code: -(when (maybe-require-package 'orderless) - (setq completion-styles '(orderless))) (when (require-package 'selectrum) (add-hook 'after-init-hook 'selectrum-mode) @@ -12,7 +10,6 @@ (require 'prescient) (prescient-persist-mode 1) (selectrum-prescient-mode 1) - (global-set-key [remap execute-extended-command] nil) (global-set-key [remap execute-extended-command] 'execute-extended-command)) (when (maybe-require-package 'embark) From 0aac95b36583afffc35cab3a4f05ba5f0f3551b3 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 15 Jan 2021 14:57:56 +1300 Subject: [PATCH 35/95] For conditionals, need `maybe-require-package` --- lisp/init-selectrum.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index fc6b246302..287e28f70c 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -3,7 +3,7 @@ ;;; Code: -(when (require-package 'selectrum) +(when (maybe-require-package 'selectrum) (add-hook 'after-init-hook 'selectrum-mode) (when (maybe-require-package 'selectrum-prescient) From 0e9861dedf2a5dcba5ba71d59873ccfd4c89afff Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 15 Jan 2021 15:40:31 +1300 Subject: [PATCH 36/95] Default to embark-act-noexit --- lisp/init-selectrum.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index 287e28f70c..bcee0b174f 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -14,7 +14,7 @@ (when (maybe-require-package 'embark) (define-key selectrum-minibuffer-map (kbd "C-c C-o") 'embark-export) - (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act)) + (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act-noexit)) (when (maybe-require-package 'consult) (when (maybe-require-package 'projectile) From 23c40e6078390b49a0ff48e9b66ab8e534d97dd1 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 15 Jan 2021 15:40:45 +1300 Subject: [PATCH 37/95] Fix config for embark-consult --- lisp/init-selectrum.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index bcee0b174f..ebcecacf19 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -27,9 +27,8 @@ (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark - (add-hook 'embark-collect-mode-hook 'embark-consult-preview-minor-mode) - (with-eval-after-load 'consult - (require 'embark-consult))))) + (require 'embark-consult) + (add-hook 'embark-collect-mode-hook 'embark-consult-preview-minor-mode)))) (maybe-require-package 'consult-flycheck) From a423aab174d8bb65f71397ec28ecaa273ae6a722 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 26 Jan 2021 17:44:30 +1300 Subject: [PATCH 38/95] Provide sanityinc/consult-ripgrep-at-point for M-? binding --- lisp/init-selectrum.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index ebcecacf19..0680708375 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -21,20 +21,24 @@ (setq-default consult-project-root-function 'projectile-project-root)) (when (executable-find "rg") - (global-set-key (kbd "M-?") 'consult-ripgrep)) + (defun sanityinc/consult-ripgrep-at-point (&optional dir initial) + (interactive (list prefix-arg (let ((s (symbol-at-point))) + (when s (symbol-name s))))) + (consult-ripgrep dir initial))) + (global-set-key (kbd "M-?") 'sanityinc/consult-ripgrep-at-point) (global-set-key [remap switch-to-buffer] 'consult-buffer) (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark (require 'embark-consult) - (add-hook 'embark-collect-mode-hook 'embark-consult-preview-minor-mode)))) + (add-hook 'embark-collect-mode-hook 'embark-consult-preview-minor-mode))) - (maybe-require-package 'consult-flycheck) + (maybe-require-package 'consult-flycheck))) - (when (maybe-require-package 'marginalia) - (add-hook 'after-init-hook 'marginalia-mode) - (setq-default marginalia-annotators '(marginalia-annotators-heavy)))) +(when (maybe-require-package 'marginalia) + (add-hook 'after-init-hook 'marginalia-mode) + (setq-default marginalia-annotators '(marginalia-annotators-heavy))) (with-eval-after-load 'desktop ;; Try to prevent old minibuffer completion system being reactivated in From a238c395aa182b69b7118ce21a9c0dcb9322e54e Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 26 Jan 2021 17:44:59 +1300 Subject: [PATCH 39/95] Disable some auto-compile cleanup to minimise org startup time --- lisp/init-lisp.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/init-lisp.el b/lisp/init-lisp.el index b8f8adfe70..5e11561228 100644 --- a/lisp/init-lisp.el +++ b/lisp/init-lisp.el @@ -129,6 +129,7 @@ there is no current file, eval the current buffer." ;; Automatic byte compilation ;; ---------------------------------------------------------------------------- (when (maybe-require-package 'auto-compile) + (setq auto-compile-delete-stray-dest nil) (add-hook 'after-init-hook 'auto-compile-on-save-mode) (add-hook 'after-init-hook 'auto-compile-on-load-mode)) From 640d0afe6963adfcad55d4b76ece0fdfea6aa585 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 9 Feb 2021 15:28:50 +1300 Subject: [PATCH 40/95] embark-act-noexit has been removed upstream Fixes #768 --- lisp/init-selectrum.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index 0680708375..cd440ee111 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -14,7 +14,7 @@ (when (maybe-require-package 'embark) (define-key selectrum-minibuffer-map (kbd "C-c C-o") 'embark-export) - (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act-noexit)) + (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act)) (when (maybe-require-package 'consult) (when (maybe-require-package 'projectile) From 18816a9ffbc4b607d9b2409fa6775996573b3c76 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 17 Feb 2021 15:51:47 +1300 Subject: [PATCH 41/95] Allow require-package to upgrade a package if min-version given See #771 --- lisp/init-elpa.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el index f0b1ae6751..47f58eb0de 100644 --- a/lisp/init-elpa.el +++ b/lisp/init-elpa.el @@ -34,13 +34,16 @@ If NO-REFRESH is non-nil, the available package lists will not be re-downloaded in order to locate PACKAGE." (or (package-installed-p package min-version) (let* ((known (cdr (assoc package package-archive-contents))) - (versions (mapcar #'package-desc-version known))) - (if (cl-some (lambda (v) (version-list-<= min-version v)) versions) - (package-install package) + (best (car (sort known (lambda (a b) + (version-list-<= (package-desc-version b) + (package-desc-version a))))))) + (if (and best (version-list-<= min-version (package-desc-version best))) + (package-install best) (if no-refresh (error "No version of %s >= %S is available" package min-version) (package-refresh-contents) - (require-package package min-version t)))))) + (require-package package min-version t))) + (package-installed-p package min-version)))) (defun maybe-require-package (package &optional min-version no-refresh) "Try to install PACKAGE, and return non-nil if successful. From e78c2b9bbea4913a8b52a4c923c0ff3419ca58c4 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 22 Feb 2021 14:20:33 +1300 Subject: [PATCH 42/95] Workaround for company menu with page-break-lines is now redundant --- lisp/init-company.el | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/lisp/init-company.el b/lisp/init-company.el index 84c0a74997..2c4037abae 100644 --- a/lisp/init-company.el +++ b/lisp/init-company.el @@ -28,24 +28,6 @@ (when (maybe-require-package 'company-quickhelp) (add-hook 'after-init-hook 'company-quickhelp-mode))) -;; Suspend page-break-lines-mode while company menu is active -;; (see https://github.com/company-mode/company-mode/issues/416) -(with-eval-after-load 'company - (with-eval-after-load 'page-break-lines - (defvar-local sanityinc/page-break-lines-on-p nil) - - (defun sanityinc/page-break-lines-disable (&rest ignore) - (when (setq sanityinc/page-break-lines-on-p (bound-and-true-p page-break-lines-mode)) - (page-break-lines-mode -1))) - - (defun sanityinc/page-break-lines-maybe-reenable (&rest ignore) - (when sanityinc/page-break-lines-on-p - (page-break-lines-mode 1))) - - (add-hook 'company-completion-started-hook 'sanityinc/page-break-lines-disable) - (add-hook 'company-after-completion-hook 'sanityinc/page-break-lines-maybe-reenable))) - - (provide 'init-company) ;;; init-company.el ends here From ed119437dfbe063de25965a9ae0eb7e6c50caa44 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 23 Feb 2021 11:26:39 +1300 Subject: [PATCH 43/95] Work around selectrum minibuffer height issue See #773 See https://github.com/raxod502/selectrum/issues/435 --- lisp/init-selectrum.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index cd440ee111..76cdcc6e9f 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -5,6 +5,7 @@ (when (maybe-require-package 'selectrum) (add-hook 'after-init-hook 'selectrum-mode) + (setq-default selectrum-fix-vertical-window-height t) (when (maybe-require-package 'selectrum-prescient) (require 'prescient) From c53fc4ff2ee3b31ec6921d391131a7f372f79b6d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Thu, 4 Mar 2021 13:22:33 +1300 Subject: [PATCH 44/95] Add support for ocaml's "dune" build tool --- lisp/init-ocaml.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index 7c616094a3..9720867eeb 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -45,6 +45,8 @@ (define-key tuareg-mode-map (kbd "C-c C-z") 'sanityinc/tuareg-repl-switch) (define-key tuareg-interactive-mode-map (kbd "C-c C-z") 'sanityinc/tuareg-repl-switch-back))) +(maybe-require-package 'dune) + (when (maybe-require-package 'reformatter) (defcustom ocp-indent-args nil "Arguments for \"ocp-indent\" invocation.") @@ -52,7 +54,12 @@ (reformatter-define ocp-indent :program "ocp-indent" :args ocp-indent-args - :lighter " OCP")) + :lighter " OCP") + + (reformatter-define dune-format + :program "dune" + :args '("format-dune-file") + :lighter " DuneFmt")) (provide 'init-ocaml) From 61fb6047abdd578774008c256cd0a7f2066403f0 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 13 Mar 2021 11:37:27 +1300 Subject: [PATCH 45/95] Update note about using pyvenv, see #774 --- lisp/init-python.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/init-python.el b/lisp/init-python.el index 8b14dd0500..7ad5f81dac 100644 --- a/lisp/init-python.el +++ b/lisp/init-python.el @@ -2,10 +2,9 @@ ;;; Commentary: ;;; Code: - -;; See the following note about how I set up python + virtualenv to -;; work seamlessly with Emacs: -;; https://gist.github.com/purcell/81f76c50a42eee710dcfc9a14bfc7240 +;; I use nix + direnv instead of virtualenv/pyenv/pyvenv, and it is an +;; approach which extends to other languages too. I recorded a +;; screencast about this: https://www.youtube.com/watch?v=TbIHRHy7_JM (setq auto-mode-alist From 5f324a707647b98aa2cca993189b8a20a00995b9 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 13 Mar 2021 12:34:11 +1300 Subject: [PATCH 46/95] Pre-declare url-show-status var in startup script Aiming to prevent this in Emacs 28: Debugger entered--Lisp error: (error "Defining as dynamic an already lexical var") internal--define-uninitialized-variable(url-show-status "Whether to show a running total of bytes transferr...") --- test-startup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test-startup.sh b/test-startup.sh index c5b29d653c..3d3d83c329 100755 --- a/test-startup.sh +++ b/test-startup.sh @@ -1,11 +1,13 @@ #!/bin/sh -e echo "Attempting startup..." ${EMACS:=emacs} -nw --batch \ - --eval '(let ((debug-on-error t) + --eval '(progn + (defvar url-show-status) + (let ((debug-on-error t) (url-show-status nil) (user-emacs-directory default-directory) (user-init-file (expand-file-name "init.el")) (load-path (delq default-directory load-path))) (load-file user-init-file) - (run-hooks (quote after-init-hook)))' + (run-hooks (quote after-init-hook))))' echo "Startup successful" From 0cd0ca857f3ee863f202b66df78a7a0e7c488e8e Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 16 Mar 2021 13:32:42 +1300 Subject: [PATCH 47/95] Zap-up-to-char has been autoloaded for 5 years now --- lisp/init-editing-utils.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 0cc9bd3717..c00d8b4c8c 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -130,8 +130,6 @@ ;;; Zap *up* to char is a handy pair for zap-to-char - -(autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.") (global-set-key (kbd "M-Z") 'zap-up-to-char) From 9f506ab520f2f6ec3fae44a27a864ee5e0d24af0 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 16 Mar 2021 13:33:05 +1300 Subject: [PATCH 48/95] move-dup commands have been renamed --- lisp/init-editing-utils.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index c00d8b4c8c..6d75dcc532 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -203,13 +203,13 @@ ;; use M-S-up and M-S-down, which will work even in lisp modes. (require-package 'move-dup) -(global-set-key [M-up] 'md-move-lines-up) -(global-set-key [M-down] 'md-move-lines-down) -(global-set-key [M-S-up] 'md-move-lines-up) -(global-set-key [M-S-down] 'md-move-lines-down) +(global-set-key [M-up] 'move-dup-move-lines-up) +(global-set-key [M-down] 'move-dup-move-lines-down) +(global-set-key [M-S-up] 'move-dup-move-lines-up) +(global-set-key [M-S-down] 'move-dup-move-lines-down) -(global-set-key (kbd "C-c d") 'md-duplicate-down) -(global-set-key (kbd "C-c u") 'md-duplicate-up) +(global-set-key (kbd "C-c d") 'move-dup-duplicate-down) +(global-set-key (kbd "C-c u") 'move-dup-duplicate-up) ;;; Fix backward-up-list to understand quotes, see http://bit.ly/h7mdIL From 2f068fc36653353e2ccea10d21628583a6333160 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 29 Mar 2021 15:18:29 +1300 Subject: [PATCH 49/95] Support company margin icons --- lisp/init-company.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp/init-company.el b/lisp/init-company.el index 2c4037abae..77d4b76583 100644 --- a/lisp/init-company.el +++ b/lisp/init-company.el @@ -14,6 +14,12 @@ (dolist (backend '(company-eclim company-semantic)) (delq backend company-backends)) (diminish 'company-mode) + (defun sanityinc/company-icons-margin-auto (&rest args) + (apply (if (eq 'dark (frame-parameter nil 'background-mode)) + #'company-vscode-dark-icons-margin + #'company-vscode-light-icons-margin) + args)) + (setq company-format-margin-function #'sanityinc/company-icons-margin-auto) (define-key company-mode-map (kbd "M-/") 'company-complete) (define-key company-mode-map [remap completion-at-point] 'company-complete) (define-key company-mode-map [remap indent-for-tab-command] 'company-indent-or-complete-common) From 0b5c4b530e0fe1a6de4f15445619d44100a8c950 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 31 Mar 2021 13:03:30 +1300 Subject: [PATCH 50/95] Prefer consult-goto-line to goto-line-preview --- lisp/init-editing-utils.el | 9 --------- lisp/init-selectrum.el | 1 + 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 6d75dcc532..3128243d75 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -96,15 +96,6 @@ (setq-default display-line-numbers-width 3) (add-hook 'prog-mode-hook 'display-line-numbers-mode)) -(when (maybe-require-package 'goto-line-preview) - (global-set-key [remap goto-line] 'goto-line-preview) - - (when (fboundp 'display-line-numbers-mode) - (defun sanityinc/with-display-line-numbers (f &rest args) - (let ((display-line-numbers t)) - (apply f args))) - (advice-add 'goto-line-preview :around #'sanityinc/with-display-line-numbers))) - (when (boundp 'display-fill-column-indicator) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index 76cdcc6e9f..a878223038 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -30,6 +30,7 @@ (global-set-key [remap switch-to-buffer] 'consult-buffer) (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) + (global-set-key [remap goto-line] 'consult-goto-line) (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark (require 'embark-consult) From 90aef2612e3e5f9ac79f0e17b50ceb61936a563b Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 31 Mar 2021 13:42:52 +1300 Subject: [PATCH 51/95] Add Emacs 27.2 to CI --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17072d257b..6d51a7b20f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,10 +21,11 @@ jobs: - 26.2 - 26.3 - 27.1 + - 27.2 - snapshot include: - os: macos-latest - emacs_version: 27.1 + emacs_version: 27.2 steps: - uses: purcell/setup-emacs@master with: From 130b24ecb6f97155b2ec20654697c774d85fc0eb Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Thu, 1 Apr 2021 13:25:17 +1300 Subject: [PATCH 52/95] Tweaks to consult config --- lisp/init-selectrum.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index a878223038..058367e61c 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -23,14 +23,15 @@ (when (executable-find "rg") (defun sanityinc/consult-ripgrep-at-point (&optional dir initial) - (interactive (list prefix-arg (let ((s (symbol-at-point))) - (when s (symbol-name s))))) + (interactive (list prefix-arg (when-let ((s (symbol-at-point))) + (symbol-name s)))) (consult-ripgrep dir initial))) (global-set-key (kbd "M-?") 'sanityinc/consult-ripgrep-at-point) (global-set-key [remap switch-to-buffer] 'consult-buffer) (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) (global-set-key [remap goto-line] 'consult-goto-line) + (global-set-key [remap yank-pop] 'consult-yank-replace) (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark (require 'embark-consult) From f36c1db8ce0f7e427b240aa8fbfaeff49b5593bb Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Apr 2021 13:05:19 +1200 Subject: [PATCH 53/95] Use new dune-format package extracted from this config --- lisp/init-ocaml.el | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index 9720867eeb..5bdca0bcc1 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -45,8 +45,10 @@ (define-key tuareg-mode-map (kbd "C-c C-z") 'sanityinc/tuareg-repl-switch) (define-key tuareg-interactive-mode-map (kbd "C-c C-z") 'sanityinc/tuareg-repl-switch-back))) -(maybe-require-package 'dune) +(when (maybe-require-package 'dune) + (maybe-require-package 'dune-format)) +;; Add my own lightweight ocp-indent reformatter, instead of the clunky upstream package (when (maybe-require-package 'reformatter) (defcustom ocp-indent-args nil "Arguments for \"ocp-indent\" invocation.") @@ -54,12 +56,7 @@ (reformatter-define ocp-indent :program "ocp-indent" :args ocp-indent-args - :lighter " OCP") - - (reformatter-define dune-format - :program "dune" - :args '("format-dune-file") - :lighter " DuneFmt")) + :lighter " OCP")) (provide 'init-ocaml) From 476728fadee8c063f0ae1749760bfcaa18958c60 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Apr 2021 13:08:25 +1200 Subject: [PATCH 54/95] Remove defunct company-elm package --- lisp/init-elm.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/lisp/init-elm.el b/lisp/init-elm.el index 2251660324..1548210a03 100644 --- a/lisp/init-elm.el +++ b/lisp/init-elm.el @@ -5,8 +5,6 @@ (when (maybe-require-package 'elm-mode) (with-eval-after-load 'elm-mode (diminish 'elm-indent-mode) - (with-eval-after-load 'company - (add-to-list 'company-backends 'company-elm)) (when (executable-find "elm-format") (setq-default elm-format-on-save t))) (maybe-require-package 'elm-test-runner) From cde8b07752a7517bc6cce176ac55af4919f4f5b1 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Apr 2021 13:17:06 +1200 Subject: [PATCH 55/95] Divide code sections consistently --- init.el | 29 ++++++++--------------------- lisp/init-gui-frames.el | 12 ++++++------ lisp/init-javascript.el | 6 ++---- lisp/init-lisp.el | 18 ++++++++---------- lisp/init-misc.el | 4 ++-- lisp/init-mmm.el | 3 --- lisp/init-nxml.el | 3 +-- lisp/init-ruby.el | 3 +-- lisp/init-sessions.el | 4 ++-- lisp/init-themes.el | 4 ++-- lisp/init-uniquify.el | 2 -- lisp/init-utils.el | 19 +++++++++---------- lisp/init-windows.el | 15 ++++++++------- 13 files changed, 49 insertions(+), 73 deletions(-) diff --git a/init.el b/init.el index 98f3f86501..fc2150b500 100644 --- a/init.el +++ b/init.el @@ -21,18 +21,19 @@ (defconst *spell-check-support-enabled* nil) ;; Enable with t if you prefer (defconst *is-a-mac* (eq system-type 'darwin)) -;;---------------------------------------------------------------------------- + ;; Adjust garbage collection thresholds during startup, and thereafter -;;---------------------------------------------------------------------------- + (let ((normal-gc-cons-threshold (* 20 1024 1024)) (init-gc-cons-threshold (* 128 1024 1024))) (setq gc-cons-threshold init-gc-cons-threshold) (add-hook 'emacs-startup-hook (lambda () (setq gc-cons-threshold normal-gc-cons-threshold)))) -;;---------------------------------------------------------------------------- + ;; Bootstrap config -;;---------------------------------------------------------------------------- + + (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) (require 'init-utils) (require 'init-site-lisp) ;; Must come before elpa, as it may provide package.el @@ -40,15 +41,11 @@ (require 'init-elpa) ;; Machinery for installing required packages (require 'init-exec-path) ;; Set up $PATH -;;---------------------------------------------------------------------------- + ;; Allow users to provide an optional "init-preload-local.el" -;;---------------------------------------------------------------------------- (require 'init-preload-local nil t) -;;---------------------------------------------------------------------------- ;; Load configs for specific features and modes -;;---------------------------------------------------------------------------- - (require-package 'diminish) (maybe-require-package 'scratch) (require-package 'command-log-mode) @@ -155,35 +152,25 @@ (require 'init-direnv) -;;---------------------------------------------------------------------------- + + ;; Allow access from emacsclient -;;---------------------------------------------------------------------------- (add-hook 'after-init-hook (lambda () (require 'server) (unless (server-running-p) (server-start)))) -;;---------------------------------------------------------------------------- ;; Variables configured via the interactive 'customize' interface -;;---------------------------------------------------------------------------- (when (file-exists-p custom-file) (load custom-file)) - -;;---------------------------------------------------------------------------- ;; Locales (setting them earlier in this file doesn't work in X) -;;---------------------------------------------------------------------------- (require 'init-locales) - -;;---------------------------------------------------------------------------- ;; Allow users to provide an optional "init-local" containing personal settings -;;---------------------------------------------------------------------------- (require 'init-local nil t) - - (provide 'init) ;; Local Variables: diff --git a/lisp/init-gui-frames.el b/lisp/init-gui-frames.el index e86e80a09b..2e49da8a4d 100644 --- a/lisp/init-gui-frames.el +++ b/lisp/init-gui-frames.el @@ -2,9 +2,9 @@ ;;; Commentary: ;;; Code: -;;---------------------------------------------------------------------------- + ;; Stop C-z from minimizing windows under OS X -;;---------------------------------------------------------------------------- + (defun sanityinc/maybe-suspend-frame () (interactive) (unless (and *is-a-mac* window-system) @@ -13,17 +13,17 @@ (global-set-key (kbd "C-z") 'sanityinc/maybe-suspend-frame) -;;---------------------------------------------------------------------------- + ;; Suppress GUI features -;;---------------------------------------------------------------------------- + (setq use-file-dialog nil) (setq use-dialog-box nil) (setq inhibit-startup-screen t) -;;---------------------------------------------------------------------------- + ;; Window size and features -;;---------------------------------------------------------------------------- + (setq-default window-resize-pixelwise t frame-resize-pixelwise t) diff --git a/lisp/init-javascript.el b/lisp/init-javascript.el index 9c20b78128..68fa5f0678 100644 --- a/lisp/init-javascript.el +++ b/lisp/init-javascript.el @@ -76,9 +76,8 @@ (when (fboundp 'coffee-mode) (add-to-list 'auto-mode-alist '("\\.coffee\\.erb\\'" . coffee-mode)))) -;; --------------------------------------------------------------------------- + ;; Run and interact with an inferior JS via js-comint.el -;; --------------------------------------------------------------------------- (when (maybe-require-package 'js-comint) (setq js-comint-program-command "node") @@ -94,9 +93,8 @@ (dolist (hook '(js2-mode-hook js-mode-hook)) (add-hook hook 'inferior-js-keys-mode))) -;; --------------------------------------------------------------------------- + ;; Alternatively, use skewer-mode -;; --------------------------------------------------------------------------- (when (maybe-require-package 'skewer-mode) (with-eval-after-load 'skewer-mode diff --git a/lisp/init-lisp.el b/lisp/init-lisp.el index 5e11561228..9a4f22436e 100644 --- a/lisp/init-lisp.el +++ b/lisp/init-lisp.el @@ -114,9 +114,8 @@ there is no current file, eval the current buffer." (with-eval-after-load 'ielm (define-key ielm-map (kbd "C-c C-z") 'sanityinc/repl-switch-back)) -;; ---------------------------------------------------------------------------- + ;; Hippie-expand -;; ---------------------------------------------------------------------------- (defun set-up-hippie-expand-for-elisp () "Locally set `hippie-expand' completion functions for use with Emacs Lisp." @@ -125,17 +124,17 @@ there is no current file, eval the current buffer." (add-to-list 'hippie-expand-try-functions-list 'try-complete-lisp-symbol-partially t)) -;; ---------------------------------------------------------------------------- + ;; Automatic byte compilation -;; ---------------------------------------------------------------------------- + (when (maybe-require-package 'auto-compile) (setq auto-compile-delete-stray-dest nil) (add-hook 'after-init-hook 'auto-compile-on-save-mode) (add-hook 'after-init-hook 'auto-compile-on-load-mode)) -;; ---------------------------------------------------------------------------- + ;; Load .el if newer than corresponding .elc -;; ---------------------------------------------------------------------------- + (setq load-prefer-newer t) @@ -160,9 +159,9 @@ there is no current file, eval the current buffer." " "))))) -;; ---------------------------------------------------------------------------- + ;; Enable desired features for all lisp modes -;; ---------------------------------------------------------------------------- + (defun sanityinc/enable-check-parens-on-save () "Run `check-parens' when the current buffer is saved." (add-hook 'after-save-hook #'check-parens nil t)) @@ -211,9 +210,8 @@ there is no current file, eval the current buffer." (with-eval-after-load 'lisp-mode (cl-lib-highlight-initialize)) -;; ---------------------------------------------------------------------------- + ;; Delete .elc files when reverting the .el from VC or magit -;; ---------------------------------------------------------------------------- ;; When .el files are open, we can intercept when they are modified ;; by VC or magit in order to remove .elc files that are likely to diff --git a/lisp/init-misc.el b/lisp/init-misc.el index ed7cca05ea..253c1995de 100644 --- a/lisp/init-misc.el +++ b/lisp/init-misc.el @@ -2,9 +2,9 @@ ;;; Commentary: ;;; Code: -;;---------------------------------------------------------------------------- + ;; Misc config - yet to be placed in separate files -;;---------------------------------------------------------------------------- + (add-auto-mode 'tcl-mode "^Portfile\\'") (fset 'yes-or-no-p 'y-or-n-p) diff --git a/lisp/init-mmm.el b/lisp/init-mmm.el index 7bd37bf59e..4cd592fe0d 100644 --- a/lisp/init-mmm.el +++ b/lisp/init-mmm.el @@ -2,9 +2,6 @@ ;;; Commentary: ;;; Code: -;;---------------------------------------------------------------------------- -;; Multiple major modes -;;---------------------------------------------------------------------------- (require-package 'mmm-mode) (require 'mmm-auto) (setq mmm-global-mode 'buffers-with-submode-classes) diff --git a/lisp/init-nxml.el b/lisp/init-nxml.el index 7ebbfb5e99..78b3449eda 100644 --- a/lisp/init-nxml.el +++ b/lisp/init-nxml.el @@ -34,9 +34,8 @@ indentation rules." (nxml-mode) (indent-region beg end))) -;;---------------------------------------------------------------------------- + ;; Integration with tidy for html + xml -;;---------------------------------------------------------------------------- (defun sanityinc/tidy-buffer-xml (beg end) "Run \"tidy -xml\" on the region from BEG to END, or whole buffer." diff --git a/lisp/init-ruby.el b/lisp/init-ruby.el index 12c879eca1..d6dd10095b 100644 --- a/lisp/init-ruby.el +++ b/lisp/init-ruby.el @@ -108,9 +108,8 @@ (mmm-add-mode-ext-class mode "\\.js\\.erb\\'" 'erb)) -;;---------------------------------------------------------------------------- + ;; Ruby - my convention for heredocs containing SQL -;;---------------------------------------------------------------------------- ;; (require-package 'mmm-mode) ;; (eval-after-load 'mmm-mode diff --git a/lisp/init-sessions.el b/lisp/init-sessions.el index 7b3e3077e0..4d606d3944 100644 --- a/lisp/init-sessions.el +++ b/lisp/init-sessions.el @@ -27,9 +27,9 @@ (abbreviate-file-name filename)))))) (advice-add 'desktop-create-buffer :around 'sanityinc/desktop-time-buffer-create) -;;---------------------------------------------------------------------------- + ;; Restore histories and registers after saving -;;---------------------------------------------------------------------------- + (setq-default history-length 1000) (add-hook 'after-init-hook 'savehist-mode) diff --git a/lisp/init-themes.el b/lisp/init-themes.el index 1ea7f11be6..1ac94c5d8a 100644 --- a/lisp/init-themes.el +++ b/lisp/init-themes.el @@ -23,9 +23,9 @@ (add-hook 'after-init-hook 'reapply-themes) -;;------------------------------------------------------------------------------ + ;; Toggle between light and dark -;;------------------------------------------------------------------------------ + (defun light () "Activate a light color theme." (interactive) diff --git a/lisp/init-uniquify.el b/lisp/init-uniquify.el index 3daa06c50d..71fd2706be 100644 --- a/lisp/init-uniquify.el +++ b/lisp/init-uniquify.el @@ -2,9 +2,7 @@ ;;; Commentary: ;;; Code: -;;---------------------------------------------------------------------------- ;; Nicer naming of buffers for files with identical names -;;---------------------------------------------------------------------------- (require 'uniquify) (setq uniquify-buffer-name-style 'reverse) diff --git a/lisp/init-utils.el b/lisp/init-utils.el index 0bdd8c843f..cff9fab9c1 100644 --- a/lisp/init-utils.el +++ b/lisp/init-utils.el @@ -4,9 +4,8 @@ (define-obsolete-function-alias 'after-load 'with-eval-after-load "") -;;---------------------------------------------------------------------------- + ;; Handier way to add modes to auto-mode-alist -;;---------------------------------------------------------------------------- (defun add-auto-mode (mode &rest patterns) "Add entries to `auto-mode-alist' to use `MODE' for all given file `PATTERNS'." (dolist (pattern patterns) @@ -21,9 +20,9 @@ (add-hook (derived-mode-hook-name mode) (apply-partially 'sanityinc/set-major-mode-name name))) -;;---------------------------------------------------------------------------- + ;; String utilities missing from core emacs -;;---------------------------------------------------------------------------- + (defun sanityinc/string-all-matches (regex str &optional group) "Find all matches for `REGEX' within `STR', returning the full match string or group `GROUP'." (let ((result nil) @@ -35,9 +34,9 @@ result)) -;;---------------------------------------------------------------------------- + ;; Delete the current file -;;---------------------------------------------------------------------------- + (defun delete-this-file () "Delete the current file, and kill the buffer." (interactive) @@ -49,9 +48,9 @@ (kill-this-buffer))) -;;---------------------------------------------------------------------------- + ;; Rename the current file -;;---------------------------------------------------------------------------- + (defun rename-this-file-and-buffer (new-name) "Renames both current buffer and file it's visiting to NEW-NAME." (interactive "sNew name: ") @@ -65,9 +64,9 @@ (set-visited-file-name new-name) (rename-buffer new-name)))) -;;---------------------------------------------------------------------------- + ;; Browse current HTML file -;;---------------------------------------------------------------------------- + (defun browse-current-file () "Open the current file as a URL using `browse-url'." (interactive) diff --git a/lisp/init-windows.el b/lisp/init-windows.el index 8c1a6b4fab..1c996845f5 100644 --- a/lisp/init-windows.el +++ b/lisp/init-windows.el @@ -7,11 +7,9 @@ ;;; Code: -;;---------------------------------------------------------------------------- ;; Navigate window layouts with "C-c " and "C-c " -;;---------------------------------------------------------------------------- -(add-hook 'after-init-hook 'winner-mode) +(add-hook 'after-init-hook 'winner-mode) ;; Make "C-x o" prompt for a target window when there are more than 2 @@ -21,9 +19,9 @@ (global-set-key (kbd "C-x o") 'switch-window) -;;---------------------------------------------------------------------------- + ;; When splitting window, show (other-buffer) in the new window -;;---------------------------------------------------------------------------- + (defun split-window-func-with-other-buffer (split-function) (lambda (&optional arg) "Split this window and switch to the new window unless ARG is provided." @@ -47,9 +45,9 @@ (global-set-key (kbd "C-x 1") 'sanityinc/toggle-delete-other-windows) -;;---------------------------------------------------------------------------- + ;; Rearrange split windows -;;---------------------------------------------------------------------------- + (defun split-window-horizontally-instead () "Kill any other windows and re-split such that the current window is on the top half of the frame." (interactive) @@ -73,6 +71,7 @@ ;; Borrowed from http://postmomentum.ch/blog/201304/blog-on-emacs + (defun sanityinc/split-window() "Split the window to see the most recent buffer in the other window. Call a second time to restore the original window configuration." @@ -88,6 +87,7 @@ Call a second time to restore the original window configuration." + (defun sanityinc/toggle-current-window-dedication () "Toggle whether the current window is dedicated to its current buffer." (interactive) @@ -102,6 +102,7 @@ Call a second time to restore the original window configuration." + (unless (memq window-system '(nt w32)) (require-package 'windswap) (add-hook 'after-init-hook (apply-partially 'windmove-default-keybindings 'control)) From 090b7995d774f427b8b5f9ee3e32a27b7467527d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Apr 2021 17:06:56 +1200 Subject: [PATCH 56/95] init-ocaml: remove merlin-mode code no longer required since upstream fixes --- lisp/init-ocaml.el | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index 5bdca0bcc1..18bf63ee03 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -4,15 +4,9 @@ (when (maybe-require-package 'tuareg) (when (maybe-require-package 'merlin) - (autoload 'merlin-mode "merlin" "Merlin mode" t) (add-hook 'tuareg-mode-hook 'merlin-mode) (with-eval-after-load 'merlin - (add-hook 'merlin-mode-hook - (lambda () - (if merlin-mode - (add-hook 'xref-backend-functions 'merlin-xref-backend nil t) - (remove-hook 'xref-backend-functions 'merlin-xref-backend t)))) (with-eval-after-load 'company (push 'merlin-company-backend company-backends))) From 4b16a4cef625f29dfe92e398cbd5869337b6d047 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Apr 2021 17:08:17 +1200 Subject: [PATCH 57/95] init-ocaml: better handling of merlin-company --- lisp/init-ocaml.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index 18bf63ee03..7e1092c27d 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -6,9 +6,10 @@ (when (maybe-require-package 'merlin) (add-hook 'tuareg-mode-hook 'merlin-mode) - (with-eval-after-load 'merlin - (with-eval-after-load 'company - (push 'merlin-company-backend company-backends))) + (when (maybe-require-package 'merlin-company) + (with-eval-after-load 'merlin + (with-eval-after-load 'company + (push 'merlin-company-backend company-backends)))) (when (maybe-require-package 'merlin-eldoc) (with-eval-after-load 'merlin From 5fc677db02da96ff8a75e7cf6201276d961e400a Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 12 Apr 2021 17:09:04 +1200 Subject: [PATCH 58/95] init-ocaml: add incantations for using ocamllsp with eglot --- lisp/init-ocaml.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index 7e1092c27d..876a9e6b2a 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -2,6 +2,10 @@ ;;; Commentary: ;;; Code: +(with-eval-after-load 'eglot + (put 'tuareg-mode 'eglot-language-id "ocaml") + (add-to-list 'eglot-server-programs '((tuareg-mode) . ("ocamllsp")) t)) + (when (maybe-require-package 'tuareg) (when (maybe-require-package 'merlin) (add-hook 'tuareg-mode-hook 'merlin-mode) From 7fc76f7e39222f784c32c81a0178829e2f2184ca Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 24 Apr 2021 10:47:31 +1200 Subject: [PATCH 59/95] Don't remap yank-pop to consult-yank-replace --- lisp/init-selectrum.el | 1 - 1 file changed, 1 deletion(-) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index 058367e61c..77d936b244 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -31,7 +31,6 @@ (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) (global-set-key [remap goto-line] 'consult-goto-line) - (global-set-key [remap yank-pop] 'consult-yank-replace) (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark (require 'embark-consult) From bad8ac68dd07d841eb1f570c03a5409013f4b69a Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 24 Apr 2021 10:47:54 +1200 Subject: [PATCH 60/95] Don't automatically preview consult ripgrep commands --- lisp/init-selectrum.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp/init-selectrum.el b/lisp/init-selectrum.el index 77d936b244..ce824b27ef 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-selectrum.el @@ -31,6 +31,12 @@ (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) (global-set-key [remap goto-line] 'consult-goto-line) + + (with-eval-after-load 'consult + (dolist (cmd '(consult-ripgrep sanityinc/consult-ripgrep-at-point)) + (add-to-list 'consult-config + `(,cmd :preview-key ,(kbd "M-P"))))) + (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark (require 'embark-consult) From 27397903021f9e3f62f25ef00a68ff07d6ec229d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 24 Apr 2021 11:17:39 +1200 Subject: [PATCH 61/95] Clarify why users should update packes regularly --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a185db76b6..12d37e6d99 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,9 @@ running `M-x package-refresh-contents` before doing so. ## Updates -Update the config with `git pull`. You'll probably also want/need to update -the third-party packages regularly too: +Update the config with `git pull`. You'll probably also want/need to +update the third-party packages regularly too, because that's what I +do, and the config assumes it: M-x package-list-packages, then U followed by x. From 47b66aea700c382ecf5b2cf35a00b6e6050acd89 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 24 Apr 2021 11:18:59 +1200 Subject: [PATCH 62/95] Update copyright year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index edaae7aec4..9c161b813e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2006-2018, Steve Purcell +Copyright (c) 2006-2021, Steve Purcell All rights reserved. Redistribution and use in source and binary forms, with or without From 55c2d42708c2f5385f140bfbb227be0c6abda616 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Fri, 14 May 2021 11:54:10 +1200 Subject: [PATCH 63/95] Don't override company-format-margin-function The default is smarter now, so this is unnecessary. --- lisp/init-company.el | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lisp/init-company.el b/lisp/init-company.el index 77d4b76583..2c4037abae 100644 --- a/lisp/init-company.el +++ b/lisp/init-company.el @@ -14,12 +14,6 @@ (dolist (backend '(company-eclim company-semantic)) (delq backend company-backends)) (diminish 'company-mode) - (defun sanityinc/company-icons-margin-auto (&rest args) - (apply (if (eq 'dark (frame-parameter nil 'background-mode)) - #'company-vscode-dark-icons-margin - #'company-vscode-light-icons-margin) - args)) - (setq company-format-margin-function #'sanityinc/company-icons-margin-auto) (define-key company-mode-map (kbd "M-/") 'company-complete) (define-key company-mode-map [remap completion-at-point] 'company-complete) (define-key company-mode-map [remap indent-for-tab-command] 'company-indent-or-complete-common) From 0d980c8baa5bb4d9ec9b99398eec8977bb04709c Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 26 May 2021 10:05:43 +1200 Subject: [PATCH 64/95] Switch from selectrum to vertico for minibuffer completion --- init.el | 2 +- .../{init-selectrum.el => init-minibuffer.el} | 41 +++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) rename lisp/{init-selectrum.el => init-minibuffer.el} (51%) diff --git a/init.el b/init.el index fc2150b500..7ee135e846 100644 --- a/init.el +++ b/init.el @@ -63,7 +63,7 @@ (require 'init-flycheck) (require 'init-recentf) -(require 'init-selectrum) +(require 'init-minibuffer) (require 'init-hippie-expand) (require 'init-company) (require 'init-windows) diff --git a/lisp/init-selectrum.el b/lisp/init-minibuffer.el similarity index 51% rename from lisp/init-selectrum.el rename to lisp/init-minibuffer.el index ce824b27ef..88522880e3 100644 --- a/lisp/init-selectrum.el +++ b/lisp/init-minibuffer.el @@ -1,39 +1,41 @@ -;;; init-selectrum.el --- Config for selectrum -*- lexical-binding: t; -*- +;;; init-minibuffer.el --- Config for minibuffer completion -*- lexical-binding: t; -*- ;;; Commentary: ;;; Code: -(when (maybe-require-package 'selectrum) - (add-hook 'after-init-hook 'selectrum-mode) - (setq-default selectrum-fix-vertical-window-height t) +(when (maybe-require-package 'vertico) + (add-hook 'after-init-hook 'vertico-mode) - (when (maybe-require-package 'selectrum-prescient) - (require 'prescient) - (prescient-persist-mode 1) - (selectrum-prescient-mode 1) - (global-set-key [remap execute-extended-command] 'execute-extended-command)) + (require-package 'orderless) + (with-eval-after-load 'vertico + (require 'orderless)) + + (setq completion-styles '(substring orderless)) (when (maybe-require-package 'embark) - (define-key selectrum-minibuffer-map (kbd "C-c C-o") 'embark-export) - (define-key selectrum-minibuffer-map (kbd "C-c C-c") 'embark-act)) + (with-eval-after-load 'vertico + (define-key vertico-map (kbd "C-c C-o") 'embark-export) + (define-key vertico-map (kbd "C-c C-c") 'embark-act))) (when (maybe-require-package 'consult) (when (maybe-require-package 'projectile) (setq-default consult-project-root-function 'projectile-project-root)) (when (executable-find "rg") - (defun sanityinc/consult-ripgrep-at-point (&optional dir initial) + (maybe-require-package 'affe) + (defun sanityinc/affe-grep-at-point (&optional dir initial) (interactive (list prefix-arg (when-let ((s (symbol-at-point))) (symbol-name s)))) - (consult-ripgrep dir initial))) - (global-set-key (kbd "M-?") 'sanityinc/consult-ripgrep-at-point) + (affe-grep dir initial)) + (global-set-key (kbd "M-?") 'sanityinc/affe-grep-at-point)) + (global-set-key [remap switch-to-buffer] 'consult-buffer) (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) (global-set-key [remap goto-line] 'consult-goto-line) (with-eval-after-load 'consult - (dolist (cmd '(consult-ripgrep sanityinc/consult-ripgrep-at-point)) + (dolist (cmd '(consult-ripgrep sanityinc/affe-grep-at-point)) (add-to-list 'consult-config `(,cmd :preview-key ,(kbd "M-P"))))) @@ -48,11 +50,6 @@ (add-hook 'after-init-hook 'marginalia-mode) (setq-default marginalia-annotators '(marginalia-annotators-heavy))) -(with-eval-after-load 'desktop - ;; Try to prevent old minibuffer completion system being reactivated in - ;; buffers restored via desktop.el - (push (cons 'counsel-mode nil) desktop-minor-mode-table) - (push (cons 'ivy-mode nil) desktop-minor-mode-table)) -(provide 'init-selectrum) -;;; init-selectrum.el ends here +(provide 'init-minibuffer) +;;; init-minibuffer.el ends here From fce80299d9b37f577423299c7aafe0f4f314be85 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 26 May 2021 11:48:31 +1200 Subject: [PATCH 65/95] Drop daemons package, which I don't use --- init.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/init.el b/init.el index 7ee135e846..2f83508070 100644 --- a/init.el +++ b/init.el @@ -138,8 +138,6 @@ (require-package 'htmlize) (when *is-a-mac* (require-package 'osx-location)) -(unless (eq system-type 'windows-nt) - (maybe-require-package 'daemons)) (maybe-require-package 'dotenv-mode) (maybe-require-package 'shfmt) From 962b988740f2258c88a32fe5971a7d67a3b9aac4 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 26 May 2021 11:48:54 +1200 Subject: [PATCH 66/95] Don't override default company backends --- lisp/init-company.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/lisp/init-company.el b/lisp/init-company.el index 2c4037abae..9d0de03d47 100644 --- a/lisp/init-company.el +++ b/lisp/init-company.el @@ -11,8 +11,6 @@ (when (maybe-require-package 'company) (add-hook 'after-init-hook 'global-company-mode) (with-eval-after-load 'company - (dolist (backend '(company-eclim company-semantic)) - (delq backend company-backends)) (diminish 'company-mode) (define-key company-mode-map (kbd "M-/") 'company-complete) (define-key company-mode-map [remap completion-at-point] 'company-complete) From 2e24253e8144cf40970373d6f6c37cc75539b4bb Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 26 May 2021 11:49:59 +1200 Subject: [PATCH 67/95] Define function inside conditional block which uses it --- lisp/init-direnv.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/init-direnv.el b/lisp/init-direnv.el index 7d81dfb748..d35e646cf9 100644 --- a/lisp/init-direnv.el +++ b/lisp/init-direnv.el @@ -2,12 +2,12 @@ ;;; Commentary: ;;; Code: -(defun sanityinc/maybe-enable-envrc-global-mode () - "Enable `envrc-global-mode' if `direnv' is installed." - (when (executable-find "direnv") - (envrc-global-mode))) - (when (maybe-require-package 'envrc) + (defun sanityinc/maybe-enable-envrc-global-mode () + "Enable `envrc-global-mode' if `direnv' is installed." + (when (executable-find "direnv") + (envrc-global-mode))) + (with-eval-after-load 'envrc (define-key envrc-mode-map (kbd "C-c e") 'envrc-command-map)) (add-hook 'after-init-hook 'sanityinc/maybe-enable-envrc-global-mode)) From fae993861b498343453153af11923b9ab60d48b8 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Thu, 27 May 2021 12:34:28 +1200 Subject: [PATCH 68/95] Use manual rather than automatic previews with affe-grep --- lisp/init-minibuffer.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-minibuffer.el b/lisp/init-minibuffer.el index 88522880e3..bd68d7602a 100644 --- a/lisp/init-minibuffer.el +++ b/lisp/init-minibuffer.el @@ -35,7 +35,7 @@ (global-set-key [remap goto-line] 'consult-goto-line) (with-eval-after-load 'consult - (dolist (cmd '(consult-ripgrep sanityinc/affe-grep-at-point)) + (dolist (cmd '(consult-ripgrep affe-grep sanityinc/affe-grep-at-point)) (add-to-list 'consult-config `(,cmd :preview-key ,(kbd "M-P"))))) From c23b081db0e50a5f0f777cf0d45b41fb81bec49c Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 29 May 2021 10:34:38 +1200 Subject: [PATCH 69/95] Drop redundant setting of obsolete marginalia-annotators var Fixes #777 --- lisp/init-minibuffer.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/init-minibuffer.el b/lisp/init-minibuffer.el index bd68d7602a..e7b7308a0e 100644 --- a/lisp/init-minibuffer.el +++ b/lisp/init-minibuffer.el @@ -47,8 +47,7 @@ (maybe-require-package 'consult-flycheck))) (when (maybe-require-package 'marginalia) - (add-hook 'after-init-hook 'marginalia-mode) - (setq-default marginalia-annotators '(marginalia-annotators-heavy))) + (add-hook 'after-init-hook 'marginalia-mode)) (provide 'init-minibuffer) From cfa5feb61aca319e8013c5ef64e11eb867dd4ef3 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 29 May 2021 18:04:09 +1200 Subject: [PATCH 70/95] Better defaults for completion-styles, for more natural ordering These styles affect completion-at-point functions, and therefore company-capf, leading to unnatural matching when that company backend is active. Fixes #778 --- lisp/init-minibuffer.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-minibuffer.el b/lisp/init-minibuffer.el index e7b7308a0e..0dedd87419 100644 --- a/lisp/init-minibuffer.el +++ b/lisp/init-minibuffer.el @@ -10,7 +10,7 @@ (with-eval-after-load 'vertico (require 'orderless)) - (setq completion-styles '(substring orderless)) + (setq completion-styles '(basic partial-completion orderless)) (when (maybe-require-package 'embark) (with-eval-after-load 'vertico From 5e2cda9a544aaecbc318f38b30c933a9e25162a9 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 21 Jun 2021 11:45:44 +1200 Subject: [PATCH 71/95] Only override completion-styles in minibuffer Thanks @Eason0210, see #778 --- lisp/init-minibuffer.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/init-minibuffer.el b/lisp/init-minibuffer.el index 0dedd87419..6915560bbc 100644 --- a/lisp/init-minibuffer.el +++ b/lisp/init-minibuffer.el @@ -10,7 +10,9 @@ (with-eval-after-load 'vertico (require 'orderless)) - (setq completion-styles '(basic partial-completion orderless)) + (defun sanityinc/use-orderless-in-minibuffer () + (setq-local completion-styles '(substring orderless))) + (add-hook 'minibuffer-setup-hook 'sanityinc/use-orderless-in-minibuffer) (when (maybe-require-package 'embark) (with-eval-after-load 'vertico From 7b55c418e8cbfc20b22ceb5ab4de2320ba8a9e46 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 27 Jun 2021 16:34:46 +1200 Subject: [PATCH 72/95] More neatly and completely disable file-jumping consult previews Fixes #779 --- lisp/init-minibuffer.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/init-minibuffer.el b/lisp/init-minibuffer.el index 6915560bbc..bf808677f2 100644 --- a/lisp/init-minibuffer.el +++ b/lisp/init-minibuffer.el @@ -37,9 +37,13 @@ (global-set-key [remap goto-line] 'consult-goto-line) (with-eval-after-load 'consult - (dolist (cmd '(consult-ripgrep affe-grep sanityinc/affe-grep-at-point)) - (add-to-list 'consult-config - `(,cmd :preview-key ,(kbd "M-P"))))) + (consult-customize + consult-ripgrep + affe-grep sanityinc/affe-grep-at-point + consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-file consult--source-project-file consult--source-bookmark + :preview-key (kbd "M-P"))) (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark From 72715575f08cbee7651b4e318321854a4385f7e9 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 27 Jun 2021 21:37:25 +1200 Subject: [PATCH 73/95] Work around consult-customize insisting customized commands are loaded See https://github.com/minad/consult/issues/345 --- lisp/init-minibuffer.el | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lisp/init-minibuffer.el b/lisp/init-minibuffer.el index bf808677f2..e5453ebba3 100644 --- a/lisp/init-minibuffer.el +++ b/lisp/init-minibuffer.el @@ -20,30 +20,34 @@ (define-key vertico-map (kbd "C-c C-c") 'embark-act))) (when (maybe-require-package 'consult) + (defmacro sanityinc/no-consult-preview (&rest cmds) + `(with-eval-after-load 'consult + (consult-customize ,@cmds :preview-key (kbd "M-P")))) + + (sanityinc/no-consult-preview + consult-ripgrep + consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-file consult--source-project-file consult--source-bookmark) + (when (maybe-require-package 'projectile) (setq-default consult-project-root-function 'projectile-project-root)) - (when (executable-find "rg") - (maybe-require-package 'affe) + (when (and (executable-find "rg") (maybe-require-package 'affe)) (defun sanityinc/affe-grep-at-point (&optional dir initial) (interactive (list prefix-arg (when-let ((s (symbol-at-point))) (symbol-name s)))) (affe-grep dir initial)) - (global-set-key (kbd "M-?") 'sanityinc/affe-grep-at-point)) + (global-set-key (kbd "M-?") 'sanityinc/affe-grep-at-point) + (sanityinc/no-consult-preview sanityinc/affe-grep-at-point) + (with-eval-after-load 'affe (sanityinc/no-consult-preview affe-grep))) (global-set-key [remap switch-to-buffer] 'consult-buffer) (global-set-key [remap switch-to-buffer-other-window] 'consult-buffer-other-window) (global-set-key [remap switch-to-buffer-other-frame] 'consult-buffer-other-frame) (global-set-key [remap goto-line] 'consult-goto-line) - (with-eval-after-load 'consult - (consult-customize - consult-ripgrep - affe-grep sanityinc/affe-grep-at-point - consult-git-grep consult-grep - consult-bookmark consult-recent-file consult-xref - consult--source-file consult--source-project-file consult--source-bookmark - :preview-key (kbd "M-P"))) + (when (maybe-require-package 'embark-consult) (with-eval-after-load 'embark From 8583325874875152c35c7a78ad46091248d3461d Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 5 Jul 2021 14:34:56 +1200 Subject: [PATCH 74/95] Remove stack-exec-path-mode, which I no longer use --- lisp/init-haskell.el | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lisp/init-haskell.el b/lisp/init-haskell.el index a128b46da5..f32f19b22a 100644 --- a/lisp/init-haskell.el +++ b/lisp/init-haskell.el @@ -44,28 +44,6 @@ (add-to-list 'page-break-lines-modes 'haskell-mode))) - -(define-minor-mode stack-exec-path-mode - "If this is a stack project, set `exec-path' to the path \"stack exec\" would use." - nil - :lighter "" - :global nil - (if stack-exec-path-mode - (when (and (executable-find "stack") - (locate-dominating-file default-directory "stack.yaml")) - (let ((stack-path (replace-regexp-in-string - "[\r\n]+\\'" "" - (shell-command-to-string (concat "stack exec -- sh -c " - (shell-quote-argument "echo $PATH")))))) - (setq-local exec-path (seq-uniq (parse-colon-path stack-path) 'string-equal)) - (make-local-variable 'process-environment) - (setenv "PATH" (string-join exec-path path-separator)))) - (kill-local-variable 'exec-path) - (kill-local-variable 'process-environment))) - -(add-hook 'haskell-mode-hook 'stack-exec-path-mode) - - (when (maybe-require-package 'dhall-mode) (add-hook 'dhall-mode-hook 'stack-exec-path-mode)) From adf337dfa8c324983e5dc01ed055a34c3cc4a964 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 5 Jul 2021 14:35:37 +1200 Subject: [PATCH 75/95] Fix deprecated params passed to define-minor mode (fixes #780) --- lisp/init-javascript.el | 2 +- lisp/init-org.el | 2 +- lisp/init-purescript.el | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/init-javascript.el b/lisp/init-javascript.el index 68fa5f0678..70f9aa6b9a 100644 --- a/lisp/init-javascript.el +++ b/lisp/init-javascript.el @@ -88,7 +88,7 @@ (define-minor-mode inferior-js-keys-mode "Bindings for communicating with an inferior js interpreter." - nil " InfJS" inferior-js-minor-mode-map) + :init-value nil :lighter " InfJS" :keymap inferior-js-minor-mode-map) (dolist (hook '(js2-mode-hook js-mode-hook)) (add-hook hook 'inferior-js-keys-mode))) diff --git a/lisp/init-org.el b/lisp/init-org.el index a90b89d96a..b1b946b1b5 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -69,7 +69,7 @@ This enables or modifies a number of settings so that the experience of editing prose is a little more like that of a typical word processor." - nil " Prose" nil + :init-value nil :lighter " Prose" :keymap nil (if prose-mode (progn (when (fboundp 'writeroom-mode) diff --git a/lisp/init-purescript.el b/lisp/init-purescript.el index f69c57b82b..794ecb0ff8 100644 --- a/lisp/init-purescript.el +++ b/lisp/init-purescript.el @@ -45,7 +45,7 @@ corresponding .purs file is open." (define-minor-mode psc-ide-foreign-js-mode "Rebuild corresponding purescript file." - nil + :init-value nil :lighter " PursJS" :global nil (if psc-ide-foreign-js-mode From 03bcd2789976a3ea021653cdc9f58583de02b71f Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 19 Jul 2021 15:38:29 +1200 Subject: [PATCH 76/95] Drop obsolete cl-lib-highlight package Fixes #784 --- lisp/init-lisp.el | 3 --- 1 file changed, 3 deletions(-) diff --git a/lisp/init-lisp.el b/lisp/init-lisp.el index 9a4f22436e..f8c64477c0 100644 --- a/lisp/init-lisp.el +++ b/lisp/init-lisp.el @@ -206,9 +206,6 @@ there is no current file, eval the current buffer." (add-to-list 'auto-mode-alist '("\\.emacs-project\\'" . emacs-lisp-mode)) (add-to-list 'auto-mode-alist '("archive-contents\\'" . emacs-lisp-mode)) -(require-package 'cl-lib-highlight) -(with-eval-after-load 'lisp-mode - (cl-lib-highlight-initialize)) ;; Delete .elc files when reverting the .el from VC or magit From 58ba9e023b85954ad694ff9133742160076706b2 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 10 Aug 2021 10:29:15 +0200 Subject: [PATCH 77/95] Fix dangling reference to removed stack-exec-path-mode Fixes #786 --- lisp/init-haskell.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/init-haskell.el b/lisp/init-haskell.el index f32f19b22a..18afe058f9 100644 --- a/lisp/init-haskell.el +++ b/lisp/init-haskell.el @@ -45,8 +45,7 @@ -(when (maybe-require-package 'dhall-mode) - (add-hook 'dhall-mode-hook 'stack-exec-path-mode)) +(maybe-require-package 'dhall-mode) From 85ce2603e1b891bfa98f40ed3b9018024c62dc14 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 22 Aug 2021 10:28:56 +0200 Subject: [PATCH 78/95] Use locate-user-emacs-file where applicable --- init.el | 2 +- lisp/init-editing-utils.el | 2 +- lisp/init-sessions.el | 2 +- lisp/init-sql.el | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/init.el b/init.el index 2f83508070..6ce48c92c7 100644 --- a/init.el +++ b/init.el @@ -34,7 +34,7 @@ ;; Bootstrap config -(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) +(setq custom-file (locate-user-emacs-file "custom.el")) (require 'init-utils) (require 'init-site-lisp) ;; Must come before elpa, as it may provide package.el ;; Calls (package-initialize) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index 3128243d75..87069bd249 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -15,7 +15,7 @@ (setq-default blink-cursor-interval 0.4 - bookmark-default-file (expand-file-name ".bookmarks.el" user-emacs-directory) + bookmark-default-file (locate-user-emacs-file ".bookmarks.el") buffers-menu-max-size 30 case-fold-search t column-number-mode t diff --git a/lisp/init-sessions.el b/lisp/init-sessions.el index 4d606d3944..1ae7fd59ff 100644 --- a/lisp/init-sessions.el +++ b/lisp/init-sessions.el @@ -35,7 +35,7 @@ (require-package 'session) -(setq session-save-file (expand-file-name ".session" user-emacs-directory)) +(setq session-save-file (locate-user-emacs-file ".session")) (setq session-name-disable-regexp "\\(?:\\`'/tmp\\|\\.git/[A-Z_]+\\'\\)") (setq session-save-file-coding-system 'utf-8) diff --git a/lisp/init-sql.el b/lisp/init-sql.el index 3844c8b42f..891ee4534d 100644 --- a/lisp/init-sql.el +++ b/lisp/init-sql.el @@ -38,7 +38,7 @@ Fix for the above hasn't been released as of Emacs 25.2." (advice-add 'sql-set-product :after 'sanityinc/maybe-set-dash-db-docset))) (setq-default sql-input-ring-file-name - (expand-file-name ".sqli_history" user-emacs-directory)) + (locate-user-emacs-file ".sqli_history")) ;; See my answer to https://emacs.stackexchange.com/questions/657/why-do-sql-mode-and-sql-interactive-mode-not-highlight-strings-the-same-way/673 (defun sanityinc/font-lock-everything-in-sql-interactive-mode () From ee74d758ba5fce41722ee500cb861816687ccc35 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sat, 9 Oct 2021 16:58:02 +0200 Subject: [PATCH 79/95] Don't load ob-* modules that can't be located Fixes #791 --- lisp/init-org.el | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lisp/init-org.el b/lisp/init-org.el index b1b946b1b5..199ad6c180 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -362,23 +362,27 @@ typical word processor." (with-eval-after-load 'org (org-babel-do-load-languages 'org-babel-load-languages - `((R . t) - (ditaa . t) - (dot . t) - (emacs-lisp . t) - (gnuplot . t) - (haskell . nil) - (latex . t) - (ledger . t) - (ocaml . nil) - (octave . t) - (plantuml . t) - (python . t) - (ruby . t) - (screen . nil) - (,(if (locate-library "ob-sh") 'sh 'shell) . t) - (sql . t) - (sqlite . t)))) + (seq-filter + (lambda (pair) + (featurep (intern (concat "ob-" (symbol-name (car pair)))))) + '((R . t) + (ditaa . t) + (dot . t) + (emacs-lisp . t) + (gnuplot . t) + (haskell . nil) + (latex . t) + (ledger . t) + (ocaml . nil) + (octave . t) + (plantuml . t) + (python . t) + (ruby . t) + (screen . nil) + (sh . t) ;; obsolete + (shell . t) + (sql . t) + (sqlite . t))))) (provide 'init-org) From 64695dd330650391e7c2b03c0b70e1d414333ec7 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Thu, 21 Oct 2021 14:10:05 +0200 Subject: [PATCH 80/95] Prefer cl-incf to incf --- lisp/init-benchmarking.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-benchmarking.el b/lisp/init-benchmarking.el index eb7c1cf99b..cfae65673e 100644 --- a/lisp/init-benchmarking.el +++ b/lisp/init-benchmarking.el @@ -49,7 +49,7 @@ LOAD-DURATION is the time taken in milliseconds to load FEATURE.") (defun sanityinc/require-times-tabulated-list-entries () (cl-loop for (feature start-time millis) in sanityinc/require-times with order = 0 - do (incf order) + do (cl-incf order) collect (list order (vector (format "%.3f" (sanityinc/time-subtract-millis start-time before-init-time)) From 4699f24b46d4c3f203e94fd22d7910d1a122c2c9 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Thu, 21 Oct 2021 14:18:03 +0200 Subject: [PATCH 81/95] Use new bundled git-modes package --- lisp/init-git.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/init-git.el b/lisp/init-git.el index 9320a0cb9a..e1ae32f555 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -8,8 +8,7 @@ ;; TODO: link commits from vc-log to magit-show-commit ;; TODO: smerge-mode (require-package 'git-blamed) -(require-package 'gitignore-mode) -(require-package 'gitconfig-mode) +(require-package 'git-modes) (when (maybe-require-package 'git-timemachine) (global-set-key (kbd "C-x v t") 'git-timemachine-toggle)) From 195386b93503b4c931fb058a4d9dfa918264a226 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Thu, 21 Oct 2021 14:22:37 +0200 Subject: [PATCH 82/95] Don't load company backend for nixos-options until nix-mode is needed See #793 --- lisp/init-nix.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/init-nix.el b/lisp/init-nix.el index 652f57506f..47d886b9ee 100644 --- a/lisp/init-nix.el +++ b/lisp/init-nix.el @@ -10,16 +10,16 @@ (when (maybe-require-package 'nixos-options) (when (maybe-require-package 'company-nixos-options) (with-eval-after-load 'company + (with-eval-after-load 'nix-mode + ;; Patch pending https://github.com/travisbhartwell/nix-emacs/pull/46 + (with-eval-after-load 'company-nixos-options + (defun company-nixos--in-nix-context-p () + (unless (executable-find "nix-build") + (or (derived-mode-p 'nix-mode 'nix-repl-mode) + (let ((file-name (buffer-file-name (current-buffer)))) + (and file-name (equal "nix" (file-name-extension file-name)))))))) - ;; Patch pending https://github.com/travisbhartwell/nix-emacs/pull/46 - (with-eval-after-load 'company-nixos-options - (defun company-nixos--in-nix-context-p () - (unless (executable-find "nix-build") - (or (derived-mode-p 'nix-mode 'nix-repl-mode) - (let ((file-name (buffer-file-name (current-buffer)))) - (and file-name (equal "nix" (file-name-extension file-name)))))))) - - (add-to-list 'company-backends 'company-nixos-options))))) + (add-to-list 'company-backends 'company-nixos-options)))))) (provide 'init-nix) From b3ac7029eada16ac82324515b0eed203d32d6042 Mon Sep 17 00:00:00 2001 From: Arthur Lee Date: Sat, 6 Nov 2021 12:51:18 +0000 Subject: [PATCH 83/95] Add "-" arg to make black reformatter read from stdin --- lisp/init-python.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-python.el b/lisp/init-python.el index 7ad5f81dac..99719bbbb0 100644 --- a/lisp/init-python.el +++ b/lisp/init-python.el @@ -37,7 +37,7 @@ (add-to-list 'auto-mode-alist '("poetry\\.lock\\'" . toml-mode))) (when (maybe-require-package 'reformatter) - (reformatter-define black :program "black")) + (reformatter-define black :program "black" :args '("-"))) (provide 'init-python) ;;; init-python.el ends here From e81e69a2aba8793b3c4a36ccb49daf9d8168e932 Mon Sep 17 00:00:00 2001 From: moonpole <92289673+moonpole@users.noreply.github.com> Date: Wed, 9 Feb 2022 01:22:21 +0000 Subject: [PATCH 84/95] Fix consult-buffer error please refer to https://github.com/minad/consult/issues/508 --- lisp/init-minibuffer.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-minibuffer.el b/lisp/init-minibuffer.el index e5453ebba3..a6f0cf3201 100644 --- a/lisp/init-minibuffer.el +++ b/lisp/init-minibuffer.el @@ -28,7 +28,7 @@ consult-ripgrep consult-git-grep consult-grep consult-bookmark consult-recent-file consult-xref - consult--source-file consult--source-project-file consult--source-bookmark) + consult--source-recent-file consult--source-project-recent-file consult--source-bookmark) (when (maybe-require-package 'projectile) (setq-default consult-project-root-function 'projectile-project-root)) From adc5d50f5845a32a2340f1ad0bdcd1866c685f76 Mon Sep 17 00:00:00 2001 From: archer Date: Thu, 3 Mar 2022 09:55:58 +0800 Subject: [PATCH 85/95] $PATH for PGTK window --- lisp/init-exec-path.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/init-exec-path.el b/lisp/init-exec-path.el index 557bfa9d34..494b4c486a 100644 --- a/lisp/init-exec-path.el +++ b/lisp/init-exec-path.el @@ -9,7 +9,7 @@ (add-to-list 'exec-path-from-shell-variables var))) -(when (or (memq window-system '(mac ns x)) +(when (or (memq window-system '(mac ns x pgtk)) (unless (memq system-type '(ms-dos windows-nt)) (daemonp))) (exec-path-from-shell-initialize)) From 7c5861664f7912ddd4014798a9b2dec4681cb767 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Mar 2022 10:16:45 +0100 Subject: [PATCH 86/95] Switch from flycheck to flymake (but with flymake-flycheck) --- README.md | 6 +++--- init.el | 2 +- lisp/init-flycheck.el | 14 -------------- lisp/init-flymake.el | 41 +++++++++++++++++++++++++++++++++++++++++ lisp/init-lisp.el | 7 ++----- 5 files changed, 47 insertions(+), 23 deletions(-) delete mode 100644 lisp/init-flycheck.el create mode 100644 lisp/init-flymake.el diff --git a/README.md b/README.md index 12d37e6d99..3575caba24 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ in the approximate order of how much I use them, from most to least: In particular, there's a nice config for *autocompletion* with [company](https://company-mode.github.io/), and -[flycheck](http://www.flycheck.org) is used to immediately highlight -syntax errors in Ruby, Python, Javascript, Haskell and a number of -other languages. +`flymake` (re-using backends from [flycheck](http://www.flycheck.org)) +is used to immediately highlight syntax errors in Ruby, Python, +Javascript, Haskell and a number of other languages. ## Supported Emacs versions diff --git a/init.el b/init.el index 6ce48c92c7..bfce66d756 100644 --- a/init.el +++ b/init.el @@ -60,7 +60,7 @@ (require 'init-grep) (require 'init-uniquify) (require 'init-ibuffer) -(require 'init-flycheck) +(require 'init-flymake) (require 'init-recentf) (require 'init-minibuffer) diff --git a/lisp/init-flycheck.el b/lisp/init-flycheck.el deleted file mode 100644 index fe4190952d..0000000000 --- a/lisp/init-flycheck.el +++ /dev/null @@ -1,14 +0,0 @@ -;;; init-flycheck.el --- Configure Flycheck global behaviour -*- lexical-binding: t -*- -;;; Commentary: -;;; Code: - -(when (maybe-require-package 'flycheck) - (add-hook 'after-init-hook 'global-flycheck-mode) - (setq flycheck-display-errors-function #'flycheck-display-error-messages-unless-error-list) - - (when (maybe-require-package 'flycheck-color-mode-line) - (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))) - - -(provide 'init-flycheck) -;;; init-flycheck.el ends here diff --git a/lisp/init-flymake.el b/lisp/init-flymake.el new file mode 100644 index 0000000000..fa7f7c1fa0 --- /dev/null +++ b/lisp/init-flymake.el @@ -0,0 +1,41 @@ +;;; init-flymake.el --- Configure Flymake global behaviour -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(with-eval-after-load 'flymake + (defun sanityinc/eldoc-flymake-first () + "Gives flymake's eldoc function priority in the minibuffer." + (when flymake-mode + (setq-local eldoc-documentation-functions + (cons 'flymake-eldoc-function + (delq 'flymake-eldoc-function eldoc-documentation-functions))))) + + (add-hook 'flymake-mode-hook 'sanityinc/eldoc-flymake-first)) + + +;; Use flycheck checkers with flymake, to extend its coverage +(when (maybe-require-package 'flymake-flycheck) + ;; Disable flycheck checkers for which we have flymake equivalents + (with-eval-after-load 'flycheck + (setq-default flycheck-disabled-checkers + (append (default-value 'flycheck-disabled-checkers) + '(emacs-lisp emacs-lisp-checkdoc emacs-lisp-package)))) + + (defun sanityinc/enable-flymake-flycheck () + (setq-local flymake-diagnostic-functions + (append flymake-diagnostic-functions + (flymake-flycheck-all-chained-diagnostic-functions)))) + + (add-hook 'flymake-mode-hook 'sanityinc/enable-flymake-flycheck) + (add-hook 'prog-mode-hook 'flymake-mode) + (add-hook 'text-mode-hook 'flymake-mode)) + +(with-eval-after-load 'flymake + ;; Provide some flycheck-like bindings in flymake mode to ease transition + (define-key flymake-mode-map (kbd "C-c ! n") 'flymake-goto-next-error) + (define-key flymake-mode-map (kbd "C-c ! p") 'flymake-goto-prev-error) + (define-key flymake-mode-map (kbd "C-c ! c") 'flymake-start)) + + +(provide 'init-flymake) +;;; init-flymake.el ends here diff --git a/lisp/init-lisp.el b/lisp/init-lisp.el index f8c64477c0..6d2594b57b 100644 --- a/lisp/init-lisp.el +++ b/lisp/init-lisp.el @@ -270,11 +270,8 @@ there is no current file, eval the current buffer." (add-hook 'emacs-lisp-mode-hook 'highlight-quoted-mode)) -(when (maybe-require-package 'flycheck) - (require-package 'flycheck-package) - (with-eval-after-load 'flycheck - (with-eval-after-load 'elisp-mode - (flycheck-package-setup)))) +(when (maybe-require-package 'package-lint-flymake) + (add-hook 'emacs-lisp-mode-hook #'package-lint-flymake-setup)) From 5ebfbeb1bdb7c2b35e126ca0fadbe161bd33066b Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Mar 2022 10:18:18 +0100 Subject: [PATCH 87/95] Add eglot config for LSP, and remove some pre-LSP tool support --- init.el | 1 + lisp/init-eglot.el | 18 ++++++++++++++++++ lisp/init-elm.el | 7 +------ lisp/init-haskell.el | 6 ------ lisp/init-ocaml.el | 16 ---------------- lisp/init-python.el | 17 ----------------- 6 files changed, 20 insertions(+), 45 deletions(-) create mode 100644 lisp/init-eglot.el diff --git a/init.el b/init.el index bfce66d756..003e1a1e11 100644 --- a/init.el +++ b/init.el @@ -61,6 +61,7 @@ (require 'init-uniquify) (require 'init-ibuffer) (require 'init-flymake) +(require 'init-eglot) (require 'init-recentf) (require 'init-minibuffer) diff --git a/lisp/init-eglot.el b/lisp/init-eglot.el new file mode 100644 index 0000000000..9cf28b84f0 --- /dev/null +++ b/lisp/init-eglot.el @@ -0,0 +1,18 @@ +;;; init-eglot.el --- LSP support via eglot -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +;; For Emacs >= 27 +(setq read-process-output-max (* 1024 1024)) + + +(when (maybe-require-package 'eglot) + (maybe-require-package 'consult-eglot)) + + + + +(provide 'init-eglot) +;;; init-eglot.el ends here diff --git a/lisp/init-elm.el b/lisp/init-elm.el index 1548210a03..aa1c8a5c61 100644 --- a/lisp/init-elm.el +++ b/lisp/init-elm.el @@ -7,12 +7,7 @@ (diminish 'elm-indent-mode) (when (executable-find "elm-format") (setq-default elm-format-on-save t))) - (maybe-require-package 'elm-test-runner) - (when (maybe-require-package 'flycheck-elm) - (with-eval-after-load 'elm-mode - (flycheck-elm-setup))) - (when (maybe-require-package 'add-node-modules-path) - (add-hook 'elm-mode-hook 'add-node-modules-path))) + (maybe-require-package 'elm-test-runner)) (provide 'init-elm) ;;; init-elm.el ends here diff --git a/lisp/init-haskell.el b/lisp/init-haskell.el index 18afe058f9..1a061bb8b9 100644 --- a/lisp/init-haskell.el +++ b/lisp/init-haskell.el @@ -6,12 +6,6 @@ (add-hook 'haskell-mode-hook 'subword-mode) (add-hook 'haskell-cabal-mode 'subword-mode) - (when (maybe-require-package 'dante) - (add-hook 'haskell-mode-hook 'dante-mode) - (with-eval-after-load 'dante - (flycheck-add-next-checker 'haskell-dante - '(warning . haskell-hlint)))) - (add-hook 'haskell-mode-hook 'interactive-haskell-mode) (add-auto-mode 'haskell-mode "\\.ghci\\'") diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index 876a9e6b2a..209b180075 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -7,22 +7,6 @@ (add-to-list 'eglot-server-programs '((tuareg-mode) . ("ocamllsp")) t)) (when (maybe-require-package 'tuareg) - (when (maybe-require-package 'merlin) - (add-hook 'tuareg-mode-hook 'merlin-mode) - - (when (maybe-require-package 'merlin-company) - (with-eval-after-load 'merlin - (with-eval-after-load 'company - (push 'merlin-company-backend company-backends)))) - - (when (maybe-require-package 'merlin-eldoc) - (with-eval-after-load 'merlin - (autoload 'merlin-eldoc--gather-info "merlin-eldoc") - (add-hook 'merlin-mode-hook - (lambda () - (setq-local eldoc-documentation-function - #'merlin-eldoc--gather-info)))))) - (with-eval-after-load 'tuareg (defvar-local tuareg-previous-tuareg-buffer nil "Buffer from which we jumped to the REPL.") diff --git a/lisp/init-python.el b/lisp/init-python.el index 99719bbbb0..1c20728ce7 100644 --- a/lisp/init-python.el +++ b/lisp/init-python.el @@ -16,23 +16,6 @@ (require-package 'pip-requirements) -(when (maybe-require-package 'anaconda-mode) - (with-eval-after-load 'python - ;; Anaconda doesn't work on remote servers without some work, so - ;; by default we enable it only when working locally. - (add-hook 'python-mode-hook - (lambda () (unless (file-remote-p default-directory) - (anaconda-mode 1)))) - (add-hook 'anaconda-mode-hook - (lambda () - (anaconda-eldoc-mode (if anaconda-mode 1 0))))) - (with-eval-after-load 'anaconda-mode - (define-key anaconda-mode-map (kbd "M-?") nil)) - (when (maybe-require-package 'company-anaconda) - (with-eval-after-load 'company - (with-eval-after-load 'python - (add-to-list 'company-backends 'company-anaconda))))) - (when (maybe-require-package 'toml-mode) (add-to-list 'auto-mode-alist '("poetry\\.lock\\'" . toml-mode))) From e3ea4fa189142fcd14ebe24b917b7c6528955db6 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Mar 2022 10:19:56 +0100 Subject: [PATCH 88/95] Note provision of LSP support with eglot --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3575caba24..44ee9ce443 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ In particular, there's a nice config for *autocompletion* with is used to immediately highlight syntax errors in Ruby, Python, Javascript, Haskell and a number of other languages. +LSP support is provided using `eglot`. + ## Supported Emacs versions The config should run on Emacs 25.1 or greater and is designed to From 23eb550a87ee7392e78b0d91e8038fe4ea3e9255 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Mar 2022 10:33:03 +0100 Subject: [PATCH 89/95] Avoid problematic wrangling of flymake-eldoc-function --- lisp/init-flymake.el | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lisp/init-flymake.el b/lisp/init-flymake.el index fa7f7c1fa0..19681cb5a0 100644 --- a/lisp/init-flymake.el +++ b/lisp/init-flymake.el @@ -2,16 +2,6 @@ ;;; Commentary: ;;; Code: -(with-eval-after-load 'flymake - (defun sanityinc/eldoc-flymake-first () - "Gives flymake's eldoc function priority in the minibuffer." - (when flymake-mode - (setq-local eldoc-documentation-functions - (cons 'flymake-eldoc-function - (delq 'flymake-eldoc-function eldoc-documentation-functions))))) - - (add-hook 'flymake-mode-hook 'sanityinc/eldoc-flymake-first)) - ;; Use flycheck checkers with flymake, to extend its coverage (when (maybe-require-package 'flymake-flycheck) From a3689baaec293f38a9545855ef8f61859bedcd14 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Mar 2022 10:36:42 +0100 Subject: [PATCH 90/95] Require a relatively recent flymake This is probably helpful for Emacs 26.x and 27.x users --- lisp/init-flymake.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/init-flymake.el b/lisp/init-flymake.el index 19681cb5a0..17d6c7760c 100644 --- a/lisp/init-flymake.el +++ b/lisp/init-flymake.el @@ -2,6 +2,7 @@ ;;; Commentary: ;;; Code: +(maybe-require-package 'flymake "1.2.1") ;; Use flycheck checkers with flymake, to extend its coverage (when (maybe-require-package 'flymake-flycheck) From d5a8f36d30ca8de9b9b1bb60e7cec3563057d207 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 13 Mar 2022 10:41:38 +0100 Subject: [PATCH 91/95] Remove unnecessary setting of js2-basic-offset --- lisp/init-javascript.el | 3 --- 1 file changed, 3 deletions(-) diff --git a/lisp/init-javascript.el b/lisp/init-javascript.el index 70f9aa6b9a..3ab2fbf260 100644 --- a/lisp/init-javascript.el +++ b/lisp/init-javascript.el @@ -41,9 +41,6 @@ (js2-imenu-extras-setup)) -;; In Emacs >= 25, the following is an alias for js-indent-level anyway -(setq-default js2-basic-offset 2) - (add-to-list 'interpreter-mode-alist (cons "node" 'js2-mode)) (with-eval-after-load 'js2-mode From f80fbe52d1ce04f850eb63e51d5d08fef9411196 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 14 Mar 2022 11:03:37 +0100 Subject: [PATCH 92/95] Add slime contrib path This workaround somehow only seems necessary in snapshot emacs versions. --- lisp/init-slime.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/init-slime.el b/lisp/init-slime.el index b7d176cb33..6e0e3d46cf 100644 --- a/lisp/init-slime.el +++ b/lisp/init-slime.el @@ -3,6 +3,7 @@ ;;; Code: (require-package 'slime) +(push (expand-file-name "contrib" (file-name-directory (locate-library "slime"))) load-path) (when (maybe-require-package 'slime-company) (setq slime-company-completion 'fuzzy From 88aa6035fb0517bf59f9efdffe55f4dd5c939d63 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 15 Mar 2022 01:06:36 +1300 Subject: [PATCH 93/95] Don't try to maintain any pointers to other configs --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 44ee9ce443..a47ed06a7d 100644 --- a/README.md +++ b/README.md @@ -104,10 +104,6 @@ config remains compatible with the latest package and Emacs versions. *Please note that I cannot provide support for customised versions of this configuration.* -## Similar configs - -You might also want to check out `emacs-starter-kit` and `prelude`. - ## Support / issues If you hit any problems, please first ensure that you are using the latest version From 259323bb8c644be6c340330bee08131cd6de1ce7 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 14 Mar 2022 11:07:39 +0100 Subject: [PATCH 94/95] Switch from browse-at-remote to git-link --- lisp/init-git.el | 2 +- lisp/init-vc.el | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lisp/init-git.el b/lisp/init-git.el index e1ae32f555..d3d57dec1e 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -12,7 +12,7 @@ (when (maybe-require-package 'git-timemachine) (global-set-key (kbd "C-x v t") 'git-timemachine-toggle)) - +(require-package 'git-link) (when (maybe-require-package 'magit) (setq-default magit-diff-refine-hunk t) diff --git a/lisp/init-vc.el b/lisp/init-vc.el index 09b2084a34..8df0cc4933 100644 --- a/lisp/init-vc.el +++ b/lisp/init-vc.el @@ -15,7 +15,5 @@ (kbd " ") 'diff-hl-diff-goto-hunk))) -(maybe-require-package 'browse-at-remote) - (provide 'init-vc) ;;; init-vc.el ends here From 521829cb549801fd9479e673f2cc343d6e52aeb2 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Mon, 14 Mar 2022 11:08:27 +0100 Subject: [PATCH 95/95] Ignore "~/.emacs.d/projects" save file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 87b89afb3b..d03d13d586 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ site-lisp/package/ /.lsp-session-v1 /smex-items /eln-cache/ +/projects