瀏覽代碼

org-macs: Fix visibility issue with file local variables

* lisp/org-macs.el (org-preserve-local-variables): When file local
  variables are preserved and located in a folded section, make sure
  to hide them again.

Reported-by: Scott Randby <srandby@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2019-02/msg00105.html>
Nicolas Goaziou 6 年之前
父節點
當前提交
e54f09af50
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      lisp/org-macs.el

+ 10 - 2
lisp/org-macs.el

@@ -193,8 +193,16 @@ because otherwise all these markers will point to nowhere."
        (when local-variables
 	 (org-with-wide-buffer
 	  (goto-char (point-max))
-	  (unless (bolp) (insert "\n"))
-	  (insert local-variables))))))
+	  ;; If last section is folded, make sure to also hide file
+	  ;; local variables after inserting them back.
+	  (let ((overlay
+		 (cl-find-if (lambda (o)
+			       (eq 'outline (overlay-get o 'invisible)))
+			     (overlays-at (1- (point))))))
+	    (unless (bolp) (insert "\n"))
+	    (insert local-variables)
+	    (when overlay
+	      (move-overlay overlay (overlay-start overlay) (point-max)))))))))
 
 (defmacro org-no-popups (&rest body)
   "Suppress popup windows and evaluate BODY."