Made marker logic for jumping from hyperlinked reports to source files work by simplifying.

This commit is contained in:
adamsrl 2012-10-15 13:29:22 -05:00
parent 6094c202c1
commit 9173190a8f

View file

@ -231,28 +231,6 @@ the default."
(ledger-reports-custom-save)) (ledger-reports-custom-save))
report-cmd)) report-cmd))
(defvar ledger-report-patch-alist nil)
(defun ledger-report-patch-reports (buf)
(when ledger-report-patch-alist
(let ((entry (assoc (expand-file-name (buffer-file-name buf))
ledger-report-patch-alist)))
(when entry
(dolist (b (cdr entry))
(if (buffer-live-p b)
(with-current-buffer b
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(let ((record (get-text-property (point) 'ledger-source)))
(if (and record (not (markerp (cdr record))))
(setcdr record (with-current-buffer buf
(save-excursion
(goto-char (point-min))
(forward-line (cdr record))
(point-marker))))))
(forward-line 1))))))))))
(defun ledger-do-report (cmd) (defun ledger-do-report (cmd)
"Run a report command line." "Run a report command line."
(goto-char (point-min)) (goto-char (point-min))
@ -274,20 +252,14 @@ the default."
(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 (save-window-excursion
(end-of-line) (save-excursion
(let* ((fullpath (expand-file-name file)) (find-file file)
(entry (assoc fullpath ledger-report-patch-alist))) (widen)
(if entry (goto-char (point-min))
(nconc (cdr entry) (list (current-buffer))) (forward-line (1- line))
(push (cons (expand-file-name file) (point-marker))))))
(list (current-buffer))) (end-of-line))))
ledger-report-patch-alist))
(add-to-list 'files-in-report fullpath))))
(dolist (path files-in-report)
(let ((buf (get-file-buffer path)))
(if (and buf (buffer-live-p buf))
(ledger-report-patch-reports buf)))))
(goto-char data-pos))) (goto-char data-pos)))