Allow non-register reports to work again

This commit is contained in:
John Wiegley 2012-07-30 22:35:21 -05:00
parent e6acb5a9cc
commit d203393cab

View file

@ -238,23 +238,27 @@ the default."
(format "Command: %s\n" cmd) (format "Command: %s\n" cmd)
(make-string (- (window-width) 1) ?=) (make-string (- (window-width) 1) ?=)
"\n") "\n")
(let ((register-report (string-match " reg\\(ister\\)? " cmd)))
(shell-command (shell-command
(concat cmd " --prepend-format='%(filename):%(beg_line):'") t nil) (if register-report
(concat cmd " --prepend-format='%(filename):%(beg_line):'")
cmd) t nil)
(when register-report
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "^\\([^:]+\\)?:\\([0-9]+\\)?:" nil t) (while (re-search-forward "^\\([^:]+\\)?:\\([0-9]+\\)?:" nil t)
(let ((file (match-string 1)) (let ((file (match-string 1))
(line (string-to-number (match-string 2)))) (line (string-to-number (match-string 2))))
(delete-region (match-beginning 0) (match-end 0)) (delete-region (match-beginning 0) (match-end 0))
(set-text-properties (line-beginning-position) (line-end-position) (set-text-properties (line-beginning-position) (line-end-position)
(list 'ledger-source (cons file line)))))) (list 'ledger-source (cons file line))))))))
(defun ledger-report-visit-source () (defun ledger-report-visit-source ()
(interactive) (interactive)
(destructuring-bind (file . line) (let ((prop (get-text-property (point) 'ledger-source)))
(get-text-property (point) 'ledger-source) (destructuring-bind (file . line) prop
(find-file-other-window file) (find-file-other-window file)
(goto-char (point-min)) (goto-char (point-min))
(forward-line (1- line)))) (forward-line (1- line)))))
(defun ledger-report-goto () (defun ledger-report-goto ()
"Goto the ledger report buffer." "Goto the ledger report buffer."