Browse Source

Fix buffer local org-agenda-overriding-columns-format bug

* doc/org-manual.org (Using Column View in the Agenda): Updated
  reference to variable.
* lisp/org-agenda.el (org-agenda-finalize): Set buffer local variable
  instead.
* lisp/org-colview.el (org-overriding-columns-format): Renamed.
(org-agenda-overriding-columns-format): Renamed.
(org-local-columns-format): New buffer local variable.
(org-columns-edit-value): Updated reference to variable.
(org-columns-next-allowed-value): Updated reference to variable.
(org-agenda-columns): Updated reference to variable.

Setting org-agenda-overriding-columns-format as a buffer local value
interferes with how it is used as a dynamically scoped var, so use a
separate variable for buffer local setting.
Allen Li 6 years ago
parent
commit
cc020dbe4d
3 changed files with 25 additions and 14 deletions
  1. 5 5
      doc/org-manual.org
  2. 5 4
      lisp/org-agenda.el
  3. 15 5
      lisp/org-colview.el

+ 5 - 5
doc/org-manual.org

@@ -10477,11 +10477,11 @@ environment.  This causes the following issues:
    the entries in the agenda are collected from different files, and
    the entries in the agenda are collected from different files, and
    different files may have different columns formats, this is
    different files may have different columns formats, this is
    a non-trivial problem.  Org first checks if the variable
    a non-trivial problem.  Org first checks if the variable
-   ~org-agenda-overriding-columns-format~ is currently set, and if so,
-   takes the format from there.  Otherwise it takes the format
-   associated with the first item in the agenda, or, if that item does
-   not have a specific format (defined in a property, or in its file),
-   it uses ~org-columns-default-format~.
+   ~org-overriding-columns-format~ is currently set, and if so, takes
+   the format from there.  Otherwise it takes the format associated
+   with the first item in the agenda, or, if that item does not have
+   a specific format (defined in a property, or in its file), it uses
+   ~org-columns-default-format~.
 
 
 2.
 2.
    #+cindex: @samp{CLOCKSUM}, special property
    #+cindex: @samp{CLOCKSUM}, special property

+ 5 - 4
lisp/org-agenda.el

@@ -3766,7 +3766,8 @@ FILTER-ALIST is an alist of filters we need to apply when
 	     (setq-local org-agenda-name name)))
 	     (setq-local org-agenda-name name)))
       (setq buffer-read-only nil))))
       (setq buffer-read-only nil))))
 
 
-(defvar org-agenda-overriding-columns-format)  ; From org-colview.el
+(defvar org-overriding-columns-format)
+(defvar org-local-columns-format)
 (defun org-agenda-finalize ()
 (defun org-agenda-finalize ()
   "Finishing touch for the agenda buffer, called just before displaying it."
   "Finishing touch for the agenda buffer, called just before displaying it."
   (unless org-agenda-multi
   (unless org-agenda-multi
@@ -3781,9 +3782,9 @@ FILTER-ALIST is an alist of filters we need to apply when
 	  (org-agenda-align-tags))
 	  (org-agenda-align-tags))
 	(unless org-agenda-with-colors
 	(unless org-agenda-with-colors
 	  (remove-text-properties (point-min) (point-max) '(face nil)))
 	  (remove-text-properties (point-min) (point-max) '(face nil)))
-	(when (bound-and-true-p org-agenda-overriding-columns-format)
-	  (setq-local org-agenda-overriding-columns-format
-		      org-agenda-overriding-columns-format))
+	(when (bound-and-true-p org-overriding-columns-format)
+	  (setq-local org-local-columns-format
+		      org-overriding-columns-format))
 	(when org-agenda-view-columns-initially
 	(when org-agenda-view-columns-initially
 	  (org-agenda-columns))
 	  (org-agenda-columns))
 	(when org-agenda-fontify-priorities
 	(when org-agenda-fontify-priorities

+ 15 - 5
lisp/org-colview.el

@@ -565,9 +565,18 @@ for the duration of the command.")
       (org-columns-next-allowed-value)
       (org-columns-next-allowed-value)
     (org-columns-edit-value "TAGS")))
     (org-columns-edit-value "TAGS")))
 
 
-(defvar org-agenda-overriding-columns-format nil
+(define-obsolete-variable-alias 'org-agenda-overriding-columns-format
+  'org-overriding-columns-format "Org 9.2.2")
+
+(defvar org-overriding-columns-format nil
+  "When set, overrides any other format definition for the agenda.
+Don't set this, this is meant for dynamic scoping.  Set
+`org-local-columns-format' instead.")
+
+(defvar-local org-local-columns-format nil
   "When set, overrides any other format definition for the agenda.
   "When set, overrides any other format definition for the agenda.
-Don't set this, this is meant for dynamic scoping.")
+This can be set as a buffer local value to avoid interfering with
+dynamic scoping for `org-overriding-columns-format'.")
 
 
 (defun org-columns-edit-value (&optional key)
 (defun org-columns-edit-value (&optional key)
   "Edit the value of the property at point in column view.
   "Edit the value of the property at point in column view.
@@ -628,7 +637,7 @@ Where possible, use the standard interface for changing this line."
       (org-columns--call action)
       (org-columns--call action)
       ;; The following let preserves the current format, and makes
       ;; The following let preserves the current format, and makes
       ;; sure that in only a single file things need to be updated.
       ;; sure that in only a single file things need to be updated.
-      (let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
+      (let* ((org-overriding-columns-format org-columns-current-fmt)
 	     (buffer (marker-buffer pom))
 	     (buffer (marker-buffer pom))
 	     (org-agenda-contributing-files
 	     (org-agenda-contributing-files
 	      (list (with-current-buffer buffer
 	      (list (with-current-buffer buffer
@@ -722,7 +731,7 @@ an integer, select that value."
 	(org-columns--call action)
 	(org-columns--call action)
 	;; The following let preserves the current format, and makes
 	;; The following let preserves the current format, and makes
 	;; sure that in only a single file things need to be updated.
 	;; sure that in only a single file things need to be updated.
-	(let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
+	(let* ((org-overriding-columns-format org-columns-current-fmt)
 	       (buffer (marker-buffer pom))
 	       (buffer (marker-buffer pom))
 	       (org-agenda-contributing-files
 	       (org-agenda-contributing-files
 		(list (with-current-buffer buffer
 		(list (with-current-buffer buffer
@@ -1563,7 +1572,8 @@ PARAMS is a property list of parameters:
   (let* ((org-columns--time (float-time))
   (let* ((org-columns--time (float-time))
 	 (fmt
 	 (fmt
 	  (cond
 	  (cond
-	   ((bound-and-true-p org-agenda-overriding-columns-format))
+	   ((bound-and-true-p org-overriding-columns-format))
+	   ((bound-and-true-p org-local-columns-format))
 	   ((let ((m (org-get-at-bol 'org-hd-marker)))
 	   ((let ((m (org-get-at-bol 'org-hd-marker)))
 	      (and m
 	      (and m
 		   (or (org-entry-get m "COLUMNS" t)
 		   (or (org-entry-get m "COLUMNS" t)