aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-07-07 09:56:01 +1000
committerYuchen Pei <id@ypei.org>2023-07-07 09:56:01 +1000
commitd1786b852a786164769423321caed0fc99be9421 (patch)
treee9c479b1aa73eec4e64255b2b818d5302a52e0ff /emacs/.emacs.d/lisp/my
parent56119e39b25f77a91cd5bbcb8660ffee34178824 (diff)
wiki mode should call activate link in syntax
Diffstat (limited to 'emacs/.emacs.d/lisp/my')
-rw-r--r--emacs/.emacs.d/lisp/my/my-libgen.el2
-rw-r--r--emacs/.emacs.d/lisp/my/wiki.el24
2 files changed, 16 insertions, 10 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-libgen.el b/emacs/.emacs.d/lisp/my/my-libgen.el
index 09a663a..c7fad33 100644
--- a/emacs/.emacs.d/lisp/my/my-libgen.el
+++ b/emacs/.emacs.d/lisp/my/my-libgen.el
@@ -151,7 +151,7 @@
(format "%s/main/%s" my-libgen-library-host
(alist-get 'md5 info))
(format "\\.%s$" (alist-get 'extension info))))
- (format "%s/%s" my-libgen-download-dir
+ (format "%s/%s" (expand-file-name my-libgen-download-dir)
(my-libgen-format-filename info)))))
(defvar my-libgen-button-keymap
diff --git a/emacs/.emacs.d/lisp/my/wiki.el b/emacs/.emacs.d/lisp/my/wiki.el
index 03a13ec..c1ea064 100644
--- a/emacs/.emacs.d/lisp/my/wiki.el
+++ b/emacs/.emacs.d/lisp/my/wiki.el
@@ -63,8 +63,9 @@
(cons "'''[^ \t\n'].*?[^ \t\n']'''" 'wiki-bold)
(cons "''[^ \t\n'].*?[^ \t\n']''" 'wiki-italic)
(cons "^ .*$" 'wiki-pre-face)
+ '(wiki-activate-external-links)
+ '(wiki-activate-internal-links)
))
-(defvar wiki-font-lock-keywords nil)
(defvar wiki-outline-regexp "=+.*=+\ *$")
@@ -75,24 +76,30 @@
6)))
;; Like `org-activate-links'
-(defun wiki-activate-links (link-re)
+(defun wiki-activate-links (link-re limit)
(save-excursion
(goto-char (point-min))
- (while (re-search-forward link-re nil t)
+ (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)))
)
(put-text-property start visible-start 'invisible t)
- (put-text-property visible-start visible-end 'font-lock-face 'wiki-link)
+ (put-text-property start end 'font-lock-face 'wiki-link)
(put-text-property visible-end end 'invisible t)
(add-text-properties (1- visible-start) visible-start
- '(rear-nonsticky invisible))
- (add-text-properties (1- visible-start) visible-start
- '(rear-nonsticky invisible))
+ '(rear-nonsticky (invisible)))
+ (add-text-properties (1- visible-end) visible-end
+ '(rear-nonsticky (invisible)))
))))
+(defun wiki-activate-internal-links (limit)
+ (wiki-activate-links wiki-internal-link-re limit))
+
+(defun wiki-activate-external-links (limit)
+ (wiki-activate-links wiki-external-link-re limit))
+
(define-derived-mode wiki-mode outline-mode "Wiki"
"A wikitext mode."
@@ -103,8 +110,7 @@
(setq-local font-lock-defaults '(wiki-font-lock-keywords t nil nil nil))
(setq-local outline-regexp wiki-outline-regexp)
(setq-local outline-level 'wiki-outline-level)
- (wiki-activate-links wiki-external-link-re)
- (wiki-activate-links wiki-internal-link-re))
+ )
(provide 'wiki)
;;; wiki.el ends here