[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape bb1921b624 130/146: Add cape-repair-misbehaving-ca
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape bb1921b624 130/146: Add cape-repair-misbehaving-capf |
Date: |
Sun, 9 Jan 2022 20:57:48 -0500 (EST) |
branch: externals/cape
commit bb1921b6245bd9c201b31893f0348db3463e947e
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add cape-repair-misbehaving-capf
---
README.org | 14 ++++++++++++++
cape.el | 21 +++++++++++++++++++--
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index dea6d1f661..4db0a7c94b 100644
--- a/README.org
+++ b/README.org
@@ -194,6 +194,20 @@ achieve a similarly refreshing strategy.
(list (cape-capf-buster #'some-caching-capf)))
#+end_src
+** Repair misbehaving Capfs
+
+Unfortunately some completion of point functions from Emacs show misbehavior.
+This is not a term I've made up, but minibuffer.el distinguishes old-style
+("misbehaving") Capfs and modern-style Capfs. The misbehaving Capfs do not
+return a completion table but just perform completion right away. Such behavior
+is particularily harmful for completion UIs like Company or Corfu in
+idle/auto-completion mode. There is at least one completion function, which
+affects the Eshell:
+
+#+begin_src emacs-lisp
+ (advice-add #'pcomplete-completions-at-point :around
#'cape-repair-misbehaving-capf)
+#+end_src
+
** Other Capf transformers
- ~cape-silent-capf~: Wrap a chatty Capf and silence it.
diff --git a/cape.el b/cape.el
index 0b1ef45319..368522e569 100644
--- a/cape.el
+++ b/cape.el
@@ -466,8 +466,10 @@ If INTERACTIVE is nil the function acts like a capf."
(interactive (list t))
(if interactive
(cape--interactive #'cape-symbol)
- (let ((bounds (cape--bounds 'symbol)))
- `(,(car bounds) ,(cdr bounds)
+ (pcase-let ((`(,beg . ,end) (cape--bounds 'symbol)))
+ (when (eq (char-after beg) ?')
+ (setq beg (1+ beg) end (max beg end)))
+ `(,beg ,end
,(cape--table-with-properties obarray :category 'symbol)
:exclusive no ,@cape--symbol-properties))))
@@ -1012,6 +1014,21 @@ case sensitive instead."
(`(,beg ,end ,table . ,plist)
`(,beg ,end ,(cape--noninterruptible-table table) ,@plist)))))
+;;;###autoload
+(defun cape-repair-misbehaving-capf (capf)
+ "Repair a misbehaving CAPF."
+ (catch 'cape--misbehaving-capf
+ (save-mark-and-excursion
+ (atomic-change-group
+ (pcase (funcall capf)
+ ((and res `(,beg ,end ,_table . ,_plist)
+ (guard (integer-or-marker-p beg))
+ (guard (integer-or-marker-p end)))
+ (ignore beg end)
+ res)
+ (_
+ (throw 'cape--misbehaving-capf nil)))))))
+
;;;###autoload
(defun cape-interactive-capf (capf)
"Create interactive completion function from CAPF."
- [elpa] externals/cape 6ddd50e7b7 116/146: Improve prefix setting of file capf, (continued)
- [elpa] externals/cape 6ddd50e7b7 116/146: Improve prefix setting of file capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape fab063f187 119/146: Add cape-rfc1345, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 6652d62c5a 118/146: README: Fix list, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ad7f35fdbe 121/146: cape-tex: Fix range issue, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 516eb36e8d 120/146: Minor fixes, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1e73d032e4 125/146: Fix compilation error (Fix #16), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 89aaca7789 128/146: Protect cape--char-translation from macro expansion, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 399fdad016 122/146: cape-tex/sgml: Add docsig, improve parsing of describe-input-method, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c2db8ce4d9 127/146: Expand docstrings, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ab91f727fb 126/146: cape-tex/sgml: Filter candidates during compilation, ELPA Syncer, 2022/01/09
- [elpa] externals/cape bb1921b624 130/146: Add cape-repair-misbehaving-capf,
ELPA Syncer <=
- [elpa] externals/cape c442f055dd 132/146: Blurb, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3495692f4c 133/146: Expand README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ba24e62961 139/146: README: Expand cape-super-capf documentation, ELPA Syncer, 2022/01/09
- [elpa] externals/cape bcf2fe1bdc 141/146: Version 0.4, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 9defa71303 142/146: cape-dabbrev: Add cape-dabbrev-forbid-space, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c629043156 145/146: cape-abbrev: Take all abbrev tables into account (Fix #19), ELPA Syncer, 2022/01/09