mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-02-16 16:24:18 +00:00
88 lines
3 KiB
Org Mode
88 lines
3 KiB
Org Mode
|
|
* Separate tasks
|
|
#+begin_src emacs-lisp
|
|
(use-package doct)
|
|
(require 'org)
|
|
|
|
(defvar my/custom-task-templates
|
|
(doct `(("convert [p]aycheck"
|
|
:keys "p"
|
|
:file ,(my/agenda-file "puppet.org")
|
|
:template-file ,(my/org-file "templates/puppet/paycheck.org")))))
|
|
|
|
(defun my/run-custom-tasks ()
|
|
(interactive)
|
|
(let ((org-capture-templates my/custom-task-templates))
|
|
(call-interactively #'org-capture)))
|
|
|
|
(when my/puppet-p
|
|
(global-set-key (kbd "<f1>") #'my/run-custom-tasks))
|
|
#+end_src
|
|
|
|
* Some Extra Bindings
|
|
#+begin_src emacs-lisp
|
|
(when my/puppet-p
|
|
(global-set-key (kbd "<f2>")
|
|
#'org-roam-node-find)
|
|
(global-set-key (kbd "<f3>")
|
|
#'(lambda ()
|
|
(interactive)
|
|
(find-file (my/plaintext-file "org/random/things_puppet_should_remember.org")))))
|
|
#+end_src
|
|
|
|
* Add Ledger
|
|
#+begin_src emacs-lisp
|
|
(defun paycheck->ledger (file)
|
|
(interactive
|
|
(list (read-file-name "Paycheck file? ")))
|
|
(unless (string= "ledger.ledger"
|
|
(file-name-nondirectory
|
|
(buffer-file-name (current-buffer))))
|
|
(user-error "You're in the wrong file..."))
|
|
|
|
(unless (string= "pdf" (file-name-extension file))
|
|
(user-error "Oops, that's not a pdf file..."))
|
|
|
|
(let* ((buf (get-buffer-create "*output*"))
|
|
(res
|
|
(save-window-excursion
|
|
(shell-command (format "ledger-convert.el '%s'" file)
|
|
buf nil))))
|
|
(unless (eq res 0)
|
|
(user-error "Something went wrong with that file... Maybe ask Lambda?"))
|
|
|
|
(let ((str (with-current-buffer buf (buffer-string))))
|
|
(goto-char (point-max))
|
|
(insert "\n" str))))
|
|
#+end_src
|
|
|
|
* Sending reports to mom
|
|
#+begin_src emacs-lisp
|
|
(defun my/run-report-get-file-name (arg)
|
|
(aprog1
|
|
(with-temp-buffer
|
|
(let ((return-code
|
|
(--> (format "./mom_report_2.sh %s"
|
|
(if arg "end" "mid"))
|
|
(call-process-shell-command it nil (current-buffer)))))
|
|
(if (not (eq return-code 0))
|
|
(error "Script is broken")
|
|
(string-trim (buffer-string)))))
|
|
(save-window-excursion
|
|
(let ((buff (find-buffer-visiting it)))
|
|
(if (not buff)
|
|
(find-file it)
|
|
(switch-to-buffer buff)
|
|
(revert-buffer nil t)))
|
|
(when (not (y-or-n-p "Looks good? "))
|
|
(user-error "Fix up ledger.ledger and try again")))))
|
|
|
|
(defun my/run-ledger-report (arg)
|
|
(interactive "P")
|
|
(let* ((default-directory (expand-file-name "report_2"
|
|
(my/plaintext-file "ledger-finance")))
|
|
(fname (my/run-report-get-file-name arg)))
|
|
(mu4e-compose-mail "benedi.chu@hotmail.com" (if arg "Rent" "Finance Report")
|
|
'(("From" . "bensonchu457@fastmail.com")))
|
|
(mml-attach-file fname)))
|
|
#+end_src
|