Explorar o código

Bug fixes and come cleaning up.

Carsten Dominik %!s(int64=17) %!d(string=hai) anos
pai
achega
f19c474a78
Modificáronse 4 ficheiros con 73 adicións e 42 borrados
  1. 4 0
      ChangeLog
  2. 4 2
      lisp/org-archive.el
  3. 7 6
      lisp/org-clock.el
  4. 58 34
      lisp/org-colview.el

+ 4 - 0
ChangeLog

@@ -1,5 +1,9 @@
 2008-04-18  Carsten Dominik  <dominik@science.uva.nl>
 2008-04-18  Carsten Dominik  <dominik@science.uva.nl>
 
 
+	* lisp/org-colview.el (org-columns-next-allowed-value)
+	(org-columns-edit-value): Limit the effort for updatig in the
+	agenda to recomputing a single file.
+
 	* lisp/org.el (org-add-archive-files): New function.
 	* lisp/org.el (org-add-archive-files): New function.
 
 
 	* lisp/org-clock.el (org-dblock-write:clocktable): Allow a Lisp
 	* lisp/org-clock.el (org-dblock-write:clocktable): Allow a Lisp

+ 4 - 2
lisp/org-archive.el

@@ -126,7 +126,8 @@ archive file is."
 	(while (re-search-forward 
 	(while (re-search-forward 
 		"^\\(#\\+\\|[ \t]*:\\)ARCHIVE:[ \t]+\\(.*\\)"
 		"^\\(#\\+\\|[ \t]*:\\)ARCHIVE:[ \t]+\\(.*\\)"
 		nil t)
 		nil t)
-	  (setq file (org-extract-archive-file (match-string 2)))
+	  (setq file (org-extract-archive-file
+		      (org-match-string-no-properties 2)))
 	  (and file (> (length file) 0) (file-exists-p file)
 	  (and file (> (length file) 0) (file-exists-p file)
 	       (add-to-list 'files file)))))
 	       (add-to-list 'files file)))))
     (setq files (nreverse files))
     (setq files (nreverse files))
@@ -138,7 +139,8 @@ archive file is."
 (defun org-extract-archive-file (&optional location)
 (defun org-extract-archive-file (&optional location)
   (setq location (or location org-archive-location))
   (setq location (or location org-archive-location))
   (if (string-match "\\(.*\\)::\\(.*\\)" location)
   (if (string-match "\\(.*\\)::\\(.*\\)" location)
-      (format (match-string 1 location) buffer-file-name)))
+      (expand-file-name 
+       (format (match-string 1 location) buffer-file-name))))
 
 
 (defun org-extract-archive-heading (&optional location)
 (defun org-extract-archive-heading (&optional location)
   (setq location (or location org-archive-location))
   (setq location (or location org-archive-location))

+ 7 - 6
lisp/org-clock.el

@@ -592,7 +592,7 @@ the currently selected interval size."
 	   (block (plist-get params :block))
 	   (block (plist-get params :block))
 	   (link (plist-get params :link))
 	   (link (plist-get params :link))
 	   ipos time p level hlc hdl
 	   ipos time p level hlc hdl
-	   cc beg end pos tbl tbl1 range-text rm-file-column)
+	   cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list)
       (setq org-clock-file-total-minutes nil)
       (setq org-clock-file-total-minutes nil)
       (when step
       (when step
 	(org-clocktable-steps params)
 	(org-clocktable-steps params)
@@ -627,6 +627,7 @@ the currently selected interval size."
        ((eq scope 'file-with-archives)
        ((eq scope 'file-with-archives)
 	(setq scope (org-add-archive-files (list (buffer-file-name)))
 	(setq scope (org-add-archive-files (list (buffer-file-name)))
 	      rm-file-column t)))
 	      rm-file-column t)))
+      (setq scope-is-list (and scope (listp scope)))
       (save-restriction
       (save-restriction
 	(cond
 	(cond
 	 ((not scope))
 	 ((not scope))
@@ -644,7 +645,7 @@ the currently selected interval size."
 	      (if (<= (org-reduced-level (funcall outline-level)) level)
 	      (if (<= (org-reduced-level (funcall outline-level)) level)
 		  (throw 'exit nil))))
 		  (throw 'exit nil))))
 	  (org-narrow-to-subtree))
 	  (org-narrow-to-subtree))
-	 ((listp scope)
+	 (scope-is-list
 	  (let* ((files scope)
 	  (let* ((files scope)
 		 (scope 'agenda)
 		 (scope 'agenda)
 		 (p1 (copy-sequence params))
 		 (p1 (copy-sequence params))
@@ -668,7 +669,7 @@ the currently selected interval size."
 				      org-clock-file-total-minutes))))))))
 				      org-clock-file-total-minutes))))))))
 	(goto-char pos)
 	(goto-char pos)
 
 
-	(unless (listp scope)
+	(unless scope-is-list
 	  (org-clock-sum ts te)
 	  (org-clock-sum ts te)
 	  (goto-char (point-min))
 	  (goto-char (point-min))
 	  (while (setq p (next-single-property-change (point) :org-clock-minutes))
 	  (while (setq p (next-single-property-change (point) :org-clock-minutes))
@@ -710,12 +711,12 @@ the currently selected interval size."
 		"]"
 		"]"
 		(if block (concat ", for " range-text ".") "")
 		(if block (concat ", for " range-text ".") "")
 		"\n\n"))
 		"\n\n"))
-	   (if (listp scope) "|File" "")
+	   (if scope-is-list "|File" "")
 	   "|L|Headline|Time|\n")
 	   "|L|Headline|Time|\n")
 	  (setq total-time (or total-time org-clock-file-total-minutes))
 	  (setq total-time (or total-time org-clock-file-total-minutes))
 	  (insert-before-markers
 	  (insert-before-markers
 	   "|-\n|"
 	   "|-\n|"
-	   (if (listp scope) "|" "")
+	   (if scope-is-list "|" "")
 	   "|"
 	   "|"
 	   "*Total time*| *"
 	   "*Total time*| *"
 	   (org-minutes-to-hh:mm-string (or total-time 0))
 	   (org-minutes-to-hh:mm-string (or total-time 0))
@@ -726,7 +727,7 @@ the currently selected interval size."
 	      (pop tbl))
 	      (pop tbl))
 	  (insert-before-markers (mapconcat
 	  (insert-before-markers (mapconcat
 				  'identity (delq nil tbl)
 				  'identity (delq nil tbl)
-				  (if (listp scope) "\n|-\n" "\n")))
+				  (if scope-is-list "\n|-\n" "\n")))
 	  (backward-delete-char 1)
 	  (backward-delete-char 1)
 	  (goto-char ipos)
 	  (goto-char ipos)
 	  (skip-chars-forward "^|")
 	  (skip-chars-forward "^|")

+ 58 - 34
lisp/org-colview.el

@@ -373,20 +373,34 @@ Where possible, use the standard interface for changing this line."
       (when (not (equal nval value))
       (when (not (equal nval value))
 	(setq eval '(org-entry-put pom key nval)))))
 	(setq eval '(org-entry-put pom key nval)))))
     (when eval
     (when eval
-      (let ((inhibit-read-only t))
-	(org-unmodified
-	 (remove-text-properties (max (point-min) (1- bol)) eol '(read-only t)))
-	(unwind-protect
-	    (progn
-	      (setq org-columns-overlays
-		    (org-delete-all line-overlays org-columns-overlays))
-	      (mapc 'org-delete-overlay line-overlays)
-	      (org-columns-eval eval))
-	  (org-columns-display-here))))
-    (move-to-column col)
-    (if (and (org-mode-p)
-	     (nth 3 (assoc key org-columns-current-fmt-compiled)))
-	(org-columns-update key))))
+
+      (cond
+       ((equal major-mode 'org-agenda-mode)
+	(org-columns-eval '(org-entry-put pom key nval))
+	;; The following let preserves the current format, and makes sure
+	;; that in only a single file things need to be upated.
+	(let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
+	       (buffer (marker-buffer pom))
+	       (org-agenda-contributing-files
+		(list (with-current-buffer buffer
+			(buffer-file-name (buffer-base-buffer))))))
+	  (org-agenda-columns)))
+       (t
+	(let ((inhibit-read-only t))
+	  (org-unmodified
+	   (remove-text-properties
+	    (max (point-min) (1- bol)) eol '(read-only t)))
+	  (unwind-protect
+	      (progn
+		(setq org-columns-overlays
+		      (org-delete-all line-overlays org-columns-overlays))
+		(mapc 'org-delete-overlay line-overlays)
+		(org-columns-eval eval))
+	    (org-columns-display-here)))
+	(move-to-column col)
+	(if (and (org-mode-p)
+		 (nth 3 (assoc key org-columns-current-fmt-compiled)))
+	    (org-columns-update key)))))))
 
 
 (defun org-edit-headline () ; FIXME: this is not columns specific.  Make interactive?????  Use from agenda????
 (defun org-edit-headline () ; FIXME: this is not columns specific.  Make interactive?????  Use from agenda????
   "Edit the current headline, the part without TODO keyword, TAGS."
   "Edit the current headline, the part without TODO keyword, TAGS."
@@ -477,22 +491,30 @@ Where possible, use the standard interface for changing this line."
       (setq nval (or nval (car allowed)))
       (setq nval (or nval (car allowed)))
       (if (equal nval value)
       (if (equal nval value)
 	  (error "Only one allowed value for this property")))
 	  (error "Only one allowed value for this property")))
-    (let ((inhibit-read-only t))
-      (remove-text-properties (1- bol) eol '(read-only t))
-      (unwind-protect
-	  (progn
-	    (setq org-columns-overlays
-		  (org-delete-all line-overlays org-columns-overlays))
-	    (mapc 'org-delete-overlay line-overlays)
-	    (org-columns-eval '(org-entry-put pom key nval)))
-	(org-columns-display-here)))
-    (move-to-column col)
     (cond
     (cond
      ((equal major-mode 'org-agenda-mode)
      ((equal major-mode 'org-agenda-mode)
-      (org-agenda-columns))
-     ((and (org-mode-p)
-	   (nth 3 (assoc key org-columns-current-fmt-compiled)))
-      (org-columns-update key)))))
+      (org-columns-eval '(org-entry-put pom key nval))
+      ;; The following let preserves the current format, and makes sure
+      ;; that in only a single file things need to be upated.
+      (let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
+	     (buffer (marker-buffer pom))
+	     (org-agenda-contributing-files
+	      (list (with-current-buffer buffer
+		      (buffer-file-name (buffer-base-buffer))))))
+	(org-agenda-columns)))
+     (t
+      (let ((inhibit-read-only t))
+	(remove-text-properties (1- bol) eol '(read-only t))
+	(unwind-protect
+	    (progn
+	      (setq org-columns-overlays
+		    (org-delete-all line-overlays org-columns-overlays))
+	      (mapc 'org-delete-overlay line-overlays)
+	      (org-columns-eval '(org-entry-put pom key nval)))
+	  (org-columns-display-here)))
+      (move-to-column col)
+      (and (nth 3 (assoc key org-columns-current-fmt-compiled))
+	   (org-columns-update key))))))
 
 
 (defun org-verify-version (task)
 (defun org-verify-version (task)
   (cond
   (cond
@@ -673,8 +695,9 @@ display, or in the #+COLUMNS line of the current buffer."
 		(insert-before-markers "#+COLUMNS: " fmt "\n")))
 		(insert-before-markers "#+COLUMNS: " fmt "\n")))
 	    (org-set-local 'org-columns-default-format fmt))))))
 	    (org-set-local 'org-columns-default-format fmt))))))
 
 
-(defvar org-overriding-columns-format nil
-  "When set, overrides any other definition.")
+(defvar org-agenda-overriding-columns-format nil
+  "When set, overrides any other format definition for the agenda.
+Don't set this, this is meant for dynamic scoping.")
 
 
 (defun org-columns-get-autowidth-alist (s cache)
 (defun org-columns-get-autowidth-alist (s cache)
   "Derive the maximum column widths from the format and the cache."
   "Derive the maximum column widths from the format and the cache."
@@ -1037,16 +1060,17 @@ and tailing newline characters."
 (defvar org-agenda-columns-add-appointments-to-effort-sum); as well
 (defvar org-agenda-columns-add-appointments-to-effort-sum); as well
 
 
 (defun org-agenda-columns ()
 (defun org-agenda-columns ()
-  "Turn on column view in the agenda."
+  "Turn on or update column view in the agenda."
   (interactive)
   (interactive)
   (org-verify-version 'columns)
   (org-verify-version 'columns)
   (org-columns-remove-overlays)
   (org-columns-remove-overlays)
   (move-marker org-columns-begin-marker (point))
   (move-marker org-columns-begin-marker (point))
   (let (fmt cache maxwidths m p a d)
   (let (fmt cache maxwidths m p a d)
     (cond
     (cond
-     ((and (local-variable-p 'org-overriding-columns-format)
-	   org-overriding-columns-format)
-      (setq fmt org-overriding-columns-format))
+     ((and (boundp 'org-agenda-overriding-columns-format)
+	   org-agenda-overriding-columns-format)
+      (setq fmt org-agenda-overriding-columns-format)
+      (org-set-local 'org-agenda-overriding-columns-format fmt))
      ((setq m (get-text-property (point-at-bol) 'org-hd-marker))
      ((setq m (get-text-property (point-at-bol) 'org-hd-marker))
       (setq fmt (or (org-entry-get m "COLUMNS" t)
       (setq fmt (or (org-entry-get m "COLUMNS" t)
 		    (with-current-buffer (marker-buffer m)
 		    (with-current-buffer (marker-buffer m)