8000 Case sensitivity, flags, and beancount-transaction-clear · Issue #61 · beancount/beancount-mode · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Case sensitivity, flags, and beancount-transaction-clear #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
loverobean opened this issue Feb 20, 2025 · 2 comments
Closed

Case sensitivity, flags, and beancount-transaction-clear #61

loverobean opened this issue Feb 20, 2025 · 2 comments

Comments

@loverobean
Copy link
Contributor
loverobean commented Feb 20, 2025

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?

@loverobean loverobean changed the title Case sensitivity, flags, and C-c C-c Case sensitivity, flags, and beancount-transaction-clear Feb 20, 2025
@blais
Copy link
Member
blais commented Feb 21, 2025

Thanks for flagging this.
It would be nice to enforce case-fold-search to nil where we're using this regexp (if possible)

@loverobean
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0