@@ -224,7 +224,7 @@ an alist (ACCOUNT-ELEMENT . NODE)."
224
224
(defvar ledger-complete--current-time-for-testing nil
225
225
" Internal, used for testing only." )
226
226
227
- (defun ledger-complete-date (month-string day-string )
227
+ (defun ledger-complete-date (month-string day-string date-at-eol-p )
228
228
" Complete a date."
229
229
(let* ((now (or ledger-complete--current-time-for-testing (current-time )))
230
230
(decoded (decode-time now))
@@ -243,15 +243,16 @@ an alist (ACCOUNT-ELEMENT . NODE)."
243
243
(let ((collection
244
244
(list (concat (ledger-format-date
245
245
(cl-find-if (lambda (date ) (not (time-less-p now date))) dates))
246
- (and ( = ( point ) ( line-end-position )) " " )))))
246
+ (when date-at-eol-p " " )))))
247
247
(lambda (string predicate action )
248
248
(if (eq action 'metadata )
249
249
'(metadata (category . ledger-date))
250
250
(complete-with-action action collection string predicate))))))
251
251
252
252
(defun ledger-complete-effective-date
253
253
(tx-year-string tx-month-string tx-day-string
254
- month-string day-string)
254
+ month-string day-string
255
+ date-at-eol-p)
255
256
" Complete an effective date."
256
257
(let* ((tx-year (string-to-number tx-year-string))
257
258
(tx-month (string-to-number tx-month-string))
@@ -270,7 +271,7 @@ an alist (ACCOUNT-ELEMENT . NODE)."
270
271
(let ((collection
271
272
(list (concat (ledger-format-date
272
273
(cl-find-if (lambda (date ) (not (time-less-p date tx-date))) dates))
273
- (and ( = ( point ) ( line-end-position )) " " )))))
274
+ (when date-at-eol-p " " )))))
274
275
(lambda (string predicate action )
275
276
(if (eq action 'metadata )
276
277
'(metadata (category . ledger-date))
@@ -286,7 +287,9 @@ an alist (ACCOUNT-ELEMENT . NODE)."
286
287
(save-excursion
287
288
(skip-chars-forward " 0-9/-" )
288
289
(looking-back (concat " ^" ledger-incomplete-date-regexp) (line-beginning-position )))
289
- (setq collection (ledger-complete-date (match-string 1 ) (match-string 2 ))
290
+ (setq collection (ledger-complete-date (match-string 1 )
291
+ (match-string 2 )
292
+ (= (line-end-position ) (match-end 0 )))
290
293
start (match-beginning 0 )
291
294
delete-suffix (save-match-data
292
295
(when (looking-at (rx (one-or-more (or digit (any ?/ ?- )))))
@@ -299,7 +302,8 @@ an alist (ACCOUNT-ELEMENT . NODE)."
299
302
(setq start (line-beginning-position ))
300
303
(setq collection (ledger-complete-effective-date
301
304
(match-string 2 ) (match-string 3 ) (match-string 4 )
302
- (match-string 5 ) (match-string 6 ))))
305
+ (match-string 5 ) (match-string 6 )
306
+ (= (line-end-position ) (match-end 0 )))))
303
307
(; ; Payees
304
308
(eq 'transaction
305
309
(save-excursion
0 commit comments