Ignore some local variables upon cloning
* lisp/org.el (org-unique-local-variables): New variable. (org-get-local-variables): (org-clone-local-variables): Use variable above. Do not rely on an obscure naming convention to determine if a local variable is meant to be cloned or read.
This commit is contained in:
parent
dbaab40bda
commit
d02f9d41af
49
lisp/org.el
49
lisp/org.el
|
@ -9410,30 +9410,31 @@ Possible values in the list of contexts are `table', `headline', and `item'."
|
||||||
(org-in-item-p)))
|
(org-in-item-p)))
|
||||||
(goto-char pos))))
|
(goto-char pos))))
|
||||||
|
|
||||||
|
(defconst org-unique-local-variables
|
||||||
|
'(org-element--cache
|
||||||
|
org-element--cache-objects
|
||||||
|
org-element--cache-sync-keys
|
||||||
|
org-element--cache-sync-requests
|
||||||
|
org-element--cache-sync-timer)
|
||||||
|
"List of local variables that cannot be transferred to another buffer.")
|
||||||
|
|
||||||
(defun org-get-local-variables ()
|
(defun org-get-local-variables ()
|
||||||
"Return a list of all local variables in an Org mode buffer."
|
"Return a list of all local variables in an Org mode buffer."
|
||||||
(let ((varlist
|
(delq nil
|
||||||
(prog1 (with-current-buffer (get-buffer-create "*Org tmp*")
|
(mapcar
|
||||||
(erase-buffer)
|
(lambda (x)
|
||||||
(org-mode)
|
(let* ((binding (if (symbolp x) (list x) (list (car x) (cdr x))))
|
||||||
(buffer-local-variables))
|
(name (car binding)))
|
||||||
(kill-buffer "*Org tmp*"))))
|
(and (not (get name 'org-state))
|
||||||
(delq nil
|
(not (memq name org-unique-local-variables))
|
||||||
(mapcar
|
(string-match-p
|
||||||
(lambda (x)
|
"\\`\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|\
|
||||||
(let* ((binding (if (symbolp x) (list x) (list (car x) (cdr x))))
|
auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
|
||||||
(name (car binding)))
|
(symbol-name name))
|
||||||
(and (not (get name 'org-state))
|
x)))
|
||||||
;; Ignore internal local variables, since those
|
(with-temp-buffer
|
||||||
;; are likely variables that are not meant to be
|
(org-mode)
|
||||||
;; copied.
|
(buffer-local-variables)))))
|
||||||
(not (string-match-p "--" (symbol-name name)))
|
|
||||||
(string-match-p
|
|
||||||
"\\`\\(org-\\|orgtbl-\\|outline-\\|comment-\\|\
|
|
||||||
paragraph-\\|auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
|
|
||||||
(symbol-name name))
|
|
||||||
x)))
|
|
||||||
varlist))))
|
|
||||||
|
|
||||||
(defun org-clone-local-variables (from-buffer &optional regexp)
|
(defun org-clone-local-variables (from-buffer &optional regexp)
|
||||||
"Clone local variables from FROM-BUFFER.
|
"Clone local variables from FROM-BUFFER.
|
||||||
|
@ -9441,9 +9442,7 @@ Optional argument REGEXP selects variables to clone."
|
||||||
(dolist (pair (buffer-local-variables from-buffer))
|
(dolist (pair (buffer-local-variables from-buffer))
|
||||||
(let ((name (car pair)))
|
(let ((name (car pair)))
|
||||||
(when (and (symbolp name)
|
(when (and (symbolp name)
|
||||||
;; Ignore internal local variables, since those are
|
(not (memq name org-unique-local-variables))
|
||||||
;; likely variables that are not meant to be copied.
|
|
||||||
(not (string-match-p "--" (symbol-name name)))
|
|
||||||
(or (null regexp) (string-match regexp (symbol-name name))))
|
(or (null regexp) (string-match regexp (symbol-name name))))
|
||||||
(set (make-local-variable name) (cdr pair))))))
|
(set (make-local-variable name) (cdr pair))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue