;;; ll-w3m-url --- ll w3m url -*- lexical-binding: t -*- ;;; Commentary: ;;; Code: (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'll) (-> 'w3m) (-> 'thingatpt) (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)))))) (defun w3m-kill-url-and-title () (i) (let ((tit (w3m-current-title)) (url w3m-current-url)) (unless (s= tit "") (kill-new (@f "%s # %s" url tit)) ($ "%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 () (i) (let* ((url (or (w3m-anchor) (thing-at-point 'url) w3m-current-url)) (tit (& (s= url w3m-current-url) (w3m-current-title))) (prt (if tit (@f " ; %s" tit) "")) (cmd (@f "echo \"%s\" | xi" url))) (append-string-to-file (@f "%s%s" url prt) (@f "%s/URL" (getenv "HOME")) t) (kill-new url) (shell-command cmd)) (@f "%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 w3m-dired () (i) (w3m-find-file (dired-get-filename))) (defun w3m-file () (i) (w3m-find-file (buffer-file-name))) (defun w3m-name () (i) (w3m (buffer-file-name))) (defun w3m-url () (i) (w3m (thing-at-point 'url))) (<- 'll-w3m-url) ;;; ll-w3m-url.el ends here