From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Stefan-W. Hahn" Subject: Bug: buffer local variables handled wrong [9.0.5 (release_9.0.5-497-g5bc540 @ /home/hs/.emacs.d/lib/org-mode/lisp/)] Date: Sat, 3 Jun 2017 13:48:59 +0200 Message-ID: <20170603114859.GE7145@seven> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dH7YL-00089x-Ao for emacs-orgmode@gnu.org; Sat, 03 Jun 2017 07:49:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dH7YG-0005Fk-Fw for emacs-orgmode@gnu.org; Sat, 03 Jun 2017 07:49:09 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:50698) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dH7YG-0005Cl-4I for emacs-orgmode@gnu.org; Sat, 03 Jun 2017 07:49:04 -0400 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Good day, Emacs : GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2017-05-20 Package: Org mode version 9.0.5 (release_9.0.5-497-g5bc540 @ /home/hs/.emacs.d/lib/org-mode/lisp/) I use a minor mode (moccur-edit-mode, seems a little bit old) which initializes one variable in this way: ,---- | (defvar moccur-edit-old-content) | (make-local-variable 'moccur-edit-old-content) `---- This leads to following result in (buffer-local-variables): ,---- | ... (moccur-edit-file-overlays) moccur-edit-old-content (company-prefix) ... `---- I think this is correct and happens not only by the used minor-mode. When doing org-capture now I got a lisp error: Debugger entered--Lisp error: listp moccur-edit-old-content This error comes from org-clone-local-variables, because there the prediction for local variables is always to be a list. I traced all other code points where (buffer-local-variables) is used: ,---- | grep --color -nH -e buffer-local-var *.el | 1. org-agenda.el:2158: (let ((save (buffer-local-variables))) | 2. org.el:9401: (buffer-local-variables))))) | 3. org.el:9406: (dolist (pair (buffer-local-variables from-buffer)) | 4. org-element.el:4091: (t (let ((local-variables (buffer-local-variables))) | 5. ox.el:2646: (dolist (entry (buffer-local-variables (buffer-base-buffer)) vars) `---- The code 2., 4. and 5. are correct, they use (consp v) or (symbolp v) to decide what to do. The code 1. and 3. are wrong. They both work directly with (car v) or (cdr v). For 1. and 3. I would like to suggest the following corrections: modified lisp/org-agenda.el @@ -2159,11 +2159,12 @@ org-agenda-mode (kill-all-local-variables) (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))))) + (if (consp elem) + (let ((var (car elem)) + (val (cdr elem))) + (when (and val + (member 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 modified lisp/org.el @@ -9404,11 +9404,12 @@ org-clone-local-variables "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)))))) + (if (consp pair) + (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))))))) ;;;###autoload (defun org-run-like-in-org-mode (cmd) With kind regards, Stefan -- Stefan-W. Hahn It is easy to make things. It is hard to make things simple.