[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] [patch] Create tasks at point in plan page
From: |
Toby Allsopp |
Subject: |
[emacs-wiki-discuss] [patch] Create tasks at point in plan page |
Date: |
Thu, 06 Jan 2005 22:34:07 +1300 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) |
I was using planner to make a hierarchical list of tasks for a project
and got sick of hitting C-u C-c C-t and then moving the task into the
correct position from the top of the page. So, here's a patch that
adds a C-c C-S-t binding that inserts the new task wherever you have
the cursor if you're on a plan page.
As an example, I was structuring my plan page like so:
--8<---------------cut here---------------start------------->8---
* Tasks
** Major group of tasks
#B _ Task
*** Less major group
#B _ Task
*** Another subgroup
#B _ Task
#B _ Task
** Group 2
*** Subgroup three
#B _ Task
--8<---------------cut here---------------end--------------->8---
Regards,
Toby.
--- emacs-lisp/sacha-dev/planner/planner.el~ 2004-12-27 18:27:33.000000000
+1300
+++ emacs-lisp/sacha-dev/planner/planner.el 2005-01-05 10:15:33.647408300
+1300
@@ -658,6 +658,7 @@
(define-key map "\C-c\C-j\C-r" 'planner-goto-most-recent)) ; recent
(define-key map "\C-c\C-t" 'planner-create-task-from-buffer)
+ (define-key map '[(control ?c) (control ?T)]
'planner-create-task-from-buffer-at-point)
(define-key map "\C-c\C-c" 'planner-copy-or-move-task)
(define-key map "\C-c\C-u" 'planner-raise-task)
(define-key map "\C-c\C-d" 'planner-lower-task)
@@ -1537,6 +1538,13 @@
;;;_ + Creation
+(defvar planner-insert-task-at-point-flag nil
+ "Whether to insert the current task at point in the plan page.
+The usual behaviour is to insert it in the first block of tasks
+in the 'Tasks' section of the plan page. This is dynamically
+bound to `t' by the `planner-create-task-from-buffer-at-point'
+function.")
+
(defun planner-create-task-from-info
(info &optional category priority status description link-text date plan)
"Create a task in the date and plan pages based on INFO.
@@ -1557,8 +1565,15 @@
plan-page)
(setq plan-page nil)))
(when (and plan-page (not (string= plan-page "")))
- (planner-find-file plan-page)
- (planner-seek-task-creation-point)
+ ;; If the user has requested that the task be inserted at
+ ;; point and the current buffer is the correct plan page for
+ ;; the task then don't move point and therefore insert the
+ ;; task where the user wanted. Otherwise, go to the normal
+ ;; place for inserting tasks.
+ (unless (and planner-insert-task-at-point-flag
+ (string= (planner-page-name) plan-page))
+ (planner-find-file plan-page)
+ (planner-seek-task-creation-point))
(insert (planner-format-task info category priority
status description
date-page date-page)
@@ -2803,7 +2818,8 @@
(or planner-expand-name-favor-future-p
planner-task-dates-favor-future-p)))
(planner-read-date))))
- (if (and current-prefix-arg (planner-derived-mode-p 'planner-mode)
+ (if (and (or current-prefix-arg planner-insert-task-at-point-flag)
+ (planner-derived-mode-p 'planner-mode)
(not (string-match planner-date-regexp (planner-page-name))))
;; Universal prefix means pick up from current page
(planner-page-name)
@@ -2827,6 +2843,15 @@
plan-page
status))
+(defun planner-create-task-from-buffer-at-point ()
+ "Create a new task at the current point position in a plan page.
+The task created is exactly the same as would be created by
+`planner-create-task-from-buffer' with a prefix argument. This
+is only useful when editing a plan page."
+ (interactive)
+ (let ((planner-insert-task-at-point-flag t))
+ (call-interactively 'planner-create-task-from-buffer)))
+
(defun planner-create-task (title date &optional annotation plan-page status)
"Create a new task named TITLE based on the current Wiki page.
If DATE is non-nil, makes a daily entry on DATE, else makes an
- [emacs-wiki-discuss] [patch] Create tasks at point in plan page,
Toby Allsopp <=