beancount-mode
beancount-mode copied to clipboard
`.gitignore`, `defadvice`, `flymake`, ...
I think we should fold the flymake code into beancount.el
.
At the very least beancount-mode
should add itself to flymake-diagnostic-functions
so people who want to use Flymake in Beancount can just enable flyamke-mode
rather than having to call some ad-hoc function.
Also, in etc/emacsrc
there's a very weird advice, which I don't understand.
The patch below summarizes the kind of changes I think we should do.
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..bdc4ea6af6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.elc
+/beancount-autoloads.el
+/beancount-pkg.el
diff --git a/beancount.el b/beancount.el
index 50c8cd07e2..9d89a86314 100644
--- a/beancount.el
+++ b/beancount.el
@@ -1,7 +1,7 @@
;;; beancount.el --- A major mode to edit Beancount input files. -*- lexical-binding: t -*-
;; Copyright (C) 2013 Martin Blais <[email protected]>
-;; Copyright (C) 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2024 Free Software Foundation, Inc.
;; Copyright (C) 2019 Daniele Nicolodi <[email protected]>
;; Version: 0
@@ -398,6 +398,8 @@ are reserved for the mode anyway.)")
(setq-local outline-regexp beancount-outline-regexp)
(setq-local outline-level #'beancount-outline-level)
+ (add-hook 'flymake-diagnostic-functions #'flymake-bean-check--run nil t)
+
(setq imenu-generic-expression
(list (list nil (concat "^" beancount-outline-regexp "\\s-+\\(.*\\)$") 2))))
diff --git a/etc/emacsrc b/etc/emacsrc
index 6d3f366423..c4d2bceb8b 100644
--- a/etc/emacsrc
+++ b/etc/emacsrc
@@ -1,4 +1,4 @@
-;; -*- mode: emacs-lisp -*-
+;; -*- mode: emacs-lisp; lexical-binding: t -*-
;;
;; Emacs setup for Ledger.
;;
@@ -8,7 +8,8 @@
(require 'beancount)
;; Automatically open .beancount files in beancount-mode.
-(add-to-list 'auto-mode-alist '("\\.beancount$" . beancount-mode))
+;; FIXME: Shouldn't that be in `beancount.el' with an ;;;###autoload ?
+(add-to-list 'auto-mode-alist '("\\.beancount\\'" . beancount-mode))
;; Support parsing Python logging errors, with a suitable logging.basicConfig()
@@ -73,13 +74,13 @@
;; alignment column to be determined from file content. Postings in
;; transactions are indented with `beancount-transaction-indent` spaces.
-(defadvice shell-quote-argument (around dont-quote-already-quoted-args activate)
- "Avoid quoting argument if it's already quoted."
- (let ((arg (ad-get-arg 0)))
- (setq ad-return-value
- (if (or (string-match "\".*\"$" arg)
- (string-match "\'.*\'$" arg))
- arg ad-do-it))))
+;; (defadvice shell-quote-argument (around dont-quote-already-quoted-args activate)
+;; "Avoid quoting argument if it's already quoted."
+;; (let ((arg (ad-get-arg 0)))
+;; (setq ad-return-value
+;; (if (or (string-match "\".*\"$" arg)
+;; (string-match "\'.*\'$" arg))
+;; arg ad-do-it))))
(defvar beancount-journal-command
(concat
@@ -90,7 +91,7 @@
"Run a journal command for the account at point."
(interactive)
(let* ((account (thing-at-point 'beancount-account))
- (sql (concat "\"" (format beancount-journal-command account) "\"")))
+ (sql (format beancount-journal-command account) "\""))
(beancount--run beancount-query-program
(file-relative-name buffer-file-name)
sql)))
@@ -110,7 +111,7 @@
"Run a balance command for the account at point."
(interactive)
(let* ((account (thing-at-point 'beancount-account))
- (sql (concat "\"" (format beancount-balance-command account) "\"")))
+ (sql (format beancount-balance-command account)))
(beancount--run beancount-query-program
(file-relative-name buffer-file-name)
sql)))
Thanks @monnier. Al these look good to me. Can you submit this as a PR with one patch per logical change?