diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2010-04-14 16:45:45 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2010-04-14 16:45:45 +0200 |
commit | a74a748d0f206a82b8f67b3d60d6528d9e876feb (patch) | |
tree | 7e3e0d60527ae2874b086b33c0dd53ed06140048 | |
parent | 2db83c67a81f54e8c28b35c048df474280345d8a (diff) | |
download | org-mode-a74a748d0f206a82b8f67b3d60d6528d9e876feb.tar.gz |
Search backward from a footnote definition to find reference.
With multiple definitions of a footnote with the same label in a
buffer, this has a higher chance to find the right one.
Request by Samuel Wales
-rwxr-xr-x | lisp/ChangeLog | 3 | ||||
-rw-r--r-- | lisp/org-footnote.el | 18 |
2 files changed, 12 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index add1dda..29e420d 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-04-14 Carsten Dominik <carsten.dominik@gmail.com> + * org-footnote.el (org-footnote-goto-previous-reference): Renamed + from `org-footnote-goto-next-reference'. + * org.el (org-auto-repeat-maybe): Only record LAST_REPEAT if org-log-repeat is non-nil, or if there is clocking data in the entry. diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 64ddf04..ada3a8e 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -182,25 +182,25 @@ with start and label of the footnote if there is a definition at point." (org-show-context 'link-search) (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))) -(defun org-footnote-goto-next-reference (label) - "Find the next reference of the footnote with label LABEL." +(defun org-footnote-goto-previous-reference (label) + "Find the next previous of the footnote with label LABEL." (interactive "sLabel: ") (org-mark-ring-push) (setq label (org-footnote-normalize-label label)) (let ((re (format ".\\[%s[]:]" label)) (p0 (point)) pos) (save-excursion - (setq pos (or (re-search-forward re nil t) - (and (goto-char (point-min)) - (re-search-forward re nil t)) + (setq pos (or (re-search-backward re nil t) + (and (goto-char (point-max)) + (re-search-backward re nil t)) (and (progn (widen) t) (goto-char p0) - (re-search-forward re nil t)) - (and (goto-char (point-min)) + (re-search-backward re nil t)) + (and (goto-char (point-max)) (re-search-forward re nil t))))) (if pos (progn - (goto-char pos) + (goto-char (match-end 0)) (org-show-context 'link-search)) (error "Cannot find reference of footnote %s" label)))) @@ -339,7 +339,7 @@ With prefix arg SPECIAL, offer additional commands in a menu." (org-footnote-goto-definition (nth 1 tmp)) (goto-char (match-beginning 4)))) ((setq tmp (org-footnote-at-definition-p)) - (org-footnote-goto-next-reference (nth 1 tmp))) + (org-footnote-goto-previous-reference (nth 1 tmp))) (t (org-footnote-new))))) ;;;###autoload |