Change to when-let* and if-let*
This commit is contained in:
@ -49,7 +49,7 @@ As this is :around advice, OLDFUN is the real (advised) function to call."
|
||||
|
||||
(defun ctp--load-content (candidate buffer)
|
||||
"Load the documentation for CANDIDATE into BUFFER."
|
||||
(when-let ((content (funcall corfu-popupinfo--function candidate)))
|
||||
(when-let* ((content (funcall corfu-popupinfo--function candidate)))
|
||||
;; A bunch of this comes straight from `corfu-popupinfo--show'
|
||||
(with-current-buffer buffer
|
||||
(dolist (var corfu-popupinfo--buffer-parameters)
|
||||
@ -86,7 +86,7 @@ As this is :around advice, OLDFUN is the real (advised) function to call."
|
||||
(forward-line))))
|
||||
(goto-char (point-min))
|
||||
(put-text-property (point-min) (point-max) 'face 'corfu-popupinfo)
|
||||
(when-let ((m (memq 'corfu-default (alist-get 'default face-remapping-alist))))
|
||||
(when-let* ((m (memq 'corfu-default (alist-get 'default face-remapping-alist))))
|
||||
(setcar m 'corfu-popupinfo)))
|
||||
;; We succeeded in loading the data
|
||||
t))
|
||||
@ -95,20 +95,20 @@ As this is :around advice, OLDFUN is the real (advised) function to call."
|
||||
"Find a good position to open the popon for BUFFER's content.
|
||||
Return a list of the position, the max line length that can be shown, and the
|
||||
max height that can be shown. Each line of BUFFER _MUST_ be the same lenght."
|
||||
(when-let ((point-posn (posn-at-point))
|
||||
(point-x (car (posn-x-y point-posn)))
|
||||
(point-y (cdr (posn-x-y point-posn))))
|
||||
(when-let* ((point-posn (posn-at-point))
|
||||
(point-x (car (posn-x-y point-posn)))
|
||||
(point-y (cdr (posn-x-y point-posn))))
|
||||
(with-current-buffer buffer
|
||||
(when-let ((completion-pos (popon-position corfu-terminal--popon))
|
||||
(completion-size (popon-size corfu-terminal--popon))
|
||||
(comp-x (car completion-pos))
|
||||
(comp-y (cdr completion-pos))
|
||||
(comp-w (car completion-size))
|
||||
(comp-h (cdr completion-size))
|
||||
(win-w (window-max-chars-per-line))
|
||||
(win-h (window-body-height))
|
||||
(line-len (- (pos-eol) (pos-bol)))
|
||||
(num-lines (count-lines (point-min) (point-max))))
|
||||
(when-let* ((completion-pos (popon-position corfu-terminal--popon))
|
||||
(completion-size (popon-size corfu-terminal--popon))
|
||||
(comp-x (car completion-pos))
|
||||
(comp-y (cdr completion-pos))
|
||||
(comp-w (car completion-size))
|
||||
(comp-h (cdr completion-size))
|
||||
(win-w (window-max-chars-per-line))
|
||||
(win-h (window-body-height))
|
||||
(line-len (- (pos-eol) (pos-bol)))
|
||||
(num-lines (count-lines (point-min) (point-max))))
|
||||
(let* ((align 'row)
|
||||
(width (min line-len corfu-popupinfo-max-width))
|
||||
(pop-x (cond
|
||||
@ -178,8 +178,8 @@ The content extracted is for a popon of size WIDTH by HEIGHT."
|
||||
(cl-destructuring-bind (&optional pos width height)
|
||||
(ctp--popon-position buffer)
|
||||
(popon-kill ctp--popon)
|
||||
(when-let ((pos)
|
||||
(content (ctp--extract-content buffer width height)))
|
||||
(when-let* ((pos)
|
||||
(content (ctp--extract-content buffer width height)))
|
||||
(setq ctp--popon
|
||||
;; appear behind the auto-complete window, in case something
|
||||
;; happens
|
||||
@ -212,10 +212,10 @@ CANDIDATE is the same as for `corfu-popupinfo--show'. As this is meant to be
|
||||
|
||||
(defun ctp--move-away-from-eob ()
|
||||
"Ensure the point isn't too close to the end of the buffer."
|
||||
(if-let ((total-lines (count-lines (point-min) (point-max)))
|
||||
((> total-lines corfu-popupinfo-max-height))
|
||||
(rem-lines (count-lines (point) (point-max)))
|
||||
((< rem-lines corfu-popupinfo-max-height)))
|
||||
(if-let* ((total-lines (count-lines (point-min) (point-max)))
|
||||
((> total-lines corfu-popupinfo-max-height))
|
||||
(rem-lines (count-lines (point) (point-max)))
|
||||
((< rem-lines corfu-popupinfo-max-height)))
|
||||
(forward-line (- (- corfu-popupinfo-max-height rem-lines)))))
|
||||
|
||||
(defun ctp--corfu-popupinfo-scroll-up-advice
|
||||
|
||||
Reference in New Issue
Block a user