diff options
Diffstat (limited to 'wiki-markup.el')
-rw-r--r-- | wiki-markup.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/wiki-markup.el b/wiki-markup.el index 0675c44..4a74974 100644 --- a/wiki-markup.el +++ b/wiki-markup.el @@ -68,8 +68,14 @@ (defvar wiki-outline-regexp "=+.*=+\ *$") +(defvar-local wiki-fetcher nil + "Buffer-local function to fetch a wiki title") +(defun wiki-follow-wikilink-action (data) + "Button action to follow a wikilink" + (funcall wiki-fetcher (alist-get 'title data))) + (defun wiki-outline-level () - (when (looking-at "\\(=+\\).*\\(=+\\)\ *$") + (when (looking-at "\\(=+\\).*[^=]\\(=+\\)\\ *$") (min (length (match-string 1)) (length (match-string 2)) 6))) @@ -83,9 +89,13 @@ (end (match-end 0)) (visible-start (or (match-beginning 2) (match-beginning 1))) (visible-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 end 'font-lock-face 'wiki-link) + (make-text-button start end + 'action 'wiki-follow-wikilink-action + 'button-data `((title . ,title))) (put-text-property visible-end end 'invisible t) (add-text-properties (1- visible-start) visible-start '(rear-nonsticky (invisible))) @@ -105,7 +115,6 @@ (setq-local comment-start "<!--") (setq-local comment-end "-->") - ;; FIXME: this should not be necessary in outline mode (setq-local font-lock-defaults '(wiki-font-lock-keywords t |