diff options
Diffstat (limited to 'lisp/ldg-init.el')
-rw-r--r-- | lisp/ldg-init.el | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/lisp/ldg-init.el b/lisp/ldg-init.el index 29839c9e..f283c77c 100644 --- a/lisp/ldg-init.el +++ b/lisp/ldg-init.el @@ -30,25 +30,25 @@ (defvar ledger-environment-alist nil) -(defun ledger-init-parse-initialization (file) - (with-current-buffer file - (setq ledger-environment-alist nil) - (goto-char (point-min)) - (while (re-search-forward ledger-init-string-regex nil t ) - (let ((matchb (match-beginning 0)) ;; save the match data, string-match stamp on it - (matche (match-end 0))) - (end-of-line) - (setq ledger-environment-alist - (append ledger-environment-alist - (list (cons (let ((flag (buffer-substring-no-properties (+ 2 matchb) matche))) - (if (string-match "[ \t\n\r]+\\'" flag) - (replace-match "" t t flag) - flag)) - (let ((value (buffer-substring-no-properties matche (point) ))) - (if (> (length value) 0) - value - t)))))))) - ledger-environment-alist)) +(defun ledger-init-parse-initialization (buffer) + (with-current-buffer buffer + (let (environment-alist) + (goto-char (point-min)) + (while (re-search-forward ledger-init-string-regex nil t ) + (let ((matchb (match-beginning 0)) ;; save the match data, string-match stamp on it + (matche (match-end 0))) + (end-of-line) + (setq environment-alist + (append environment-alist + (list (cons (let ((flag (buffer-substring-no-properties (+ 2 matchb) matche))) + (if (string-match "[ \t\n\r]+\\'" flag) + (replace-match "" t t flag) + flag)) + (let ((value (buffer-substring-no-properties matche (point) ))) + (if (> (length value) 0) + value + t)))))))) + environment-alist))) (defun ledger-init-load-init-file () (interactive) @@ -59,7 +59,8 @@ (file-exists-p ledger-init-file-name) (file-readable-p ledger-init-file-name)) (find-file-noselect ledger-init-file-name) - (ledger-init-parse-initialization init-base-name) + (setq ledger-environment-alist + (ledger-init-parse-initialization init-base-name)) (kill-buffer init-base-name))))) (provide 'ldg-init) |