From 01c91130d79b8ed23443507550641ffafae1b88c Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 9 Dec 2014 16:26:51 +0000 Subject: [emacs] Parse transaction leading lines more robustly This began with noticing that the code didn't support the (ugly, yet valid) case of a tab between the date and txn description. I took the opportunity to make the regexes more consistent along the way. --- lisp/ledger-state.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lisp/ledger-state.el') diff --git a/lisp/ledger-state.el b/lisp/ledger-state.el index b2574b10..8fe84053 100644 --- a/lisp/ledger-state.el +++ b/lisp/ledger-state.el @@ -68,10 +68,12 @@ (defun ledger-state-from-string (state-string) "Get state from STATE-CHAR." - (cond ((string-match "\\!" state-string) 'pending) - ((string-match "\\*" state-string) 'cleared) - ((string-match ";" state-string) 'comment) - (t nil))) + (when state-string + (cond + ((string-match "\\!" state-string) 'pending) + ((string-match "\\*" state-string) 'cleared) + ((string-match ";" state-string) 'comment) + (t nil)))) (defun ledger-toggle-current-posting (&optional style) "Toggle the cleared status of the transaction under point. -- cgit v1.2.3