소스 검색

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.
Nicolas Goaziou 14 년 전
부모
커밋
4574cc11bc
1개의 변경된 파일11개의 추가작업 그리고 10개의 파일을 삭제
  1. 11 10
      lisp/org-footnote.el

+ 11 - 10
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."