Hi TRS-80, Thanks so much for exploring this. I'll give this a try shortly and let you know if doesn't work. This is great!
thanks, Jonathan On Sunday, May 2, 2021 at 12:58:47 PM UTC+12 TRS-80 wrote: > On 2021-04-29 19:04, Jonathan Goldman wrote: > > Yes I want to create a modification to Emacs Lisp code to specify a > > specific file to load. In my case I have one file called > > "journal.beancount" that loads "accounts.beancount" and then all the > > transactions which are organized by real-world accounts. So ideally > > all I need to do is load "accounts.beancount" and then when I'm > > editing any specific transactions file I have access to type-ahead for > > any of the accounts found in accounts.beancount. > > > > I'm not yet comfortable with Emacs Lisp. I'll try to figure it out but > > if anyone knows how to do this modification easily that would save me > > a lot of time and perhaps be generally useful as I think there are > > others who split up their beancount data among multiple files. > > Jonathan, > > Here is a second approach. > > If you are planning on doing a lot of manual entry, you might want the > autocompletion to "just work" in the mode (with <TAB> or whatever). > In that case, my first try is not going to be ideal (invoking a > function every time, even with a keybinding). > > First I started thinking about modifying beancount-collect function, > until I realized that is a general function called from many different > places. So instead I think we need to try modifying the > beancount-account-completion-table function. > > Note that this is completely untested code, but give this a whirl: > > #+begin_src emacs-lisp > > ;; Define variable > > (defvar my-beancount-accounts-file nil > "Full path to beancount accounts file.") > > > ;; (Re-)Define function > > ;; N.B. this must go AFTER (require 'beancount) in your init > ;; file, as we are re-defining the function. > (defun beancount-account-completion-table (string pred action) > (if (eq action 'metadata) '(metadata (category . beancount-account)) > (if (null beancount-accounts) > (setq beancount-accounts > (save-current-buffer > (find-file-noselect my-beancount-accounts-file) > (set-buffer (file-name-nondirectory > my-beancount-accounts-file)) > (sort (beancount-collect beancount-account-regexp 0) #'string<)))) > (complete-with-action action beancount-accounts string pred))) > > > ;; Set variable > > (setq my-beancount-accounts-file "/path/to/your/accounts.beancount") > > #+end_src > > Essentially we inserted a call to open (if it's not already) your > accounts file in a background buffer, execute the search over there, > and then return to current position. > > Let me know if it works. > > Cheers, > TRS-80 > -- You received this message because you are subscribed to the Google Groups "Beancount" group. To unsubscribe from this group and stop receiving emails from it, send an email to beancount+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/3abc455b-7ee4-4182-be20-a8c0d00a9556n%40googlegroups.com.