Tenho usado o moneylog há alguns meses.
Como uso bastante o emacs, acabei escrevendo algumas funções em elisp para facilitar a minha vida
O código abaixo lista as funções, que fazem o seguinte:
- i-register — Uso: M-x i-register — insere um registro na posição atual
- i-reg-ccredit — Uso: M-x i-reg-ccredit — insere um registro de cartão de crédito
Nota: As variáveis ”fechamento” e”diaspgtoaposfechamento” configuram o comportamento de pré-preenchimento da
data de pagamento. No meu caso, a fatura fecha dia 7 e o pagamento é dia 17, ou seja 10
dias após o pagamento
(setq fechamento 7)
(setq diaspgtoaposfechamento 10)
Para mudar, basta colocar os dias correspondentes ao seu cartão de crédito.
Nota2: O comportamento padrão da função é procurar por um registro já inserido e
inserir o registro atual após o último registro com a data de pagamento do cartão.
Caso não encontre um registro pré-existente, o registro é inserido na posição atual
- i-reg-gas — Uso: M-x i-reg-gas — insere um registro de consumo de gasolina.
Eu uso essa função para poder controlar o consumo de combustível da moto
. Esta função utiliza as duas anteriores para inserir um registro imediato ou de cartão de crédito.
Exemplo de registro:
2009-MM-DD -22.26 ccredXX, posto, moto| @MM.DD Gasolina para a Moto. otot}15872.9} opar(170.2) l{9.279{ R/l$2.399$ km/l _18.342_ aditivada
Explicação:
- Odômetro Total — otot}15872.9}
- Odômetro Parcial — opar(170.2)
- Litros Abastecidos — l{9.279{
- Preço por Litro — R/l$2.399$
- Km/l – Calculado automaticamente — km/l _18.342_
- Tipo da Gasolina — aditivada
- i-atualiza-dados-dev — Uso: M-x i-atualiza-dados-dev –Atualiza o arquivo moneylog.txt no diretório ../moneylog-dev . Como eu uso tantouma versão quanto a outra, atualizo sempre os dados. Nota: Para que
essa função funcione, é necessário ter as seguintes marcações no arquivo
moneylog.html:
## começo
no começo dos dados e
## fim
ao final dos dados.
Ah, mais uma coisa, ainda. Para tornar as funções disponíveis dentro do emacs
você pode fazer de duas maneiras diferentes:
1. Uma mais rápida e só para a sessão corrente:
+ abra o arquivo moneylog.el e digite
M-x eval-buffer
dentro do buffer do moneylog. A partir daí é só abrir o moneylog.html e usar as funções.
2. Uma outra mais permanente:
adicione ao seu arquivo .emacs o seguinte:
(setq load-path (append load-path '("/diretorio/do/moneylog_el/"))) (load-library "paren")e pronto, na próxima vez que vc iniciar o emacs estarão lá as funções
Espero que seja útil para mais alguém
Se alguém tiver alguma sugestão, é só entrar em contato
Ah, o Código
;;; moneylog.el --- Provide a way to enter moneylog logs ;; Copyright (C) 2009 Leslie Harlley Watter ;; Author: Leslie Harlley Watter ;; Keywords: ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; This file should be used with moneylog (www.aurelio.net/moneylog) ;;; Code: (defun i-register (&optional tag) "Inserts/format an account record. It should be used with moneylog 2009.08.15 -29.00 bicicleta | Mesa para a bicicleta" (interactive) ;; pre-fills the today variable with today's date (setq today (format-time-string "%Y-%m-%d")) (setq rdata (read-string "Data (2009.06.15): " today )) (unless (equal rdata "") (setq rvalor (read-string "Valor (110.00 ou -110.00): ")) (unless (equal rvalor "") (setq rtags (read-string "Tags (poupanca,visa,ccred): " tag)) (setq rcomentario (read-string "Comentario: ")) (unless (equal rcomentario "") (insert (format "%s\t%s\t%s| %s\n" rdata rvalor rtags rcomentario )) ; )))) (defun i-reg-ccredit (&optional tag) "Inserts/format an account record. It should be used with moneylog 2009.08.15 -29.00 visa | Mesa para a bicicleta" (interactive) ;; pre-fills the today variable with today's date ;; fechamento is the date where the credit card closes it's bills (setq fechamento 7) (setq diaspgtoaposfechamento 10) (setq dia (string-to-number (format-time-string "%d"))) (if (<= dia fechamento) (setq mes (format-time-string "%m")) (setq mes (format "%02d" (% (+ (string-to-number (format-time-string "%m")) 1 ) 12 ))) ) (setq today (format "%s%s-%s" (format-time-string "%Y-") mes (+ fechamento diaspgtoaposfechamento) )) (setq rdata (read-string "Data Vencimento (2009.06.15): " today )) (unless (equal rdata "") (setq rvalor (read-string "Valor (110.00 ou -110.00): ")) (unless (equal rvalor "") (setq rtags (read-string "Tags (ccred): " tag)) (setq bdate (format-time-string "%m.%d")) (setq rdatacompra (read-string "Data compra (mm.dd): " bdate)) (unless (equal rdatacompra "") (setq rcomentario (read-string "Comentario: ")) (unless (equal rcomentario "") (setq atual (point)) (goto-char (point-max)) (goto-char (if (equal (search-backward rdata (point-min) t) nil) atual (search-backward rdata (point-min)) )) (beginning-of-line) (forward-line 2) (insert (format "%s\t%s\t%s| @%s %s\n" rdata rvalor rtags rdatacompra rcomentario )) ; ))))) (defun i-reg-gas () "Inserts/format a gas account record. It should be used with moneylog" (interactive) ;; prefills month variable to be concatenated to default tags (setq fechamento 7) (setq diaspgtoaposfechamento 10) (setq dia (string-to-number (format-time-string "%d"))) (if (<= dia fechamento) (setq mes (format-time-string "%m")) (setq mes (format "%02d" (% (+ (string-to-number (format-time-string "%m")) 1 ) 12 ))) ) ;; here starts the real gas function (setq tiporeg (read-string "tipo Registro (C|I) (Credito/Imediato): ")) (unless (equal tiporeg "") (if (equal tiporeg "C") (i-reg-ccredit (concat (concat "ccred" mes) ", posto, ")) (i-register (concat (concat "ccred" mes) ", posto, ")) ) (setq odomtotal (read-string "Odometro Total: ")) (unless (equal odomtotal "") (setq odomparc (read-string "Odometro Parcial: ")) (unless (equal odomparc "") (setq litabast (read-string "Litros Abastecidos: ")) (unless (equal litabast "") (setq precolitro (read-string "Preço por Litro: ")) (unless (equal precolitro "") (setq kmporlitro (number-to-string (/ (string-to-number odomparc)(string-to-number litabast)))) (setq tipogas (read-string "Tipo ( aditivada / comum ): ")) (unless (equal tipogas "") (backward-char 1) (insert (format " otot}%s} opar(%s) l{%s{ R/l$%s$ km/l _%s_ %s \n" odomtotal odomparc litabast precolitro (substring kmporlitro 0 6) tipogas )) ; ))))))) (defun i-atualiza-dados-dev () "Atualiza os dados no arquivo moneylog.txt em ../moneylog-dev/." (interactive) (goto-char (point-min)) (search-forward "## começo") ; grab the current line (beginning-of-line) (setq myStartPos (line-beginning-position)) (goto-char (point-min)) (search-forward "## fim") ; grab the current line (end-of-line) (setq myEndPos (line-end-position)) ; get the strings between start and end point (setq myStr (buffer-substring myStartPos myEndPos)) ;; (message "%s" myStr) (pop-to-buffer (find-file-noselect "../moneylog-dev/moneylog.txt")) (goto-char (point-min)) (search-forward "## começo") ; grab the current line (beginning-of-line) (setq myStartPos2 (line-beginning-position)) (goto-char (point-min)) (search-forward "## fim") ; grab the current line (end-of-line) (setq myEndPos2 (line-end-position)) ;; delete the region (delete-region myStartPos2 myEndPos2) (goto-char myStartPos2) (insert myStr) (basic-save-buffer) (message "Arquivo Atualizado" ) ) (provide 'moneylog) ;;; moneylog.el ends herePra facilitar a vida daqueles que leram até aqui, o arquivo de código também
pode ser encontrado aqui
Valeu Leslie, obrigado pela ferramenta!
Se eu usasse Emcas eu a usaria, tá?
Por: Aurélio em Outubro 2, 2009
às 6:11 pm