From 8d3aba77466d9a48481050f6b7469e72204813f7 Mon Sep 17 00:00:00 2001
From: jao <jao@gnu.org>
Date: Wed, 31 Mar 2021 01:13:09 +0100
Subject: attic

---
 attic/counsel.org | 250 +++++++++++++++++++++++++++++++++++++++
 attic/w3m.org     | 344 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 594 insertions(+)
 create mode 100644 attic/counsel.org
 create mode 100644 attic/w3m.org

(limited to 'attic')

diff --git a/attic/counsel.org b/attic/counsel.org
new file mode 100644
index 0000000..5732fb7
--- /dev/null
+++ b/attic/counsel.org
@@ -0,0 +1,250 @@
+#+title: Completion configuration using ivy, counsel and friends
+
+* ivy
+  #+begin_src emacs-lisp
+    (use-package ivy
+      :ensure t
+      :demand t
+      :custom
+      ((ivy-count-format "(%d/%d) ")
+       (ivy-do-completion-in-region t)
+       (ivy-height 20)
+       (ivy-re-builders-alist '((counsel-ag . ivy--regex)
+                                (counsel-rg . ivy--regex)
+                                (counsel-yank-pop . ivy--regex)
+                                (swiper . ivy--regex)
+                                (swiper-isearch . ivy--regex)
+                                (t . ivy--regex-fuzzy)))
+       (ivy-use-virtual-buffers t)
+       (ivy-virtual-abbreviate 'abbreviate)
+       (ivy-wrap t))
+
+      :config
+      ;; used by ivy--regex-fuzzy to order results
+      (use-package flx :ensure t)
+
+      ;; Try C-o in the minibuffer
+      (use-package ivy-hydra
+        :after ivy
+        :ensure t
+        :init (setq ivy-read-action-function #'ivy-hydra-read-action))
+
+      (add-to-list 'ivy-initial-inputs-alist
+                   '(gnus-summary-move-article . ""))
+
+      :bind (("C-R" . ivy-resume)
+             ("C-x b" . ivy-switch-buffer)
+             ("C-c v" . ivy-push-view)
+             ("C-c V" . ivy-pop-view))
+      :diminish)
+  #+end_src
+* counsel
+  #+begin_src emacs-lisp
+    (use-package counsel
+      :ensure t
+      :custom ((counsel-describe-function-function 'helpful-callable)
+               (counsel-describe-variable-function 'helpful-variable)
+               (counsel-find-file-at-point t)
+               (counsel-linux-app-format-function
+                #'counsel-linux-app-format-function-name-pretty)
+               (counsel-mode-override-describe-bindings nil)
+               (counsel-recentf-include-xdg-list t))
+      :config
+      :bind (("C-s" . swiper-isearch)
+             ("C-S-s" . isearch-forward)
+             ("M-x" . counsel-M-x)
+             ("C-x f" . counsel-find-file)
+             ("C-c k" . counsel-ag)
+             ("C-c K" . counsel-rg)
+             ("C-c l" . counsel-locate)
+             ("C-c b" . counsel-git)
+             ("C-c i" . counsel-imenu)
+             ("C-c G" . counsel-search)
+             ("s-r" . counsel-linux-app))
+      :diminish)
+  #+end_src
+* counsel add-ons
+*** recoll
+  #+BEGIN_SRC emacs-lisp
+    (use-package jao-recoll)
+    (use-package jao-counsel-recoll
+      :after counsel
+      :bind (("C-c R" . jao-counsel-recoll)))
+  #+END_SRC
+*** notmuch
+    #+begin_src emacs-lisp
+      (use-package counsel-notmuch
+        :ensure t
+        :config (with-eval-after-load "gnus-group"
+                  (define-key gnus-group-mode-map "Gg" 'counsel-notmuch)))
+    #+end_src
+* ivy rich
+  #+begin_src emacs-lisp
+    (use-package ivy-rich
+      :after (ivy counsel)
+      :ensure t
+      :custom ((ivy-rich-path-style 'relative)
+               (ivy-rich-parse-remote-buffer nil)
+               (ivy-rich-parse-remote-file-path nil))
+      :config
+      (ivy-rich-modify-columns
+       'ivy-switch-buffer
+       '((ivy-rich-candidate (:width 80))
+         (ivy-rich-switch-buffer-indicators (:face jao-themes-f00))
+         (ivy-rich-switch-buffer-project (:width 15))
+         (ivy-rich-switch-buffer-major-mode (:width 15 :face jao-themes-f12)))))
+  #+end_src
+* cmap
+  #+begin_src emacs-lisp
+    (jao-load-path "cmap")
+    (use-package cmap
+      :demand t
+      :bind (("C-;" . cmap-cmap)
+             ("C-'" . cmap-default)))
+  #+end_src
+*** prompter
+    #+begin_src emacs-lisp
+      (defun jao-cmap--hide-help ()
+        (when-let ((w (get-buffer-window (help-buffer))))
+          (with-selected-window w (kill-buffer-and-window))))
+
+      (defun jao-cmap--prompter (keymap)
+        (let ((display-buffer-alist '(("*Help*"
+                                       (display-buffer-at-bottom)
+                                       (window-parameters (mode-line-format . none))
+                                       (window-height . fit-window-to-buffer)))))
+          (let ((inhibit-message t))
+            (describe-keymap keymap))))
+
+      (defun jao-cmap--prompter-done ()
+        (save-current-buffer (jao-cmap--hide-help)))
+
+      (setq cmap-prompter #'jao-cmap--prompter)
+      (setq cmap-prompter-done #'jao-cmap--prompter-done)
+    #+end_src
+*** minibuffer actions
+    #+begin_src emacs-lisp
+      (defun jao-cmap--completion-metadata ()
+        (completion-metadata
+         (buffer-substring-no-properties (field-beginning) (point))
+         minibuffer-completion-table
+         minibuffer-completion-predicate))
+
+      (defun jao-cmap--completion-category ()
+        (completion-metadata-get (jao-cmap--completion-metadata) 'category))
+
+      (defmacro cmap-define-keymap (v d &rest b)
+        `(defvar ,v (cmap-keymap ,@b) ,d))
+
+      (cmap-define-keymap jao-cmap-buffer-map
+        "Keymap for buffer actions."
+        ("k" . kill-buffer)
+        ("b" . switch-to-buffer)
+        ("o" . switch-to-buffer-other-window)
+        ("z" . bury-buffer)
+        ("q" . kill-buffer-and-window)
+        ("=" . ediff-buffers))
+
+      ;; (cmap-define-keymap espotify-item-keymap
+      ;;   "Actions for Spotify search results"
+      ;;   ("a" espotify--play-album)
+      ;;   ("h" espotify--show-info))
+
+      (defvar jao-cmap--smaps
+        '((command . cmap-command-map)
+          ;; (espotify-search-item . espotify-item-keymap)
+          (function . cmap-function-map)
+          (variable . cmap-variable-map)
+          (face . cmap-face-map)
+          (buffer . jao-cmap-buffer-map)
+          (consult-buffer . jao-cmap-buffer-map)))
+
+      (defun jao-cmap-target-minibuffer-candidate ()
+        (when (minibuffer-window-active-p (selected-window))
+          (let ((cand (ivy-state-current ivy-last))
+                (cat (jao-cmap--completion-category)))
+            (when-let (m (alist-get cat jao-cmap--smaps))
+              (cons m cand)))))
+
+      (add-to-list 'cmap-targets #'jao-cmap-target-minibuffer-candidate)
+    #+end_src
+*** url / video actions
+    #+begin_src emacs-lisp
+      (defvar jao-cmap-video-url-rx
+        (format "^https?://\\(?:www\\.\\)?%s/.+"
+                (regexp-opt '("youtu.be"
+                              "youtube.com"
+                              "blip.tv"
+                              "vimeo.com"
+                              "infoq.com")
+                            t))
+        "A regular expression matching URLs that point to video streams")
+
+      (defun jao-cmap--play-video (player url)
+        (interactive "sURL: ")
+        (let ((cmd (format "%s %s" player (shell-quote-argument url))))
+          (start-process-shell-command player nil cmd)))
+
+      (defun jao-cmap-mpv (&optional url)
+        "Play video stream with mpv"
+        (interactive "sURL: ")
+        (jao-cmap--play-video "mpv" url))
+
+      (defun jao-cmap-vlc (&optional url)
+        "Play video stream with vlc"
+        (interactive "sURL: ")
+        (jao-cmap--play-video "vlc" url))
+
+      (defun jao-cmap-target-w3m-url ()
+        (when-let (url (or (thing-at-point-url-at-point)
+                           (w3m-anchor)
+                           w3m-current-url))
+          (cons 'cmap-url-map url)))
+
+      (defun jao-cmap-kill (&optional x)
+        "Save to kill ring"
+        (interactive "s")
+        (kill-new x))
+
+      (defun jao-cmap-url (url)
+        "Browse URL, externally if we're already in emacs-w3m"
+        (if (derived-mode-p 'w3m-mode)
+            (jao-browse-with-external-browser url)
+          (browse-url url)))
+
+      (define-key cmap-url-map [return] #'jao-cmap-url)
+      (define-key cmap-url-map "f" #'browse-url-firefox)
+      (define-key cmap-url-map "w" #'jao-cmap-kill)
+
+      (defun jao-cmap-target-video-url ()
+        (when-let (url (jao-cmap-target-w3m-url))
+          (when (string-match-p jao-cmap-video-url-rx (cdr url))
+            (cons 'jao-cmap-video-url-map (cdr url)))))
+
+      (cmap-define-keymap jao-cmap-video-url-map
+        "Actions on URLs pointing to remote video streams."
+        ("v" . jao-cmap-vlc)
+        ([return] . jao-cmap-mpv))
+
+      (add-to-list 'cmap-targets #'jao-cmap-target-w3m-url)
+      (add-to-list 'cmap-targets #'jao-cmap-target-video-url)
+    #+end_src
+* hooks
+  #+begin_src emacs-lisp
+    (with-eval-after-load "exwm"
+      (add-to-list 'exwm-input-global-keys '([?\s-r] . counsel-linux-app)))
+
+    (with-eval-after-load "espotify"
+      (require 'ivy-spotify)
+      (defalias 'jao-spotify-album #'ivy-spotify-album)
+      (defalias 'jao-spotify-track #'ivy-spotify-track)
+      (defalias 'jao-spotify-artist #'ivy-spotify-artist)
+      (defalias 'jao-spotify-playlist #'ivy-spotify-playlist))
+  #+end_src
+* startup
+  #+begin_src emacs-lisp
+    (ivy-mode 1)
+    (counsel-mode 1)
+    (ivy-rich-mode 1)
+    (ivy-rich-project-root-cache-mode 1)
+  #+end_src
diff --git a/attic/w3m.org b/attic/w3m.org
new file mode 100644
index 0000000..e169e28
--- /dev/null
+++ b/attic/w3m.org
@@ -0,0 +1,344 @@
+#+title: Customizations for emacs-w3m
+
+* Custom variables:
+  #+BEGIN_SRC emacs-lisp
+    (use-package w3m
+      :ensure t
+      :custom ((w3m-key-binding 'info)
+               (w3m-display-mode 'dual-pane))
+      :init
+      (setq w3m-add-user-agent nil
+            w3m-command "w3m"
+            w3m-confirm-leaving-secure-page nil
+            w3m-cookie-accept-bad-cookies t
+            w3m-use-tab nil
+            w3m-display-mode 'dual-pane
+            w3m-do-cleanup-temp-files t
+            w3m-doc-view-content-types ()
+            w3m-fill-column 110
+            w3m-form-input-textarea-buffer-lines 40
+            w3m-history-minimize-in-new-session t
+            w3m-history-reuse-history-elements nil
+            w3m-image-no-idle-timer t
+            w3m-make-new-session t
+            w3m-profile-directory "~/.w3m"
+            w3m-redisplay-pages-automatically-p nil
+            w3m-safe-url-regexp nil
+            w3m-search-default-engine "duckduckgo" ; "google-en"
+            w3m-select-buffer-horizontal-window nil
+            w3m-select-buffer-window-ratio '(20 . 40)
+            w3m-session-load-last-sessions t
+            w3m-session-load-crashed-sessions 'ask
+            w3m-show-graphic-icons-in-header-line t
+            w3m-space-before-favicon "|"
+            w3m-tab-separator ""
+            w3m-use-cookies t
+            w3m-use-favicon nil
+            w3m-use-header-line nil
+            w3m-use-refresh nil)
+
+      (with-eval-after-load 'org (require 'ol-w3m nil t))
+      (setq jao-browse-url-function 'jao-w3m-browse-url)
+      :config (defalias 'jao-goto-w3m-frame 'jao-afio--goto-www)
+      :bind (:map w3m-mode-map (("C-c C-@" . tracking-next-buffer)
+                                ("C-c C-SPC" . tracking-next-buffer))))
+    (require 'w3m)
+  #+END_SRC
+* Coding systems and content type
+  #+begin_src emacs-lisp
+    (mapc (lambda (v) (set v 'utf-8))
+          '(w3m-default-coding-system
+            w3m-bookmark-file-coding-system
+            w3m-coding-system
+            w3m-file-coding-system
+            w3m-file-name-coding-system
+            w3m-terminal-coding-system))
+
+    (jao-when-linux
+     (setq w3m-content-type-alist
+           '(("text/plain" "\\.\\(?:txt\\|tex\\|el\\)\\'" nil nil)
+             ("text/html" "\\.s?html?\\'" jao-browse-with-external-browser nil)
+             ("text/html" "." jao-browse-with-external-browser nil)
+             ("text/sgml" "\\.sgml?\\'" nil "text/plain")
+             ("text/xml" "\\.xml\\'" nil "text/plain")
+             ("image/jpeg" "\\.jpe?g\\'" ("emacsclient" file) nil)
+             ("image/png" "\\.png\\'" ("emacsclient" file) nil)
+             ("image/gif" "\\.gif\\'" ("emacsclient" file) nil)
+             ("image/tiff" "\\.tif?f\\'" ("emacsclient" file) nil)
+             ("image/x-xwd" "\\.xwd\\'" ("emacsclient" file) nil)
+             ("image/x-xbm" "\\.xbm\\'" ("emacsclient" file) nil)
+             ("image/x-xpm" "\\.xpm\\'" ("emacsclient" file) nil)
+             ("image/x-bmp" "\\.bmp\\'" ("emacsclient" file) nil)
+             ("video/mpeg" "\\.mpe?g\\'" jao-maybe-view-video nil)
+             ("video/quicktime" "\\.mov\\'" jao-maybe-view-video nil)
+             ("video/*" "\\.mpe?g\\'" jao-maybe-view-video nil)
+             ("application/dvi" "\\.dvi\\'" ("xdvi" file) nil)
+             ("application/postscript" "\\.e?ps\\'" ("/usr/bin/see" file) nil)
+             ("application/pdf" "\\.pdf\\'" ("viewpdf.sh" file) nil)
+             ("application/xml" "\\.xml\\'" nil w3m-detect-xml-type)
+             ("application/rdf+xml" "\\.rdf\\'" nil "text/plain")
+             ("application/rss+xml" "\\.rss\\'" nil "text/plain")
+             ("application/xhtml+xml" nil nil "text/html")
+             ("unknown" nil nil "text/plain"))))
+  #+end_src
+* Filters
+  #+begin_src emacs-lisp
+    (setq w3m-use-filter t
+          w3m-filter-configuration
+          '((t "Strip Google's click-tracking"
+               "\\`https?://[a-z]+\\.google\\."
+               w3m-filter-google-click-tracking)
+            (t "Align table columns vertically to shrink the table width in Google"
+               "\\`http://\\(www\\|images\\|news\\|maps\\|groups\\)\\.google\\."
+               w3m-filter-google-shrink-table-width)
+           (t "Add name anchors that w3m can handle in all pages"
+              ""
+              w3m-filter-add-name-anchors)
+           (t "Substitute disabled attr with readonly attr in forms"
+              ""
+              w3m-filter-subst-disabled-with-readonly)
+           (t "Filter top and bottom cruft for stackexchange.com"
+              "\\`https://\\(?:[0-9A-Za-z_~-]+\\.\\)*stackexchange\\.com\\(?:\\'\\|/\\)"
+              w3m-filter-stackexchange)
+           (t "filter for github.com repository main page"
+              "\\`http[s]?://github\\.com/[^/]+/[^/]+[/]?\\'"
+              w3m-filter-github-repo-main-page)
+           (t "xkcd filter" "\\`http[s]?://xkcd.com/" w3m-filter-xkcd)
+           (nil "Prefer a lazy image specified with data-src= in img tags"
+                ""
+                w3m-filter-prefer-lazy-images)))
+  #+end_src
+* Symbols and drawing
+  #+BEGIN_SRC emacs-lisp
+    (setq w3m-default-symbol '("┼" "├" "┬" "┌" "┤" "│" "┐" ""
+                               "┴" "└" "─" ""  "┘" ""  ""  ""
+                               "┼" "├" "┬" "┌" "┤" "│" "┐" ""
+                               "┴" "└" "─" ""  "┘" ""  ""  ""
+                               "•" "•" "•" "•" " • "
+                               "•" "•" "•" "•" "•" "•" "•" "•"
+                               "≪ ↑ ↓ "))
+    (setq w3m-symbol w3m-default-symbol)
+    (setq-default w3m-use-symbol t)
+  #+END_SRC
+* Browse url (with unique buffer support)
+  #+BEGIN_SRC emacs-lisp
+    (defvar jao-w3m-unique-buffer-rxs
+      '("^file:.*hyperspec/.*"
+        "^file:.*/usr/\\(local/\\)?share/doc/racket/.*"
+        "^file:///home/jao/src/racket/doc/.*"
+        "^file:.*/usr/local/plt/doc/.*"
+        "^file:.*/\\(usr/share/doc/ghc6-doc/html/.*\\|\\.cabal/\\).*"
+        "^file:.*/doc/hyperspec/.*"
+        ("/tmp/jde_meta\.html" . "^file:.*/java/docs/.*")))
+
+    (defun jao-w3m-url-matcher (url)
+      (let* ((url (w3m-canonicalize-url url))
+             (urx (format "^%s$" url)))
+        (dolist (rx jao-w3m-unique-buffer-rxs)
+          (let ((m (if (consp rx) (car rx) rx))
+                (r (if (consp rx) (cdr rx) rx)))
+            (when (string-match m url) (setq urx r))))
+        urx))
+
+    (defun jao-w3m-find-url (url)
+      ;; (message "finding %s" url)
+      (let ((urx (jao-w3m-url-matcher url))
+            (buffers (w3m-list-buffers))
+            (found nil))
+        (save-current-buffer
+          (while (not (or found (null buffers)))
+            (let ((b (car buffers)))
+              (set-buffer b)
+              (if (and w3m-current-url
+                       (string-match urx
+                                     (w3m-canonicalize-url w3m-current-url)))
+                  (setq found b)
+                (setq buffers (cdr buffers))))))
+        (when found
+          (let ((pop-up-windows nil)
+                (display-buffer-reuse-frames nil))
+            (pop-to-buffer found)))
+        found))
+
+    (defun jao-w3m-browse-url (url &rest r)
+      "Browse URL using w3m.
+
+    If a frame running w3m already exists, reuses it creating
+    a new tab.  If the URL is already open, though, the tab
+    containing it is selected."
+      (jao-goto-w3m-frame)
+      (select-window (frame-first-window))
+      (or (jao-w3m-find-url url)
+          (w3m-goto-url-new-session url)))
+
+    (defun jao-w3m-do-browse ()
+      "Use the generic browse-url with URL at point."
+      (interactive)
+      (let ((uri (or (w3m-anchor) (w3m-image) w3m-current-url)))
+        (browse-url uri)))
+
+    (defun jao-w3m-download (arg)
+      (interactive "P")
+      (jao-download (w3m-anchor) arg))
+
+    (setq w3m-goto-article-function 'jao-w3m-browse-url)
+  #+END_SRC
+* Tweeting and tooting
+  #+BEGIN_SRC emacs-lisp
+    (defun jao-w3m--toot-text (from to title)
+      (let ((a (or (jao-url-around-point)
+                   w3m-current-url
+                   (error "No URL to tweet!")))
+            (txt (or title
+                     (if (and from to)
+                         (buffer-substring from to)
+                       (w3m-current-title)))))
+        (if (string-empty-p (or txt ""))
+            a
+          (format "'%s' -- %s" txt a))))
+
+    (defun jao-w3m-tweet (&optional from to title buff)
+      (interactive (when (use-region-p) (list (region-beginning) (region-end))))
+      (let ((txt (jao-w3m--toot-text from to title)))
+        (pop-to-buffer (or buff "#twitter_jaotwits"))
+        (goto-char (point-max))
+        (insert "post " txt)))
+
+    (defun jao-w3m-toot (&optional from to title)
+      (interactive (when (use-region-p) (list (region-beginning) (region-end))))
+      (jao-w3m-tweet from to title "#mastodon"))
+  #+END_SRC
+* Cookies
+  #+begin_src emacs-lisp
+    ;; for reddit http://i.reddit.com is non-js friendly
+    (setq w3m-cookie-reject-domains '(".")
+          w3m-cookie-accept-domains '(".github.com"
+                                      ".librarything.com"
+                                      ".goodreads.com"
+                                      ".sr.ht"
+                                      ".gnu.org"
+                                      ".codeberg.org"
+                                      "codeberg.org"
+                                      ".bookshop.org"
+                                      ".reddit.com"))
+  #+end_src
+* Email
+  #+begin_src emacs-lisp
+    (defun jao-w3m-gmail-mark-all (unmark)
+      (interactive "P")
+      (goto-char (point-min))
+      (when (search-forward (if unmark "[*]" "[ ]") nil t)
+        (backward-char 4)
+        (w3m-form-goto-next-field)
+        (while (looking-at (if unmark "\\*\\]" " \\]"))
+          (w3m-view-this-url)
+          (w3m-form-goto-next-field))))
+
+    (defun jao-w3m-mail-page ()
+      (interactive)
+      (let ((wb (w3m-alive-p)))
+        (when wb
+          (compose-mail nil
+                        (read-string "Subject: " (w3m-buffer-title wb)))
+          (message-goto-body)
+          (insert "\n\n<" (with-current-buffer wb w3m-current-url) ">\n")
+          (message-goto-to))))
+
+    (defun jao-w3m-gnus-html-renderer (handle)
+        (let ((w3m-message-silent t)
+              (mm-w3m-safe-url-regexp nil)
+              (shr-use-colors nil)
+              (shr-use-fonts nil)
+              (fill-column (min (window-width) 110)))
+          (condition-case nil
+              (mm-inline-text-html-render-with-w3m handle)
+            (error (delete-region (point) (point-max))
+                   (mm-shr handle)))))
+
+  #+end_src
+* Proxies
+  #+BEGIN_SRC emacs-lisp
+    (defun jao-w3m-activate-proxy ()
+      (interactive)
+      (setq w3m-command-arguments
+            (nconc w3m-command-arguments
+                   '("-o" "http_proxy=http://localhost:8888"))))
+
+    (defun jao-w3m-deactivate-proxy ()
+      (interactive)
+      (setq w3m-command-arguments (cdr w3m-command-arguments)))
+  #+END_SRC
+* Switch buffers
+  #+BEGIN_SRC emacs-lisp
+    (defun jao-w3m-switch-buffers (dist)
+      (interactive "p")
+      (let* ((dist (if (zerop dist) 1 dist))
+             (current (current-buffer))
+             (current-no (w3m-buffer-number current))
+             (next (progn (w3m-next-buffer dist)
+                          (current-buffer)))
+             (next-no (w3m-buffer-number next)))
+        (with-current-buffer current
+          (rename-buffer "*w3m*<*>")
+          (w3m-buffer-set-number next current-no)
+          (w3m-buffer-set-number current next-no)
+          (w3m-pack-buffer-numbers))
+        (switch-to-buffer current)))
+  #+END_SRC
+* Capture page
+  #+BEGIN_SRC emacs-lisp
+    (defun jao-w3m-capture-page ()
+      (interactive)
+      (let* ((title (w3m-current-title))
+             (url w3m-current-url)
+             (html (y-or-n-p "Save as HTML (y) or PS (n)? "))
+             (basename (concat (read-string "File name: ")
+                               (if html ".html" ".ps")))
+             (name (expand-file-name basename jao-sink-dir)))
+        (if html
+            (progn
+              (w3m-view-source)
+              (write-region (point-min) (point-max) name nil nil nil t)
+              (w3m-view-source))
+          (progn
+            (split-window-horizontally 85)
+            (w3m-redisplay-this-page)
+            (ps-print-buffer name)
+            (delete-other-windows)
+            (w3m-redisplay-this-page)))
+        (kill-new (format "[[doc:%s][%s]] ([[%s][original]])"
+                          basename title url))))
+
+    (defun jao-w3m-get-link ()
+      (let ((wb (w3m-alive-p)))
+        (when wb
+          (let ((url (with-current-buffer wb w3m-current-url))
+                (title (w3m-buffer-title wb)))
+            (cons url title)))))
+
+    (defun jao-insert-w3m-link ()
+      (interactive)
+      (let ((link (jao-w3m-get-link)))
+        (when link (insert "[[" (car link) "][" (cdr link) "]]"))))
+  #+END_SRC
+* Keybindings
+  #+BEGIN_SRC emacs-lisp
+    (define-key w3m-mode-map "B" 'jao-w3m-do-browse)
+    (define-key w3m-mode-map "d" 'jao-w3m-download)
+    (define-key w3m-mode-map (kbd "\C-ck") 'jao-w3m-gmail-mark-all)
+    (define-key w3m-mode-map (kbd "\C-c\C-f") 'jao-w3m-switch-buffers)
+    (define-key w3m-mode-map (kbd "\C-cc") 'jao-w3m-capture-page)
+    (define-key w3m-mode-map "\M-\r" 'w3m-view-this-url-new-session)
+    (define-key w3m-mode-map "+" 'w3m-zoom-in-image)
+    (define-key w3m-mode-map "-" 'w3m-zoom-out-image)
+    (define-key w3m-mode-map "m" 'jao-w3m-mail-page)
+    (define-key w3m-mode-map "M" 'w3m-view-url-with-external-browser)
+    (define-key w3m-mode-map "t" 'jao-w3m-tweet)
+    (define-key w3m-mode-map "T" 'jao-w3m-toot)
+    (define-key w3m-mode-map "f" 'w3m-lnum-follow)
+    (define-key w3m-mode-map "c" 'w3m-print-this-url)
+    (define-key w3m-mode-map "v" 'jao-view-video)
+    (define-key w3m-mode-map "V" 'w3m-download)
+    (define-key w3m-mode-map "x" 'jao-rss-subscribe-rss)
+    (define-key w3m-mode-map "Y" 'w3m-print-current-url)
+  #+END_SRC
-- 
cgit v1.2.3