diff options
author | Yuchen Pei <id@ypei.org> | 2023-07-10 12:53:08 +1000 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2023-07-10 12:53:08 +1000 |
commit | 2e735a1052984299337decc6648ac02034d1263b (patch) | |
tree | 919992303f5f50a232912ee6f122aa8221757c25 | |
parent | 35a15e183ced5cb9529d7e35433dcb26db548897 (diff) |
Show link target in help-echo
-rw-r--r-- | wiki-engine.el | 7 | ||||
-rw-r--r-- | wiki-markup.el | 18 | ||||
-rw-r--r-- | wiki-utils.el | 9 |
3 files changed, 23 insertions, 11 deletions
diff --git a/wiki-engine.el b/wiki-engine.el index fb6fcba..b82b9aa 100644 --- a/wiki-engine.el +++ b/wiki-engine.el @@ -22,7 +22,9 @@ ;;; Commentary: -;; client to wiki engines, wiki server software. +;; client to wiki engines, wiki server software. Each engine defines +;; how emacs interacts with the remote server, including how to +;; construct a url to fetch from. ;;; Code: (require 'wiki-utils) @@ -34,6 +36,7 @@ The site name is passed as a symbol WIKI-SITE." (let ((wiki-site-info (alist-get wiki-site wiki-sites))) (cl-assert (eq (plist-get wiki-site-info :engine) 'mediawiki)) + (when (string-empty-p title) (setq title "Main Page")) (wiki-fetch-url (format "%s%s?action=raw" (plist-get wiki-site-info :base-url) @@ -42,7 +45,7 @@ The site name is passed as a symbol WIKI-SITE." (wiki-mode) (setq-local wiki-site wiki-site) ) - title))) + ))) (defun wiki-engine-oddmuse-fetch (wiki-site title) (let ((wiki-site-info (alist-get wiki-site wiki-sites))) diff --git a/wiki-markup.el b/wiki-markup.el index 63bec0e..341610a 100644 --- a/wiki-markup.el +++ b/wiki-markup.el @@ -98,20 +98,26 @@ (while (re-search-forward link-re limit t) (let ((start (match-beginning 0)) (end (match-end 0)) - (visible-start (or (match-beginning 2) (match-beginning 1))) - (visible-end (or (match-end 2) (match-end 1))) + (target-start (match-beginning 1)) + (target-end (match-end 1)) + (label-start (or (match-beginning 2) (match-beginning 1))) + (label-end (or (match-end 2) (match-end 1))) (title (buffer-substring-no-properties (match-beginning 1) (match-end 1))) ) - (put-text-property start visible-start 'invisible t) + (put-text-property start label-start 'invisible t) (make-text-button start end 'action 'wiki-follow-wikilink-action 'button-data `((title . ,title))) + (put-text-property start end 'help-echo + (format "LINK: %s" + (buffer-substring-no-properties + target-start target-end))) (add-face-text-property start end 'org-link) - (put-text-property visible-end end 'invisible t) - (add-text-properties (1- visible-start) visible-start + (put-text-property label-end end 'invisible t) + (add-text-properties (1- label-start) label-start '(rear-nonsticky (invisible))) - (add-text-properties (1- visible-end) visible-end + (add-text-properties (1- label-end) label-end '(rear-nonsticky (invisible))) )))) diff --git a/wiki-utils.el b/wiki-utils.el index b99be9c..5b66075 100644 --- a/wiki-utils.el +++ b/wiki-utils.el @@ -75,9 +75,9 @@ Then calls CALLBACK which is a closure taking no argument." ;; TODO: default engine to mediawiki (defvar wiki-sites '((local) - (archwiki-en :base-url "https://wiki.archlinux.org/title/" - :engine mediawiki - :display-name "Archwiki EN") + (archwiki :base-url "https://wiki.archlinux.org/title/" + :engine mediawiki + :display-name "ArchWiki") (debian-wiki :base-url "https://wiki.debian.org/" :engine moinmoin :display-name "Debian Wiki") @@ -102,6 +102,9 @@ Then calls CALLBACK which is a closure taking no argument." (oddmuse :base-url "https://oddmuse.org/wiki/" :engine oddmuse :display-name "Oddmuse") + (parabolawiki :base-url "https://wiki.parabola.nu/" + :engine mediawiki + :display-name "ParabolaWiki") (ubuntu-wiki :base-url "https://wiki.ubuntu.com/" :engine moinmoin :display-name "Ubuntu Wiki") |