aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/.emacs.d/lisp/my/wiki.el29
1 files changed, 17 insertions, 12 deletions
diff --git a/emacs/.emacs.d/lisp/my/wiki.el b/emacs/.emacs.d/lisp/my/wiki.el
index 4b8184d..03a13ec 100644
--- a/emacs/.emacs.d/lisp/my/wiki.el
+++ b/emacs/.emacs.d/lisp/my/wiki.el
@@ -27,7 +27,18 @@
;;; Code:
(require 'wiki-faces)
-(defvar wiki-link-re
+(defvar wiki-url-regexp "https?://[^ ]+")
+
+(defvar wiki-external-link-re
+ (rx (seq "[["
+ (group (seq "http"
+ (opt "s")
+ "://"
+ (+ (not " "))))
+ (opt (seq " " (group (+? anything))))
+ "]]")))
+
+(defvar wiki-internal-link-re
(rx (seq "[["
;; Target
(group
@@ -52,13 +63,6 @@
(cons "'''[^ \t\n'].*?[^ \t\n']'''" 'wiki-bold)
(cons "''[^ \t\n'].*?[^ \t\n']''" 'wiki-italic)
(cons "^ .*$" 'wiki-pre-face)
- ;; FIXME: not working, need to do something like `org-activate-links'
- (cons "\\(\\[\\[\\)\\([^][|]+\\)\\(|\\)\\([^][|]+\\)\\(\\]\\]\\)"
- '((1 invisible)
- (2 invisible)
- (3 invisible)
- (4 wiki-link)
- (5 invisible)))
))
(defvar wiki-font-lock-keywords nil)
@@ -70,11 +74,11 @@
(length (match-string 2))
6)))
-;; `org-activate-links'
-(defun wiki-activate-links ()
+;; Like `org-activate-links'
+(defun wiki-activate-links (link-re)
(save-excursion
(goto-char (point-min))
- (while (re-search-forward wiki-link-re nil t)
+ (while (re-search-forward link-re nil t)
(let ((start (match-beginning 0))
(end (match-end 0))
(visible-start (or (match-beginning 2) (match-beginning 1)))
@@ -99,7 +103,8 @@
(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-activate-links wiki-external-link-re)
+ (wiki-activate-links wiki-internal-link-re))
(provide 'wiki)
;;; wiki.el ends here