emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]new org-columns-nth-allowed-value function and keys
@ 2008-06-03  8:40 Levin Du
  2008-06-03 15:45 ` new " Peter Jones
  2008-06-09  7:54 ` [PATCH]new " Dominik, C.
  0 siblings, 2 replies; 3+ messages in thread
From: Levin Du @ 2008-06-03  8:40 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 387 bytes --]

Hi list,

While editing with Org column view, I'd like some easy navigate and modify keys.
In the patch attached (against git version), I bind vi-style key
h,j,k,l to move around, and numeric key 1-9,0 to set the nth (actually
'1' is the first, and '0' is the last) allowed value.

I mock up this by copying org-columns-next-allowed-value and modifying a bit.
Hope it is useful.

-Levin

[-- Attachment #2: org-colview-nth-value.diff --]
[-- Type: application/octet-stream, Size: 3710 bytes --]

commit 24ebff32aff6812e1f97557faa77b7e000dc3ee3
Author: Levin Du <zslevin@gmail.com>
Date:   Tue Jun 3 16:26:02 2008 +0800

    org-colview.el: new org-columns-nth-allowed-value, add speedy navigate and modify keys

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 39a4463..d3efa3c 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -92,6 +92,14 @@ 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)
+(org-defkey org-columns-map "h" 'backward-char)
+(org-defkey org-columns-map "l" (lambda () (interactive) (goto-char (1+ (point)))))
+(org-defkey org-columns-map "j" 'next-line)
+(org-defkey org-columns-map "k" 'previous-line)
+(dotimes (i 10)
+  (org-defkey org-columns-map (number-to-string i)
+              `(lambda () (interactive)
+                 (org-columns-nth-allowed-value ,i))))
 
 (easy-menu-define org-columns-menu org-columns-map "Org Column Menu"
   '("Column"
@@ -564,6 +572,63 @@ Where possible, use the standard interface for changing this line."
       (and (nth 3 (assoc key org-columns-current-fmt-compiled))
 	   (org-columns-update key))))))
 
+(defun org-columns-nth-allowed-value (arg)
+  "Switch to the nth allowed value for this column."
+  (interactive "p")
+  (org-columns-check-computed)
+  (let* ((col (current-column))
+	 (key (get-char-property (point) 'org-columns-key))
+	 (value (get-char-property (point) 'org-columns-value))
+	 (bol (point-at-bol)) (eol (point-at-eol))
+	 (pom (or (get-text-property bol 'org-hd-marker)
+		  (point))) ; keep despite of compiler waring
+	 (line-overlays
+	  (delq nil (mapcar (lambda (x)
+			      (and (eq (overlay-buffer x) (current-buffer))
+				   (>= (overlay-start x) bol)
+				   (<= (overlay-start x) eol)
+				   x))
+			    org-columns-overlays)))
+	 (allowed (or (org-property-get-allowed-values pom key)
+		      (and (memq
+			    (nth 4 (assoc key org-columns-current-fmt-compiled))
+			    '(checkbox checkbox-n-of-m checkbox-percent))
+			   '("[ ]" "[X]"))))
+	 nval)
+    (when (equal key "ITEM")
+      (error "Cannot edit item headline from here"))
+    (unless (or allowed (member key '("SCHEDULED" "DEADLINE")))
+      (error "Allowed values for this property have not been defined"))
+    (if (member key '("SCHEDULED" "DEADLINE"))
+        (setq allowed '(earlier later)))
+    (if (> arg (length allowed))
+        (error "Out of range"))
+    (setq nval (nth (mod (1- arg) (length allowed)) allowed))
+    (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))
+	(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)))
+      (org-move-to-column col)
+      (and (nth 3 (assoc key org-columns-current-fmt-compiled))
+	   (org-columns-update key))))))
+
 (defun org-verify-version (task)
   (cond
    ((eq task 'columns)

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: new org-columns-nth-allowed-value function and keys
  2008-06-03  8:40 [PATCH]new org-columns-nth-allowed-value function and keys Levin Du
@ 2008-06-03 15:45 ` Peter Jones
  2008-06-09  7:54 ` [PATCH]new " Dominik, C.
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Jones @ 2008-06-03 15:45 UTC (permalink / raw)
  To: Levin Du; +Cc: emacs-orgmode

"Levin Du" <zslevin@gmail.com> writes:
> While editing with Org column view, I'd like some easy navigate and modify keys.
> In the patch attached (against git version), I bind vi-style key
> h,j,k,l to move around, and numeric key 1-9,0 to set the nth (actually
> '1' is the first, and '0' is the last) allowed value.

Levin, the normal Emacs movement keys already work in column view.
For example, C-f moves to the next column.

Personally, I think I'd pass out if Org-mode had vi-like key bindings
for movement!

-- 
Peter Jones, pmade inc.
http://pmade.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH]new org-columns-nth-allowed-value function and keys
  2008-06-03  8:40 [PATCH]new org-columns-nth-allowed-value function and keys Levin Du
  2008-06-03 15:45 ` new " Peter Jones
@ 2008-06-09  7:54 ` Dominik, C.
  1 sibling, 0 replies; 3+ messages in thread
From: Dominik, C. @ 2008-06-09  7:54 UTC (permalink / raw)
  To: Levin Du, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1147 bytes --]

Hi Levin, this is an interesting patch, thank you very much.

I will not add the vi keys - maybe you would like to write that up as
a setup and add it to the FAQ in Worg?

Picking the nth allowed value I do like a lot, and I am putting that
in, at least for now.  I might change it at some point so that you
need to type `4 e' or something like this, if I ever think we need
direct prefix arguments for other functions as well.  For now, I am
using yur proposal.  Thanks.

- Carsten


-----Original Message-----
From: emacs-orgmode-bounces+dominik=science.uva.nl@gnu.org on behalf of Levin Du
Sent: Tue 6/3/2008 10:40 AM
To: emacs-orgmode@gnu.org
Subject: [Orgmode] [PATCH]new org-columns-nth-allowed-value function and keys
 
Hi list,

While editing with Org column view, I'd like some easy navigate and modify keys.
In the patch attached (against git version), I bind vi-style key
h,j,k,l to move around, and numeric key 1-9,0 to set the nth (actually
'1' is the first, and '0' is the last) allowed value.

I mock up this by copying org-columns-next-allowed-value and modifying a bit.
Hope it is useful.

-Levin


[-- Attachment #1.2: Type: text/html, Size: 1704 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-09  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-03  8:40 [PATCH]new org-columns-nth-allowed-value function and keys Levin Du
2008-06-03 15:45 ` new " Peter Jones
2008-06-09  7:54 ` [PATCH]new " Dominik, C.

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).