[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-posframe 556c9a9 161/195: Check (display-graphic-p)
From: |
Feng Shu |
Subject: |
[elpa] externals/ivy-posframe 556c9a9 161/195: Check (display-graphic-p) dynamically in advices |
Date: |
Sat, 3 Oct 2020 07:12:05 -0400 (EDT) |
branch: externals/ivy-posframe
commit 556c9a960c902164ef4fe059dfa6f3b19d9154dc
Author: Gerry Agbobada <10496163+gagbo@users.noreply.github.com>
Commit: Gerry Agbobada <gerry.agbobada@external.engie.com>
Check (display-graphic-p) dynamically in advices
Add an advice for all ivy-posframe-advices
With this advice, we can wrap all ivy-posframe-advice with a function
which will bypass ivy-posframe for any predicate we would like.
(display-graphic-p) is hardcoded for now, but it's unlikely to change.
---
ivy-posframe.el | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/ivy-posframe.el b/ivy-posframe.el
index 5392f6e..63c5906 100644
--- a/ivy-posframe.el
+++ b/ivy-posframe.el
@@ -467,6 +467,20 @@ selection, non-nil otherwise."
;;; Advice
+(defun ivy-posframe--posframe-p-advice (advice-fn &rest args)
+ "Advice function of ADVICE-FN, used to bypass the advice from
+`ivy-posframe-advice-alist' if the posframe cannot be displayed.
+
+ADVICE-FN should be a value from `ivy-posframe-advice-alist', but
+the function only errors if ARGS is empty. There should at least be
+the advised function there (a key from `ivy-posframe-advice-alist')."
+ (unless (< 0 (length args))
+ (error "This function should advise an advice, so args should be at least
a key from ivy-posframe-advice-alist"))
+ (if (display-graphic-p)
+ (apply advice-fn args)
+ (apply (car args) (cdr args)))
+ )
+
(defun ivy-posframe--minibuffer-setup (fn &rest args)
"Advice function of FN, `ivy--minibuffer-setup' with ARGS."
(let ((ivy-fixed-height-minibuffer nil))
@@ -532,10 +546,14 @@ selection, non-nil otherwise."
(let ((advices ivy-posframe-advice-alist))
(if ivy-posframe-mode
(mapcar (lambda (elm)
- (advice-add (car elm) :around (cdr elm)))
+ (progn
+ (advice-add (cdr elm) :around
'ivy-posframe--posframe-p-advice)
+ (advice-add (car elm) :around (cdr elm))))
advices)
(mapcar (lambda (elm)
- (advice-remove (car elm) (cdr elm)))
+ (progn
+ (advice-remove (cdr elm) 'ivy-posframe--posframe-p-advice)
+ (advice-remove (car elm) (cdr elm))))
advices))))
;;;###autoload
- [elpa] externals/ivy-posframe 1794866 170/195: not use let variable to make code simple, (continued)
- [elpa] externals/ivy-posframe 1794866 170/195: not use let variable to make code simple, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 65bc90d 151/195: fix minor mode option, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 2f2c7f6 154/195: Merge pull request #48 from tttuuu888/work-list, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 187288c 167/195: accept declare form, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe d9ceee9 181/195: Fix: Regression : not usable with tty and gui emacsen under same daemon #69, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe aadadf1 185/195: Merge pull request #73 from tttuuu888/work-issue-71-2, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 85f2f7a 184/195: Fix for prompt line duplicated issue in another way. #71, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 61cb32e 192/195: Fix swiper-avy and ivy-posframe are having trouble #80, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe ad83ce5 189/195: Merge pull request #79 from xeijin/patch-1, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 4474956 194/195: let ivy-posframe-swiper-avy work when do not use ivy-posframe function, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 556c9a9 161/195: Check (display-graphic-p) dynamically in advices,
Feng Shu <=
- [elpa] externals/ivy-posframe 46b4089 081/195: Merge pull request #33 from conao3/issue/remove-top-level-setup-executing, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe f5da408 157/195: remove ivy-display-function, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe c9a7331 143/195: handle ivy-display-function, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 45dc8ee 137/195: Remove ivy-posframe-demo, ivy-posframe-mode can do same job, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 9872f35 135/195: Merge pull request #43 from conao3/ivy-posframe-mode, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 7e33255 134/195: not use macro, write all form, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 2a97933 155/195: Fix for `Error in post-command-hook ...`, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 7be71b6 126/195: fix align, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 3433b00 077/195: Merge pull request #29 from CeleritasCelery/recursive-fix, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe d13ad21 111/195: fix argument issue, Feng Shu, 2020/10/03