[elpa] externals/consult updated (ae90550 -> 8065178)

2021-06-12 Thread ELPA Syncer
elpasync pushed a change to branch externals/consult.

  from  ae90550   Update changelog
   new  d15f784   consult--read/consult--prompt: Add inherit-input-method 
(Fix #335)
   new  abc404d   Add preview debouncing (Fix #333)
   new  df440be   README/CHANGELOG: Update with regards to preview 
debouncing
   new  8065178   README: Document :inherit-input-method


Summary of changes:
 CHANGELOG.org |  2 ++
 README.org| 36 --
 consult.el| 83 ++-
 3 files changed, 89 insertions(+), 32 deletions(-)



[elpa] externals/consult abc404d 2/4: Add preview debouncing (Fix #333)

2021-06-12 Thread ELPA Syncer
branch: externals/consult
commit abc404d13e8f246a65ecd3e082828a226a440a04
Author: Daniel Mendler 
Commit: Daniel Mendler 

Add preview debouncing (Fix #333)
---
 consult.el | 63 +++---
 1 file changed, 48 insertions(+), 15 deletions(-)

diff --git a/consult.el b/consult.el
index e5f2320..9080307 100644
--- a/consult.el
+++ b/consult.el
@@ -1049,20 +1049,37 @@ FACE is the cursor face."
  (when (and cand restore)
(,(intern (format "consult--%s-action" type)) cand))
 
+(defun consult--preview-key-normalize (preview-key)
+  "Normalize PREVIEW-KEY, return alist of keys and debounce times."
+  (let ((keys)
+(debounce 0))
+(unless (listp preview-key)
+  (setq preview-key (list preview-key)))
+(while preview-key
+  (if (eq (car preview-key) :debounce)
+  (setq debounce (cadr preview-key)
+preview-key (cddr preview-key))
+(push (cons (car preview-key) debounce) keys)
+(pop preview-key)))
+keys))
+
 (defun consult--preview-key-pressed-p (preview-key cand)
   "Return t if PREVIEW-KEY has been pressed given the current candidate CAND."
   (when (and (consp preview-key) (memq :keys preview-key))
 (setq preview-key (funcall (plist-get preview-key :predicate) cand)))
-  (setq preview-key (if (listp preview-key) preview-key (list preview-key)))
-  (or (memq 'any preview-key)
-  (let ((keys (this-single-command-keys)))
-(seq-find (lambda (x) (equal (vconcat x) keys)) preview-key
+  (setq preview-key (consult--preview-key-normalize preview-key))
+  (let ((keys (this-single-command-keys)))
+(cdr (or (seq-find (lambda (x)
+ (and (not (eq (car x) 'any))
+  (equal (vconcat (car x)) keys)))
+   preview-key)
+ (assq 'any preview-key)
 
 (defun consult--with-preview-1 (preview-key state transform candidate fun)
   "Add preview support for FUN.
 
 See `consult--with-preview' for the arguments PREVIEW-KEY, STATE, TRANSFORM 
and CANDIDATE."
-  (let ((input "") (selected))
+  (let ((input "") (selected) (timer))
 (consult--minibuffer-with-setup-hook
 (if (and state preview-key)
 (lambda ()
@@ -1071,14 +1088,28 @@ See `consult--with-preview' for the arguments 
PREVIEW-KEY, STATE, TRANSFORM and
   (lambda ()
 (when-let (cand (funcall candidate))
   (with-selected-window (active-minibuffer-window)
-(let ((input (minibuffer-contents-no-properties))
-  (new-preview (cons input cand)))
-  (unless (equal last-preview new-preview)
-(with-selected-window (or 
(minibuffer-selected-window) (next-window))
-  (let ((transformed (funcall transform input 
cand)))
-(when (consult--preview-key-pressed-p 
preview-key transformed)
-  (funcall state transformed nil)
-  (setq last-preview new-preview)))
+(let ((input (minibuffer-contents-no-properties)))
+  (with-selected-window (or 
(minibuffer-selected-window) (next-window))
+(let ((transformed (funcall transform input 
cand))
+  (new-preview (cons input cand)))
+  (when-let (debounce 
(consult--preview-key-pressed-p preview-key transformed))
+(when timer
+  (cancel-timer timer)
+  (setq timer nil))
+(unless (equal last-preview new-preview)
+  (if (> debounce 0)
+  (let ((win (selected-window)))
+(setq timer
+  (run-at-time
+   debounce
+   nil
+   (lambda ()
+ (when (window-live-p win)
+   (with-selected-window 
win
+ (funcall state 
transformed nil)
+ (setq last-preview 
new-preview)))
+(funcall state transformed nil)
+(setq last-preview 
new-preview
   (let ((post-command-sym (make-symbol 
"consult--preview-post-command")))
 (fset post-command-sym (lambda

[elpa] externals/consult d15f784 1/4: consult--read/consult--prompt: Add inherit-input-method (Fix #335)

2021-06-12 Thread ELPA Syncer
branch: externals/consult
commit d15f784ca4e1e587fefde9fccdd5288daaf296ad
Author: Daniel Mendler 
Commit: Daniel Mendler 

consult--read/consult--prompt: Add inherit-input-method (Fix #335)
---
 consult.el | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/consult.el b/consult.el
index 6c03b39..e5f2320 100644
--- a/consult.el
+++ b/consult.el
@@ -1714,7 +1714,7 @@ PREVIEW-KEY is the preview key."
 (cl-defun consult--read-1 (candidates &key
   prompt predicate require-match history 
default
   keymap category initial narrow 
add-history annotate
-  state preview-key sort lookup title 
group)
+  state preview-key sort lookup title 
group inherit-input-method)
   "See `consult--read' for the documentation of the arguments."
   (when title
 (message "Deprecation: `%s' passed obsolete :title argument to 
`consult--read'" this-command)
@@ -1754,7 +1754,8 @@ PREVIEW-KEY is the preview key."
  (complete-with-action action (funcall 
async nil) str pred)))
  predicate require-match initial
  (if (symbolp history) history (cadr history))
- default
+ default
+ inherit-input-method
 (pcase-exhaustive history
   (`(:input ,var)
(set var (cdr (symbol-value var)))
@@ -1765,7 +1766,7 @@ PREVIEW-KEY is the preview key."
 (cl-defun consult--read (candidates &rest options &key
   prompt predicate require-match history 
default
   keymap category initial narrow 
add-history annotate
-  state preview-key sort lookup title 
group)
+  state preview-key sort lookup title 
group inherit-input-method)
   "Enhanced completing read function selecting from CANDIDATES.
 
 Keyword OPTIONS:
@@ -1785,7 +1786,8 @@ STATE is the state function, see `consult--with-preview'.
 GROUP is a completion metadata `group-function'.
 PREVIEW-KEY are the preview keys (nil, 'any, a single key or a list of keys).
 NARROW is an alist of narrowing prefix strings and description.
-KEYMAP is a command-specific keymap."
+KEYMAP is a command-specific keymap.
+INHERIT-INPUT-METHOD, if non-nil the minibuffer inherits the input method."
   ;; supported types
   (cl-assert (or (functionp candidates) ;; async table
  (obarrayp candidates)  ;; obarray
@@ -1796,7 +1798,7 @@ KEYMAP is a command-specific keymap."
  (and (consp (car candidates)) (symbolp (caar candidates) 
;; symbol alist
   (ignore prompt predicate require-match history default
   keymap category initial narrow add-history annotate
-  state preview-key sort lookup title group)
+  state preview-key sort lookup title group inherit-input-method)
   (apply #'consult--read-1 candidates
  (append
   (alist-get this-command consult--read-config)
@@ -1981,7 +1983,7 @@ Optional source fields:
  Internal API: consult--prompt
 
 (cl-defun consult--prompt-1 (&key prompt history add-history initial default
-  keymap state preview-key transform)
+  keymap state preview-key transform 
inherit-input-method)
   "See `consult--prompt' for documentation."
   (consult--minibuffer-with-setup-hook
   (:append (lambda ()
@@ -1990,10 +1992,10 @@ Optional source fields:
  (apply-partially #'consult--add-history nil 
add-history
 (car (consult--with-preview preview-key state
 (lambda (inp _) (funcall transform inp)) 
(lambda () t)
-   (read-from-minibuffer prompt initial nil nil history default)
+   (read-from-minibuffer prompt initial nil nil history default 
inherit-input-method)
 
 (cl-defun consult--prompt (&rest options &key prompt history add-history 
initial default
- keymap state preview-key transform)
+ keymap state preview-key transform 
inherit-input-method)
   "Read from minibuffer.
 
 Keyword OPTIONS:
@@ -2008,7 +2010,7 @@ STATE is the state function, see `consult--with-preview'.
 PREVIEW-KEY are the preview keys (nil, 'any, a single key or a list of keys).
 KEYMAP is a command-specific keymap."
   (ignore prompt history add-history initial default
-  keymap state preview-key transform)
+  keymap state preview-key transform inherit-input-method)
   (apply #'consult--prompt-1
  (append
   (alist-get this-command consult--read-config)



[elpa] externals/consult 8065178 4/4: README: Document :inherit-input-method

2021-06-12 Thread ELPA Syncer
branch: externals/consult
commit 80651785f204de7e0ed23b10fff69e4c4a33a213
Author: Daniel Mendler 
Commit: Daniel Mendler 

README: Document :inherit-input-method
---
 README.org | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.org b/README.org
index 826fe2a..f949181 100644
--- a/README.org
+++ b/README.org
@@ -940,7 +940,8 @@ contributed.
  - =:history= set the history variable symbol
  - =:add-history= add items to the future history, for example symbol at point
  - =:sort= enable or disable sorting
- - =:group= set to nil in order to disable candidate grouping and titles.
+ - =:group= set to nil to disable candidate grouping and titles.
+ - =:inherit-input-method= set to non-nil to inherit the input method.
 
  #+begin_src emacs-lisp
(consult-customize



[elpa] externals/consult df440be 3/4: README/CHANGELOG: Update with regards to preview debouncing

2021-06-12 Thread ELPA Syncer
branch: externals/consult
commit df440be557358b2dae733440ca17f555230e583f
Author: Daniel Mendler 
Commit: Daniel Mendler 

README/CHANGELOG: Update with regards to preview debouncing
---
 CHANGELOG.org |  2 ++
 README.org| 33 ++---
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index c00d066..71f8970 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -5,6 +5,8 @@
 * Development version
 
 - Add =consult-preview-excluded-hooks=
+- =consult--read/consult--prompt=: Add =:inherit-input-method= argument
+- Add debouncing support for preview
 
 * Version 0.8 (2021-05-30)
 
diff --git a/README.org b/README.org
index f51d7b2..826fe2a 100644
--- a/README.org
+++ b/README.org
@@ -405,14 +405,19 @@ their descriptions.
  =consult-preview-key= variable. Furthermore it is possible to specify
  keybindings which trigger the preview manually as shown in the 
[[#use-package-example][example
  configuration]]. The default setting of =consult-preview-key= is =any= which
- means that the preview will be triggered on any keypress when the selected
- candidate changes. Each command can be configured individually with its own
- =:preview-key=, such that preview can be manual for some commands, for some
- commands automatic and for some commands completely disabled.
+ means that the preview will be triggered /immediately/ on any keypress when 
the
+ selected candidate changes. Each command can be configured individually with
+ its own =:preview-key=. The preview key can be configured to be:
 
- A safe recommendation is to leave automatic previews enabled in general and
- disable the automatic preview only for commands, where the preview may be
- expensive due to file loading.
+ - Automatic and immediate =any=
+ - Automatic and delayed =(:debounce 0.5 any)=
+ - Manual and immediate =(kbd "M-.")=
+ - Manual and delayed =(list :debounce 0.5 (kbd "M-."))=
+ - Disabled =nil=
+
+ A safe recommendation is to leave automatic immediate previews enabled in
+ general and disable the automatic preview only for commands, where the preview
+ may be expensive due to file loading.
 
  #+begin_src emacs-lisp
(consult-customize
@@ -431,6 +436,20 @@ their descriptions.
  are previewed literally without syntax highlighting and without changing the
  major mode.
 
+ Delaying the preview is particularily useful for =consult-theme=, since the 
theme
+ preview is a little bit slow. The delay can result in a smoother UI.
+
+ #+begin_src emacs-lisp
+   ;; Preview on any key press, but delay 0.5s
+   (consult-customize consult-theme :preview-key '(:debounce 0.5 any))
+   ;; Preview immediately on M-., on up/down after 0.5s, on any other key 
after 1s
+   (consult-customize consult-theme
+  :preview-key
+  (list (kbd "M-.")
+:debounce 0.5 (kbd "") (kbd "")
+:debounce 1 any))
+ #+end_src
+
 ** Narrowing and grouping
:properties:
:description: Restricting the completion to a candidate group



[elpa] externals/consult 1187937: README: Simplify recommended configuration

2021-06-12 Thread ELPA Syncer
branch: externals/consult
commit 118793723a0b3dd999be21182512dcfd5d1ead2e
Author: Daniel Mendler 
Commit: Daniel Mendler 

README: Simplify recommended configuration
---
 README.org | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/README.org b/README.org
index f949181..ea7f057 100644
--- a/README.org
+++ b/README.org
@@ -607,8 +607,9 @@ their descriptions.
   perform preview.
 
   #+begin_src emacs-lisp
-  (dolist (src '(consult--source-file consult--source-project-file 
consult--source-bookmark))
-(set src (plist-put (symbol-value src) :preview-key (kbd "M-."
+(consult-customize
+ consult--source-file consult--source-project-file consult--source-bookmark
+ :preview-key (kbd "M-."))
   #+end_src
 
   Sources can be added directly to the =consult-buffer-source= list for