From 88366a828ba5bee39e704eb7525102db65878e22 Mon Sep 17 00:00:00 2001 From: Matteo Landi Date: Mon, 1 Jun 2020 11:52:18 +0200 Subject: [PATCH] Try to load `.lispwords` from the current directory first. --- README.adoc | 15 +++++++-------- lispindent.lisp | 10 +++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/README.adoc b/README.adoc index b5759b1..8f87ea6 100644 --- a/README.adoc +++ b/README.adoc @@ -167,16 +167,15 @@ have an LIN of 0. == Customization -You can specify your own LINs for keywords via a customization -file. The name of the file is the first available of the -following: +You can specify your own LINs for keywords via one customization +files; `lispindent` will try and read these files, in this order: -- the value of the environment variable `LISPWORDS`, if set -- the file `.lispwords` in your home directory +- the file `.lispwords` in the current directory +- the value of the environment variable `LISPWORDS`, if set, or `.lispwords` in + your home directory -If `LISPWORDS` isn't set and `~/.lispwords` doesn't exist, no -customization is done. If `LISPWORDS` is set but the thus named -file doesn't exist, no customization is done. +If `lispindent` for whatever reason can't read any of these `.lispindent` files, +then no customization is done. `~/.lispwords` can contain any number of 2-element lists: The first element of each list is a Lisp symbol diff --git a/lispindent.lisp b/lispindent.lisp index fbcb6e8..6f2bf2c 100755 --- a/lispindent.lisp +++ b/lispindent.lisp @@ -34,10 +34,8 @@ #+mkcl (mkcl:getenv s) #+sbcl (sb-ext:posix-getenv s)) -(defun read-home-lispwords () - (with-open-file (i (or (retrieve-env "LISPWORDS") - (merge-pathnames ".lispwords" (user-homedir-pathname))) - :if-does-not-exist nil) +(defun read-lisp-words (path) + (with-open-file (i path :if-does-not-exist nil) (when i (loop (let ((w (or (read i nil) (return)))) @@ -176,7 +174,9 @@ (incf i)) (incr-finished-subforms))))))) -(read-home-lispwords) +(read-lisp-words (merge-pathnames ".lispwords")) +(read-lisp-words (or (retrieve-env "LISPWORDS") + (merge-pathnames ".lispwords" (user-homedir-pathname)))) (indent-lines)