aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2013-03-24 21:57:59 +0100
committerGravatar Tom Willemsen2013-03-24 21:57:59 +0100
commit30acc48afd7e99da2a2792cef027706a2b027931 (patch)
tree4de1afb3ab337abe65772f5e16119d19809d5241
parent2e2c401a86c0ff7c421d311f1d8f9c4a4d63bcff (diff)
downloadclark-30acc48afd7e99da2a2792cef027706a2b027931.tar.gz
clark-30acc48afd7e99da2a2792cef027706a2b027931.zip
Load an init file at startup
With this init file one can change certain defaults, and define their own commands.
-rw-r--r--lisp/clark.lisp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/clark.lisp b/lisp/clark.lisp
index cd9bd19..ef7b6f2 100644
--- a/lisp/clark.lisp
+++ b/lisp/clark.lisp
@@ -111,6 +111,14 @@ The result contains the url, name and the description of the bookmark."
(list (sb-ext:posix-getenv "HOME") "/.local/share"))
'("/clark/bookmarks.db"))))
+(defun get-rc-location ()
+ "Get the location of the RC file."
+ (pathname
+ (apply 'concatenate 'string
+ (or (sb-ext:posix-getenv "XDG_CONFIG_HOME")
+ (list (sb-ext:posix-getenv "HOME") "/.config"))
+ '("/clark/rc.lisp"))))
+
(defun get-tag-id (name)
"Get the rowid of tag NAME."
(execute-single *db* "SELECT rowid FROM tag WHERE name = ?" name))
@@ -156,6 +164,11 @@ The result contains the url, name and the description of the bookmark."
(ensure-directories-exist db-location)
(ensure-db-exists db-location)))
+(defun load-rc ()
+ "Load the RC file."
+ (let ((*package* (in-package :org.ryuslash.clark)))
+ (load (get-rc-location) :if-does-not-exist nil)))
+
(eval-when (:compile-toplevel :load-toplevel)
(defun make-command-name (base)
"Turn BASE into the name of a possible command."
@@ -294,6 +307,7 @@ Print the version number and exit."
Connect to the database, parse command-line arguments, execute and
then disconnect."
+ (load-rc)
(load-db)
(parse-args (cdr args))
(disconnect *db*))