Prechádzať zdrojové kódy

Make 1-9,0 access allowed values in column view.

This was proposed by Levin Du, I implemented a modified version of his
patch.
Carsten Dominik 17 rokov pred
rodič
commit
049b5931dd
5 zmenil súbory, kde vykonal 60 pridanie a 14 odobranie
  1. 2 0
      doc/org.texi
  2. 11 0
      lisp/ChangeLog
  3. 22 7
      lisp/org-colview-xemacs.el
  4. 22 7
      lisp/org-colview.el
  5. 3 0
      lisp/org.el

+ 2 - 0
doc/org.texi

@@ -3962,6 +3962,8 @@ Move through the column view from field to field.
 @item  S-@key{left}/@key{right}
 Switch to the next/previous allowed value of the field.  For this, you
 have to have specified allowed values for a property.
+@item 1..9,0
+Directly select the nth allowed value, @kbd{0} selects the 10th value.
 @kindex n
 @kindex p
 @itemx  n / p

+ 11 - 0
lisp/ChangeLog

@@ -1,3 +1,14 @@
+2008-06-09  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-set-regexps-and-options): Set `org-file-properties' and
+	`org-file-tags' to nil.
+
+	* org-colview.el (org-columns-next-allowed-value): Handle next
+	argument NTH to directly select a value.
+
+	* org-colview-xemacs.el (org-columns-next-allowed-value): Handle next
+	argument NTH to directly select a value.
+
 2008-06-08  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-agenda.el (org-agenda-scheduled-leaders): Fix docstring.

+ 22 - 7
lisp/org-colview-xemacs.el

@@ -228,6 +228,10 @@ This is the compiled version of the format.")
 (org-defkey org-columns-map [(meta left)] 'org-columns-move-left)
 (org-defkey org-columns-map [(shift meta right)] 'org-columns-new)
 (org-defkey org-columns-map [(shift meta left)] 'org-columns-delete)
+(dotimes (i 10)
+  (org-defkey org-columns-map (number-to-string i)
+              `(lambda () (interactive)
+                 (org-columns-next-allowed-value nil ,i))))
 
 (easy-menu-define org-columns-menu org-columns-map "Org Column Menu"
   '("Column"
@@ -701,8 +705,10 @@ Where possible, use the standard interface for changing this line."
   (interactive)
   (org-columns-next-allowed-value t))
 
-(defun org-columns-next-allowed-value (&optional previous)
-  "Switch to the next allowed value for this column."
+(defun org-columns-next-allowed-value (&optional previous nth)
+  "Switch to the next allowed value for this column.
+When PREVIOUS is set, go to the previous value.  When NTH is
+an integer, select that value."
   (interactive)
   (org-columns-check-computed)
   (let* ((col (current-column))
@@ -724,6 +730,9 @@ Where possible, use the standard interface for changing this line."
 			    '(checkbox checkbox-n-of-m checkbox-percent))
 			   '("[ ]" "[X]"))))
 	 nval)
+    (when (integerp nth)
+      (setq nth (1- nth))
+      (if (= nth -1) (setq nth 9)))
     (when (equal key "ITEM")
       (error "Cannot edit item headline from here"))
     (unless (or allowed (member key '("SCHEDULED" "DEADLINE")))
@@ -731,11 +740,17 @@ Where possible, use the standard interface for changing this line."
     (if (member key '("SCHEDULED" "DEADLINE"))
 	(setq nval (if previous 'earlier 'later))
       (if previous (setq allowed (reverse allowed)))
-      (if (member value allowed)
-	  (setq nval (car (cdr (member value allowed)))))
-      (setq nval (or nval (car allowed)))
-      (if (equal nval value)
-	  (error "Only one allowed value for this property")))
+      (cond
+       (nth
+	(setq nval (nth nth allowed))
+	(if (not nval)
+	    (error "There are only %d allowed values for property `%s'"
+		   (length allowed) key)))
+       ((member value allowed)
+	(setq nval (or (car (cdr (member value allowed)))
+		       (car allowed)))
+	(if (equal nval value)
+	    (error "Only one allowed value for this property")))))
     (cond
      ((equal major-mode 'org-agenda-mode)
       (org-columns-eval '(org-entry-put pom key nval))

+ 22 - 7
lisp/org-colview.el

@@ -92,6 +92,10 @@ This is the compiled version of the format.")
 (org-defkey org-columns-map [(meta left)] 'org-columns-move-left)
 (org-defkey org-columns-map [(shift meta right)] 'org-columns-new)
 (org-defkey org-columns-map [(shift meta left)] 'org-columns-delete)
+(dotimes (i 10)
+  (org-defkey org-columns-map (number-to-string i)
+              `(lambda () (interactive)
+                 (org-columns-next-allowed-value nil ,i))))
 
 (easy-menu-define org-columns-menu org-columns-map "Org Column Menu"
   '("Column"
@@ -504,8 +508,10 @@ Where possible, use the standard interface for changing this line."
   (interactive)
   (org-columns-next-allowed-value t))
 
-(defun org-columns-next-allowed-value (&optional previous)
-  "Switch to the next allowed value for this column."
+(defun org-columns-next-allowed-value (&optional previous nth)
+  "Switch to the next allowed value for this column.
+When PREVIOUS is set, go to the previous value.  When NTH is
+an integer, select that value."
   (interactive)
   (org-columns-check-computed)
   (let* ((col (current-column))
@@ -527,6 +533,9 @@ Where possible, use the standard interface for changing this line."
 			    '(checkbox checkbox-n-of-m checkbox-percent))
 			   '("[ ]" "[X]"))))
 	 nval)
+    (when (integerp nth)
+      (setq nth (1- nth))
+      (if (= nth -1) (setq nth 9)))
     (when (equal key "ITEM")
       (error "Cannot edit item headline from here"))
     (unless (or allowed (member key '("SCHEDULED" "DEADLINE")))
@@ -534,11 +543,17 @@ Where possible, use the standard interface for changing this line."
     (if (member key '("SCHEDULED" "DEADLINE"))
 	(setq nval (if previous 'earlier 'later))
       (if previous (setq allowed (reverse allowed)))
-      (if (member value allowed)
-	  (setq nval (car (cdr (member value allowed)))))
-      (setq nval (or nval (car allowed)))
-      (if (equal nval value)
-	  (error "Only one allowed value for this property")))
+      (cond
+       (nth
+	(setq nval (nth nth allowed))
+	(if (not nval)
+	    (error "There are only %d allowed values for property `%s'"
+		   (length allowed) key)))
+       ((member value allowed)
+	(setq nval (or (car (cdr (member value allowed)))
+		       (car allowed)))
+	(if (equal nval value)
+	    (error "Only one allowed value for this property")))))
     (cond
      ((equal major-mode 'org-agenda-mode)
       (org-columns-eval '(org-entry-put pom key nval))

+ 3 - 0
lisp/org.el

@@ -1921,6 +1921,7 @@ You can set buffer-local values for this by adding lines like
   "List of property/value pairs that can be inherited by any entry.
 Valid for the current buffer.
 This variable is populated from #+PROPERTY lines.")
+(make-variable-buffer-local 'org-file-properties)
 
 (defgroup org-agenda nil
   "Options concerning agenda views in Org-mode."
@@ -2787,6 +2788,8 @@ means to push this value onto the list in the variable.")
     (org-set-local 'org-todo-heads nil)
     (org-set-local 'org-todo-sets nil)
     (org-set-local 'org-todo-log-states nil)
+    (org-set-local 'org-file-properties nil)
+    (org-set-local 'org-file-tags nil)
     (let ((re (org-make-options-regexp
 	       '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS"
 		 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"