You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be some debate about which flags are accepted in beancount. Ad hoc testing shows that bean-check 3.1.0 seems to accept !#%&*? and A-Z. It does not accept digits or other punctuation.
In general, case-fold-search is t, which means that the current regexp, which intends to exclude lowercase letters excludes all letters.
This version of beancount-transaction-clear illustrates the problem:
(defun beancount-transaction-clear (&optional arg)
"Clear transaction at point. With a prefix argument set the
transaction as pending."
(interactive "P")
(save-excursion
(save-match-data
(let ((flag (if arg "!" "*")))
(beancount-goto-transaction-begin)
(if (looking-at beancount-transaction-regexp)
(progn
(message "match %s" (match-string 0))
(replace-match flag t t nil 2))
(message "NO match! case-fold-search: %s" case-fold-search)
)))))
Any transaction flagged with a letter will not be cleared. Also, due to issues elsewhere in the code, transactions flagged with digits will be highlighted as though they are valid, even though they are invalid.
Setting case-fold-search to nil temporarily within the function makes it work correctly:
(defun beancount-transaction-clear (&optional arg)
"Clear transaction at point. With a prefix argument set the
transaction as pending."
(interactive "P")
(save-excursion
(save-match-data
(let ((case-fold-search nil))
(let ((flag (if arg "!" "*")))
(beancount-goto-transaction-begin)
(if (looking-at beancount-transaction-regexp)
(replace-match flag t t nil 2)))))))
I suspect that this affects many other functions in beancount.el, so it is probably best to change the regexp to not use complement, e.g., beancount-flag-regexp should be "[!#%&*?A-Z]". This will result in transactions with single lowercase letters being syntax highlighted as though they were valid, but this will be caught by flymake).
Thoughts?
The text was updated successfully, but these errors were encountered:
loverobean
changed the title
Case sensitivity, flags, and C-c C-c
Case sensitivity, flags, and beancount-transaction-clear
Feb 20, 2025
I created a new issue regarding case-fold-search, as it is an issue affecting every function in this mode. This function is actually more convenient with case folding.
Uh oh!
There was an error while loading. Please reload this page.
There seems to be some debate about which flags are accepted in beancount. Ad hoc testing shows that
bean-check 3.1.0
seems to accept!#%&*?
andA-Z
. It does not accept digits or other punctuation.In general,
case-fold-search
ist
, which means that the current regexp, which intends to exclude lowercase letters excludes all letters.This version of
beancount-transaction-clear
illustrates the problem:Any transaction flagged with a letter will not be cleared. Also, due to issues elsewhere in the code, transactions flagged with digits will be highlighted as though they are valid, even though they are invalid.
Setting
case-fold-search
tonil
temporarily within the function makes it work correctly:I suspect that this affects many other functions in
beancount.el
, so it is probably best to change the regexp to not use complement, e.g.,beancount-flag-regexp
should be"[!#%&*?A-Z]"
. This will result in transactions with single lowercase letters being syntax highlighted as though they were valid, but this will be caught byflymake
).Thoughts?
The text was updated successfully, but these errors were encountered: