From 1526479a39989b6556f83d039064b180208a0ed1 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 15 Oct 2023 22:46:40 +0200 Subject: [PATCH] Update Emacs configuration --- .emacs.d/init.el | 19 +++---- .emacs.d/lisp/completions-auto-update.el | 68 ++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 .emacs.d/lisp/completions-auto-update.el diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 6676847..1258eeb 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -103,6 +103,12 @@ ;;; Install packages +(unless (eq system-type 'android) + (elpaca org-transclusion) + (elpaca (sweeprolog + :repo "~/checkouts/sweep/" + :files ("*.org" "*.texi" "sweep.pl" + "sweeprolog-pce-theme.el" "sweeprolog.el")))) (elpaca avy) (elpaca (bbdb :repo "https://git.savannah.nongnu.org/git/bbdb.git" @@ -193,14 +199,6 @@ ("mv" "README.texi" "pdf-tools.texi")))) (elpaca ob-prolog) -(unless (eq system-type 'android) - (elpaca org) - (elpaca org-transclusion) - (elpaca (sweeprolog - :repo "~/checkouts/sweep/" - :files ("*.org" "*.texi" "sweep.pl" - "sweeprolog-pce-theme.el" "sweeprolog.el")))) - (elpaca-wait) (defvar-keymap esy/elpaca-prefix-map @@ -505,6 +503,7 @@ (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) (unless (eq system-type 'android) (add-to-list 'load-path "~/checkouts/esy-publish/") @@ -1145,7 +1144,8 @@ as the initial input for completion, and return that directory." (dolist (key-binding '(("C-p" . minibuffer-previous-completion) ("C-n" . minibuffer-next-completion) - ("M-j" . minibuffer-force-complete-and-exit))) + ("M-j" . minibuffer-force-complete-and-exit) + ("SPC" . nil))) (keymap-set minibuffer-local-completion-map (car key-binding) (cdr key-binding))) @@ -1223,6 +1223,7 @@ as the initial input for completion, and return that directory." show-paren-mode transient-mark-mode winner-mode + completions-auto-update-mode )) (funcall mode)) diff --git a/.emacs.d/lisp/completions-auto-update.el b/.emacs.d/lisp/completions-auto-update.el new file mode 100644 index 0000000..59b4065 --- /dev/null +++ b/.emacs.d/lisp/completions-auto-update.el @@ -0,0 +1,68 @@ +;;; 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 -- 2.39.2