;; -*- lexical-binding: t -*- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (cl-pushnew (file-name-concat ".." "ll") load-path :test #'string=) (require 'll) (defun w3m-cat-source () (i) (w3m-pipe-source w3m-current-url "/bin/cat")) (defun goto-next-url () (i) (let ((beg (point)) (end (point-max))) (cl-dolist (url-type thing-at-point-uri-schemes) (goto-char beg) (when (re-search-forward url-type end t) (goto-char (match-beginning 0)) (when-let* ((url (thing-at-point 'url))) (w3m-goto-url url) (cl-return)))))) ;; (goto-next-url) ; http://www.google.com (defun w3m-kill-url-and-title () (i) (let ((title (w3m-current-title)) (url w3m-current-url)) (unless (s= title "") (kill-new (format "%s # %s" url title)) ($ "%s" (current-kill 0))))) (defun w3m-kill-title () (i) (kill-new (w3m-current-title)) ($ "%s" (current-kill 0))) (defun append-string-to-file (str file &optional uniq) (unless (& uniq (xref-matches-in-files (regexp-quote str) (list file))) (append-to-file (@f "%s\n" str) nil file))) (defun w3m-kill-url-dwim () (i) (let* ((url (or (w3m-anchor) (thing-at-point 'url) w3m-current-url)) (title (& (s= url w3m-current-url) (w3m-current-title))) (title-part (if title (@f " ; %s" title) "")) (cmd (@f "echo \"%s\" | xi" url))) (append-string-to-file (@f "%s%s" url title-part) (@f "%s/URL" (getenv "HOME")) t) (kill-new url) (shell-command cmd)) (message "%s" (current-kill 0))) (defun w3m-goto-url-kill-current () (i) (& w3m-current-url (kill-new w3m-current-url)) (call-interactively #'w3m-goto-url)) (defun rfc (num) (interactive "nRFC: ") (w3m-browse-url (@f "https://datatracker.ietf.org/doc/html/rfc%d" num))) (defun dired-view-in-w3m () (i) (w3m-find-file (dired-get-filename))) (defun w3m-browse-url-at-point () (i) (w3m (thing-at-point 'url))) (defun w3m-view () (i) (w3m (buffer-file-name))) (defun w3m-view-html () (i) (w3m-find-file (buffer-file-name))) (<- 'w3m-url)