summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-05-16 01:41:35 +0100
committerjao <jao@gnu.org>2021-05-16 01:41:35 +0100
commitdebec7e4a401b0ae2d12923264db8adfa577f3c2 (patch)
tree5bc9805bcdf29e762f8c4a678f9be517c1d51a4e
parent55ee1d666e5d07cd1cbc71803366c91bf0292bfe (diff)
downloadelibs-debec7e4a401b0ae2d12923264db8adfa577f3c2.tar.gz
elibs-debec7e4a401b0ae2d12923264db8adfa577f3c2.tar.bz2
a very nice thing: narrowing w3m buffers
-rw-r--r--completion.org31
1 files changed, 31 insertions, 0 deletions
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