diff options
-rw-r--r-- | completion.org | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/completion.org b/completion.org index dcf844f..26d8b46 100644 --- a/completion.org +++ b/completion.org @@ -173,6 +173,45 @@ (add-to-list 'consult-config '(jao-consult-hunks :preview-key any)) (global-set-key (kbd "C-x v c") #'jao-consult-hunks)) #+end_src +*** narrow helpers + #+begin_src emacs-lisp + (defvar jao-consult-www-narrow nil) + + (defun jao-consult-initial-narrow () + (when (and jao-consult-www-narrow + (eq this-command #'consult-buffer) + (string-equal "Web" (jao-afio-current-frame))) + (setq unread-command-events + (append unread-command-events + (list jao-consult-www-narrow 32))))) + (add-hook 'minibuffer-setup-hook #'jao-consult-initial-narrow) + #+end_src +*** narrowing eww buffers + #+begin_src emacs-lisp + (with-eval-after-load "jao-eww-session" + (defvar jao-eww-consult-history nil) + (defvar jao-eww-buffer-source + (list :name "eww buffer" + :category 'eww-buffer + :hidden t + :narrow (cons ?e "eww") + :annotate (lambda (b) (get-text-property 0 'url b)) + :history 'jao-eww-consult-history + :action (lambda (b) + (jao-afio--goto-www) + (switch-to-buffer (get-text-property 0 'buffer b))) + :items + (lambda () + (seq-map (lambda (b) + (with-current-buffer b + (propertize (jao-eww-buffer-title) + 'buffer b + 'url (jao-eww--current-url)))) + (jao-eww-session--list-buffers))))) + + (add-to-list 'consult-buffer-sources 'jao-eww-buffer-source t) + (unless jao-afio-use-w3m (setq jao-consult-www-narrow ?e))) + #+end_src *** narrowing w3m buffers #+begin_src emacs-lisp (with-eval-after-load "w3m" @@ -194,15 +233,8 @@ 'buffer b 'url w3m-current-url))) (w3m-list-buffers))))) - - (defun jao-consult-initial-narrow () - (when (and (eq this-command #'consult-buffer) - (string-equal "Web" (jao-afio-current-frame))) - (setq unread-command-events - (append unread-command-events (list ?w 32))))) - - (add-hook 'minibuffer-setup-hook #'jao-consult-initial-narrow) - (add-to-list 'consult-buffer-sources 'jao-consult-w3m-source 'append)) + (when jao-afio-use-w3m (setq jao-consult-www-narrow ?w)) + (add-to-list 'consult-buffer-sources 'jao-consult-w3m-source t)) #+end_src * embark *** packages |