about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.emacs.d/lisp/init-minibuffer.el34
1 files changed, 18 insertions, 16 deletions
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el
index 5453050..4aa1f4c 100644
--- a/.emacs.d/lisp/init-minibuffer.el
+++ b/.emacs.d/lisp/init-minibuffer.el
@@ -141,7 +141,13 @@
          :map isearch-mode-map
          ("M-e" . consult-isearch)                 ;; orig. isearch-edit-string
          ("M-s e" . consult-isearch)               ;; orig. isearch-edit-string
-         ("M-s l" . consult-line))                 ;; needed by consult-line to detect isearch
+         ("M-s l" . consult-line)                  ;; needed by consult-line to detect isearch
+         (:map vertico-map
+               ;; These are used for previewing with some consult commands (see consult-customize call below)
+               ("C-S-p" . vertico-previous)
+               ("C-S-n" . vertico-next)
+               ;; Toggle preview on/off without changing preview-key
+               ("M-P" . consult-toggle-preview)))
 
   :init
 
@@ -228,29 +234,26 @@
   (define-key search-map "u" 'consult-focus-lines)
   (define-key search-map "e" 'consult-isearch)
 
-  ;; Optionally configure preview. The default value
-  ;; is 'any, such that any key triggers the preview.
-  ;; (setq consult-preview-key 'any)
-  ;; (setq consult-preview-key (kbd "M-."))
-  ;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
-  ;; For some commands and buffer sources it is useful to configure the
-  ;; :preview-key on a per-command basis using the `consult-customize' macro.
   (consult-customize
    consult-theme
    :preview-key '(:debounce 0.2 any)
+   ;; For these commands we can use C-S/C-P to scoll and preview, or M-. to preview
    consult-ripgrep consult-git-grep consult-grep
    consult-ripgrep-unrestricted consult-ripgrep-symbol-at-point
    consult-bookmark consult-recent-file consult-xref consult-buffer-no-preview
    consult--source-file consult--source-project-file consult--source-bookmark
-   :preview-key (kbd "M-."))
+   :preview-key (list (kbd "M-.") (kbd "C-S-n") (kbd "C-S-p")))
 
-  ;; Optionally configure the narrowing key.
-  ;; Both < and C-+ work reasonably well.
-  (setq consult-narrow-key "<") ;; (kbd "C-+")
+  (defun consult-toggle-preview ()
+    "Command to enable/disable preview."
+    (interactive)
+    (if consult-toggle-preview-orig
+        (setq consult--preview-function consult-toggle-preview-orig
+              consult-toggle-preview-orig nil)
+      (setq consult-toggle-preview-orig consult--preview-function
+            consult--preview-function #'ignore)))
 
-  ;; Optionally make narrowing help available in the minibuffer.
-  ;; You may want to use `embark-prefix-help-command' or which-key instead.
-  ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
+  (setq consult-narrow-key "<")
 
   (setq consult-project-root-function
         (lambda ()
@@ -365,7 +368,6 @@
   :init
   (setq prefix-help-command #'embark-prefix-help-command)
   :config
-  ;; (define-key minibuffer-local-map (kbd "M-.") #'embark-preview)
   (defun embark-preview ()
     (interactive)
     (unless (bound-and-true-p consult--preview-function) ;; Disable preview for Consult commands
' href='#n196'>196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362