[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu a878346677 2/2: Improve error messages
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu a878346677 2/2: Improve error messages |
Date: |
Wed, 23 Nov 2022 14:57:28 -0500 (EST) |
branch: externals/corfu
commit a87834667752cfbdf771d0c55328a1645584c6f2
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve error messages
---
extensions/corfu-info.el | 48 +++++++++++++++++++++++--------------------
extensions/corfu-popupinfo.el | 5 +++--
2 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/extensions/corfu-info.el b/extensions/corfu-info.el
index 432e0fb5e8..c5c42f07b1 100644
--- a/extensions/corfu-info.el
+++ b/extensions/corfu-info.el
@@ -59,13 +59,14 @@
;; Company support, taken from `company.el', see `company-show-doc-buffer'.
(when (< corfu--index 0)
(user-error "No candidate selected"))
- (if-let* ((fun (plist-get corfu--extra :company-doc-buffer))
- (res (funcall fun (nth corfu--index corfu--candidates))))
- (let ((buf (or (car-safe res) res)))
- (corfu-info--restore-on-next-command)
- (setq other-window-scroll-buffer (get-buffer buf))
- (set-window-start (display-buffer buf t) (or (cdr-safe res)
(point-min))))
- (user-error "No documentation available")))
+ (let ((cand (nth corfu--index corfu--candidates)))
+ (if-let* ((fun (plist-get corfu--extra :company-doc-buffer))
+ (res (funcall fun cand)))
+ (let ((buf (or (car-safe res) res)))
+ (corfu-info--restore-on-next-command)
+ (setq other-window-scroll-buffer (get-buffer buf))
+ (set-window-start (display-buffer buf t) (or (cdr-safe res)
(point-min))))
+ (user-error "No documentation available for `%s'" cand))))
;;;###autoload
(defun corfu-info-location ()
@@ -74,21 +75,24 @@
;; Company support, taken from `company.el', see `company-show-location'.
(when (< corfu--index 0)
(user-error "No candidate selected"))
- (if-let* ((fun (plist-get corfu--extra :company-location))
- (loc (funcall fun (nth corfu--index corfu--candidates))))
- (let ((buf (or (and (bufferp (car loc)) (car loc)) (find-file-noselect
(car loc) t))))
- (corfu-info--restore-on-next-command)
- (setq other-window-scroll-buffer buf)
- (with-selected-window (display-buffer buf t)
- (save-restriction
- (widen)
- (goto-char (point-min))
- (when-let (pos (cdr loc))
- (if (bufferp (car loc))
- (goto-char pos)
- (forward-line (1- pos))))
- (set-window-start nil (point)))))
- (user-error "No location available")))
+ (let ((cand (nth corfu--index corfu--candidates)))
+ ;; BUG: company-location may throw errors if location is not found
+ (if-let* ((fun (ignore-errors (plist-get corfu--extra :company-location)))
+ (loc (funcall fun cand)))
+ (let ((buf (or (and (bufferp (car loc)) (car loc))
+ (find-file-noselect (car loc) t))))
+ (corfu-info--restore-on-next-command)
+ (setq other-window-scroll-buffer buf)
+ (with-selected-window (display-buffer buf t)
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (when-let (pos (cdr loc))
+ (if (bufferp (car loc))
+ (goto-char pos)
+ (forward-line (1- pos))))
+ (set-window-start nil (point)))))
+ (user-error "No location available for `%s'" cand))))
;; Emacs 28: Do not show Corfu commands with M-X
(put #'corfu-info-location 'completion-predicate #'ignore)
diff --git a/extensions/corfu-popupinfo.el b/extensions/corfu-popupinfo.el
index c646ace922..0f423d4287 100644
--- a/extensions/corfu-popupinfo.el
+++ b/extensions/corfu-popupinfo.el
@@ -368,8 +368,9 @@ the candidate popup, its value is 'vertical, 'right or
'left."
(setf face-remapping-alist (copy-tree face-remapping-alist)
(alist-get 'default face-remapping-alist)
'corfu-popupinfo))
(unless (eq corfu-popupinfo--toggle 'init)
- (message "No %s available"
- (car (last (split-string (symbol-name
corfu-popupinfo--function) "-+")))))
+ (message "No %s available for `%s'"
+ (car (last (split-string (symbol-name
corfu-popupinfo--function) "-+")))
+ candidate))
(corfu-popupinfo--hide)
(setq cand-changed nil coords-changed nil)))
(when (or cand-changed coords-changed)