diff options
| -rw-r--r-- | README.org | 23 | ||||
| -rw-r--r-- | corfu.el | 40 | ||||
| -rw-r--r-- | extensions/corfu-echo.el | 2 | ||||
| -rw-r--r-- | extensions/corfu-history.el | 2 | ||||
| -rw-r--r-- | extensions/corfu-indexed.el | 2 | ||||
| -rw-r--r-- | extensions/corfu-info.el | 2 | ||||
| -rw-r--r-- | extensions/corfu-popupinfo.el | 11 | ||||
| -rw-r--r-- | extensions/corfu-quick.el | 2 |
8 files changed, 20 insertions, 64 deletions
@@ -172,7 +172,6 @@ completion at point function provided by my [[https://github.com/minad/cape][Cap ("C-M-/" . dabbrev-expand)) :config (add-to-list 'dabbrev-ignored-buffer-regexps "\\` ") - ;; Available since Emacs 29 (Use `dabbrev-ignored-buffer-regexps' on older Emacs) (add-to-list 'dabbrev-ignored-buffer-modes 'authinfo-mode) (add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode) (add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode) @@ -357,23 +356,11 @@ confirmation. Fortunately it is easy to improve this by using the command Shell completion uses the flexible Pcomplete mechanism internally, which allows you to program the completions per shell command. If you want to know more, look into this [[https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs][blog post]], which shows how to configure Pcomplete for git commands. -Since Emacs 29, Pcomplete offers the =pcomplete-from-help= function which parses -the ~--help~ output of a command and produces completions for command line -options. - -Pcomplete has a few bugs on Emacs 28. We can work around the issues -with the [[https://github.com/minad/cape][Cape]] library (Completion at point extensions). Cape provides wrappers -which sanitize the Pcomplete function. On Emacs 29 the advices should not be -necessary anymore, since most relevant bugs have been fixed. In case you -discover any remaining Pcomplete issues, please report them upstream. - -#+begin_src emacs-lisp -;; Sanitize the `pcomplete-completions-at-point' Capf. The Capf has undesired -;; side effects on Emacs 28. These advices are not needed on Emacs 29 and newer. -(when (< emacs-major-version 29) - (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent) - (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)) -#+end_src +Pcomplete offers the =pcomplete-from-help= function which parses the ~--help~ output +of a command and produces completions for command line options. In the past, +before Emacs 29, Pcomplete had a few bugs, which had to be worked around using +the [[https://github.com/minad/cape][Cape]] library (Completion at point extensions). In case you discover any +remaining Pcomplete issues, please report them upstream. ** Orderless completion @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> ;; Created: 2021 ;; Version: 2.3 -;; Package-Requires: ((emacs "28.1") (compat "30")) +;; Package-Requires: ((emacs "29.1") (compat "30")) ;; URL: https://github.com/minad/corfu ;; Keywords: abbrev, convenience, matching, completion, text @@ -616,28 +616,18 @@ FRAME is the existing frame." (eq t (compare-strings word 0 len it 0 len completion-ignore-case)))))) -;; bug#6581: `equal-including-properties' uses `eq' for properties until 29.1. -;; Approximate by comparing `text-properties-at' position 0. -(defalias 'corfu--equal-including-properties - (static-if (< emacs-major-version 29) - (lambda (x y) - (and (equal x y) - (equal (text-properties-at 0 x) (text-properties-at 0 y)))) - #'equal-including-properties)) - (defun corfu--delete-dups (list) "Delete `equal-including-properties' consecutive duplicates from LIST." (let ((beg list)) (while (cdr beg) (let ((end (cdr beg))) (while (equal (car beg) (car end)) (pop end)) - ;; The deduplication is quadratic in the number of duplicates. We can - ;; avoid the quadratic complexity with a hash table which takes - ;; properties into account (available since Emacs 28). + ;; The deduplication is quadratic in the number of duplicates. We could + ;; avoid this via a hash table taking properties into account. (while (not (eq beg end)) (let ((dup beg)) (while (not (eq (cdr dup) end)) - (if (corfu--equal-including-properties (car beg) (cadr dup)) + (if (equal-including-properties (car beg) (cadr dup)) (setcdr dup (cddr dup)) (pop dup)))) (pop beg))))) @@ -1437,17 +1427,6 @@ Quit if no candidate is selected." (remove-hook 'post-command-hook #'corfu--auto-post-command 'local) (kill-local-variable 'completion-in-region-function)))) -(defcustom global-corfu-modes t - "List of modes where Corfu should be enabled by `global-corfu-mode'. -The variable can either be t, nil or a list of t, nil, mode -symbols or elements of the form (not modes). Examples: - - Enable everywhere, except in Org: ((not org-mode) t). - - Enable in programming modes except Python: ((not python-mode) prog-mode). - - Enable only in text modes: (text-mode)." - :type '(choice (const t) (repeat sexp)) - :group 'corfu) - -;; TODO use `:predicate' on Emacs 29 (defcustom global-corfu-minibuffer t "Corfu should be enabled in the minibuffer by `global-corfu-mode'. The variable can either be t, nil or a custom predicate function. If @@ -1460,21 +1439,14 @@ local `completion-at-point-functions'." (define-globalized-minor-mode global-corfu-mode corfu-mode corfu--on :group 'corfu + :predicate t (remove-hook 'minibuffer-setup-hook #'corfu--minibuffer-on) (when (and global-corfu-mode global-corfu-minibuffer) (add-hook 'minibuffer-setup-hook #'corfu--minibuffer-on 100))) (defun corfu--on () "Enable `corfu-mode' in the current buffer respecting `global-corfu-modes'." - (when (and (not noninteractive) (not (eq (aref (buffer-name) 0) ?\s)) - ;; TODO use `:predicate' on Emacs 29 - (or (eq t global-corfu-modes) - (eq t (cl-loop for p in global-corfu-modes thereis - (pcase-exhaustive p - ('t t) - ('nil 0) - ((pred symbolp) (and (derived-mode-p p) t)) - (`(not . ,m) (and (seq-some #'derived-mode-p m) 0))))))) + (unless (or noninteractive (eq (aref (buffer-name) 0) ?\s)) (corfu-mode))) (defun corfu--minibuffer-on () diff --git a/extensions/corfu-echo.el b/extensions/corfu-echo.el index af4d981..4d159ad 100644 --- a/extensions/corfu-echo.el +++ b/extensions/corfu-echo.el @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> ;; Created: 2022 ;; Version: 2.3 -;; Package-Requires: ((emacs "28.1") (compat "30") (corfu "2.3")) +;; Package-Requires: ((emacs "29.1") (compat "30") (corfu "2.3")) ;; URL: https://github.com/minad/corfu ;; This file is part of GNU Emacs. diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el index b79a919..e3ca9f8 100644 --- a/extensions/corfu-history.el +++ b/extensions/corfu-history.el @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> ;; Created: 2022 ;; Version: 2.3 -;; Package-Requires: ((emacs "28.1") (compat "30") (corfu "2.3")) +;; Package-Requires: ((emacs "29.1") (compat "30") (corfu "2.3")) ;; URL: https://github.com/minad/corfu ;; This file is part of GNU Emacs. diff --git a/extensions/corfu-indexed.el b/extensions/corfu-indexed.el index 0d20148..5d2a9ea 100644 --- a/extensions/corfu-indexed.el +++ b/extensions/corfu-indexed.el @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> ;; Created: 2022 ;; Version: 2.3 -;; Package-Requires: ((emacs "28.1") (compat "30") (corfu "2.3")) +;; Package-Requires: ((emacs "29.1") (compat "30") (corfu "2.3")) ;; URL: https://github.com/minad/corfu ;; This file is part of GNU Emacs. diff --git a/extensions/corfu-info.el b/extensions/corfu-info.el index 1b71a2f..07f425c 100644 --- a/extensions/corfu-info.el +++ b/extensions/corfu-info.el @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> ;; Created: 2022 ;; Version: 2.3 -;; Package-Requires: ((emacs "28.1") (compat "30") (corfu "2.3")) +;; Package-Requires: ((emacs "29.1") (compat "30") (corfu "2.3")) ;; URL: https://github.com/minad/corfu ;; This file is part of GNU Emacs. diff --git a/extensions/corfu-popupinfo.el b/extensions/corfu-popupinfo.el index c55fced..be3b11f 100644 --- a/extensions/corfu-popupinfo.el +++ b/extensions/corfu-popupinfo.el @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> ;; Created: 2022 ;; Version: 2.3 -;; Package-Requires: ((emacs "28.1") (compat "30") (corfu "2.3")) +;; Package-Requires: ((emacs "29.1") (compat "30") (corfu "2.3")) ;; URL: https://github.com/minad/corfu ;; This file is part of GNU Emacs. @@ -346,8 +346,7 @@ form (X Y WIDTH HEIGHT DIR)." (when (corfu-popupinfo--visible-p corfu--frame) (let* ((cand-changed (not (and (corfu-popupinfo--visible-p) - (corfu--equal-including-properties - candidate corfu-popupinfo--candidate)))) + (equal-including-properties candidate corfu-popupinfo--candidate)))) (new-coords (frame-edges corfu--frame 'inner-edges)) (coords-changed (not (equal new-coords corfu-popupinfo--coordinates)))) (when cand-changed @@ -493,8 +492,7 @@ not be displayed until this command is called again, even if corfu-popupinfo-delay)) (corfu-popupinfo--toggle)) (if (or (<= delay 0) - (and (corfu--equal-including-properties - cand corfu-popupinfo--candidate) + (and (equal-including-properties cand corfu-popupinfo--candidate) (corfu-popupinfo--visible-p))) (corfu-popupinfo--show cand) (when (corfu-popupinfo--visible-p) @@ -505,8 +503,7 @@ not be displayed until this command is called again, even if (corfu-popupinfo--show corfu-popupinfo--candidate)))) (setq corfu-popupinfo--timer (run-at-time delay nil #'corfu-popupinfo--show cand))) - (unless (corfu--equal-including-properties - cand corfu-popupinfo--candidate) + (unless (equal-including-properties cand corfu-popupinfo--candidate) (corfu-popupinfo--hide)))) (corfu-popupinfo--hide)))) diff --git a/extensions/corfu-quick.el b/extensions/corfu-quick.el index bb7235d..a0f6f8d 100644 --- a/extensions/corfu-quick.el +++ b/extensions/corfu-quick.el @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de> ;; Created: 2022 ;; Version: 2.3 -;; Package-Requires: ((emacs "28.1") (compat "30") (corfu "2.3")) +;; Package-Requires: ((emacs "29.1") (compat "30") (corfu "2.3")) ;; URL: https://github.com/minad/corfu ;; This file is part of GNU Emacs. |
