diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-05-02 15:56:42 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-05-02 16:45:54 +0200 |
commit | c8e3873a5efc68f62304e376aef031137542f0be (patch) | |
tree | 1d93a5e7513935cc0d839e5eafee4e2fc5b8b746 | |
parent | 5b49f18941129063f8743e15f991a53fa5fad444 (diff) | |
download | org-mode-c8e3873a5efc68f62304e376aef031137542f0be.tar.gz |
org-footnote: Offer to widen buffer when trying to move to a definiton
* lisp/org-footnote.el (org-footnote-action): Offer to widen buffer if
definition is outside of narrow part of buffer.
-rw-r--r-- | lisp/org-footnote.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 2125cb5..f4c3f7e 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -641,8 +641,20 @@ offer additional commands in a menu." ;; definition. ((not label) (goto-char (org-element-property :contents-begin context))) - ;; A definition exists: move to it. - ((ignore-errors (org-footnote-goto-definition label))) + ;; A definition exists: move to it, if possible, or offer to + ;; widen buffer to reach it. + ((let ((definition (org-footnote-get-definition label))) + (when definition + (let ((begin (nth 1 definition))) + (catch 'do-nothing + (cond ((and (>= begin (point-min)) (<= begin (point-max)))) + ((yes-or-no-p "Definition outside scope. Widen? ") + (widen)) + (t (throw 'do-nothing nil))) + (goto-char begin) + (search-forward label) + (forward-char) + t))))) ;; No definition exists: offer to create it. ((yes-or-no-p (format "No definition for %s. Create one? " label)) (org-footnote-create-definition label))))) |