From debec7e4a401b0ae2d12923264db8adfa577f3c2 Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 16 May 2021 01:41:35 +0100 Subject: a very nice thing: narrowing w3m buffers --- completion.org | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/completion.org b/completion.org index 0be5a47..29b85a3 100644 --- a/completion.org +++ b/completion.org @@ -199,6 +199,37 @@ (add-to-list 'consult-config '(jao-consult-hunks :preview-key any)) (global-set-key (kbd "C-x v c") #'jao-consult-hunks)) #+end_src +*** narrowing w3m buffers + #+begin_src emacs-lisp + (with-eval-after-load "w3m" + (defvar jao-consult-w3m-buffer-history nil) + (setq jao-consult-w3m-source + (list :name "w3m buffer" + :category 'w3m-buffer + :hidden t + :narrow (cons ?w "w3m") + :annotate (lambda (b) (get-text-property 0 'url b)) + :history 'jao-consult-w3m-buffer-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 w3m-current-title + '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)) + #+end_src * embark *** packages #+begin_src emacs-lisp -- cgit v1.2.3