about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el3
-rw-r--r--lisp/acdw.el69
2 files changed, 72 insertions, 0 deletions
diff --git a/init.el b/init.el index 2c18993..759541a 100644 --- a/init.el +++ b/init.el
@@ -886,6 +886,9 @@ if ripgrep is installed, otherwise `consult-grep'."
886 (elpher-go url)) 886 (elpher-go url))
887 (t (apply fn url args)))) 887 (t (apply fn url args))))
888 888
889 ;; And buttonize gemini:// links.
890 (acdw/add-button-url-regexp-protocol "gemini")
891
889 (:when-loaded 892 (:when-loaded
890 (setup (:straight (gemini-write 893 (setup (:straight (gemini-write
891 :host nil 894 :host nil
diff --git a/lisp/acdw.el b/lisp/acdw.el index 9ac315c..ce3e9f8 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -408,6 +408,75 @@ Prompt only if there are unsaved changes."
408 ((t (:foreground "dim gray")))))) 408 ((t (:foreground "dim gray"))))))
409 409
410 410
411;;; URL regexp
412;; really, I just want to add gemini:// protocol, but I'm going to do some
413;; reverse-engineering here.
414
415(defvar acdw/button-protocols '("http"
416 "https"
417 "shttp"
418 "shttps"
419 "ftp"
420 "file"
421 "gopher"
422 "nntp"
423 "news"
424 "telnet"
425 "wais"
426 "mailto"
427 "info")
428 "The list of protocols to splice into `browse-url-button-regexp'.")
429
430(defun acdw/build-button-url-regexp ()
431 "Build `browse-url-button-regexp' from `acdw/button-protocols'.
432I used `xr' (not included in Emacs) to get the RX form of the
433default, so I can easily splice the list into it. THIS IS
434BRITTLE AF!!!"
435 (rx
436 (seq word-boundary
437 (group
438 (group
439 (or "www."
440 (seq
441 (group
442 (eval (cons 'or acdw/button-protocols)))
443 ":")))
444 (opt
445 (group "//"
446 (one-or-more
447 (any "0-9a-z" "._-"))
448 ":"
449 (zero-or-more
450 (any "0-9"))))
451 (or
452 (seq
453 (one-or-more
454 (any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
455 "("
456 (one-or-more
457 (any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
458 (zero-or-more
459 (any "0-9a-z" "#$%&*+/=@\\_~-" word))
460 ")"
461 (opt
462 (one-or-more
463 (any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
464 (any "0-9a-z" "#$%&*+/=@\\_~-" word)))
465 (seq
466 (one-or-more
467 (any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
468 (any "0-9a-z" "#$%&*+/=@\\_~-" word))))))
469 )
470
471(defun acdw/add-button-url-regexp-protocol (proto)
472 "Add PROTO to `browse-url-button-regexp'
473First, add PROTO to `acdw/button-protocols'.
474Then, build `browse-url-button-regexp' with the new protocol."
475 (add-to-list 'acdw/button-protocols proto)
476 (setq browse-url-button-regexp (acdw/build-button-url-regexp)))
477
478
479
411;;; Keymaps 480;;; Keymaps
412 481
413(defvar acdw/leader 482(defvar acdw/leader