From 4574cc11bcb22a42157ed67a4141558f23ccf730 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 25 Aug 2011 21:12:07 +0200 Subject: [PATCH] org-footnote: preserve narrowing when searching a definition * lisp/org-footnote.el (org-footnote-get-definition): the function has to widen buffer if definition has not been found in the current narrowed part. Be sure to restore that restriction once the definition is found. --- lisp/org-footnote.el | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 648dd604d..9765aaf17 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -328,16 +328,17 @@ If no footnote is found, return nil." (re (format "^\\[%s\\]\\|.\\[%s:" label label)) pos) (save-excursion - (when (or (re-search-forward re nil t) - (and (goto-char (point-min)) - (re-search-forward re nil t)) - (and (progn (widen) t) - (goto-char (point-min)) - (re-search-forward re nil t))) - (let ((refp (org-footnote-at-reference-p))) - (cond - ((and (nth 3 refp) refp)) - ((org-footnote-at-definition-p)))))))) + (save-restriction + (when (or (re-search-forward re nil t) + (and (goto-char (point-min)) + (re-search-forward re nil t)) + (and (progn (widen) t) + (goto-char (point-min)) + (re-search-forward re nil t))) + (let ((refp (org-footnote-at-reference-p))) + (cond + ((and (nth 3 refp) refp)) + ((org-footnote-at-definition-p))))))))) (defun org-footnote-goto-definition (label) "Move point to the definition of the footnote LABEL."