Skip to content

Commit e9bb645

Browse files
authored
Merge pull request #449 from bcc32/outline-config
Configure a reasonable default outline-regexp
2 parents 5243dd2 + a32d756 commit e9bb645

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

NEWS.org

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ containing that posting.
2525
** Removed unused ledger-occur-narrowed-face
2626
This face was not actually used to mark up narrowed text, which is instead
2727
hidden by using overlays.
28+
** ledger-mode now sets default outline-regexp
29+
For =outline-minor-mode= users, ledger-mode now configures a default regexp that
30+
causes multiline, entries, comments, directives, etc. to be folded by the
31+
outline commands.
32+
33+
This will not conflict with existing configurations for using
34+
=outline-minor-mode= to organize large sections of the ledger file, if such
35+
configurations set =outline-regexp= in =ledger-mode-hook= or local variables.
2836
* Release v4.0.0
2937
** The completion system now respects whatever completion system the user prefers
3038
Some users prefer different completion systems such as ivy or helm. To get the

doc/ledger-mode.texi

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ The column Ledger-mode attempts to align accounts to.
11511151
@item ledger-post-amount-alignment-at
11521152
Position at which the amount is aligned.
11531153

1154-
Can be @code{:end} to align on the last number of the amount (can be followed
1154+
Can be @code{:end} to align on the last number of the amount (can be followed
11551155
by unaligned commodity) or @code{:decimal} to align at the decimal separator.
11561156

11571157
@item ledger-post-amount-alignment-column
@@ -1236,12 +1236,11 @@ configuration:
12361236
@cindex org
12371237
@cindex folding
12381238
@lisp
1239-
(eval-after-load 'ledger-mode
1240-
(progn
1241-
;; org-cycle allows completion to work whereas outline-toggle-children does not
1242-
(define-key ledger-mode-map (kbd "TAB") #'org-cycle)
1243-
(add-hook 'ledger-mode-hook #'outline-minor-mode)
1244-
(font-lock-add-keywords 'ledger-mode outline-font-lock-keywords)))
1239+
(with-eval-after-load 'ledger-mode
1240+
;; org-cycle allows completion to work whereas outline-toggle-children does not
1241+
(define-key ledger-mode-map (kbd "TAB") #'org-cycle)
1242+
(add-hook 'ledger-mode-hook #'outline-minor-mode)
1243+
(font-lock-add-keywords 'ledger-mode outline-font-lock-keywords))
12451244
@end lisp
12461245

12471246
@node Concept Index, Command & Variable Index, Hacking Ledger-mode, Top

ledger-mode.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,16 @@ With prefix ARG, decrement by that many instead."
455455
(add-hook 'before-revert-hook 'ledger-highlight--before-revert nil t)
456456
(add-hook 'after-revert-hook 'ledger-highlight-xact-under-point nil t)
457457

458+
(add-to-invisibility-spec 'ledger-occur-hidden)
459+
458460
(ledger-init-load-init-file)
459461
(setq-local comment-start ";")
460462
(setq-local indent-line-function #'ledger-indent-line)
461463
(setq-local indent-region-function 'ledger-post-align-postings)
462464
(setq-local beginning-of-defun-function #'ledger-navigate-beginning-of-xact)
463-
(setq-local end-of-defun-function #'ledger-navigate-end-of-xact))
465+
(setq-local end-of-defun-function #'ledger-navigate-end-of-xact)
466+
467+
(setq-local outline-regexp "[^[:space:]]"))
464468

465469
;;;###autoload
466470
(add-to-list 'auto-mode-alist '("\\.ledger\\'" . ledger-mode))

ledger-occur.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ long, otherwise it is the word at point."
119119
"Make an overlay for an invisible portion of the buffer, from BEG to END."
120120
(let ((ovl (make-overlay beg end)))
121121
(overlay-put ovl ledger-occur-overlay-property-name t)
122-
(overlay-put ovl 'invisible t)))
122+
(overlay-put ovl 'invisible 'ledger-occur-hidden)))
123123

124124
(defun ledger-occur-create-overlays (ovl-bounds)
125125
"Create the overlays for the visible transactions.

0 commit comments

Comments
 (0)