-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoinrpc-common.el
68 lines (45 loc) · 1.57 KB
/
moinrpc-common.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; package --- moinmoin xml-rpc client
;;; Commentary:
;;; Code:
;; Common codes
(defvar moinrpc-buffer-name-wiki-format )
(defvar moinrpc-regex-bracket-wikilink
"\\[\\[[^|]+?\\]\\]")
(defvar moinrpc-regex-wikilink
"\\([A-Z][a-z]+\\)\\{2,\\}?")
(defvar moinrpc-regex-table
"\\(||.*?\\)+||")
(defun moinrpc-wiki-name (wiki)
(cdr (assoc 'wiki-alias wiki)))
(defun moinrpc-buffer-name (pagename &optional wiki)
"Construct a buffer name of wiki PAGENAME."
(cond ((and (null wiki) (null pagename))
"*moin*")
((and wiki (null pagename))
(format "*moin:%s*" (moinrpc-wiki-name wiki)))
((and pagename (null wiki))
(format "*moin:%s*" pagename))
(t
(format "*moin:%s:%s*" (moinrpc-wiki-name wiki) pagename))))
(defun moinrpc-strip-text-properties (txt)
"Remove all text properties of TXT."
(set-text-properties 0 (length txt) nil txt)
txt)
(defun moinrpc-get-overlay-text (overlay)
(buffer-substring (overlay-start overlay)
(overlay-end overlay)))
(defun moinrpc-wikilink-p (&optional word)
"."
(if (null word)
(thing-at-point-looking-at moinrpc-regex-wikilink
100)
(string-match-p (format "^%s$" moinrpc-regex-wikilink)
word)))
(defun moinrpc-bracket-wikilink-p (&optional word)
"."
(if (null word)
(thing-at-point-looking-at moinrpc-regex-bracket-wikilink
100)
(string-match-p (format "^%s$" moinrpc-regex-bracket-wikilink)
word)))
(provide 'moinrpc-common)