From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: [RFC] Display most recent log item in Agenda Date: Sun, 14 Dec 2014 18:07:06 +0800 Message-ID: <87388imto5.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y05zj-0002Lo-Jk for emacs-orgmode@gnu.org; Sun, 14 Dec 2014 05:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y05zd-0000NS-DI for emacs-orgmode@gnu.org; Sun, 14 Dec 2014 05:01:43 -0500 Received: from plane.gmane.org ([80.91.229.3]:42097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y05zd-0000NL-1E for emacs-orgmode@gnu.org; Sun, 14 Dec 2014 05:01:37 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Y05zb-0003QU-RD for emacs-orgmode@gnu.org; Sun, 14 Dec 2014 11:01:35 +0100 Received: from 114.248.13.96 ([114.248.13.96]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Dec 2014 11:01:35 +0100 Received: from eric by 114.248.13.96 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Dec 2014 11:01:35 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Undeterred by my previous bum patch, I'm sending more patches! Most of these are "what do you think" patches. 1. Ensure-org-log-into-drawer-returns-nil-or-string If the answer to my last question is "make sure `org-log-into-drawer' never returns just t", then this patch does that. If that isn't the answer, something can be done with `org-log-beginning'. 2. Missing-comma-in-org-agenda-with-point-at-orig-entry The (currently unused) macro `org-agenda-with-point-at-orig-entry' is missing a comma. 3. New-function-org-get-log-list and New-function-org-agenda-show-log-item This is the "what do you think part". The first patch finds and returns the state log items of the current entry, as a list of parsed elements. It probably doesn't try hard enough to make sure it's really found the list. The second implements an Agenda command which displays the text of the most recent note on the entry under point. I use logging a lot, and am forever looking at "WAIT" or "NEXT" todos, and wondering what the heck I was waiting for, or actually supposed to do next. If this is acceptable in principle, the finished product would probably be a normal org-mode function, with an Agenda implementation on top of that, and maybe some sort of guard against displaying overly-long notes. Alternately, I could probably make this into something akin to org-agenda-entry-text-mode, where *all* entries have their most recent log item stuck under them. I find that sort of thing distracting, but some people might like it. WDYT? Eric --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Ensure-org-log-into-drawer-returns-nil-or-string.patch >From c8d00f77135022b239e251b9ddde4a4bbffcf110 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sun, 14 Dec 2014 17:31:49 +0800 Subject: [PATCH 1/4] Ensure org-log-into-drawer returns nil or string * lisp/org.el (org-log-into-drawer): Don't let it simply return t. --- lisp/org.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 4aa7988..6df6e2e 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -2969,7 +2969,11 @@ If the current entry has or inherits a LOG_INTO_DRAWER property, it will be used instead of the default value." (let ((p (org-entry-get nil "LOG_INTO_DRAWER" 'inherit t))) (cond - ((not p) org-log-into-drawer) + ((not p) + (when log-into-drawer + (if (stringp org-log-into-drawer) + org-log-into-drawer + "LOGBOOK"))) ((equal p "nil") nil) ((equal p "t") "LOGBOOK") (t p)))) -- 2.1.3 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Missing-comma-in-org-agenda-with-point-at-orig-entry.patch >From cc386175a8a6cc7d1606bbc6c1c47589f95f8ac2 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sun, 14 Dec 2014 17:30:49 +0800 Subject: [PATCH 2/4] Missing comma in org-agenda-with-point-at-orig-entry * lisp/org-agenda.el (org-agenda-with-point-at-orig-entry): Fix backquote structure. --- lisp/org-agenda.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 5990bbb..529cd0e 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2004,7 +2004,7 @@ If STRING is non-nil, the text property will be fetched from position 0 in that string. If STRING is nil, it will be fetched from the beginning of the current line." (org-with-gensyms (marker) - `(let ((,marker (get-text-property (if string 0 (point-at-bol)) + `(let ((,marker (get-text-property (if ,string 0 (point-at-bol)) 'org-hd-marker ,string))) (with-current-buffer (marker-buffer ,marker) (save-excursion -- 2.1.3 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-New-function-org-get-log-list.patch >From 79ebf2977ff54d4160c53f42a7a4bb25b59583a8 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sun, 14 Dec 2014 17:33:00 +0800 Subject: [PATCH 3/4] New function org-get-log-list * lisp/org.el (org-get-log-list): Returns the items in an entry's log list. --- lisp/org.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lisp/org.el b/lisp/org.el index 6df6e2e..0e750e1 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -13641,6 +13641,27 @@ narrowing." (forward-line))))) (if (bolp) (point) (line-beginning-position 2))))) +(defun org-get-log-list () + "Return the entry's log items, or nil. +The items are returned as a list of 'item elements." + (save-excursion + (goto-char (org-log-beginning)) + (let* ((el (org-element-at-point)) + list-string list-items) + ;; Should we try harder to make sure it's actually the log list? + (when (eq (org-element-type el) 'plain-list) + (setq list-string + (buffer-substring + (org-element-property :contents-begin el) + (org-element-property :contents-end el))) + (with-temp-buffer + (insert list-string) + (setq list-items + (org-element-map + (org-element-parse-buffer) + 'item #'identity)))) + list-items))) + (defun org-add-log-setup (&optional purpose state prev-state findpos how extra) "Set up the post command hook to take a note. If this is about to TODO state change, the new state is expected in STATE. -- 2.1.3 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-New-function-org-agenda-show-log-item.patch >From 565858ac1316ffb91be7b1fec8459da93a1670a8 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sun, 14 Dec 2014 17:33:55 +0800 Subject: [PATCH 4/4] New function org-agenda-show-log-item * lisp/org-agenda.el (org-agenda-show-log-item): Function to echo an entry's most recent log item in the message area. Bind to "V" in the agenda keymap. --- lisp/org-agenda.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 529cd0e..0063b31 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2247,6 +2247,7 @@ The following commands are available: (org-defkey org-agenda-mode-map "E" 'org-agenda-entry-text-mode) (org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode) (org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch) +(org-defkey org-agenda-mode-map "V" 'org-agenda-show-log-item) (org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary) (org-defkey org-agenda-mode-map "!" 'org-agenda-toggle-deadlines) (org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid) @@ -8844,6 +8845,21 @@ the same tree node, and the headline of the tree node in the Org-mode file." (org-flag-heading nil))) ; show the next heading (org-add-note)))) +(defun org-agenda-show-log-item () + "Echo the text of the entry's most recent log note." + (interactive) + (let (log-list item) + (org-agenda-with-point-at-orig-entry + nil (setq log-list (org-get-log-list))) + (if (not log-list) + (message "Entry has no log") + (setq item + (if org-log-states-order-reversed + (car log-list) + (last log-list))) + (message (org-element-interpret-data + (org-element-contents item)))))) + (defun org-agenda-change-all-lines (newhead hdmarker &optional fixface just-this) "Change all lines in the agenda buffer which match HDMARKER. -- 2.1.3 --=-=-=--