emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/company 073aef72dd: Add a wrapper for the wrapper, to h


From: ELPA Syncer
Subject: [elpa] externals/company 073aef72dd: Add a wrapper for the wrapper, to handle misbehaving capfs
Date: Sun, 27 Mar 2022 21:57:20 -0400 (EDT)

branch: externals/company
commit 073aef72ddf93f897a856c246c58dcdfe003674e
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Add a wrapper for the wrapper, to handle misbehaving capfs
    
    See https://github.com/company-mode/company-mode/discussions/1278.
    
    Fixes #409 and fixes #974.
---
 company-capf.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/company-capf.el b/company-capf.el
index 6c8dcc78a5..84b79de679 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -67,9 +67,21 @@ so we can't just use the preceding variable instead.")
              (completion-at-point-functions (company--capf-workaround))
              (data (run-hook-wrapped 'completion-at-point-functions
                                      ;; Ignore misbehaving functions.
-                                     #'completion--capf-wrapper 'optimist)))
+                                     #'company--capf-wrapper 'optimist)))
     (when (and (consp (cdr data)) (integer-or-marker-p (nth 1 data))) data)))
 
+(defun company--capf-wrapper (fun which)
+  (let ((buffer-read-only t)
+        (inhibit-read-only nil)
+        (completion-in-region-function
+         (lambda (beg end coll pred)
+           (throw 'company--illegal-completion-in-region
+                  (list fun beg end coll :predicate pred)))))
+    (catch 'company--illegal-completion-in-region
+      (condition-case nil
+          (completion--capf-wrapper fun which)
+        (buffer-read-only nil)))))
+
 (declare-function python-shell-get-process "python")
 
 (defun company--capf-workaround ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]