From e687d4dbf4a8d07a2f1a19b5ca676828038eff31 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 20 Sep 2025 10:43:12 +0200 Subject: Require Emacs 29 --- README.org | 29 ++++++++++++++--------------- cape-char.el | 2 +- cape-keyword.el | 5 +---- cape.el | 6 ++---- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/README.org b/README.org index 796d8bd..f22fc5f 100644 --- a/README.org +++ b/README.org @@ -37,11 +37,11 @@ advantage of Company backends even if you are not using Company as frontend. * Available Capfs + ~cape-abbrev~: Complete abbreviation (~add-global-abbrev~, ~add-mode-abbrev~). -+ ~cape-dabbrev~: Complete word from current buffers. See also ~dabbrev-capf~ on Emacs 29. ++ ~cape-dabbrev~: Complete word from current buffers. See also ~dabbrev-capf~. + ~cape-dict~: Complete word from dictionary file. + ~cape-elisp-block~: Complete Elisp in Org or Markdown code block. + ~cape-elisp-symbol~: Complete Elisp symbol. -+ ~cape-emoji~: Complete Emoji. Available on Emacs 29 and newer. ++ ~cape-emoji~: Complete Emoji. + ~cape-file~: Complete file name. + ~cape-history~: Complete from Eshell, Comint or minibuffer history. + ~cape-keyword~: Complete programming language keyword. @@ -257,25 +257,18 @@ In the following we show a few example configurations, which have come up on the personal configuration. #+begin_src emacs-lisp -;; Example 1: 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)) - -;; Example 2: Configure a Capf with a specific auto completion prefix length +;; Example 1: Configure a Capf with a specific auto completion prefix length (setq-local completion-at-point-functions (list (cape-capf-prefix-length #'cape-dabbrev 2))) -;; Example 3: Create a Capf with debugging messages +;; Example 2: Create a Capf with debugging messages (setq-local completion-at-point-functions (list (cape-capf-debug #'cape-dict))) -;; Example 4: Named Capf +;; Example 3: Named Capf (defalias 'cape-dabbrev-min-2 (cape-capf-prefix-length #'cape-dabbrev 2)) (setq-local completion-at-point-functions (list #'cape-dabbrev-min-2)) -;; Example 5: Define a defensive Dabbrev Capf, which accepts all inputs. If you +;; Example 4: Define a defensive Dabbrev Capf, which accepts all inputs. If you ;; use Corfu and `corfu-auto=t', the first candidate won't be auto selected if ;; `corfu-preselect=valid', such that it cannot be accidentally committed when ;; pressing RET. @@ -283,17 +276,23 @@ personal configuration. (cape-wrap-accept-all #'cape-dabbrev)) (add-hook 'completion-at-point-functions #'my-cape-dabbrev-accept-all) -;; Example 6: Define interactive Capf which can be bound to a key. Here we wrap +;; Example 5: Define interactive Capf which can be bound to a key. Here we wrap ;; the `elisp-completion-at-point' such that we can complete Elisp code ;; explicitly in arbitrary buffers. (keymap-global-set "C-c p e" (cape-capf-interactive #'elisp-completion-at-point)) -;; Example 7: Ignore :keywords in Elisp completion. +;; Example 6: Ignore :keywords in Elisp completion. (defun ignore-elisp-keywords (sym) (not (keywordp sym))) (setq-local completion-at-point-functions (list (cape-capf-predicate #'elisp-completion-at-point #'ignore-elisp-keywords))) + +;; Example 7: Sanitize the `pcomplete-completions-at-point' Capf. The Capf has +;; undesired side effects on Emacs 28. These advices are not needed anymore. +(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 * Contributions diff --git a/cape-char.el b/cape-char.el index c301701..6a9814f 100644 --- a/cape-char.el +++ b/cape-char.el @@ -140,7 +140,7 @@ function acts like a Capf." method method) ;;;###autoload (autoload 'cape-rfc1345 "cape-char" nil t) (cape-char--define rfc1345 "rfc1345" ?&) -;;;###autoload (when (> emacs-major-version 28) (autoload 'cape-emoji "cape-char" nil t)) +;;;###autoload (autoload 'cape-emoji "cape-char" nil t) (cape-char--define emoji "emoji" ?:) (provide 'cape-char) diff --git a/cape-keyword.el b/cape-keyword.el index bf709f6..67781ca 100644 --- a/cape-keyword.el +++ b/cape-keyword.el @@ -404,10 +404,7 @@ (defun cape--keyword-list () "Return keywords for current major mode." (when-let ((kw (or (alist-get major-mode cape-keyword-list) - (when-let (((eval-when-compile (> emacs-major-version 28))) - (remap (rassq - major-mode - (bound-and-true-p major-mode-remap-alist)))) + (when-let ((remap (rassq major-mode major-mode-remap-alist))) (alist-get (car remap) cape-keyword-list))))) (if (symbolp (car kw)) (alist-get (car kw) cape-keyword-list) kw))) diff --git a/cape.el b/cape.el index 46de7a6..b4abdd2 100644 --- a/cape.el +++ b/cape.el @@ -6,7 +6,7 @@ ;; Maintainer: Daniel Mendler ;; Created: 2021 ;; Version: 2.1 -;; Package-Requires: ((emacs "28.1") (compat "30")) +;; Package-Requires: ((emacs "29.1") (compat "30")) ;; URL: https://github.com/minad/cape ;; Keywords: abbrev, convenience, matching, completion, text @@ -1207,9 +1207,7 @@ This function can be used as an advice around an existing Capf." ;;;###autoload (defun cape-wrap-purify (capf) "Call CAPF and ensure that it does not illegally modify the buffer. -This function can be used as an advice around an existing -Capf. It has been introduced mainly to fix the broken -`pcomplete-completions-at-point' function in Emacs versions < 29." +This function can be used as an advice around an existing Capf." ;; bug#50470: Fix Capfs which illegally modify the buffer or which illegally ;; call `completion-in-region'. The workaround here was proposed by ;; @jakanakaevangeli and is used in his capf-autosuggest package. In Emacs 29 -- cgit v1.0