diff options
-rw-r--r-- | completion.org | 5 | ||||
-rw-r--r-- | w3m.org | 28 |
2 files changed, 19 insertions, 14 deletions
diff --git a/completion.org b/completion.org index 7b30f3b..b5a6e2e 100644 --- a/completion.org +++ b/completion.org @@ -407,6 +407,7 @@ (defun jao-embark-targets--play-video (player url) (interactive "sURL: ") (let ((cmd (format "%s %s" player (shell-quote-argument url)))) + (jao-afio--goto-www) (start-process-shell-command player nil cmd))) (defun jao-embark-targets-mpv (&optional url) @@ -422,8 +423,8 @@ (embark-define-keymap jao-embark-targets-video-url-map "Actions on URLs pointing to remote video streams." :parent embark-url-map - ("RET" jao-embark-targets-mpv) - ("v" jao-embark-targets-vlc)) + ("v" jao-embark-targets-mpv) + ("RET" jao-embark-targets-vlc)) (add-to-list 'embark-transformer-alist '(url . jao-embark-targets--refine-url)) (add-to-list 'embark-keymap-alist '(video-url . jao-embark-targets-video-url-map)) @@ -67,28 +67,32 @@ (kill-new (format "[[doc:%s][%s]] ([[%s][original]])" basename title url)))) #+end_src -* Narrowing +* Consult narrowing #+begin_src emacs-lisp (with-eval-after-load "w3m-util" (with-eval-after-load "consult" (defvar jao-consult-w3m-buffer-history nil) + (defun jao-www--buffer-p (b) + (or (eq 'w3m-mode (buffer-local-value 'major-mode b)) + (member (buffer-local-value 'exwm-class-name b) '("vlc" "mpv")))) + (defun jao-www--item (b) + (with-current-buffer b + (propertize (or w3m-current-title (buffer-name)) + 'buffer b + 'url (or w3m-current-url (buffer-name))))) (defvar jao-consult-w3m-source - (list :name "w3m buffer" - :category 'w3m-buffer + (list :name "www buffer" + :category 'www-buffer :hidden t - :narrow (cons ?w "w3m") + :narrow (cons ?w "www") :annotate (lambda (b) (when b (get-text-property 0 'url b))) :history 'jao-consult-w3m-buffer-history + :items (lambda () + (seq-map #'jao-www--item + (seq-filter #'jao-www--buffer-p (buffer-list)))) :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 (or w3m-current-title "") - 'buffer b - 'url w3m-current-url))) - (w3m-list-buffers))))) + (pop-to-buffer (get-text-property 0 'buffer b))))) (jao-consult-add-buffer-source 'jao-consult-w3m-source "Web" ?w))) #+end_src * Package |