From 2f8d87a01dbae72294ef60029983f23da73a936f Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 10 Jan 2024 14:23:54 +0100 Subject: [PATCH] Update Emacs configuration --- .emacs.d/init.el | 142 ++++++++++++++--------- .emacs.d/lisp/completions-auto-update.el | 68 ----------- .emacs.d/theme/esy-theme.el | 3 +- 3 files changed, 90 insertions(+), 123 deletions(-) delete mode 100644 .emacs.d/lisp/completions-auto-update.el diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 989391d..821aab1 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -140,7 +140,7 @@ ("install-info" "--dir=dir" "eat.info")))) (elpaca (elfeed :pre-build (("pandoc" "-o" "elfeed.texi" "README.md")))) -(elpaca embark-consult) +(elpaca embark) (elpaca emms) (elpaca htmlize) (elpaca keycast) @@ -157,12 +157,6 @@ (elpaca (markdown-mode :pre-build (("pandoc" "-o" "markdown-mode.texi" "README.md")))) (elpaca mastodon) -(elpaca orderless) -(elpaca (marginalia - :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org" - "--eval" "(setq org-babel-confirm-evaluate-answer-no t)" - "-f" "org-texinfo-export-to-texinfo")) - :repo "https://github.com/minad/marginalia.git")) (elpaca (osm :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org" "--eval" "(setq org-babel-confirm-evaluate-answer-no t)" @@ -193,6 +187,7 @@ (elpaca ob-prolog) (elpaca (query-replace-parallel :repo "https://github.com/hokomo/query-replace-parallel.git")) + (elpaca-wait) (defvar-keymap esy/elpaca-prefix-map @@ -378,7 +373,7 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) ;; don't ask me about it either tramp-allow-unsafe-temporary-files t ;; increase maximum number of recent files Emacs remembers - recentf-max-saved-items 128 + recentf-max-saved-items 1024 ;; increase maximum kill ring size kill-ring-max 256 ;; save text copied from another program to the kill ring @@ -396,6 +391,21 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) shr-color-visible-luminance-min 75 ;; direct Magit to my Git checkouts directory magit-repository-directories '(("~/checkouts/" . 1)) + magit-status-sections-hook + '(magit-insert-status-headers + magit-insert-merge-log + magit-insert-rebase-sequence + magit-insert-am-sequence + magit-insert-sequencer-sequence + magit-insert-bisect-output + magit-insert-bisect-rest + magit-insert-bisect-log + magit-insert-untracked-files + magit-insert-unstaged-changes + magit-insert-staged-changes + magit-insert-stashes + magit-insert-unpushed-to-pushremote + magit-insert-recent-commits) ;; have Dired operations target another visible Dired buffer dired-dwim-target t ;; use MPV with EMMS @@ -412,8 +422,13 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) show-trailing-whitespace t read-extended-command-predicate #'command-completion-default-include-p completions-format 'one-column + completions-detailed t completion-auto-select nil - completion-styles '(orderless partial-completion basic) + completion-styles '(substring partial-completion) + completion-category-overrides '((buffer (styles substring)) + (file (styles basic + partial-completion + substring))) completion-show-help nil ;; completions-header-format nil ;; completion-auto-help 'visible @@ -427,8 +442,6 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) display-time-default-load-average nil ;; allow disabling confirming before compilation via local variables safe-local-variable-values '((compilation-read-command . nil)) - xref-show-definitions-function #'consult-xref - xref-show-xrefs-function #'consult-xref xref-search-program 'ripgrep ;; include CWD in shell command prompts shell-command-prompt-show-cwd t @@ -464,7 +477,9 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) ;; TeX-electric-escape t LaTeX-electric-left-right-brace t ;; Read remote man pages - Man-support-remote-systems t) + Man-support-remote-systems t + confirm-nonexistent-file-or-buffer t + extended-command-dim-hyphens t) (setq-default indent-tabs-mode nil) @@ -478,7 +493,8 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) (add-to-list 'load-path (expand-file-name "lisp/" user-emacs-directory)) (autoload 'some-button "some-button" nil t) -(autoload 'completions-auto-update-mode "completions-auto-update" nil t) +;; (autoload 'completions-auto-update-mode "completions-auto-update" nil t) +;; (autoload 'completions-auto-update-global-mode "completions-auto-update" nil t) (unless (eq system-type 'android) (add-to-list 'load-path "~/checkouts/esy-publish/") @@ -487,7 +503,8 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) (autoload 'esy-publish-local-server "esy-publish" nil t) (autoload 'esy-publish-create-post "esy-publish" nil t) (with-eval-after-load 'recentf - (add-to-list 'recentf-exclude "~/checkouts/esy-publish/local/.*\.html"))) + (add-to-list 'recentf-exclude "~/checkouts/esy-publish/local/.*\.html") + (add-to-list 'recentf-exclude #'file-remote-p))) (require 'esy-comm) @@ -540,10 +557,9 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t)) (backward-word) (kill-region (point) end)))) -(defvar duplicate-line-final-position) - (defun duplicate-line-stay (arg) (interactive "p") + (require 'misc) (let ((duplicate-line-final-position 0)) (duplicate-line arg))) @@ -808,15 +824,11 @@ Interactively, POINT is point and KILL is the prefix argument." display-fill-column-indicator-mode display-line-numbers-mode flymake-mode - ;; flyspell-prog-mode - completion-preview-mode - )) + completion-preview-mode)) (add-hook 'prog-mode-hook mode)) (add-hook 'lisp-data-mode-hook #'paredit-mode) -(add-hook 'lisp-data-mode-hook (lambda () - (when (require 'rainbow-delimiters nil t) - (rainbow-delimiters-mode)))) +(add-hook 'lisp-data-mode-hook #'rainbow-delimiters-mode) ;;; Extend standard text mode hooks @@ -827,13 +839,13 @@ Interactively, POINT is point and KILL is the prefix argument." (keymap-global-set "C-M-i" #'completion-at-point) (keymap-global-set "C-c c" #'org-capture) +(keymap-global-set "C-c f" #'recentf-open) (keymap-global-set "C-c l" #'org-store-link) (keymap-global-set "C-c a" #'org-agenda) (keymap-global-set "C-c v" #'esy/terminal) (keymap-global-set "C-c p" #'sweeprolog-prefix-map) (keymap-global-set "C-c S" #'scratch-buffer) (keymap-global-set "C-c m" #'esy/emms-map) -(keymap-global-set "C-c !" #'consult-flymake) (keymap-global-set "C-c C" #'esy-publish-create-post) (keymap-global-set "C-c O" #'openai-chat) (keymap-global-set "C-c e" 'esy/elpaca-prefix-map) @@ -844,14 +856,11 @@ Interactively, POINT is point and KILL is the prefix argument." (keymap-global-set "C-c M" #'mastodon) (keymap-global-set "C-c t" #'esy/tmp-dired) (keymap-global-set "C-c F" #'esy/find-init-file) -(keymap-global-set "C-c SPC" #'consult-mark) (keymap-global-set "C-c 1" #'delete-other-windows) (keymap-global-set "C-c 2" #'split-window-below) (keymap-global-set "C-c 3" #'split-window-right) (keymap-global-set " " #'esy/kill-dwim) -(keymap-global-set " " #'consult-goto-line) (keymap-global-set " " #'zap-up-to-char) -(keymap-global-set " " #'consult-imenu) (keymap-global-set "s-n" #'duplicate-line) (keymap-global-set "s-p" #'duplicate-line-stay) (keymap-global-set "s-u" #'universal-argument) @@ -869,10 +878,6 @@ Interactively, POINT is point and KILL is the prefix argument." (keymap-global-set "M-'" #'insert-pair) (keymap-global-set "M-]" #'up-list) -(keymap-set ctl-x-map "b" #'consult-buffer) -(keymap-set ctl-x-4-map "b" #'consult-buffer-other-window) -(keymap-set ctl-x-5-map "b" #'consult-buffer-other-frame) -(keymap-set ctl-x-map "r b" #'consult-bookmark) (keymap-set ctl-x-map "C-b" #'ibuffer) (keymap-set search-map "r" #'rg) @@ -916,17 +921,13 @@ Interactively, POINT is point and KILL is the prefix argument." ;;; Configure project management commands (with-eval-after-load 'project - (define-advice project--find-in-directory (:override (dir) no-remote-projects) - (unless (file-remote-p dir) - (run-hook-with-args-until-success 'project-find-functions dir))) (add-to-list 'project-switch-commands '(project-compile "Compile")) (add-to-list 'project-switch-commands '(rg-project "rg")) (add-to-list 'project-switch-commands '(magit-project-status "Magit")) (add-to-list 'project-switch-commands '(project-shell "Shell")) - (when (boundp 'project-prefix-map) - (define-key project-prefix-map "R" #'rg-project) - (define-key project-prefix-map "w" #'project-copy-relative-file-name-as-kill) - (define-key project-prefix-map "m" #'magit-project-status)) + (define-key project-prefix-map "R" #'rg-project) + (define-key project-prefix-map "w" #'project-copy-relative-file-name-as-kill) + (define-key project-prefix-map "m" #'magit-project-status) (defvar esy/project-name-history nil) @@ -1062,18 +1063,12 @@ as the initial input for completion, and return that directory." ;;; Configure minibuffer completions -(defvar esy/completing-read-commands nil) - -(add-to-list 'savehist-additional-variables - 'esy/completing-read-commands) - -(define-advice completing-read (:before (&rest _) record-command) - (cl-incf (alist-get this-command esy/completing-read-commands 0))) - (add-to-list 'display-buffer-alist '("\\*Completions\\*" (display-buffer-reuse-window display-buffer-at-bottom) - (window-parameters (mode-line-format . none)))) + (window-parameters + ;; (mode-line-format . none) + (split-window . ignore)))) (add-hook 'completion-list-mode-hook (lambda () @@ -1087,10 +1082,6 @@ as the initial input for completion, and return that directory." (car key-binding) (cdr key-binding))) -(with-eval-after-load 'consult - (with-eval-after-load 'embark - (require 'embark-consult))) - ;;; Define some custom `completion-at-point-functions' (defun file-capf () @@ -1131,7 +1122,6 @@ as the initial input for completion, and return that directory." global-diff-hl-mode global-whitespace-cleanup-mode lin-global-mode - marginalia-mode minibuffer-depth-indicate-mode pixel-scroll-precision-mode recentf-mode @@ -1216,7 +1206,7 @@ as the initial input for completion, and return that directory." ;;; Associate major modes with files based on their extensions -(dolist (cell '(("Dockerfile" . dockerfile-ts-mode) +(dolist (cell '(("Dockerfile\\'" . dockerfile-ts-mode) ("\\.ya?ml\\'" . yaml-ts-mode) ("\\.toml\\'" . toml-ts-mode) ("\\.json\\'" . json-ts-mode) @@ -1349,8 +1339,8 @@ as the initial input for completion, and return that directory." (with-eval-after-load (car mm) (add-hook (cdr mm) #'eglot-ensure))) (with-eval-after-load 'completion-preview - (push 'org-self-insert-command completion-preview-commands) - (push 'paredit-backward-delete completion-preview-commands) + (add-to-list 'completion-preview-commands 'org-self-insert-command) + (add-to-list 'completion-preview-commands 'paredit-backward-delete) (setq completion-preview-minimum-symbol-length 2) (keymap-set completion-preview-active-mode-map "M-n" #'completion-preview-next-candidate) (keymap-set completion-preview-active-mode-map "M-p" #'completion-preview-prev-candidate) @@ -1358,5 +1348,49 @@ as the initial input for completion, and return that directory." (load-file "/Users/eshelyaron/checkouts/agda/src/data/emacs-mode/agda2.el") +(defun read-buffer-to-switch-recentf (file) + (interactive + (minibuffer-with-setup-hook #'minibuffer-completion-help + (unless recentf-mode (recentf-mode 1)) + (let ((completions-sort nil)) + (list (completing-read (format-prompt "Open recent file" nil) + recentf-list nil t (minibuffer-contents)))))) + (let ((buf (find-file-noselect file))) + (delete-minibuffer-contents) + (insert (buffer-name buf)) + (exit-minibuffer))) + +(defun read-buffer-to-switch-bookmark (bookmark) + (interactive + (minibuffer-with-setup-hook #'minibuffer-completion-help + (list (bookmark-completing-read "Jump to bookmark")))) + (let ((buf (save-current-buffer + (bookmark-handle-bookmark bookmark) + (current-buffer)))) + (delete-minibuffer-contents) + (insert (buffer-name buf)) + (exit-minibuffer))) + +(defvar-keymap read-buffer-to-switch-mode-map + :doc "Keymap for `read-buffer-to-switch-mode'." + "M-m" #'read-buffer-to-switch-bookmark + "M-r" #'read-buffer-to-switch-recentf) + +(define-minor-mode read-buffer-to-switch-mode + "Minor mode for reading a buffer name in the minibuffer." + :group 'minibuffer) + +(defun esy/read-buffer (prompt &optional def require-match predicate) + (minibuffer-with-setup-hook + (lambda () + (when read-buffer-to-switch-current-buffer + (read-buffer-to-switch-mode))) + (let ((read-buffer-function nil)) + (read-buffer prompt def require-match predicate)))) + +(setq read-buffer-function #'esy/read-buffer) + +(load-file (expand-file-name "admin/cherry.el" source-directory)) + (provide 'init) ;;; init.el ends here diff --git a/.emacs.d/lisp/completions-auto-update.el b/.emacs.d/lisp/completions-auto-update.el deleted file mode 100644 index 59b4065..0000000 --- a/.emacs.d/lisp/completions-auto-update.el +++ /dev/null @@ -1,68 +0,0 @@ -;;; completions-auto-update.el --- Auto-update minibuffer completions -*- lexical-binding: t; -*- - -;; Copyright (C) 2023 Eshel Yaron - -;; Author: Eshel Yaron -;; Keywords: convenience - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; This file defines a minor mode `completions-auto-update-mode' that -;; updates the *Completions* buffer as you type in the minibuffer. - -;;; Code: - -(defcustom completions-auto-update-idle-time 0.2 - "Number of seconds of idle to wait for before updating *Completions*." - :group 'minibuffer - :type 'number) - -(defvar-local completions-auto-update-timer nil) - -(defun completions-auto-update () - "Update the *Completions* buffer, if it is visible." - (when (get-buffer-window "*Completions*") - (if completion-in-region-mode - (completion-help-at-point) - (minibuffer-completion-help))) - (setq completions-auto-update-timer nil)) - -(defun completions-auto-update-start-timer () - "Start an idle timer for updating *Completions*." - (unless (or completions-auto-update-timer - (not (get-buffer-window "*Completions*"))) - (setq completions-auto-update-timer - (run-with-idle-timer completions-auto-update-idle-time - nil #'completions-auto-update)))) - -(defun completions-auto-update-setup () - (add-hook 'post-self-insert-hook #'completions-auto-update-start-timer nil t)) - -(defun completions-auto-update-exit () - (remove-hook 'post-self-insert-hook #'completions-auto-update-start-timer t)) - -(define-minor-mode completions-auto-update-mode - "Update the *Completions* buffer as you type in the minibuffer." - :global t :group 'minibuffer - (if completions-auto-update-mode - (progn - (add-hook 'minibuffer-setup-hook #'completions-auto-update-setup) - (add-hook 'minibuffer-setup-exit #'completions-auto-update-exit)) - (remove-hook 'minibuffer-setup-hook #'completions-auto-update-setup) - (remove-hook 'minibuffer-setup-exit #'completions-auto-update-exit))) - -(provide 'completions-auto-update) -;;; completions-auto-update.el ends here diff --git a/.emacs.d/theme/esy-theme.el b/.emacs.d/theme/esy-theme.el index abece97..baab475 100644 --- a/.emacs.d/theme/esy-theme.el +++ b/.emacs.d/theme/esy-theme.el @@ -28,7 +28,8 @@ '(cursor ((t :background "salmon"))) '(font-lock-doc-face ((t :inherit font-lock-string-face :slant italic))) '(elisp-shorthand-font-lock-face ((t :inherit font-lock-keyword-face :slant italic))) - '(elfeed-search-title-face ((t :inherit shadow)))) + '(elfeed-search-title-face ((t :inherit shadow))) + '(error ((t :foreground "Red1")))) (custom-theme-set-variables 'esy -- 2.39.2