From 30acc48afd7e99da2a2792cef027706a2b027931 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 24 Mar 2013 21:57:59 +0100 Subject: Load an init file at startup With this init file one can change certain defaults, and define their own commands. --- lisp/clark.lisp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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*)) -- cgit v1.2.3-54-g00ecf