diff options
-rw-r--r-- | lisp/ledger-fontify.el | 34 | ||||
-rw-r--r-- | lisp/ledger-fonts.el | 10 | ||||
-rw-r--r-- | lisp/ledger-mode.el | 4 | ||||
-rw-r--r-- | lisp/ledger-post.el | 21 | ||||
-rw-r--r-- | lisp/ledger-xact.el | 33 |
5 files changed, 40 insertions, 62 deletions
diff --git a/lisp/ledger-fontify.el b/lisp/ledger-fontify.el index 548881aa..00fe249a 100644 --- a/lisp/ledger-fontify.el +++ b/lisp/ledger-fontify.el @@ -35,39 +35,10 @@ :type 'boolean :group 'ledger-fontification) -;; (defun ledger-fontify-whole-buffer () -;; (interactive) -;; (save-excursion -;; (message "Ledger fontify whole buffer") -;; (goto-char (point-min)) - -;; (while (not (eobp)) -;; (cond ((looking-at ledger-xact-start-regex) -;; (ledger-fontify-xact-at (point))) -;; ((looking-at ledger-directive-start-regex) -;; (ledger-fontify-directive-at (point)))) -;; (ledger-xact-next-xact-or-directive) ;; gets to beginning of next xact -;; ))) - -;; (defun ledger-fontify-activate () -;; "add hook to fontify after buffer changes" -;; (interactive) -;; (if (string= (format-mode-line 'mode-name) "Ledger") -;; (progn -;; (ledger-fontify-whole-buffer) -;; (add-hook 'after-change-functions 'ledger-fontify-buffer-part) -;; (add-hook 'before-change-functions 'ledger-fontify-ensure-activation) -;; (message "ledger-fontify-activate called")))) - -;; (defun ledger-fontify-ensure-activation (beg end) -;; (if (string= (format-mode-line 'mode-name) "Ledger") -;; (add-hook 'after-change-functions 'ledger-fontify-buffer-part))) - (defun ledger-fontify-buffer-part (beg end len) (save-excursion (unless beg (setq beg (point-min))) (unless end (setq end (point-max))) - (unless len (setq len (- end beg))) (goto-char beg) (while (< (point) end) (cond ((or (looking-at ledger-xact-start-regex) @@ -118,6 +89,7 @@ (re-search-forward ledger-posting-regex) (if (match-string 1) (save-match-data (setq state (ledger-state-from-string (s-trim (match-string 1)))))) +;;; FIX THIS. Pull the COND to the outer level and put the fontify-set-face inside. It will be clearer (ledger-fontify-set-face (list (match-beginning 0) (match-end 2)) (cond ((eq state 'cleared) 'ledger-font-posting-account-cleared-face) @@ -127,9 +99,9 @@ 'ledger-font-posting-account-face))) (ledger-fontify-set-face (list (match-beginning 4) (match-end 4)) (cond ((eq state 'cleared) - 'ledger-font-posting-account-cleared-face) + 'ledger-font-posting-amount-cleared-face) ((eq state 'cleared) - 'ledger-font-posting-account-pending-face) + 'ledger-font-posting-amount-pending-face) (t 'ledger-font-posting-amount-face))) (ledger-fontify-set-face (list (match-beginning 5) (match-end 5)) diff --git a/lisp/ledger-fonts.el b/lisp/ledger-fonts.el index b5495460..31cba9bf 100644 --- a/lisp/ledger-fonts.el +++ b/lisp/ledger-fonts.el @@ -176,11 +176,21 @@ "Face for Ledger accounts" :group 'ledger-faces) +(defface ledger-font-posting-amount-cleared-face + `((t :inherit ledger-font-posting-account-cleared-face)) + "Face for Ledger accounts" + :group 'ledger-faces) + (defface ledger-font-posting-account-pending-face `((t :inherit ledger-font-pending-face)) "Face for Ledger accounts" :group 'ledger-faces) +(defface ledger-font-posting-amount-pending-face + `((t :inherit ledger-font-posting-account-pending-face)) + "Face for Ledger accounts" + :group 'ledger-faces) + (defface ledger-font-posting-amount-face `((t :foreground "#cb4b16" )) "Face for Ledger amounts" diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index 08cbb950..cd1a587c 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -261,8 +261,8 @@ With a prefix argument, remove the effective date. " (define-key map [(control ?c) (control ?o) (control ?r)] 'ledger-report) (define-key map [(control ?c) (control ?o) (control ?s)] 'ledger-report-save) - (define-key map [(meta ?p)] 'ledger-post-prev-xact) - (define-key map [(meta ?n)] 'ledger-post-next-xact) + (define-key map [(meta ?p)] 'ledger-xact-prev-xact) + (define-key map [(meta ?n)] 'ledger-xact-next-xact-or-directive) map) "Keymap for `ledger-mode'.") diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el index ac040bb2..09c31044 100644 --- a/lisp/ledger-post.el +++ b/lisp/ledger-post.el @@ -82,7 +82,6 @@ point at beginning of the commodity." (- (or (match-end 4) (match-end 3)) (point))))) - (defun ledger-next-account (&optional end) "Move point to the beginning of the next account, or status marker (!*), as long as it is not past END. Return the column of the beginning of the account and leave point @@ -164,8 +163,6 @@ region align the posting on the current line." (setq lines-left (not (eobp)))) (setq inhibit-modification-hooks nil)))) - - (defun ledger-post-edit-amount () "Call 'calc-mode' and push the amount in the posting to the top of stack." (interactive) @@ -186,24 +183,6 @@ region align the posting on the current line." (insert " ")) (calc)))))) -(defun ledger-post-prev-xact () - "Move point to the previous transaction." - (interactive) - (backward-paragraph) - (when (re-search-backward ledger-xact-line-regexp nil t) - (goto-char (match-beginning 0)) - (re-search-forward ledger-post-line-regexp) - (goto-char (match-end ledger-regex-post-line-group-account)))) - -(defun ledger-post-next-xact () - "Move point to the next transaction." - (interactive) - (when (re-search-forward ledger-xact-line-regexp nil t) - (goto-char (match-beginning 0)) - (re-search-forward ledger-post-line-regexp) - (goto-char (match-end ledger-regex-post-line-group-account)))) - - (provide 'ledger-post) diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el index b16e5d85..277788e6 100644 --- a/lisp/ledger-xact.el +++ b/lisp/ledger-xact.el @@ -212,7 +212,7 @@ beginning with whitespace" (not (looking-at "[ \t]\\|\\(^$\\)"))) (defun ledger-xact-next-xact-or-directive () - "move to the beginning of the next xact" + "move to the beginning of the next xact or directive" (interactive) (beginning-of-line) (if (ledger-xact-start-xact-or-directive-p) ; if we are the start of an xact, move forward to the next xact @@ -224,13 +224,30 @@ beginning with whitespace" (ledger-xact-start-xact-or-directive-p))) (forward-line)))) -(defun ledger-xact-next-xact () - (interactive) - (beginning-of-line) - (if (looking-at ledger-xact-start-regex) - (forward-line)) - (re-search-forward ledger-xact-start-regex) - (forward-line -1)) +(defun ledger-xact-prev-xact () + "Move point to the previous transaction." + (interactive) + (backward-paragraph) + (when (re-search-backward ledger-xact-line-regexp nil t) + (goto-char (match-beginning 0)) + (re-search-forward ledger-post-line-regexp) + (goto-char (match-end ledger-regex-post-line-group-account)))) + +;; (defun ledger-post-next-xact () +;; "Move point to the next transaction." +;; (interactive) +;; (when (re-search-forward ledger-xact-line-regexp nil t) +;; (goto-char (match-beginning 0)) +;; (re-search-forward ledger-post-line-regexp) +;; (goto-char (match-end ledger-regex-post-line-group-account)))) + +;; (defun ledger-xact-next-xact () +;; (interactive) +;; (beginning-of-line) +;; (if (looking-at ledger-xact-start-regex) +;; (forward-line)) +;; (re-search-forward ledger-xact-start-regex) +;; (forward-line -1)) (provide 'ledger-xact) |