aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-04-11 21:33:36 +0200
committerTeddy Wing2018-04-11 21:33:36 +0200
commitf9b98ba9118195db1f6ada1954404fa39d413b76 (patch)
tree90c1eff85d6b64ecffb78852aad1159a16767b89
parent6131a68b27fae937f9d407e36e18bbbf9d8c11b1 (diff)
downloadw3m-session-backup-f9b98ba9118195db1f6ada1954404fa39d413b76.tar.bz2
Prefix all functions and variables with `w3m-session-backup-`
Since these are global Lisp-style functions, they need to be prefixed for namespacing. Looks like I'm going to call this package "w3m-session-backup" as I can't think of anything more concise and similarly descriptive. As per the Coding Conventions document, use a two-hyphen separator for private functions. > Use two hyphens to separate prefix and name if the symbol is not meant > to be used by other packages. (https://www.gnu.org/software/emacs/manual/html_node/elisp/Coding-Conventions.html#Coding-Conventions)
-rw-r--r--w3m-session-backup.el28
1 files changed, 14 insertions, 14 deletions
diff --git a/w3m-session-backup.el b/w3m-session-backup.el
index 8cb1258..34300e6 100644
--- a/w3m-session-backup.el
+++ b/w3m-session-backup.el
@@ -2,26 +2,26 @@
"TODO")
;; Configurable save directory, default to current path
-(defcustom save-directory "."
+(defcustom w3m-session-backup-save-directory "."
"Directory where backup files are saved."
:type 'directory
:group 'w3m-session-backup
:package-version '(w3m-session-backup . "0.0.1"))
-(defcustom filename-function 'filename
+(defcustom w3m-session-backup-filename-function 'filename
"Function that generates a filename for the session backup."
:type 'function
:group 'w3m-session-backup
:package-version '(w3m-session-backup . "0.0.1"))
-(defun buffers ()
+(defun w3m-session-backup--buffers ()
"TODO"
(nth 2
(first
(w3m-load-list w3m-session-file))))
-(defun my-w3m-session-backup ()
+(defun w3m-session-backup--page-list ()
"TODO"
(mapcar
(lambda (buffer)
@@ -31,20 +31,20 @@
;; Page title
(last buffer)))
- (buffers)))
+ (w3m-session-backup--buffers)))
;; (first (nth 2
;; (first
;; (w3m-load-list w3m-session-file))))
-(my-w3m-session-backup)
+(w3m-session-backup--page-list)
;; 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)
+(defun w3m-session-backup--yml-escape (str)
"YAML escape single quotes by doubling them."
(replace-regexp-in-string
(regexp-quote "'")
@@ -53,28 +53,28 @@
'fixedcase
'literal))
-(defun save-backup ()
+(defun w3m-session-backup--save-backup ()
"TODO"
(with-temp-file
(concat
- (file-name-as-directory save-directory)
- (funcall filename-function))
+ (file-name-as-directory w3m-session-backup-save-directory)
+ (funcall w3m-session-backup-filename-function))
(insert
(string-join
(mapcar
(lambda (page)
(format "- page_title: '%s'
url: '%s'"
- (yml-escape (first (last page)))
+ (w3m-session-backup--yml-escape (first (last page)))
(first page)))
- (my-w3m-session-backup))
+ (w3m-session-backup--page-list))
"\n"))))
-(defun filename ()
+(defun w3m-session-backup--filename ()
"Generates a default filename using the current date & time."
(format "w3m-tabs-%s.yml"
(format-time-string "%Y%m%d-%Hh%Mm%S")))
-(save-backup)
+(w3m-session-backup--save-backup)
;; Make filename customisable