blob: 47710d54d6945c727040edeca350118997716ca8 (
plain)
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
|
(defun buffers ()
"TODO"
(nth 2
(first
(w3m-load-list w3m-session-file))))
(defun my-w3m-session-backup ()
"TODO"
(mapcar
(lambda (buffer)
(cons
;; URL
(first buffer)
;; Page title
(last buffer)))
(buffers)))
;; (first (nth 2
;; (first
;; (w3m-load-list w3m-session-file))))
(my-w3m-session-backup)
;; Write to file
;; https://stackoverflow.com/questions/2321904/elisp-how-to-save-data-in-a-file#2322164
;; Format some YAML text to write to the file
;; Configurable dynamic filename based on date-time
(defun yml-escape (str)
"YAML escape single quotes by doubling them."
(replace-regexp-in-string
(regexp-quote "'")
"''"
str
'fixedcase
'literal))
(defun save-backup ()
"TODO"
(with-temp-file "~/tmp-w3m-session.yml"
(insert
(string-join
(mapcar
(lambda (page)
(format "- page_title: '%s'
url: '%s'"
(yml-escape (first (last page)))
(first page)))
(my-w3m-session-backup))
"\n"))))
(save-backup)
|