mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-02-16 16:24:18 +00:00
Nice, new rx form
This commit is contained in:
parent
a369afd24c
commit
6e56b8bb1c
2 changed files with 32 additions and 0 deletions
|
|
@ -247,6 +247,33 @@
|
||||||
;; (advice-add #'ledger-reconcile
|
;; (advice-add #'ledger-reconcile
|
||||||
;; :before
|
;; :before
|
||||||
;; #'my/ledger-reconcile-switch-to-master)
|
;; #'my/ledger-reconcile-switch-to-master)
|
||||||
|
|
||||||
|
(defface ledger-starting-monthly-face
|
||||||
|
`((t ,(list
|
||||||
|
:background "gray25"
|
||||||
|
:extend t
|
||||||
|
:inherit font-lock-comment-face
|
||||||
|
:box `(:line-width 1 :color "gray30" :style ,(if (>= emacs-major-version 30) 'released-button 'raised)))))
|
||||||
|
nil)
|
||||||
|
|
||||||
|
(defun ledger-apply-month-separator ()
|
||||||
|
(interactive)
|
||||||
|
(remove-overlays nil nil 'face 'ledger-starting-monthly-face)
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-buffer)
|
||||||
|
(while (not (eobp))
|
||||||
|
(when (looking-at-p (rx line-start
|
||||||
|
(separated " - "
|
||||||
|
(separated "-" (= 2 digit) (= 3 alpha) (= 2 digit))
|
||||||
|
(separated "-" (= 2 digit) (= 3 alpha) (= 2 digit)))
|
||||||
|
(+ nonl)))
|
||||||
|
(let ((ol (make-overlay (point) (line-end-position))))
|
||||||
|
(overlay-put ol 'face 'ledger-starting-monthly-face)
|
||||||
|
(overlay-put ol 'priority 5)))
|
||||||
|
(next-line))))
|
||||||
|
|
||||||
|
(add-hook 'ledger-report-mode-hook
|
||||||
|
'ledger-apply-month-separator)
|
||||||
)
|
)
|
||||||
|
|
||||||
(fset 'credit_card_statement
|
(fset 'credit_card_statement
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,10 @@
|
||||||
|
|
||||||
(rx-define separated-list (sep &rest match) (seq match (* sep match)))
|
(rx-define separated-list (sep &rest match) (seq match (* sep match)))
|
||||||
|
|
||||||
|
(rx-define separated (sep &rest matches)
|
||||||
|
(eval `(seq ,@(cdr (mapcon (lambda (x)
|
||||||
|
(list sep (car x)))
|
||||||
|
'(matches))))))
|
||||||
|
|
||||||
(provide 'my-rx-forms)
|
(provide 'my-rx-forms)
|
||||||
;;; my-rx-forms.el ends here
|
;;; my-rx-forms.el ends here
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue