-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupport.el
30 lines (26 loc) · 937 Bytes
/
support.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
;; These are just some functions I use to deconstruct ADS queries that
;; have been created by the Webform interface, to understnad the API
;; better. This file is not needed to run `ads'.
(defconst ads-encode-alist
'(("\"" . "%22")
(" " . "%20")
("," . "%2C")
("$" . "%24")
("^" . "%5E")
(":" . "%3A")
("{" . "%7B")
("}" . "%7D")
("=" . "%3D")
))
(setq ads-encode-re (concat "[" (mapconcat 'car ads-encode-alist "") "]"))
(setq ads-decode-re (concat "" (mapconcat 'cdr ads-encode-alist "\\|") ""))
(defun ads-encode-region (beg end)
(interactive "r")
(goto-char end)
(while (re-search-backward ads-encode-re beg t)
(replace-match (cdr (assoc (match-string 0) ads-encode-alist)) t t)))
(defun ads-decode-region (beg end)
(interactive "r")
(goto-char end)
(while (re-search-backward ads-decode-re beg t)
(replace-match (car (rassoc (match-string 0) ads-encode-alist)) t t)))