feat(emacs): qwerty

This commit is contained in:
js0ny 2025-09-22 01:13:21 +01:00
parent fb9ea29d52
commit 47b8460825
8 changed files with 108 additions and 52 deletions

View file

@ -6,7 +6,34 @@
(use-package beancount
:mode (("\\.beancount\\'" . beancount-mode)
("\\.bean\\'" . beancount-mode)))
("\\.bean\\'" . beancount-mode))
:init
(add-hook 'beancount-mode-hook #'outline-minor-mode)
(define-key beancount-mode-map (kbd "C-c C-n") #'outline-next-visible-heading)
(define-key beancount-mode-map (kbd "C-c C-p") #'outline-previous-visible-heading)
(defvar beancount-accounts-files nil "List of account files.")
(setq beancount-accounts-files
(directory-files "~/Dropbox/beancount/accounts/" 'full (rx ".beancount" eos)))
(defun w/beancount--collect-accounts-from-files (oldfun regex n)
"Collect all accounts from files."
(let ((keys (funcall oldfun regex n))
(hash (make-hash-table :test 'equal)))
(dolist (key keys)
(puthash key nil hash))
;; collect accounts from files
(save-excursion
(dolist (f beancount-accounts-files)
(with-current-buffer (find-file-noselect f)
(goto-char (point-min))
(while (re-search-forward beancount-account-regexp nil t)
(puthash (match-string-no-properties n) nil hash)))))
(hash-table-keys hash)))
(advice-add #'beancount-collect
:around #'w/beancount--collect-accounts-from-files
'((name . "collect accounts from files as well"))))
(provide 'init-beancount)