diff options
author | Case Duckworth | 2021-05-24 18:00:23 -0500 |
---|---|---|
committer | Case Duckworth | 2021-05-24 18:00:23 -0500 |
commit | 67c4eb7fe7ab8b9402bc375f09dc39ce766bbe50 (patch) | |
tree | da6f493aba5c90c5ef8ecdf639ed34c856e8a038 /lisp | |
parent | Further customize ERC (diff) | |
download | emacs-67c4eb7fe7ab8b9402bc375f09dc39ce766bbe50.tar.gz emacs-67c4eb7fe7ab8b9402bc375f09dc39ce766bbe50.zip |
Add gemini to browse-url-button-regexp
Also I overengineered some other stuff around that.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/acdw.el | 69 |
1 files changed, 69 insertions, 0 deletions
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'. | ||
432 | I used `xr' (not included in Emacs) to get the RX form of the | ||
433 | default, so I can easily splice the list into it. THIS IS | ||
434 | BRITTLE 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' | ||
473 | First, add PROTO to `acdw/button-protocols'. | ||
474 | Then, 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 |