forked from ledger/ledger-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ledger-fonts.el
684 lines (583 loc) · 24.5 KB
/
ledger-fonts.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
;;; ledger-fonts.el --- Helper code for use with the "ledger" command-line tool -*- lexical-binding: t; -*-
;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
;; This is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free
;; Software Foundation; either version 2, or (at your option) any later
;; version.
;;
;; This is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
;; for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
;; MA 02110-1301 USA.
;;; Commentary:
;; All of the faces for ledger mode are defined here.
;;; Code:
(require 'ledger-navigate)
(require 'ledger-regex)
(require 'ledger-state)
(require 'ledger-fontify)
(defgroup ledger-faces nil "Ledger mode highlighting" :group 'ledger)
(defface ledger-font-auto-xact-face
`((t :inherit font-lock-negation-char-face))
"Default face for automatic transactions"
:group 'ledger-faces)
(defface ledger-font-periodic-xact-face
`((t :inherit font-lock-constant-face))
"Default face for automatic transactions"
:group 'ledger-faces)
(defface ledger-font-xact-cleared-face
`((t :inherit ledger-font-payee-cleared-face))
"Default face for cleared transaction"
:group 'ledger-faces)
(defface ledger-font-xact-pending-face
`((t :inherit ledger-font-pending-face))
"Default face for pending transaction"
:group 'ledger-faces)
(defface ledger-font-payee-uncleared-face
`((t :inherit error))
"Default face for Ledger"
:group 'ledger-faces)
(defface ledger-font-payee-cleared-face
`((t :inherit shadow))
"Default face for cleared (*) payees"
:group 'ledger-faces)
(defface ledger-font-payee-pending-face
`((t :inherit ledger-font-pending-face))
"Default face for pending (!) payees"
:group 'ledger-faces)
(defface ledger-font-xact-highlight-face
`((t
,@(and (>= emacs-major-version 27) '(:extend t))
:inherit ledger-occur-xact-face))
"Default face for transaction under point"
:group 'ledger-faces)
(defface ledger-font-pending-face
`((t :inherit warning))
"Default face for pending (!) transactions"
:group 'ledger-faces)
(defface ledger-font-other-face
`((t :inherit font-lock-type-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-directive-face
`((t :inherit font-lock-preprocessor-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-account-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-account-name-face
`((t :inherit font-lock-variable-name-face))
"Face for account names in account and alias directives"
:group 'ledger-faces)
(defface ledger-font-note-directive-face
`((t :inherit ledger-font-directive-face))
"Face for note subdirectives"
:group 'ledger-faces)
(defface ledger-font-note-text-face
`((t :inherit font-lock-doc-face))
"Face for note subdirective text"
:group 'ledger-faces)
(defface ledger-font-default-directive-face
`((t :inherit ledger-font-directive-face))
"Face for default subdirectives"
:group 'ledger-faces)
(defface ledger-font-price-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-price-date-face
`((t :inherit default))
"Face for date and time in price directive"
:group 'ledger-faces)
(defface ledger-font-price-symbol-face
`((t :inherit font-lock-constant-face))
"Face for symbol in price directive"
:group 'ledger-faces)
(defface ledger-font-price-face
`((t :inherit default))
"Face for price in price directive"
:group 'ledger-faces)
(defface ledger-font-apply-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-apply-account-face
`((t :inherit default))
"Face for argument of apply account directive"
:group 'ledger-faces)
(defface ledger-font-apply-tag-face
`((t :inherit default))
"Face for argument of apply tag directive"
:group 'ledger-faces)
(defface ledger-font-alias-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-alias-definition-face
`((t :inherit default))
"Face for aliased account in alias directives"
:group 'ledger-faces)
(defface ledger-font-assert-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-condition-face
`((t :inherit default))
"Default face for check and assert conditions"
:group 'ledger-faces)
(defface ledger-font-assert-condition-face
`((t :inherit ledger-font-condition-face))
"Face for assert conditions"
:group 'ledger-faces)
(defface ledger-font-bucket-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-bucket-account-face
`((t :inherit default))
"Face for bucket directive argument"
:group 'ledger-faces)
(defface ledger-font-C-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for C directive"
:group 'ledger-faces)
(defface ledger-font-C-amount-face
`((t :inherit default))
"Face for amounts in C directives"
:group 'ledger-faces)
(defface ledger-font-capture-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-capture-account-face
`((t :inherit default))
"Face for account name in capture directives"
:group 'ledger-faces)
(defface ledger-font-capture-regex-face
`((t :inherit default))
"Face for match regex in capture directives"
:group 'ledger-faces)
(defface ledger-font-check-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-check-condition-face
`((t :inherit ledger-font-condition-face))
"Face for check conditions"
:group 'ledger-faces)
(defface ledger-font-commodity-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-commodity-name-face
`((t :inherit font-lock-constant-face))
"Face for commodity name in commodity directives"
:group 'ledger-faces)
(defface ledger-font-format-directive-face
`((t :inherit ledger-font-directive-face))
"Face for format subdirective"
:group 'ledger-faces)
(defface ledger-font-commodity-format-face
`((t :inherit default))
"Face for format subdirective argument"
:group 'ledger-faces)
(defface ledger-font-D-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for D directive"
:group 'ledger-faces)
(defface ledger-font-define-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-define-name-face
`((t :inherit font-lock-variable-name-face))
"Face for variable name in define directive"
:group 'ledger-faces)
(defface ledger-font-define-body-face
`((t :inherit default))
"Face for body in define directive"
:group 'ledger-faces)
(defface ledger-font-end-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-expr-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-expr-expression-face
`((t :inherit default))
"Face for expr and eval expressions"
:group 'ledger-faces)
(defface ledger-font-fixed-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-fixed-commodity-face
`((t :inherit font-lock-constant-face))
"Face for commodity name in fixed directive"
:group 'ledger-faces)
(defface ledger-font-fixed-price-face
`((t :inherit default))
"Face for price in fixed directive"
:group 'ledger-faces)
(defface ledger-font-include-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-include-filename-face
`((t :inherit font-lock-string-face))
"Face for file name in include directives"
:group 'ledger-faces)
(defface ledger-font-N-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for N directive"
:group 'ledger-faces)
(defface ledger-font-N-symbol-face
`((t :inherit default))
"Face for symbol in N directives")
(defface ledger-font-payee-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-payee-name-face
`((t :inherit font-lock-function-name-face))
"Face for payee name in payee directive"
:group 'ledger-faces)
(defface ledger-font-payee-regex-face
`((t :inherit font-lock-string-face))
"Face for payee subdirective regex in account directive"
:group 'ledger-faces)
(defface ledger-font-uuid-directive-face
`((t :inherit ledger-font-directive-face))
"Face for uuid subdirectives"
:group 'ledger-faces)
(defface ledger-font-uuid-face
`((t :inherit default))
"Face for uuid in uuid subdirectives"
:group 'ledger-faces)
(defface ledger-font-tag-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-tag-name-face
`((t :inherit font-lock-type-face))
"Face for tag name in tag directive"
:group 'ledger-faces)
(defface ledger-font-timeclock-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for timeclock I,i,O,o,b,h directives"
:group 'ledger-faces)
(defface ledger-font-year-directive-face
`((t :inherit ledger-font-directive-face))
"Default face for other transactions"
:group 'ledger-faces)
(defface ledger-font-year-face
`((t :inherit default))
"Font for year in year directives"
:group 'ledger-faces)
(defface ledger-font-posting-account-face
`((t :inherit ledger-font-default-directive-face))
"Face for Ledger accounts"
:group 'ledger-faces)
(defface ledger-font-posting-account-cleared-face
`((t :inherit ledger-font-payee-cleared-face))
"Face for Ledger accounts"
:group 'ledger-faces)
(defface ledger-font-posting-amount-cleared-face
`((t :inherit ledger-font-posting-account-cleared-face))
"Face for Ledger accounts"
:group 'ledger-faces)
(defface ledger-font-posting-account-pending-face
`((t :inherit ledger-font-pending-face))
"Face for Ledger accounts"
:group 'ledger-faces)
(defface ledger-font-posting-amount-pending-face
`((t :inherit ledger-font-posting-account-pending-face))
"Face for Ledger accounts"
:group 'ledger-faces)
(defface ledger-font-posting-amount-face
`((t :inherit font-lock-constant-face ))
"Face for Ledger amounts"
:group 'ledger-faces)
(defface ledger-font-posting-date-face
`((t :inherit font-lock-keyword-face))
"Face for Ledger dates"
:group 'ledger-faces)
(defface ledger-occur-narrowed-face
`((t :inherit font-lock-comment-face :invisible t))
"Default face for Ledger occur mode hidden transactions"
:group 'ledger-faces)
(defface ledger-occur-xact-face
`((t :inherit highlight))
"Default face for Ledger occur mode shown transactions"
:group 'ledger-faces)
(defface ledger-font-comment-face
`((t :inherit font-lock-comment-face))
"Face for Ledger comments"
:group 'ledger-faces)
(defface ledger-font-reconciler-uncleared-face
`((t :inherit ledger-font-payee-uncleared-face))
"Default face for uncleared transactions in the reconcile window"
:group 'ledger-faces)
(defface ledger-font-reconciler-cleared-face
`((t :inherit ledger-font-payee-cleared-face))
"Default face for cleared (*) transactions in the reconcile window"
:group 'ledger-faces)
(defface ledger-font-reconciler-pending-face
`((t :inherit ledger-font-pending-face))
"Default face for pending (!) transactions in the reconcile window"
:group 'ledger-faces)
(defface ledger-font-report-clickable-face
`((t))
"Face applied to clickable entries in the report window"
:group 'ledger-faces)
(defface ledger-font-code-face
`((t :inherit default))
"Face for Ledger codes"
:group 'ledger-faces)
(defun ledger-font-face-by-state (num faces)
"Choose one of three faces depending on transaction state.
NUM specifies a match group containing the state.
FACES has the form (CLEARED PENDING OTHER).
Return CLEARED if that group specifies a cleared transaction,
PENDING if pending, and OTHER if none of the above."
(let ((state (save-match-data (ledger-state-from-string (match-string num)))))
(cond ((eq state 'cleared) (nth 0 faces))
((eq state 'pending) (nth 1 faces))
(t (nth 2 faces)))))
(defun ledger-font-face-by-timeclock-state (num faces)
"Choose one of two faces depending on a timeclock directive character.
NUM specifies a match group containing the character.
FACES has the form (CLEARED UNCLEARED).
Return CLEARED if the character specifies a cleared transaction,
UNCLEARED otherwise."
(if (member (match-string num) '("I" "O"))
(nth 0 faces)
(nth 1 faces)))
(defun ledger-font-subdirectives (subdirectives)
"Construct anchored highlighters for subdirectives.
Each element of SUBDIRECTIVES should have the form (MATCHER
SUBEXP-HIGHLIGHTERS…). The result will be a list of elements of
the form (MATCHER PRE-FORM POST-FORM SUBEXP-HIGHLIGHTERS) with
PRE-FORM and POST-FORM set to appropriate values.
See `font-lock-keywords' for the full description."
(mapcar (lambda (item)
`(,(car item)
(save-excursion
(save-match-data
(ledger-navigate-end-of-xact))
(point))
(goto-char (match-end 0))
,@(cdr item)))
subdirectives))
(defvar ledger-font-lock-keywords
`(("^[;#%|*].*$" . 'ledger-font-comment-face)
("^\\(account\\)\\(?:[[:blank:]]\\(.*\\)\\)?$"
(1 'ledger-font-account-directive-face)
(2 'ledger-font-account-name-face nil :lax)
,@(ledger-font-subdirectives
'(("^[ \t]+\\(;.*\\)" (1 'ledger-font-comment-face))
("^[ \t]+\\(note\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-note-directive-face)
(2 'ledger-font-note-text-face nil :lax))
("^[ \t]+\\(alias\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-alias-directive-face)
(2 'ledger-font-account-name-face nil :lax))
("^[ \t]+\\(payee\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-payee-directive-face)
(2 'ledger-font-payee-regex-face nil :lax))
("^[ \t]+\\(check\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-check-directive-face)
(2 'ledger-font-check-condition-face nil :lax))
("^[ \t]+\\(assert\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-assert-directive-face)
(2 'ledger-font-assert-condition-face nil :lax))
("^[ \t]+\\(eval\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-expr-directive-face)
(2 'ledger-font-expr-expression-face nil :lax))
("^[ \t]+\\(default\\)\\>.*"
(1 'ledger-font-default-directive-face)))))
("^\\(alias\\)\\(?:[[:blank:]]+\\([^=\n]*\\)\\(?:=\\(.*\\)\\)?\\)?$"
(1 'ledger-font-alias-directive-face)
(2 'ledger-font-account-name-face nil :lax)
(3 'ledger-font-alias-definition-face nil :lax))
(,(concat "^\\(apply\\)\\(?:[[:blank:]]+"
"\\(?:\\(account\\)\\(?:[[:blank:]]+\\(.*\\)\\)?"
"\\|\\(tag\\)\\(?:[[:blank:]]+\\(.*\\)\\)?\\)\\)?$")
(1 'ledger-font-apply-directive-face)
(2 'ledger-font-apply-directive-face nil :lax)
(3 'ledger-font-apply-account-face nil :lax)
(4 'ledger-font-apply-directive-face nil :lax)
(5 'ledger-font-apply-tag-face nil :lax))
("^\\(assert\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-assert-directive-face)
(2 'ledger-font-assert-condition-face nil :lax))
("^\\(bucket\\|A\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-bucket-directive-face)
(2 'ledger-font-bucket-account-face nil :lax))
(,(concat "^\\(C\\)"
"\\(?:[[:blank:]]+\\([^=\n]*?\\)[[:blank:]]*"
"\\(?:=[[:blank:]]*\\(.*\\)\\)?\\)?$")
(1 'ledger-font-C-directive-face)
(2 'ledger-font-C-amount-face nil :lax)
(3 'ledger-font-C-amount-face nil :lax))
(,(concat "^\\(capture\\)"
"\\(?:[[:blank:]]+\\(.*?\\)"
"\\(?:\\(?:\t\\|[ \t]\\{2,\\}\\)\\(.*\\)\\)?\\)?$")
(1 'ledger-font-capture-directive-face)
(2 'ledger-font-capture-account-face nil :lax)
(3 'ledger-font-capture-regex-face nil :lax))
("^\\(check\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-check-directive-face)
(2 'ledger-font-check-condition-face nil :lax))
(,(concat "^\\(?:comment\\|test\\)\\>"
"[^\0]*?\n"
"end[[:blank:]]+\\(?:comment\\|test\\)\\>.*\n")
. 'ledger-font-comment-face)
("^\\(commodity\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-commodity-directive-face)
(2 'ledger-font-commodity-name-face nil :lax)
,@(ledger-font-subdirectives
'(("^[ \t]+\\(;.*\\)" (1 'ledger-font-comment-face))
("^[ \t]+\\(note\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-note-directive-face)
(2 'ledger-font-note-text-face nil :lax))
("^[ \t]+\\(format\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-format-directive-face)
(2 'ledger-font-commodity-format-face nil :lax))
("^[ \t]+\\(nomarket\\)\\>.*"
(1 'ledger-font-N-directive-face))
("^[ \t]+\\(default\\)\\>.*"
(1 'ledger-font-default-directive-face)))))
("^\\(D\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-D-directive-face)
(2 'ledger-font-commodity-format-face nil :lax))
(,(concat "^\\(define\\|def\\)"
"\\(?:[[:blank:]]+\\([^=\n]*?\\)[[:blank:]]*"
"\\(?:=[[:blank:]]*\\(.*\\)\\)?\\)?$")
(1 'ledger-font-define-directive-face)
(2 'ledger-font-define-name-face nil :lax)
(3 'ledger-font-define-body-face nil :lax))
(,(concat "^\\(end\\)"
"\\(?:[[:blank:]]+\\(apply\\)"
"\\(?:[[:blank:]]+\\(account\\|tag\\)\\>.*\\)?\\)?$")
(1 'ledger-font-end-directive-face)
(2 'ledger-font-end-directive-face nil :lax)
(3 'ledger-font-end-directive-face nil :lax))
("^\\(endfixed\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-end-directive-face)
(2 'ledger-font-fixed-commodity-face nil :lax))
("^\\(expr\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-expr-directive-face)
(2 'ledger-font-expr-expression-face nil :lax))
("^\\(fixed\\)\\(?:[[:blank:]]+\\([^[:blank:]\n]+\\)\\(?:[[:blank:]]+\\(.*\\)\\)?\\)?$"
(1 'ledger-font-fixed-directive-face)
(2 'ledger-font-fixed-commodity-face nil :lax)
(3 'ledger-font-fixed-price-face nil :lax))
("^\\(include\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-include-directive-face)
(2 'ledger-font-include-filename-face nil :lax))
("^\\(N\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-N-directive-face)
(2 'ledger-font-N-symbol-face nil :lax))
("^\\(payee\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-payee-directive-face)
(2 'ledger-font-payee-name-face nil :lax)
,@(ledger-font-subdirectives
'(("^[ \t]+\\(;.*\\)" (1 'ledger-font-comment-face))
("^[ \t]+\\(alias\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-alias-directive-face)
(2 'ledger-font-payee-regex-face nil :lax))
("^[ \t]+\\(uuid\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-uuid-directive-face)
(2 'ledger-font-uuid-face nil :lax)))))
(,(concat "^\\(P\\)"
"\\(?:[[:blank:]]+\\([^[:blank:]\n]+"
"\\(?:[[:blank:]]+[[:digit:]][^[:blank:]\n]*\\)?\\)"
"\\(?:[[:blank:]]+\\(\".*?\"\\|[^[:blank:]\n]+\\)"
"\\(?:[[:blank:]]+\\(.*\\)\\)?\\)?\\)?$")
(1 'ledger-font-price-directive-face)
(2 'ledger-font-price-date-face nil :lax)
(3 'ledger-font-price-symbol-face nil :lax)
(4 'ledger-font-price-face nil :lax))
("^\\(tag\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-tag-directive-face)
(2 'ledger-font-tag-name-face nil :lax)
,@(ledger-font-subdirectives
'(("^[ \t]+\\(;.*\\)" (1 'ledger-font-comment-face))
("^[ \t]+\\(check\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-check-directive-face)
(2 'ledger-font-check-condition-face nil :lax))
("^[ \t]+\\(assert\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-assert-directive-face)
(2 'ledger-font-assert-condition-face nil :lax)))))
(,(concat "^\\([IiOo]\\)"
"\\(?:[[:blank:]]+\\([^[:blank:]\n]+"
"\\(?:[[:blank:]]+[^[:blank:]\n]+\\)?\\)"
"\\(?:[[:blank:]]+\\(.*?\\)"
"\\(?:\\(?:\t\\|[ \t]\\{2,\\}\\)\\(.*?\\)"
"\\(?:\\(?:\t\\|[ \t]\\{2,\\}\\)\\(;.*\\)\\)?\\)?\\)?\\)?$")
(1 'ledger-font-timeclock-directive-face)
(2 'ledger-font-posting-date-face nil :lax)
(3 (ledger-font-face-by-timeclock-state 1 '(ledger-font-posting-account-cleared-face
ledger-font-posting-account-face)) nil :lax)
(4 (ledger-font-face-by-timeclock-state 1 '(ledger-font-payee-cleared-face
ledger-font-payee-uncleared-face)) nil :lax)
(5 'ledger-font-comment-face nil :lax))
("^\\([bh]\\)\\>.*$" (1 'ledger-font-timeclock-directive-face))
("^\\(year\\|Y\\)\\(?:[[:blank:]]+\\(.*\\)\\)?$"
(1 'ledger-font-year-directive-face)
(2 'ledger-font-year-face nil :lax))
(,(lambda (limit)
(when ledger-fontify-xact-state-overrides
(re-search-forward
(concat "^\\(?:\\([=~]\\)[ \t].*\\|" ; auto/periodic, subexpr 1
"[[:digit:]][^ \t\n]*" ; date
"[ \t]+\\([*!]\\)" ; mark, subexp 2
".*\\)" ; rest of header
"\\(?:\n[ \t]+.*\\)*" ; postings
)
limit t)))
(0 (cond ((equal "=" (match-string 1)) 'ledger-font-auto-xact-face)
((equal "~" (match-string 1)) 'ledger-font-periodic-xact-face)
(t (ledger-font-face-by-state 2 '(ledger-font-xact-cleared-face
ledger-font-xact-pending-face))))))
(,(concat "^\\(?:\\(\\([=~]\\).*\\)\\|" ; auto/periodic, subexp 1, 2
"\\([[:digit:]][^ \t\n]*\\)" ; date, subexp 3
ledger-xact-after-date-regex "\\)") ; mark 4, code 5, desc 6, comment 7
(1 (cond ((equal "=" (match-string 2)) 'ledger-font-auto-xact-face)
((equal "~" (match-string 2)) 'ledger-font-periodic-xact-face)
(t 'ledger-font-default-directive-face))
nil :lax)
(3 'ledger-font-posting-date-face nil :lax)
(5 'ledger-font-code-face nil :lax)
(6 (ledger-font-face-by-state 4 '(ledger-font-payee-cleared-face
ledger-font-payee-pending-face
ledger-font-payee-uncleared-face))
nil :lax)
(7 'ledger-font-comment-face nil :lax)
,@(ledger-font-subdirectives
`(("^[ \t]+\\(;.*\\)"
(1 'ledger-font-comment-face))
(,ledger-posting-regex ; state and account 1, state 2, account 3, amount 4, comment 5
(1 (ledger-font-face-by-state 2 '(ledger-font-posting-account-cleared-face
ledger-font-posting-account-pending-face
ledger-font-posting-account-face))
nil :lax)
(4 (ledger-font-face-by-state 2 '(ledger-font-posting-amount-cleared-face
ledger-font-posting-amount-pending-face
ledger-font-posting-amount-face))
nil :lax)
(5 'ledger-font-comment-face nil :lax))))))
"Expressions to highlight in Ledger mode.")
(provide 'ledger-fonts)
;;; ledger-fonts.el ends here