branch: externals/corfu commit 5380f0a232561f8268f494044379a778895f5659 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
corfu-popupinfo: Minor cleanup --- extensions/corfu-popupinfo.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/extensions/corfu-popupinfo.el b/extensions/corfu-popupinfo.el index 57db7bad66..1839eeaf18 100644 --- a/extensions/corfu-popupinfo.el +++ b/extensions/corfu-popupinfo.el @@ -158,7 +158,7 @@ all values are in pixels relative to the origin. See (when-let* ((fun (plist-get corfu--extra :company-location)) ;; BUG: company-location may throw errors if location is not found (loc (ignore-errors (funcall fun candidate))) - (buf (or (and (bufferp (car loc)) (car loc)) + (res (or (and (bufferp (car loc)) (car loc)) (get-file-buffer (car loc)) (let ((inhibit-message t) (enable-dir-local-variables nil) @@ -166,7 +166,7 @@ all values are in pixels relative to the origin. See (non-essential t) (delay-mode-hooks t)) (setq cleanup (find-file-noselect (car loc) t)))))) - (with-current-buffer buf + (with-current-buffer res (save-excursion (save-restriction (widen) @@ -179,10 +179,9 @@ all values are in pixels relative to the origin. See (forward-line (* 10 corfu-popupinfo-max-height)) (when jit-lock-mode (jit-lock-fontify-now beg (point))) - (let ((res (buffer-substring beg (point)))) - (and (not (string-blank-p res)) res)))))))) - (unless (bufferp (car loc)) - (kill-buffer buf)))))) + (setq res (buffer-substring beg (point))) + (and (not (string-blank-p res)) res))))))) + (when cleanup (kill-buffer cleanup))))) (defun corfu-popupinfo--get-documentation (candidate) "Get the documentation for CANDIDATE."