From: "Levin Du" <zslevin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH]new org-columns-nth-allowed-value function and keys
Date: Tue, 3 Jun 2008 16:40:16 +0800 [thread overview]
Message-ID: <9649271a0806030140pd28b727ie1cd4e2a32e97cc@mail.gmail.com> (raw)
[-- 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
next reply other threads:[~2008-06-03 8:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-03 8:40 Levin Du [this message]
2008-06-03 15:45 ` new org-columns-nth-allowed-value function and keys Peter Jones
2008-06-09 7:54 ` [PATCH]new " Dominik, C.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9649271a0806030140pd28b727ie1cd4e2a32e97cc@mail.gmail.com \
--to=zslevin@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).