diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2024-08-18 16:13:10 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2024-08-18 16:13:10 +0200 |
| commit | 49e2fe56f7e6c8dba5fbe13a277e22b63d083fc6 (patch) | |
| tree | cfc9bee8773531b5369fea17d236a45f04a58e6f | |
| parent | de5adc124faf09ad4d3c18441db2da09d409bc73 (diff) | |
cape-dabbrev-check-other-buffers: More defensive function check (Fix #127)
| -rw-r--r-- | cape.el | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -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." |
