[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-posframe cef74e6 021/195: Different command can set
From: |
Feng Shu |
Subject: |
[elpa] externals/ivy-posframe cef74e6 021/195: Different command can set different ivy-posframe display function |
Date: |
Sat, 3 Oct 2020 07:11:37 -0400 (EDT) |
branch: externals/ivy-posframe
commit cef74e68eaa4629f7c31e5b7038ef721f70aae21
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
Different command can set different ivy-posframe display function
---
README.md | 41 +++++++++++++++++++++++++++++------------
ivy-posframe.el | 52 +++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 74 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index 96fe711..f82096e 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,18 @@
# 目录
-1. [ivy-posframe README](#org517c951)
- 1. [What is ivy-posframe](#org153958a)
- 2. [How to enable ivy-posframe](#orgfb35379)
- 3. [How to set the style of ivy-posframe](#orgdd1e7a6)
+1. [ivy-posframe README](#org7b266e1)
+ 1. [What is ivy-posframe](#org1c5b744)
+ 2. [Display functions](#org2ebfad6)
+ 3. [How to enable ivy-posframe](#orgf7e39d4)
-<a id="org517c951"></a>
+<a id="org7b266e1"></a>
# ivy-posframe README
-<a id="org153958a"></a>
+<a id="org1c5b744"></a>
## What is ivy-posframe
@@ -22,7 +22,19 @@ to show its candidate menu.
NOTE: ivy-posframe requires Emacs 26
-<a id="orgfb35379"></a>
+<a id="org2ebfad6"></a>
+
+## Display functions
+
+1. ivy-posframe-display
+2. ivy-posframe-display-at-frame-center
+3. ivy-posframe-display-at-window-center
+4. ivy-posframe-display-at-frame-buttom-left
+5. ivy-posframe-display-at-window-buttom-left
+6. ivy-posframe-display-at-point
+
+
+<a id="orgf7e39d4"></a>
## How to enable ivy-posframe
@@ -30,19 +42,24 @@ NOTE: ivy-posframe requires Emacs 26
(require 'ivy-posframe)
(setq ivy-display-function #'ivy-posframe-display)
+ ;; (setq ivy-display-function #'ivy-posframe-display-at-frame-center)
+ ;; (setq ivy-display-function #'ivy-posframe-display-at-window-center)
+ ;; (setq ivy-display-function
#'ivy-posframe-display-at-frame-buttom-left)
+ ;; (setq ivy-display-function
#'ivy-posframe-display-at-window-buttom-left)
+ ;; (setq ivy-display-function #'ivy-posframe-display-at-point)
2. Per-command mode.
(require 'ivy-posframe)
- (push '(counsel-M-x . ivy-posframe-display)
ivy-display-functions-alist)
+ ;; Different command can use different display function.
+ (push '(counsel-M-x . ivy-posframe-display-at-window-buttom-left)
ivy-display-functions-alist)
+ (push '(complete-symbol . ivy-posframe-display-at-point)
ivy-display-functions-alist)
3. Fallback mode
(require 'ivy-posframe)
(push '(t . ivy-posframe-display) ivy-display-functions-alist)
-
-<a id="orgdd1e7a6"></a>
-
-## How to set the style of ivy-posframe
+If you use \`ivy-posframe-display', you can use \`ivy-posframe-style'
+to set show style.
1. window-buttom-left style
diff --git a/ivy-posframe.el b/ivy-posframe.el
index 0724122..10b6b18 100644
--- a/ivy-posframe.el
+++ b/ivy-posframe.el
@@ -34,16 +34,32 @@
;; NOTE: ivy-posframe requires Emacs 26
+;; ** Display functions
+
+;; 1. ivy-posframe-display
+;; 2. ivy-posframe-display-at-frame-center
+;; 3. ivy-posframe-display-at-window-center
+;; 4. ivy-posframe-display-at-frame-buttom-left
+;; 5. ivy-posframe-display-at-window-buttom-left
+;; 6. ivy-posframe-display-at-point
+
;; ** How to enable ivy-posframe
;; 1. Global mode
;; #+BEGIN_EXAMPLE
;; (require 'ivy-posframe)
;; (setq ivy-display-function #'ivy-posframe-display)
+;; ;; (setq ivy-display-function #'ivy-posframe-display-at-frame-center)
+;; ;; (setq ivy-display-function #'ivy-posframe-display-at-window-center)
+;; ;; (setq ivy-display-function
#'ivy-posframe-display-at-frame-buttom-left)
+;; ;; (setq ivy-display-function
#'ivy-posframe-display-at-window-buttom-left)
+;; ;; (setq ivy-display-function #'ivy-posframe-display-at-point)
;; #+END_EXAMPLE
;; 2. Per-command mode.
;; #+BEGIN_EXAMPLE
;; (require 'ivy-posframe)
-;; (push '(counsel-M-x . ivy-posframe-display) ivy-display-functions-alist)
+;; ;; Different command can use different display function.
+;; (push '(counsel-M-x . ivy-posframe-display-at-window-buttom-left)
ivy-display-functions-alist)
+;; (push '(complete-symbol . ivy-posframe-display-at-point)
ivy-display-functions-alist)
;; #+END_EXAMPLE
;; 3. Fallback mode
;; #+BEGIN_EXAMPLE
@@ -51,7 +67,9 @@
;; (push '(t . ivy-posframe-display) ivy-display-functions-alist)
;; #+END_EXAMPLE
-;; ** How to set the style of ivy-posframe
+;; If you use `ivy-posframe-display', you can use `ivy-posframe-style'
+;; to set show style.
+
;; 1. window-buttom-left style
;; #+BEGIN_EXAMPLE
;; (setq ivy-posframe-style 'window-buttom-left)
@@ -75,9 +93,14 @@
(require 'posframe)
(require 'ivy)
-(push '(ivy-posframe-display
- :cleanup ivy-posframe-cleanup)
- ivy-display-functions-props)
+(dolist (f '(ivy-posframe-display
+ ivy-posframe-display-at-frame-center
+ ivy-posframe-display-at-window-center
+ ivy-posframe-display-at-frame-buttom-left
+ ivy-posframe-display-at-window-buttom-left
+ ivy-posframe-display-at-point))
+ (push `(,f :cleanup ivy-posframe-cleanup)
+ ivy-display-functions-props))
(defgroup ivy-posframe nil
"Using posframe to show ivy"
@@ -114,7 +137,7 @@ When nil, Using current frame's font as fallback."
;; Fix warn
(defvar emacs-basic-display)
-(defun ivy-posframe-display (str)
+(defun ivy-posframe-display (str &optional style)
"Show STR in ivy's posframe."
(if (not (ivy-posframe-workable-p))
(ivy-display-function-fallback str)
@@ -126,7 +149,7 @@ When nil, Using current frame's font as fallback."
(with-current-buffer (get-buffer-create " *Minibuf-1*")
(concat (buffer-string) " " str))
:position (point)
- :poshandler (cdr (assq ivy-posframe-style
+ :poshandler (cdr (assq (or style ivy-posframe-style)
ivy-posframe-style-alist))
:background-color (face-attribute 'ivy-posframe :background)
:foreground-color (face-attribute 'ivy-posframe :foreground)
@@ -134,6 +157,21 @@ When nil, Using current frame's font as fallback."
:min-height 10
:min-width 50))))
+(defun ivy-posframe-display-at-window-center (str)
+ (ivy-posframe-display str 'window-center))
+
+(defun ivy-posframe-display-at-frame-center (str)
+ (ivy-posframe-display str 'frame-center))
+
+(defun ivy-posframe-display-at-window-buttom-left (str)
+ (ivy-posframe-display str 'window-buttom-left))
+
+(defun ivy-posframe-display-at-frame-buttom-left (str)
+ (ivy-posframe-display str 'frame-buttom-left))
+
+(defun ivy-posframe-display-at-point (str)
+ (ivy-posframe-display str 'point))
+
(defun ivy-posframe-cleanup ()
"Cleanup ivy's posframe."
(when (ivy-posframe-workable-p)
- [elpa] externals/ivy-posframe fc0820a 009/195: Update, (continued)
- [elpa] externals/ivy-posframe fc0820a 009/195: Update, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 1651770 012/195: Update, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 6494b38 005/195: Add ivy-posframe-mode, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 8a54dbb 011/195: Use ivy-display-function-fallback, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 8a3ecb3 014/195: package-require ivy, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 0136107 015/195: Remove ivy-posframe-mode, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 2546238 016/195: reuse minibuffer's ivy prompt, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 9db2b75 017/195: Update README, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 550c322 018/195: Fix warn, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe c36250a 013/195: Update README, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe cef74e6 021/195: Different command can set different ivy-posframe display function,
Feng Shu <=
- [elpa] externals/ivy-posframe 5482c07 024/195: Update README, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 1f3dbf4 026/195: Add ivy-posframe-setup and use it., Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 0be1372 029/195: Remove ivy-posframe-style variable, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 387045c 032/195: Fix README, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 26a7ba7 036/195: Add ivy-posframe-enable and use it, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe b9b9a45 038/195: Update, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 9f6b58d 040/195: Cursor face inherits from regular cursor face, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 266d622 042/195: Set ivy-posframe-cursor as mulitcursor, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe 061a125 030/195: Re-add ivy-posframe-style for compatible, Feng Shu, 2020/10/03
- [elpa] externals/ivy-posframe e0247bf 035/195: split ivy-posframe-setup to ivy-posframe-init and ivy-posframe-setup, Feng Shu, 2020/10/03