Closed sincebyte closed 3 years ago
Yoy can define a function like that:
(defun ejc-connect-ivy ()
(interactive)
(let* ((conn-list (mapcar 'car ejc-connections))
(conn-statistics (ejc-load-conn-statistics))
(conn-list-sorted (-sort (lambda (c1 c2)
(> (or (lax-plist-get conn-statistics c1) 0)
(or (lax-plist-get conn-statistics c2) 0)))
conn-list)))
(ivy-read "DataBase connection name: " conn-list-sorted
:keymap ivy-minibuffer-map
:preselect (car conn-list-sorted)
:action #'ejc-connect)))
Then use it just like ejc-connect
in any sql-mode
/org-mode
buffers: M-x ejc-connect-ivy
You can also change the two instances of ido-completing-read
to completing-read
in the ejc-sql.el file and it should work with any completion framework.
@kostafey is there a reason ido is hardcoded?
@tpeacock19 as far as I see, I can't use flx-ido
if ido-completing-read
is replaced by completing-read
despite this settings:
(ido-mode 1)
(ido-everywhere 1)
(flx-ido-mode 1)
The reason for ido
is it's flx
fuzzy matching engine, which is handy. But ok, it's only my habits, so it's worth to use modern completion frameworks for most of the users.
The solution may look like this:
+(defalias 'ejc-completing-read 'completing-read)
+
(defun ejc-read-connection-name ()
"Read connection-name in minibuffer."
- (ido-completing-read
+ (ejc-completing-read
...
so, to keep backward compatibility, one can set in personal .emacs
a setting like that:
(defalias 'ejc-completing-read 'ido-completing-read)
Furthermore, fell free to make a pull request if you agree with this idea.
Thank you,ejc-sql is so cool~
Fixed.
Yoy can define a function like that:
(defun ejc-connect-ivy () (interactive) (let* ((conn-list (mapcar 'car ejc-connections)) (conn-statistics (ejc-load-conn-statistics)) (conn-list-sorted (-sort (lambda (c1 c2) (> (or (lax-plist-get conn-statistics c1) 0) (or (lax-plist-get conn-statistics c2) 0))) conn-list))) (ivy-read "DataBase connection name: " conn-list-sorted :keymap ivy-minibuffer-map :preselect (car conn-list-sorted) :action #'ejc-connect)))
Then use it just like
ejc-connect
in anysql-mode
/org-mode
buffers: M-x ejc-connect-ivy
Thanks for your ejc-connect-ivy function, I have used it for a long time. However, there is a problem in my emacs environment. And the problem is that I must execute ejc-connect first, otherwise the system shows "let*: Symbol’s value as variable is void: ejc-connections". How to achieve my goal by only executing 'ejc-connect-ivy' rather than executing 2 steps.
Is it possible to use the ivy plugin when M-x ejc-connect choose. Can you give an example about the config?