[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu 53ecf48 03/14: corfu-show-location/documentation:
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/corfu 53ecf48 03/14: corfu-show-location/documentation: Add error messages |
Date: |
Sat, 17 Apr 2021 10:25:41 -0400 (EDT) |
branch: externals/corfu
commit 53ecf48384f097ce71d402813af838c17723aca0
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
corfu-show-location/documentation: Add error messages
---
corfu.el | 52 +++++++++++++++++++++++++++++-----------------------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/corfu.el b/corfu.el
index 0e0a05b..5e3c1e1 100644
--- a/corfu.el
+++ b/corfu.el
@@ -459,43 +459,49 @@
"Restore window configuration before next command."
(let ((config (current-window-configuration))
(other other-window-scroll-buffer)
- (hide (make-symbol "corfu--hide-help")))
- (fset hide (lambda ()
+ (restore (make-symbol "corfu--restore")))
+ (fset restore (lambda ()
(when (eq this-command #'corfu-abort)
(setq this-command #'ignore))
- (remove-hook 'pre-command-hook hide)
+ (remove-hook 'pre-command-hook restore)
(setq other-window-scroll-buffer other)
(set-window-configuration config)))
- (run-at-time 0 nil (lambda () (add-hook 'pre-command-hook hide)))))
+ (run-at-time 0 nil (lambda () (add-hook 'pre-command-hook restore)))))
;; Company support, taken from `company.el', see `company-show-doc-buffer'.
(defun corfu-show-documentation ()
"Show documentation of current candidate."
(interactive)
- (when-let* ((fun (and (>= corfu--index 0) (plist-get corfu--extra-properties
:company-doc-buffer)))
- (res (funcall fun (nth corfu--index corfu--candidates))))
- (let ((buf (or (car-safe res) res)))
- (corfu--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))))))
+ (when (< corfu--index 0)
+ (user-error "No candidate selected"))
+ (if-let* ((fun (plist-get corfu--extra-properties :company-doc-buffer))
+ (res (funcall fun (nth corfu--index corfu--candidates))))
+ (let ((buf (or (car-safe res) res)))
+ (corfu--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")))
;; Company support, taken from `company.el', see `company-show-location'.
(defun corfu-show-location ()
"Show location of current candidate."
(interactive)
- (when-let* ((fun (and (>= corfu--index 0) (plist-get corfu--extra-properties
: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--restore-on-next-command)
- (with-selected-window (display-buffer buf t)
- (setq other-window-scroll-buffer (current-buffer))
- (save-restriction
- (widen)
- (if (bufferp (car loc))
- (goto-char (cdr loc))
- (goto-char (point-min))
- (forward-line (1- (cdr loc))))
- (set-window-start nil (point)))))))
+ (when (< corfu--index 0)
+ (user-error "No candidate selected"))
+ (if-let* ((fun (plist-get corfu--extra-properties :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--restore-on-next-command)
+ (with-selected-window (display-buffer buf t)
+ (setq other-window-scroll-buffer (current-buffer))
+ (save-restriction
+ (widen)
+ (if (bufferp (car loc))
+ (goto-char (cdr loc))
+ (goto-char (point-min))
+ (forward-line (1- (cdr loc))))
+ (set-window-start nil (point)))))
+ (user-error "No candidate location available")))
(defun corfu-complete ()
"Try to complete current input."
- [elpa] externals/corfu updated (7bab236 -> 4c2c997), Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 53ecf48 03/14: corfu-show-location/documentation: Add error messages,
Protesilaos Stavrou <=
- [elpa] externals/corfu 4e58a71 04/14: Minor optimizations, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu ff1579e 11/14: README: Add link to ELPA, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 2ebd35f 12/14: corfu-map: Bind M-n and M-p, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 4c2c997 14/14: Version 0.2, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 41eb724 02/14: Ignore corfu-abort if documentation/location window is shown, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 82474fb 01/14: Fix typo in corfu-minor-mode, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 7fcd09b 08/14: README: Update caveat, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 6e9b8ef 10/14: Add corfu-completion-styles, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 10660b4 07/14: corfu-first: Jump to the prompt if first candidate is selected, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu cf7c6c9 05/14: Do not show annotation in candidate preview (See #2), Protesilaos Stavrou, 2021/04/17