branch: externals/cape
commit 49e2fe56f7e6c8dba5fbe13a277e22b63d083fc6
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    cape-dabbrev-check-other-buffers: More defensive function check (Fix #127)
---
 cape.el | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/cape.el b/cape.el
index cfdbfc8589..a8c0478e78 100644
--- a/cape.el
+++ b/cape.el
@@ -567,22 +567,19 @@ If INTERACTIVE is nil the function acts like a Capf."
 (defun cape--dabbrev-list (input)
   "Find all Dabbrev expansions for INPUT."
   (cape--silent
-    (dlet ((dabbrev-check-other-buffers
-            (and cape-dabbrev-check-other-buffers
-                 (not (functionp cape-dabbrev-check-other-buffers))))
-           (dabbrev-check-all-buffers
-            (eq cape-dabbrev-check-other-buffers t))
-           (dabbrev-search-these-buffers-only
-            (and (functionp cape-dabbrev-check-other-buffers)
-                 (funcall cape-dabbrev-check-other-buffers))))
-      (dabbrev--reset-global-variables)
-      (cons
-       (apply-partially #'string-prefix-p input)
-       (cl-loop with min-len = (+ cape-dabbrev-min-length (length input))
-                with ic = (cape--case-fold-p dabbrev-case-fold-search)
-                for w in (dabbrev--find-all-expansions input ic)
-                if (>= (length w) min-len) collect
-                (cape--case-replace (and ic dabbrev-case-replace) input w))))))
+    (let* ((chk cape-dabbrev-check-other-buffers)
+           (funp (and (not (memq chk '(nil t some))) (functionp chk))))
+      (dlet ((dabbrev-check-other-buffers (and chk (not funp)))
+             (dabbrev-check-all-buffers (eq chk t))
+             (dabbrev-search-these-buffers-only (and funp (funcall chk))))
+        (dabbrev--reset-global-variables)
+        (cons
+         (apply-partially #'string-prefix-p input)
+         (cl-loop with min-len = (+ cape-dabbrev-min-length (length input))
+                  with ic = (cape--case-fold-p dabbrev-case-fold-search)
+                  for w in (dabbrev--find-all-expansions input ic)
+                  if (>= (length w) min-len) collect
+                  (cape--case-replace (and ic dabbrev-case-replace) input 
w)))))))
 
 (defun cape--dabbrev-bounds ()
   "Return bounds of abbreviation."

Reply via email to