emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Change to next/previous-line in org agenda


From: Eric Abrahamsen
Subject: [O] [PATCH] Change to next/previous-line in org agenda
Date: Mon, 06 Aug 2012 17:40:44 +0800
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux)

I'm not sure people will actually want this change, but I like it, so
I'm providing a patch. All this does is change org-agenda-next-line and
org-agenda-previous-line so that they move by agenda items, and not by
actual lines.

The only real drawback I can see is that, since
`substitute-key-definition' is being used to rewire *all*
next/previous-line definitions, it becomes a little difficult to
actually move by single lines. But if that's not a big deal…

Eric

>From dbb39680097b21882f6bafb65b3fc6548de93496 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <address@hidden>
Date: Mon, 6 Aug 2012 17:31:52 +0800
Subject: [PATCH] Next/previous-line in agenda only go to agenda items.

---
 lisp/org-agenda.el | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index dd2c98e..1e2cbfd 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7245,17 +7245,21 @@ When called with a prefix argument, include all archive 
files as well."
            (get-text-property (max (point-min) (1- (point)))
                               'org-agenda-type))))
 
-(defun org-agenda-next-line ()
-  "Move cursor to the next line, and show if follow mode is active."
-  (interactive)
-  (call-interactively 'next-line)
-  (org-agenda-do-context-action))
-
-(defun org-agenda-previous-line ()
-  "Move cursor to the previous line, and show if follow-mode is active."
-  (interactive)
-  (call-interactively 'previous-line)
-  (org-agenda-do-context-action))
+(defun org-agenda-next-line (n)
+  "Move cursor to next agenda item."
+  (interactive "p")
+  (let ((backward (< n 0))
+       (count (or (abs n) 1)))
+    (while (> count 0)
+      (next-line (when backward -1))
+      (org-agenda-do-context-action)
+      (when (org-get-at-bol 'org-marker)
+       (setq count (1- count))))))
+
+(defun org-agenda-previous-line (n)
+  "Move cursor to next agenda item."
+  (interactive "p")
+  (org-agenda-next-line (- n)))
 
 (defun org-agenda-do-context-action ()
   "Show outline path and, maybe, follow mode window."
-- 
1.7.11.4


-- 
GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.11)
 of 2012-08-06 on pellet
7.8.11

reply via email to

[Prev in Thread] Current Thread [Next in Thread]