Skip to content
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

Transaction folding #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Transaction folding #255

wants to merge 1 commit into from

Conversation

drdv
Copy link

@drdv drdv commented Jun 22, 2020

Even though ledger-occur can be used to narrow down a buffer based on a regex, I find it useful to have, in addiction, folding of transaction records. This PR implements the latter. For example, folding a transaction

2011/01/02 Grocery Store
    Expenses:Food:Groceries                  $ 65.00
    * Assets:Checking

results in

2011/01/02 Grocery Store...

Two interactive functions are exposed:

  • ledger-mode-transaction-toggle-folding: hide/show transaction under point
  • ledger-mode-folding-toggle-transactions: hide/show all transactions in the buffer

ledger-occur and transaction folding can be used to complement each other.

The buffer-local variable ledger-mode-toggle-invisible-transactions can be used to enable/disable folding of invisible transactions (i.e., transactions whose overlay has been set using ledger-occur).

Transaction blocks are detected using the same approach as in ledger-highlight-xact-under-point (probably some code refactoring should be done).

The transaction folding functionality has been added to the ledger-occur.el file even though probably a new file should be used (my aim was to do the least amount modifications). The same thing applies to the unit tests.

The function ledger-occur-make-invisible-overlay has been modified by adding (overlay-put ovl 'display "") in order to avoid undesired trailing ellipsis when using ledger-occur together with transaction folding.

Overlay of type 'code has been used in order for incremental search to temporarily open folded blocks.

@drdv
Copy link
Author

drdv commented Jun 22, 2020

Currently, the user might choose not to activate hs-minor-mode if he/she doesn't want to use the folding functionality. On the other hand, a warning is displayed when attempting to use the folding functionality without enabling hs-minor-mode.

@josephmturner
Copy link
Contributor

I'm just stumbling across this now, and I like this idea. Is there a reason why this PR was not merged? Currently, I'm using the simpler folding technique described here:

; M-1 to collapse all transactions to one line, M-0 to reset. Useful for quickly scanning
(global-set-key "\M-0" (lambda () (interactive) (set-selective-display (* tab-width 0))))
(global-set-key "\M-1" (lambda () (interactive) (set-selective-display (* tab-width 1))))
(add-hook 'ledger-mode-hook (lambda () (setq tab-width 4)))

@drdv
Copy link
Author

drdv commented Feb 8, 2022

I don't know why it is not merged.

@jdek
Copy link

jdek commented Mar 19, 2024

@drdv can you squash this into one commit? cc: @bcc32

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

Successfully merging this pull request may close these issues.

3 participants