Browse Source

org-agenda.el: New commands for dragging a line forward/backward

* org-agenda.el (org-agenda-drag-line-forward)
(org-agenda-drag-line-backward): New commands.
(org-agenda-mode-map): Bind the new commands to M-<down> and
M-<up> respectively.

* org.texi (Agenda commands): Add a table heading for dragging
agenda lines forward/backward.
Bastien Guerry 4 years ago
parent
commit
937b4484c6
2 changed files with 39 additions and 0 deletions
  1. 11 0
      doc/org.texi
  2. 28 0
      lisp/org-agenda.el

+ 11 - 0
doc/org.texi

@@ -8913,6 +8913,17 @@ the default behavior of @code{org-capture}.
 @cindex capturing, from agenda
 @vindex org-capture-use-agenda-date
 
+@tsubheading{Dragging agenda lines forward/backward}
+@cindex dragging, agenda lines
+
+@orgcmd{M-<up>,org-agenda-drag-line-backward}
+Drag the line at point backward one line.  With a numeric prefix argument,
+drag backward by that many lines.
+
+@orgcmd{M-<down>,org-agenda-drag-line-forward}
+Drag the line at point forward one line.  With a numeric prefix argument,
+drag forward by that many lines.
+
 @tsubheading{Bulk remote editing selected entries}
 @cindex remote editing, bulk, from agenda
 @vindex org-agenda-bulk-custom-functions

+ 28 - 0
lisp/org-agenda.el

@@ -2182,6 +2182,8 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "\C-m"     'org-agenda-switch-to)
 (org-defkey org-agenda-mode-map "\C-k"     'org-agenda-kill)
 (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
+(org-defkey org-agenda-mode-map [(meta down)] 'org-agenda-drag-line-forward)
+(org-defkey org-agenda-mode-map [(meta up)] 'org-agenda-drag-line-backward)
 (org-defkey org-agenda-mode-map "m"        'org-agenda-bulk-mark)
 (org-defkey org-agenda-mode-map "\M-m"     'org-agenda-bulk-toggle)
 (org-defkey org-agenda-mode-map "*"        'org-agenda-bulk-mark-all)
@@ -9880,6 +9882,32 @@ current HH:MM time."
 	   (org-get-cursor-date (equal with-time 1))))
       (call-interactively 'org-capture))))
 
+;;; Dragging agenda lines forward/backward
+
+(defun org-agenda-drag-line-forward (arg)
+  "Drag an agenda line forward by ARG lines."
+  (interactive "p")
+  (let ((inhibit-read-only t) lst)
+    (if (save-excursion
+	  (dotimes (n arg)
+	    (beginning-of-line 2)
+	    (push (not (get-text-property (point) 'txt)) lst))
+	  (delq nil lst))
+	(message "Cannot move line forward")
+      (org-drag-line-forward arg))))
+
+(defun org-agenda-drag-line-backward (arg)
+  "Drag an agenda line backward by ARG lines."
+  (interactive "p")
+  (let ((inhibit-read-only t) lst)
+    (if (save-excursion
+	  (dotimes (n arg)
+	    (beginning-of-line 0)
+	    (push (not (get-text-property (point) 'txt)) lst))
+	  (delq nil lst))
+	(message "Cannot move line backward")
+      (org-drag-line-backward arg))))
+
 ;;; Flagging notes
 
 (defun org-agenda-show-the-flagging-note ()