Proposed patch to planner-trunk-tasks

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Proposed patch to planner-trunk-tasks

Michael Herstine <sp1ff@pobox.com>
Hello all,

Pursuant to the discussion on the "Project status?" thread, I'm posting my proposed patch & soliciting feedback.

ChangeLog entry:

2017-01-08  Michael Herstine  <[hidden email]>

* planner-trunk.el: Update `planner-trunk-tasks' and
`planner-trunk-rules-alist' to support using defuns to select the
TRUNK-SECTIONS-LIST for a page, as well as in TRUNK-SECTION_LISTs
to select the tasks in each trunk

Discussion:

My patch is to planner-trunk.el. `planner-trunk-tasks' works off of `planner-trunk-rules-alist', which is a list of lists. The outer list is indexed by regexps which are applied to the current page name to select the TRUNK-SECTIONS-LIST to be used. My patch allows users to specify defuns as well as regexps; it also supports using the symbols 'weekend & 'weekday (which will select the corresponding TRUNK-SECTIONS-LIST when the current page is a day page falling on a weekend or weekday, respectively).

Each TRUNK-SECTIONS-LIST defines task groupings. Here again, each group is currently defined by a regexp applied to the task description. My patch again allows users to specify defuns as well as regexps.

The Code:

I've attached the patch file, as well as the new planner-trunk.el, but here's the patch:

From 343f1761d849d2b7319f629bfface1183fb8ea17 Mon Sep 17 00:00:00 2001
From: Michael Herstine <[hidden email]>
Date: Sun, 8 Jan 2017 19:59:46 -0800
Subject: [PATCH] Expand 'planner-trunk-tasks' to accept defuns as well as
 regexps.

'planner-rules-alist' currently selects pages based on regexps. This
patch allows users to specify arbitrary defuns as well as regexps.

TRUNK-SECTIONS-LIST groups tasks again by regexps. This patch will
again allow users to specify arbitrary defuns as well as regexps.
---
 ChangeLog             |   9 +-
 Makefile.defs.default |   2 +-
 planner-trunk.el      | 314 ++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 250 insertions(+), 75 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 15afe8b..d0c594d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,15 @@
+2017-01-08  Michael Herstine  <[hidden email]>
+
+ * planner-trunk.el: Update `planner-trunk-tasks' and
+ `planner-trunk-rules-alist' to support using defuns to select the
+ TRUNK-SECTIONS-LIST for a page, as well as in TRUNK-SECTION_LISTs
+ to select the tasks in each trunk
+
 2014-01-12  John Sullivan  <[hidden email]>
 
  * planner-el.texi: Several updates to fix broken cross-references
  and outdated instructions. Still more to do.
-
+
 2009-07-11  John Sullivan  <[hidden email]>
 
  * planner-el.texi (Planning based on the Franklin-Covey Approach):
diff --git a/Makefile.defs.default b/Makefile.defs.default
index b95da42..ff2d644 100644
--- a/Makefile.defs.default
+++ b/Makefile.defs.default
@@ -36,7 +36,7 @@ install_info = install-info --info-dir=$(INFODIR) $(1) || :
 # Useful only for the maintainer
 PROJECT    = planner
 DEBNAME    = planner-el
-VERSION    = 3.42
+VERSION    = 3.43
 MANUAL     = planner-el
 
 # Location of Emacs Lisp Package Archive entries
diff --git a/planner-trunk.el b/planner-trunk.el
index 58d784e..87cc5b4 100644
--- a/planner-trunk.el
+++ b/planner-trunk.el
@@ -1,13 +1,15 @@
 ;;; planner-trunk.el --- Trunk tasks for the Emacs planner
-;;
+
 
 ;; Copyright (C) 2005, 2008 Dryice Dong Liu . All rights reserved.
+;; Parts copyright (C) 2016, 2017 Michael Herstine
 ;; Parts copyright (C) 2005, 2008 Keith Amidon
 ;; Parts copyright (C) 2005, 2008 Free Software Foundation, Inc.
 ;; Parts copyright (C) 2006, 2007 Software Freedom Law Center
 
 ;; Keywords: emacs planner trunk group tasks
-;; Authors: Dryice Liu <dryice AT liu DOT com DOT cn>
+;; Authors: Michael Herstine <[hidden email]>
+;;          Dryice Liu <dryice AT liu DOT com DOT cn>
 ;;          Keith Amidon <camalot AT picnicpark dot org>
 ;; Description: trunk(group) tasks for the Emacs planner
 
@@ -55,6 +57,8 @@
 
 ;;; Contributors:
 
+;; Michael Herstine added some features
+
 ;; Keith Amidon worked on a number of aspects of this file.
 
 ;; Sergey Vlasov contributed a fix that corrected regexp syntax and
@@ -79,12 +83,26 @@
 
 Each rule is a sublist of the form:
 
-   (PAGE-REGEXP COMPLETE-HEADING TRUNK-SECTIONS-LIST)
+   (PAGE-SELECTOR COMPLETE-HEADING TRUNK-SECTIONS-LIST)
+
+PAGE-SELECTOR is used to select the set of trunk sections that should be
+used for a given page. It may be given in a few ways:
+
+1. If given as a string, it will be interpreted as a regular
+expression to be matched against the name of the current planner
+page (i.e. the old planner-trunk behavior).
 
-PAGE-REGEXP is used to select the set of trunk sections that should be
-used.  It is matched against the name of the current planner page.  If
-no matching PAGE-REGEXP is found, no trunking is done.  If there is
-more than one match, the first one in the list is used.
+2. If a list of strings are provided, the page name will be
+checked for membership in that list (using string=).
+
+3. If the symbols 'weekday or 'weekend are given, the rule will
+be used for any planner day page whose correspoding date falls on
+a weekday or weekend, respectively.
+
+4. If a function is given, it will be invoked with the page name. The function should return non-nil
+
+If no matching PAGE-SELECTOR is found, no trunking is done.  If
+there is more than one match, the first one in the list is used.
 
 If COMPLETE-HEADING is nil, completed and not completed tasks will be
 in the same trunk, sorted according to `planner-sort-tasks-key-function'.
@@ -92,25 +110,35 @@ If it is a string, it is the name of a sub-heading of the tasks
 section under which to sort completed tasks separately, in which
 case it will be the last subsection of the tasks section of the page.
 
-Each element of TRUNK-SECTIONS-LIST describes a trunk of the page.
-Elements can either be a simple TASK-PLAN-REGEXP, or a sublist of the form:
-
-   (TASK-PLAN-REGEXP TRUNK-HEADING)
-
-The TASK-PLAN-REGEXP is matched against the plan page (or pages if you
-are using planner-multi) for the task.  If more than one
-TASK-PLAN-REGEXP matches, the first one in the list is used.  All
-tasks that match the same TASK-PLAN-REGEXP will be grouped together.
-The order of the groups will match the order of TRUNK-SECTIONS-LIST.
-Tasks that do not match any entry in TRUNK-SECTIONS-LIST will be in a
-separate group at the end of the tasks section.  If the sublist form
-of an entry is used, TRUNK-HEADING is a name for the outline heading
-to be inserted at the top of the trunk.  If TRUNK-SECTIONS-LIST
-contains a mix of items in the regexp and sublist forms, when tasks
-are present that match a regexp form entry, but no tasks are present
-that match the most recent preceeding sublist form entry in the list,
-the heading from the sublist form entry will be inserted anyway.  In
-use, it will become obvious why this is desirable."
+Each element of TRUNK-SECTIONS-LIST describes a trunk of the
+page.  Elements can either be a simple TASK-PLAN-SELECTOR, or a
+sublist of the form:
+
+   (TASK-PLAN-SELECTOR TRUNK-HEADING)
+
+The TASK-PLAN-SELECTOR is matched against each task to detrmine
+membership in a trunk, and again may be given in a few forms:
+
+1. If specified as a string, it is interpreted as a regular
+expression to be matched against the plan page (or pages if you
+are using planner-multi) for the task.
+
+2. If it is a function, the function will be invoked with the
+following parameters:
+
+If more than one TASK-PLAN-SELECTOR matches, the first one in the
+list is used.  All tasks that match the same TASK-PLAN-SELECTOR
+will be grouped together.  The order of the groups will match the
+order of TRUNK-SECTIONS-LIST.  Tasks that do not match any entry
+in TRUNK-SECTIONS-LIST will be in a separate group at the end of
+the tasks section.  If the sublist form of an entry is used,
+TRUNK-HEADING is a name for the outline heading to be inserted at
+the top of the trunk.  If TRUNK-SECTIONS-LIST contains a mix of
+items in the regexp and sublist forms, when tasks are present
+that match a regexp form entry, but no tasks are present that
+match the most recent preceeding sublist form entry in the list,
+the heading from the sublist form entry will be inserted anyway.
+In use, it will become obvious why this is desirable."
   :type '(repeat (list
                   :tag "Trunk rule"
                   (choice :tag "Page regexp"
@@ -129,6 +157,11 @@ use, it will become obvious why this is desirable."
                                    (string :tag "Section heading"))))))
   :group 'planner-trunk)
 
+(defcustom planner-trunk-outline-level 2
+  "Outline level at which trunk sections will be inserted"
+  :type 'integer
+  :group 'planner-trunk)
+
 (defcustom planner-trunk-tasks-before-hook nil
   "Functions to run before doing the trunk."
   :type 'hook
@@ -153,8 +186,8 @@ use, it will become obvious why this is desirable."
   "Trunk section in RULE."
   (elt rule 2))
 
-(defun planner-trunk-list-regexp (trunk)
-  "Plan page regular expression for TRUNK."
+(defun planner-trunk-list-selector (trunk)
+  "Plan page selector for TRUNK."
   (if (listp trunk)
       (car trunk)
     trunk))
@@ -167,7 +200,7 @@ use, it will become obvious why this is desirable."
 
 (defun planner-trunk-task-plan-str (task-info)
   "Return plan string for TASK-INFO."
-  (or 
+  (or
    (if (fboundp 'planner-multi-task-link-as-list)
        (mapconcat 'identity
                   (planner-multi-task-link-as-list task-info) " ")
@@ -175,6 +208,21 @@ use, it will become obvious why this is desirable."
          (planner-task-plan task-info)))
    ""))
 
+(defun planner-trunk-task-plan-pages (task-info)
+  "Return a list of the plan pages on which TASK-INFO resides"
+  (or
+   (if (fboundp 'planner-multi-task-link-as-list)
+       (map 'list (lambda (x) (substring x 2 -2))
+            (planner-multi-task-link-as-list task-info))
+     (list (or (planner-task-link task-info)
+               (planner-task-plan task-info))))
+   '()))
+
+(defun planner-trunk-task-plan-pages (task-info)
+  "Return a list of the plan pages on which TASK-INFO resides"
+  (map 'list (lambda (x) (substring x 2 -2))
+       (planner-multi-task-link-as-list task-info)))
+
 (defun planner-trunk-completed-p (task-info)
   "Return non-nil if TASK-INFO is a completed task."
   (or (equal (planner-task-status task-info) "X")
@@ -215,7 +263,7 @@ use, it will become obvious why this is desirable."
     (let ((trunk-count (length trunk-list))
           (plan (planner-trunk-task-plan-str task-info))
           (task-completed (planner-trunk-completed-p task-info)))
-      (if (not plan) 
+      (if (not plan)
           (+ 2 (if (and completed-heading task-completed)
                    (* 2 trunk-count)
                  trunk-count))
@@ -225,23 +273,59 @@ use, it will become obvious why this is desirable."
               (setq count (+ count trunk-count 2)))
             (mapc
              (lambda (trunk-entry)
-              (let ((plan-regexp (planner-trunk-list-regexp trunk-entry)))
-                (if (string-match plan-regexp plan)
+              (let ((selector (planner-trunk-list-selector trunk-entry)))
+                (if (planner-trunk-match-task selector task-info)
                     (throw 'done count)
-                  (setq count (1+ count))))) 
+                  (setq count (1+ count)))))
              trunk-list)
             count))))))
 
+(defun planner-trunk-match-task (selector task-info)
+  "Match TASK-INFO against SELECTOR.
+
+SELECTOR may be a string, in which case it is interpreted as a
+regex to be matched against the return value of
+`planner-trunk-task-plan-str' as applied to TASK-INFO (this is
+the old `planner-trunk' behavior). It may also be a function,
+which will be invoked with the following arguments:
+
+  - the current page name
+  - the task priority
+  - the task #
+  - the task status
+  - the task description
+  - the task date
+  - a list of strings naming the pages on which this task is
+    found (no file extension)"
+  (or (and (stringp selector)
+           (string-match selector
+                         (planner-trunk-task-plan-str task-info)))
+      (and (or (and (symbolp selector)
+                    (fboundp selector))
+               (and (listp selector)
+                    (eq 'lambda (car selector))))
+           (funcall selector
+                    (elt task-info 0) ; page name
+                    (elt task-info 1) ; priority
+                    (elt task-info 2) ; task #
+                    (elt task-info 3) ; status
+                    (elt task-info 4) ; description, incl. id & tags
+                    (elt task-info 8) ; date, if calendared
+                    (planner-trunk-task-plan-pages task-info)))))
+
 (defun planner-trunk-ins-heading (completed-heading task-info heading)
   "Insert the task heading.
-If COMPLETED-HEADING is non-nil and TASK-INFO is a completed task,
-use COMPLETED-HEADING instead of HEADING."
+
+The heading will be inserted at outline level
+`planner-trunk-outline-level'. If COMPLETED-HEADING is non-nil
+and TASK-INFO is a completed task, the heading will be inserted
+one level deeper."
   (when heading
     (insert "\n")
     (when (and completed-heading
                (planner-trunk-completed-p task-info))
       (insert "*"))
-    (insert "** " heading))
+    (insert (make-string planner-trunk-outline-level ?*) " " heading))
   (insert "\n"))
 
 (defun planner-trunk-do-trunk-section (rule)
@@ -257,7 +341,7 @@ beginning of the completed subsection."
         ;; case to handle headings otherwise.  It prevents anyone from
         ;; having a plan page named (_-), which I hope no-one wants to
         ;; do...
-        (trunk-list (cons "^\\\\(_-\\\\)$" 
+        (trunk-list (cons "^\\\\(_-\\\\)$"
                           (planner-trunk-rule-trunk-sections rule)))
         (first-trunk (car (planner-trunk-rule-trunk-sections rule)))
         (ntasks 0))
@@ -266,16 +350,18 @@ beginning of the completed subsection."
         (when task-info
           (setq ntasks (1+ ntasks))
           (let ((plan (planner-trunk-task-plan-str task-info))
-                (plan-regexp (planner-trunk-list-regexp (car trunk-list))))
-            (unless (string-match plan-regexp plan)
+                (selector (planner-trunk-list-selector (car trunk-list))))
+
+            (unless (planner-trunk-match-task selector task-info)
               (let ((hdr nil))
                 (while (and trunk-list
-                            (not (string-match plan-regexp plan)))
+
+                            (not (planner-trunk-match-task selector task-info)))
                   (setq trunk-list (cdr trunk-list))
-                  (setq plan-regexp
-                        (planner-trunk-list-regexp (car trunk-list)))
+                  (setq selector
+                        (planner-trunk-list-selector (car trunk-list)))
                   (when (planner-trunk-list-heading (car trunk-list))
-                    (setq hdr 
+                    (setq hdr
                           (planner-trunk-list-heading (car trunk-list)))))
                 (when (planner-trunk-list-heading (car trunk-list))
                   (setq hdr (planner-trunk-list-heading (car trunk-list))))
@@ -289,7 +375,10 @@ beginning of the completed subsection."
     ntasks))
 
 (defun planner-trunk-do-trunk (rule)
-  "Really do the trunk following RULE."
+  "Trunk the curernt page's tasks according to RULE.
+
+The buffer is assumed to have been narrowed to the Tasks section,
+and the tasks therein sorted conveniently for this operation."
   (goto-char (point-min))
   (planner-trunk-do-trunk-section rule)
   (when (planner-trunk-rule-completed-heading rule)
@@ -300,9 +389,94 @@ beginning of the completed subsection."
       (when (> (planner-trunk-do-trunk-section rule) 0)
         (when (stringp (planner-trunk-rule-completed-heading rule))
           (goto-char start-completed-pos)
-          (insert "\n** " (planner-trunk-rule-completed-heading rule) "\n"))))))
-
-;; user visible functions
+          (insert "\n" (make-string planner-trunk-outline-level ?*)
+                  " " (planner-trunk-rule-completed-heading rule) "\n"))))))
+
+;;;_ + Functions related to rule selection
+
+(defun planner-trunk-page-is-weekend (page)
+  "Determine whether PAGE is a day page correpsonding to a date
+falling on a weekend.
+
+PAGE is assumed to be in the form returned by `planner-page-name'."
+  (and (string-match planner-date-regexp page)
+       (let ((d (planner-filename-to-calendar-date page)))
+         (memq
+          (elt (decode-time (encode-time 0 0 0 (elt d 1) (elt d 0) (elt d 2)))
+           6)
+          '(0 6)))))
+
+(defun planner-trunk-page-is-weekday (page)
+  "Determine whether PAGE is a day page correpsonding to a date
+falling on a weekday.
+
+PAGE is assumed to be in the form returned by `planner-page-name'."
+  (and (string-match planner-date-regexp page)
+       (let ((d (planner-filename-to-calendar-date page)))
+         (memq
+          (elt (decode-time (encode-time 0 0 0 (elt d 1) (elt d 0) (elt d 2)))
+           6)
+          '(1 2 3 4 5)))))
+
+(defun planner-trunk-select-rule (page rule-list)
+  "Select the trunk rule from RULE-LIST appropriate to PAGE (if any).
+
+PAGE is assumed to be a page name in the form returned by
+`planner-page-name' (e.g. \"2016.12.30\", not
+\"2016.12.30.muse\"), RULE-LIST shall be a list of three-tuples:
+
+  1. A condition governing the pages to which this rule
+  applies (on which more below)
+
+  2. An optional element governing the dispostion of completed
+  stasks (nil to group them with incomplete tasks) (see
+  `planner-trunk-rules-alist' for details)
+
+  3. A list of trunk rules (see `planner-trunk-rules-alist' for
+  details)
+
+The zero-th element, the condition, may be one of the following:
+
+  1. A string, in which case it will be interepreted as a regex;
+  if it matches PAGE, the corresponding rule shall be
+  selected (this is the old `planner-trunk' behavior)
+
+  2. A list of strings, in which case PAGE shall be compared
+  against each element for a match
+
+  3. The symbols 'weekend or 'weekday, which will match day pages
+  corresponding to dates that fall on a Saturday or Sunday, or
+  dates that fall on a Monday through a Friday, respectively.
+
+  4. A function which will be invoked with PAGE-- it shall return
+  nil to continue searching, or non-nil to select the
+  corresponding rule."
+
+  (catch 'done
+    (while rule-list
+      (let* ((rule (car rule-list))
+             (C (car rule)))
+        (if (or (and (stringp C)
+                     (string-match C page))
+                (and (listp C)
+                     (member page C))
+                (and (symbolp C)
+                     (eq C 'weekend)
+                     (planner-trunk-page-is-weekend page))
+                (and (symbolp C)
+                     (eq C 'weekday)
+                     (planner-trunk-page-is-weekday page))
+                (and (listp C)
+                     (eq 'lambda (car C))
+                     (funcall C page))
+                (and (symbolp C)
+                     (fboundp C)
+                     (funcall C page)))
+            (throw 'done rule)))
+      (setq rule-list (cdr rule-list)))))
+
+
+;;;_ + User-visible functions
 
 ;;;###autoload
 (defun planner-trunk-tasks (&optional force)
@@ -313,33 +487,27 @@ and/or after you create new tasks. If a prefix is given or FORCE is not
 nil, trunk completed tasks together with non-completed tasks not
 matter what the `planner-trunk-rule-list' said."
   (interactive "P")
-  (let ((page-name (planner-page-name))
-        (rule-list planner-trunk-rule-list))
-    (let ((rule (catch 'done
-                  (while rule-list
-                    (if (string-match (caar rule-list) page-name)
-                        (throw 'done (car rule-list))
-                      (setq rule-list (cdr rule-list))))
-                  nil)))
-      (if rule
-          (save-excursion
-            (save-restriction
-              (run-hooks 'planner-trunk-tasks-before-hook)
-              (when (planner-narrow-to-section 'tasks)
-                (planner-trunk-delete-non-task-lines)
-                (if force
-                    (setq rule
-                          (list (planner-trunk-rule-page-regexp rule)
-                                nil
-                                (planner-trunk-rule-trunk-sections rule))))
-                (let ((planner-sort-tasks-key-function
-                       (lambda ()
-                         (planner-trunk-sort-tasks rule))))
-                  (planner-sort-tasks))
-                (planner-trunk-do-trunk rule))
-              (run-hooks 'planner-trunk-tasks-after-hook)))))))
+  (let ((rule (planner-trunk-select-rule
+               (planner-page-name)
+               planner-trunk-rule-list)))
+    (if rule
+        (save-excursion
+          (save-restriction
+            (run-hooks 'planner-trunk-tasks-before-hook)
+            (when (planner-narrow-to-section 'tasks)
+              (planner-trunk-delete-non-task-lines)
+              (if force
+                  (setq rule
+                        (list (planner-trunk-rule-page-regexp rule)
+                              nil
+                              (planner-trunk-rule-trunk-sections rule))))
+              (let ((planner-sort-tasks-key-function
+                     (lambda ()
+                       (planner-trunk-sort-tasks rule))))
+                (planner-sort-tasks))
+              (planner-trunk-do-trunk rule))
+            (run-hooks 'planner-trunk-tasks-after-hook))))))
 
 (provide 'planner-trunk)
 
 ;;; planner-trunk.el ends here
-
-- 
1.9.1


Comments, criticism &c welcome.

-- 
Michael




_______________________________________________
Planner-el-discuss mailing list
[hidden email]
https://mail.gna.org/listinfo/planner-el-discuss

Expand-planner-trunk-tasks-to-accept-defuns-as-well.patch (27K) Download Attachment
planner-trunk.el (26K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch to planner-trunk-tasks

Soso Rktmb
Hi Michael,

On Mon, Jan 9, 2017 at 5:24 AM, Michael <[hidden email]> wrote:
> I'm posting my proposed patch & soliciting feedback.
[...]
> Comments, criticism &c welcome.

Thanks you for posting your patch!
It is so refreshing to see new features on planner!
I have not tested it yet, but I like it so far (FWIW).

Could you comment more on why you made it, how you use it and what you
think is possible to do with it?

For example, I configure trunking like this because I find it easier
to split home and work trunking:
(defvar at-home
  (string-match "machine1\\|machine2\\|machine3" system-name))
(defvar at-work
  (not at-home))

(defvar planner-trunk-rule-list-home
 [...]
)
(defvar planner-trunk-rule-list-work
 [...]
)
(if at-home
  (setq planner-trunk-rule-list planner-trunk-rule-list-home)
  (setq planner-trunk-rule-list planner-trunk-rule-list-work)
)

But I have the feeling that with this patch it is possible to do more
dynamic configurations, which would make day and plan pages less boring.

Other comments:
- Since the patch rename planner-trunk-list-regexp into
  planner-trunk-list-selector, can it break some configuration?

- Maybe it would be better to split the patch, so that whitespace
  fixes are separated?

- Did you do some profiling? Trunking may be slow.

- Some typos: curernt, correspoding, correpsonding (x2)

Hope this helps, regards,
--
solofo

_______________________________________________
Planner-el-discuss mailing list
[hidden email]
https://mail.gna.org/listinfo/planner-el-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch to planner-trunk-tasks

Michael Herstine <sp1ff@pobox.com>
Hey Solofo,

Thanks for reading; will take your comments in order:

1. As to why I made it, I found that regexp's were not expressive enough for what I like to do. A few examples of things I can now do with my trunking:

1.a. I would like to be able to select groups of tasks based on more than simple regexps; for instance, I like to reserve my early mornings for focus tasks; I accomplish this with the following defun:

(defun mgh/plan/select-focus-tasks (projects page priority taskno
                                             status description date
                                             pages)
  ;; In PROJECTS and incomplete and priority [AB] @focused.
  ;; In PROJECTS and incomplete and priority A and widget-cranking
  (and (cl-intersection projects pages :test 'string=)
       (string-match "[_oP]" status)
       (or (and (string-match "[AB]" priority)
                (member "EnergyFocused" pages))
           (and (string= "A" priority)
                (member "EnergyWidgetCranking" pages)))))

1.a. I would like to trunk day pages differently based on whether the day is a weekend or a weekday; to continue the example above, the set of projects on which I want to focus changes depending on whether the day is a weekday or not, so my planner-trunk-rule-list can have entries like:

         (list 'weekend nil
               (list
                (list (lambda (page priority taskno status description date pages)
                        (mgh/plan/select-focus-tasks mgh-plan-personal-projects
                                                     page priority taskno status
                                                     description date pages))
                      "@first-up")
         ...
         (list 'weekday nil
               (list
                (list (lambda (page priority taskno status description date pages)
                        (mgh/plan/select-focus-tasks mgh-plan-work-projects
                                                     page priority taskno status
                                                     description date pages))
                      "@first-up")

So on weekdays, mgh/plan/select-focus-tasks will be called with the variable mgh-plan-work-projects, which is a list of projects I'm dealing with at work. On weekends, the same logic will apply, but to a different set of projects.

To your case, you could continue to do what you're doing now, or refactor the differences between trunking at home & work into a single list whose selectors include knowledge of the current host:

(setq planner-trunk-rule-list
  (list
    (list 'i-am-at-home nil
      ...
    (list...
  
probably depends on how much overlap your trunking rules have between home & work, but I wouldn't presume to say.

2. planner-trunk-list-regexp, since this was in the group labelled "Internal variables and utility functions", I assumed that I was under no obligation to retain the defun. But happy to throw that out to the group-- what is the convention here?

3. Yah, good point-- will try to do that, but do you have any suggestions as to how to do that conveniently (I'm not a git jockey)?

4. No profiling, yet

5. Damn, that's embarrassing-- thanks. Will be corrected in next patch.

Anyone else? John Sullivan, are you out there?

-- 
Michael




On Tue, Jan 10, 2017 at 10:52 PM, Soso Rktmb <[hidden email]> wrote:
Hi Michael,

On Mon, Jan 9, 2017 at 5:24 AM, Michael <[hidden email]> wrote:
> I'm posting my proposed patch & soliciting feedback.
[...]
> Comments, criticism &c welcome.

Thanks you for posting your patch!
It is so refreshing to see new features on planner!
I have not tested it yet, but I like it so far (FWIW).

Could you comment more on why you made it, how you use it and what you
think is possible to do with it?

For example, I configure trunking like this because I find it easier
to split home and work trunking:
(defvar at-home
  (string-match "machine1\\|machine2\\|machine3" system-name))
(defvar at-work
  (not at-home))

(defvar planner-trunk-rule-list-home
 [...]
)
(defvar planner-trunk-rule-list-work
 [...]
)
(if at-home
  (setq planner-trunk-rule-list planner-trunk-rule-list-home)
  (setq planner-trunk-rule-list planner-trunk-rule-list-work)
)

But I have the feeling that with this patch it is possible to do more
dynamic configurations, which would make day and plan pages less boring.

Other comments:
- Since the patch rename planner-trunk-list-regexp into
  planner-trunk-list-selector, can it break some configuration?

- Maybe it would be better to split the patch, so that whitespace
  fixes are separated?

- Did you do some profiling? Trunking may be slow.

- Some typos: curernt, correspoding, correpsonding (x2)

Hope this helps, regards,
--
solofo

_______________________________________________
Planner-el-discuss mailing list
[hidden email]
https://mail.gna.org/listinfo/planner-el-discuss


_______________________________________________
Planner-el-discuss mailing list
[hidden email]
https://mail.gna.org/listinfo/planner-el-discuss