Просмотр исходного кода

Fix local variable handling

* lisp/org.el (org-clone-local-variables):
* lisp/org-agenda.el (org-agenda-mode): Do not assume
  `buffer-local-variables' returns only cons cells.

Reported-by: "Stefan-W. Hahn" <stefan.hahn@s-hahn.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/113793>
Nicolas Goaziou 7 лет назад
Родитель
Сommit
355b0012d1
2 измененных файлов с 10 добавлено и 11 удалено
  1. 5 6
      lisp/org-agenda.el
  2. 5 5
      lisp/org.el

+ 5 - 6
lisp/org-agenda.el

@@ -2131,13 +2131,12 @@ The following commands are available:
 	 ;; while letting `kill-all-local-variables' kill the rest
 	 (let ((save (buffer-local-variables)))
 	   (kill-all-local-variables)
-	   (mapc 'make-local-variable org-agenda-local-vars)
+	   (mapc #'make-local-variable org-agenda-local-vars)
 	   (dolist (elem save)
-	     (let ((var (car elem))
-		   (val (cdr elem)))
-	       (when (and val
-			  (member var org-agenda-local-vars))
-		 (set var val)))))
+	     (pcase elem
+	       (`(,var ,val)		;ignore unbound variables
+		(when (and val (memq var org-agenda-local-vars))
+		  (set var val))))))
 	 (setq-local org-agenda-this-buffer-is-sticky t))
 	(org-agenda-sticky
 	 ;; Creating a sticky Agenda buffer for the first time

+ 5 - 5
lisp/org.el

@@ -9619,11 +9619,11 @@ auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
   "Clone local variables from FROM-BUFFER.
 Optional argument REGEXP selects variables to clone."
   (dolist (pair (buffer-local-variables from-buffer))
-    (let ((name (car pair)))
-      (when (and (symbolp name)
-		 (not (memq name org-unique-local-variables))
-		 (or (null regexp) (string-match regexp (symbol-name name))))
-	(set (make-local-variable name) (cdr pair))))))
+    (pcase pair
+      (`(,name ,_)			;ignore unbound variables
+       (when (and (not (memq name org-unique-local-variables))
+		  (or (null regexp) (string-match-p regexp (symbol-name name))))
+	 (set (make-local-variable name) (cdr pair)))))))
 
 ;;;###autoload
 (defun org-run-like-in-org-mode (cmd)