summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-05-20 06:13:31 +0100
committerjao <jao@gnu.org>2021-05-20 06:13:31 +0100
commitc29f6653150081aafa1ddcb7d6518cccb464b7c2 (patch)
tree19213708d62fbf396a389ba3f38aa1f6cab22324
parent64087b0f9620c0273d5258430f4c1f73b783f49f (diff)
downloadelibs-c29f6653150081aafa1ddcb7d6518cccb464b7c2.tar.gz
elibs-c29f6653150081aafa1ddcb7d6518cccb464b7c2.tar.bz2
eww/w3m consult narrowing refactored
-rw-r--r--completion.org66
-rw-r--r--eww.org28
-rw-r--r--init.org7
-rw-r--r--w3m.org24
4 files changed, 66 insertions, 59 deletions
diff --git a/completion.org b/completion.org
index 5c1a050..741bb26 100644
--- a/completion.org
+++ b/completion.org
@@ -175,66 +175,20 @@
#+end_src
*** narrow helpers
#+begin_src emacs-lisp
- (defvar jao-consult-www-narrow nil)
+ (defvar jao-consult-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)))
+ (when (eq this-command #'consult-buffer)
+ (when-let (c (cdr (assoc (jao-afio-current-frame) jao-consult-narrow)))
(setq unread-command-events
- (append unread-command-events `(,jao-consult-www-narrow 32)))))
+ (append unread-command-events `(,c 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 (c) (get-text-property 0 'url c))
- :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
- (let ((tl (or (jao-eww-buffer-title) ""))
- (url (or (jao-eww--current-url) "<no url>")))
- (propertize (if (string-blank-p tl) url tl)
- 'buffer b 'url 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"
- (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)))))
- (when jao-afio-use-w3m (setq jao-consult-www-narrow ?w))
- (add-to-list 'consult-buffer-sources 'jao-consult-w3m-source t))
+
+ (defun jao-consult-add-buffer-source (src &optional aframe key)
+ (add-to-list 'consult-buffer-sources src t)
+ (when (and aframe key)
+ (add-to-list 'jao-consult-narrow (cons aframe key))))
#+end_src
* embark
*** packages
diff --git a/eww.org b/eww.org
index e2e9ae5..0dd04bb 100644
--- a/eww.org
+++ b/eww.org
@@ -52,6 +52,34 @@
(eww-reload t))
(call-interactively 'eww-reload)))
#+end_src
+* Consult narrowing
+ #+begin_src emacs-lisp
+ (with-eval-after-load "consult"
+ (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 (c) (get-text-property 0 'url c))
+ :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
+ (let ((tl (or (plist-get eww-data :title) ""))
+ (url (or (eww-current-url) "<no url>")))
+ (propertize (if (string-blank-p tl) url tl)
+ 'buffer b 'url url))))
+ (seq-filter (lambda (b)
+ (eq 'eww-mode
+ (buffer-local-value 'major-mode b)))
+ (buffer-list))))))
+ (jao-consult-add-buffer-source jao-eww-buffer-source "Web" ?e))
+ #+end_src
* Images
#+begin_src emacs-lisp
(defun jao-eww-next-image ()
diff --git a/init.org b/init.org
index ea8795d..21cd552 100644
--- a/init.org
+++ b/init.org
@@ -2724,7 +2724,7 @@
erc-hide-timestamps nil
erc-input-line-position -1
erc-insert-timestamp-function 'erc-insert-timestamp-right
- erc-join-buffer 'bury
+ erc-join-buffer 'buffer
erc-kill-buffer-on-part t
erc-kill-queries-on-quit t
erc-log-channels-directory nil
@@ -2736,7 +2736,8 @@
erc-notify-signoff-hook 'erc-notify-signoff
erc-notify-signon-hook 'erc-notify-signon
erc-pcomplete-nick-postfix ","
- erc-prompt ":"
+ erc-server-send-ping-timeout 60
+ erc-prompt ">"
erc-prompt-for-nickserv-password nil
erc-use-auth-source-for-nickserv-password t
erc-prompt-for-password nil
@@ -2748,7 +2749,7 @@
erc-timestamp-format "%H:%M"
erc-timestamp-only-if-changed-flag t
erc-timestamp-right-column 84
- erc-user-full-name user-full-name
+ erc-user-full-name "https://jao.io"
erc-user-mode "+i"
erc-whowas-on-nosuchnick t)
diff --git a/w3m.org b/w3m.org
index e77bc87..e23bc82 100644
--- a/w3m.org
+++ b/w3m.org
@@ -84,6 +84,30 @@
(define-key gnus-article-mode-map "\C-ci" 'w3m-view-image)
(define-key gnus-article-mode-map "z" 'w3m-lnum-zoom-in-image))
#+end_src
+* Narrowing
+ #+begin_src emacs-lisp
+ (with-eval-after-load "consult"
+ (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)))))
+ (when jao-afio-use-w3m (setq jao-consult-www-narrow ?w))
+ (add-to-list 'consult-buffer-sources 'jao-consult-w3m-source t))
+ #+end_src
* Package
#+begin_src emacs-lisp
(use-package w3m