emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/beancount 5be04a37d6 081/103: (Merge branch 'main' into co


From: ELPA Syncer
Subject: [nongnu] elpa/beancount 5be04a37d6 081/103: (Merge branch 'main' into cost)
Date: Mon, 29 Apr 2024 15:59:48 -0400 (EDT)

branch: elpa/beancount
commit 5be04a37d6a189f1680cb47d022a85d9faeba8fc
Merge: dd024c867b e98047d715
Author: blais <blais@furius.ca>
Commit: blais <blais@furius.ca>

    (Merge branch 'main' into cost)
---
 .github/workflows/tests.yaml | 21 ++++++++++++
 Makefile                     |  4 +--
 beancount-tests.el           | 20 +++++++----
 beancount.el                 | 79 ++++++++++++++++++++++++++++++++------------
 4 files changed, 94 insertions(+), 30 deletions(-)

diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
new file mode 100644
index 0000000000..0d6eb8dc9c
--- /dev/null
+++ b/.github/workflows/tests.yaml
@@ -0,0 +1,21 @@
+name: tests
+
+on:
+  pull_request:
+  push:
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        emacs: ['26.1', '26.2', '26.3', '27.1', '27.2']
+    steps:
+    - uses: purcell/setup-emacs@master
+      with:
+        version: ${{ matrix.emacs }}
+    - run: pip install beancount
+    - uses: actions/checkout@v2
+    - run: make compile
+    - run: make test
diff --git a/Makefile b/Makefile
index e80b067359..22e1c72258 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ SRC = beancount.el
 TESTS = beancount-tests.el
 
 compile: $(SRC)
-       $(EMACS) -batch -f batch-byte-compile $<
+       $(EMACS) -Q -batch -f batch-byte-compile $<
 
 test:
-       $(EMACS) -batch -L . -l ert -l $(TESTS) -f ert-run-tests-batch-and-exit
+       $(EMACS) -Q -batch -L . -l ert -l $(TESTS) -f 
ert-run-tests-batch-and-exit
diff --git a/beancount-tests.el b/beancount-tests.el
index 41d7576d96..2dec821e7e 100644
--- a/beancount-tests.el
+++ b/beancount-tests.el
@@ -17,6 +17,7 @@
 
 (require 'ert)
 (require 'beancount)
+(require 'imenu)
 
 (ert-deftest beancount/smoke-001 ()
   :tags '(regress)
@@ -129,6 +130,15 @@ Return a list of substrings each followed by its face."
      "1.00 USD"         beancount-amount
      "Assets:Checking"  beancount-account)))
 
+(ert-deftest beancount/fontify-005 ()
+  :tags '(font regress)
+  (beancount-test-font-lock "
+2019-01-01 open Assets:TD:TDB900 TDB900
+"
+   '("2019-01-01"       beancount-date
+     "open"             beancount-directive
+     "Assets:TD:TDB900" beancount-account)))
+
 (ert-deftest beancount/indent-001 ()
   :tags '(indent regress)
   (with-temp-buffer
@@ -230,9 +240,9 @@ known option nmaes."
            (font-lock-ensure)
            (buffer-string))))
     (should (equal (beancount-test-face-groups fontified)
-                   '("* A"   org-level-1
-                     "** B"  org-level-2
-                     "*** C" org-level-3)))))
+                   '("* A"   beancount-outline-1
+                     "** B"  beancount-outline-2
+                     "*** C" beancount-outline-3)))))
 
 (ert-deftest beancount/account-currency-001 ()
   :tags '(regress)
@@ -308,8 +318,6 @@ known option nmaes."
   :tags '(regress thing-at-point)
   (with-temp-buffer
     (insert "^link")
-    (beancount-mode)
-    (goto-char 2)
     (should (equal (thing-at-point 'beancount-link) "^link"))))
 
 (ert-deftest beancount/link-at-point-002 ()
@@ -322,5 +330,5 @@ known option nmaes."
   :tags '(regress thing-at-point)
   (with-temp-buffer
     (insert "foo ^link baz")
-    (goto-char 15)
+    (goto-char 7)
     (should (equal (thing-at-point 'beancount-link) "^link"))))
diff --git a/beancount.el b/beancount.el
index a3af7556dd..fa49eb94b5 100644
--- a/beancount.el
+++ b/beancount.el
@@ -34,6 +34,7 @@
 (require 'subr-x)
 (require 'outline)
 (require 'thingatpt)
+(require 'cl-lib)
 
 (defgroup beancount ()
   "Editing mode for Beancount files."
@@ -66,49 +67,81 @@ from the open directive for the relevant account."
 (defgroup beancount-faces nil "Beancount mode highlighting" :group 'beancount)
 
 (defface beancount-directive
-  `((t :inherit font-lock-keyword-face))
+  '((t :inherit font-lock-keyword-face))
   "Face for Beancount directives.")
 
 (defface beancount-tag
-  `((t :inherit font-lock-type-face))
+  '((t :inherit font-lock-type-face))
   "Face for Beancount tags.")
 
 (defface beancount-link
-  `((t :inherit font-lock-type-face))
+  '((t :inherit font-lock-type-face))
   "Face for Beancount links.")
 
 (defface beancount-date
-  `((t :inherit font-lock-constant-face))
+  '((t :inherit font-lock-constant-face))
   "Face for Beancount dates.")
 
 (defface beancount-account
-  `((t :inherit font-lock-builtin-face))
+  '((t :inherit font-lock-builtin-face))
   "Face for Beancount account names.")
 
 (defface beancount-amount
-  `((t :inherit font-lock-default-face))
+  '((t :inherit font-lock-default-face))
   "Face for Beancount amounts.")
 
 (defface beancount-narrative
-  `((t :inherit font-lock-builtin-face))
+  '((t :inherit font-lock-builtin-face))
   "Face for Beancount transactions narrative.")
 
 (defface beancount-narrative-cleared
-  `((t :inherit font-lock-string-face))
+  '((t :inherit font-lock-string-face))
   "Face for Beancount cleared transactions narrative.")
 
 (defface beancount-narrative-pending
-  `((t :inherit font-lock-keyword-face))
+  '((t :inherit font-lock-keyword-face))
   "Face for Beancount pending transactions narrative.")
 
 (defface beancount-metadata
-  `((t :inherit font-lock-type-face))
+  '((t :inherit font-lock-type-face))
   "Face for Beancount metadata.")
 
 (defface beancount-highlight
-  `((t :inherit highlight))
+  '((t :inherit highlight))
   "Face to highlight Beancount transaction at point.")
 
+(defface beancount-outline-1
+  '((t :inherit outline-1))
+  "Outline level 1.")
+
+(defface beancount-outline-2
+  '((t :inherit outline-2))
+  "Outline level 2.")
+
+(defface beancount-outline-3
+  '((t :inherit outline-3))
+  "Outline level 3.")
+
+(defface beancount-outline-4
+  '((t :inherit outline-4))
+  "Outline level 4.")
+
+(defface beancount-outline-5
+  '((t :inherit outline-5))
+  "Outline level 5.")
+
+(defface beancount-outline-6
+  '((t :inherit outline-6))
+  "Outline level 6.")
+
+(defface beancount-outline-7
+  '((t :inherit outline-7))
+  "Outline level 7.")
+
+(defface beancount-outline-8
+  '((t :inherit outline-8))
+  "Outline level 8.")
+
 (defconst beancount-account-directive-names
   '("balance"
     "close"
@@ -221,7 +254,7 @@ from the open directive for the relevant account."
 
 (defun beancount-outline-level ()
   (let ((len (- (match-end 1) (match-beginning 1))))
-    (if (equal (substring (match-string 1) 0 1) ";")
+    (if (string-equal (substring (match-string 1) 0 1) ";")
         (- len 2)
       len)))
 
@@ -233,13 +266,15 @@ from the open directive for the relevant account."
 (defun beancount-outline-face ()
   (if outline-minor-mode
       (cl-case (funcall outline-level)
-      (1 'org-level-1)
-      (2 'org-level-2)
-      (3 'org-level-3)
-      (4 'org-level-4)
-      (5 'org-level-5)
-      (6 'org-level-6)
-      (otherwise nil))
+        (1 'beancount-outline-1)
+        (2 'beancount-outline-2)
+        (3 'beancount-outline-3)
+        (4 'beancount-outline-4)
+        (5 'beancount-outline-5)
+        (6 'beancount-outline-6)
+        (7 'beancount-outline-7)
+        (8 'beancount-outline-8)
+        (otherwise nil))
     nil))
 
 (defvar beancount-font-lock-keywords
@@ -254,14 +289,14 @@ from the open directive for the relevant account."
     (,beancount-timestamped-directive-regexp (1 'beancount-date)
                                              (2 'beancount-directive))
     ;; Fontify section headers when composed with outline-minor-mode.
-    (,(concat "^\\(" beancount-outline-regexp "\\).*") . (0 
(beancount-outline-face)))
+    (,(concat "^\\(" beancount-outline-regexp "\\).*") (0 
(beancount-outline-face)))
     ;; Tags and links.
     (,(concat "\\#[" beancount-tag-chars "]*") . 'beancount-tag)
     (,(concat "\\^[" beancount-tag-chars "]*") . 'beancount-link)
-    ;; Number followed by currency not covered by previous rules.
-    (,(concat beancount-number-regexp "\\s-+" beancount-currency-regexp) . 
'beancount-amount)
     ;; Accounts not covered by previous rules.
     (,beancount-account-regexp . 'beancount-account)
+    ;; Number followed by currency not covered by previous rules.
+    (,(concat beancount-number-regexp "\\s-+" beancount-currency-regexp) . 
'beancount-amount)
     ))
 
 (defun beancount-tab-dwim (&optional arg)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]