emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [RFC] org-agenda: Jump directly to line in case of a timestamp
@ 2017-10-07 14:45 Marco Wahl
  2017-10-07 15:14 ` Nicolas Goaziou
  0 siblings, 1 reply; 10+ messages in thread
From: Marco Wahl @ 2017-10-07 14:45 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

This is a little proposition about changing the behaviour of
`org-agenda-goto' which typically gets triggered when pressing TAB on an
line in the Org agenda.

The proposition affects only the case of an agenda line due to a
timestamp outside a planning line (i.e. SCHEDULED or DEADLINE.)

Up to now `org-agenda-goto' jumps always to the corresponding headline.
With the patch `org-agenda-goto' would jump directly to the line
containing the timestamp.

If you use plain lists with timestamps this can be helpful.

Let's say in an Org file you have the following plain list.

* test

- <2017-10-07 Sat 16:25> Start writing the RFC.
- <2017-10-07 Sat 16:29> Thought: "Will somebody notice?"
- <2017-10-07 Sat 16:30> Sent the RFC to the list.

For each list item a corresponding line appears in the day agenda.

  .tmp	.:16:25...... test
  .tmp	.:16:29...... test
  .tmp	.:16:30...... test

Pressing TAB in the agenda would jump to the respective plain list item.

Find the concrete patch below.

WDYT?


Best regards
            Marco


--8<---------------cut here---------------start------------->8---
From e2fd5f36b33e17063cf06f8df7b5d924c751b327 Mon Sep 17 00:00:00 2001
From: Marco Wahl <marcowahlsoft@gmail.com>
Date: Sat, 7 Oct 2017 15:57:36 +0200
Subject: [PATCH] org-agenda: Jump directly to line in case of a timestamp
 entry

* lisp/org-agenda.el (org-agenda-goto): Don't move back to heading
  when on a line with a free standing timestamp.
---
 lisp/org-agenda.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index fb5448ef8..6fd16b659 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -8424,10 +8424,12 @@ When called with a prefix argument, include all archive files as well."
     (when (derived-mode-p 'org-mode)
       (org-show-context 'agenda)
       (recenter (/ (window-height) 2))
-      (org-back-to-heading t)
-      (let ((case-fold-search nil))
-	(when (re-search-forward org-complex-heading-regexp nil t)
-	  (goto-char (match-beginning 4)))))
+      (unless (and (looking-at org-ts-regexp-both)
+		   (not (org-at-planning-p)))
+	(org-back-to-heading t)
+	(let ((case-fold-search nil))
+	  (when (re-search-forward org-complex-heading-regexp nil t)
+	    (goto-char (match-beginning 4))))))
     (run-hooks 'org-agenda-after-show-hook)
     (and highlight (org-highlight (point-at-bol) (point-at-eol)))))
 
-- 
2.14.2

--8<---------------cut here---------------end--------------->8---

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-07 14:45 [RFC] org-agenda: Jump directly to line in case of a timestamp Marco Wahl
@ 2017-10-07 15:14 ` Nicolas Goaziou
  2017-10-07 16:05   ` Marco Wahl
  0 siblings, 1 reply; 10+ messages in thread
From: Nicolas Goaziou @ 2017-10-07 15:14 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode

Hello,

Marco Wahl <marcowahlsoft@gmail.com> writes:

> Let's say in an Org file you have the following plain list.
>
> * test
>
> - <2017-10-07 Sat 16:25> Start writing the RFC.
> - <2017-10-07 Sat 16:29> Thought: "Will somebody notice?"
> - <2017-10-07 Sat 16:30> Sent the RFC to the list.
>
> For each list item a corresponding line appears in the day agenda.
>
>   .tmp	.:16:25...... test
>   .tmp	.:16:29...... test
>   .tmp	.:16:30...... test
>
> Pressing TAB in the agenda would jump to the respective plain list item.
>
> Find the concrete patch below.
>
> WDYT?

I have the feeling that both behaviours are useful. All things being
equal, this is the entry being displayed in the Agenda, not necessarily
the line containing the timestamp. Moreover this feature could be less
meaningful if `org-agenda-skip-additional-timestamps-same-entry' is
non-nil.

Maybe an optional argument could allow one to switch from one behaviour
to the other. I have no strong opinion about this, though.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-07 15:14 ` Nicolas Goaziou
@ 2017-10-07 16:05   ` Marco Wahl
  2017-10-08  3:23     ` Matt Lundin
  0 siblings, 1 reply; 10+ messages in thread
From: Marco Wahl @ 2017-10-07 16:05 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Marco Wahl <marcowahlsoft@gmail.com> writes:
>
>> Let's say in an Org file you have the following plain list.
>>
>> * test
>>
>> - <2017-10-07 Sat 16:25> Start writing the RFC.
>> - <2017-10-07 Sat 16:29> Thought: "Will somebody notice?"
>> - <2017-10-07 Sat 16:30> Sent the RFC to the list.
>>
>> For each list item a corresponding line appears in the day agenda.
>>
>>   .tmp	.:16:25...... test
>>   .tmp	.:16:29...... test
>>   .tmp	.:16:30...... test
>>
>> Pressing TAB in the agenda would jump to the respective plain list item.
>>
>> Find the concrete patch below.
>>
>> WDYT?
>
> I have the feeling that both behaviours are useful. All things being
> equal, this is the entry being displayed in the Agenda, not necessarily
> the line containing the timestamp. Moreover this feature could be less
> meaningful if `org-agenda-skip-additional-timestamps-same-entry' is
> non-nil.
>
> Maybe an optional argument could allow one to switch from one behaviour
> to the other. I have no strong opinion about this, though.

Thanks!

I just found function `org-agenda-switch-to' which is similar to
`org-agenda-goto' but does not the jump to the headline.

I personally configure this function to be on shift-tab.

    (org-defkey org-agenda-mode-map [(backtab)] #'org-agenda-switch-to)

So no need for a change.


Thanks again and best regards
                             Marco

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-07 16:05   ` Marco Wahl
@ 2017-10-08  3:23     ` Matt Lundin
  2017-10-08  6:25       ` Marco Wahl
  2017-10-09  6:54       ` Alan Schmitt
  0 siblings, 2 replies; 10+ messages in thread
From: Matt Lundin @ 2017-10-08  3:23 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode, Nicolas Goaziou

Marco Wahl <marcowahlsoft@gmail.com> writes:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
>> Hello,
>>
>> Marco Wahl <marcowahlsoft@gmail.com> writes:
>>
>>>
>>> Pressing TAB in the agenda would jump to the respective plain list item.
>>>
>>> Find the concrete patch below.
>>>
>>> WDYT?
>>
>> I have the feeling that both behaviours are useful. All things being
>> equal, this is the entry being displayed in the Agenda, not necessarily
>> the line containing the timestamp. Moreover this feature could be less
>> meaningful if `org-agenda-skip-additional-timestamps-same-entry' is
>> non-nil.
>>
>> Maybe an optional argument could allow one to switch from one behaviour
>> to the other. I have no strong opinion about this, though.
>
> Thanks!
>
> I just found function `org-agenda-switch-to' which is similar to
> `org-agenda-goto' but does not the jump to the headline.
>
> I personally configure this function to be on shift-tab.
>
>     (org-defkey org-agenda-mode-map [(backtab)] #'org-agenda-switch-to)

And, as a bonus, org-agenda-switch-to is bound to RET by default. I've
happily been hitting return since 2008 to jump directly to timestamps.
:)

The only difference, if I remember correctly, is that
org-agenda-switch-to replaces the agenda buffer with the target org
buffer, whereas org-agenda-goto shows the target org buffer in another
window. 

Best,
Matt

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-08  3:23     ` Matt Lundin
@ 2017-10-08  6:25       ` Marco Wahl
  2017-10-09  6:54       ` Alan Schmitt
  1 sibling, 0 replies; 10+ messages in thread
From: Marco Wahl @ 2017-10-08  6:25 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, Nicolas Goaziou

Matt Lundin <mdl@imapmail.org> writes:

>>> Maybe an optional argument could allow one to switch from one behaviour
>>> to the other. I have no strong opinion about this, though.
>>
>> Thanks!
>>
>> I just found function `org-agenda-switch-to' which is similar to
>> `org-agenda-goto' but does not the jump to the headline.
>>
>> I personally configure this function to be on shift-tab.
>>
>>     (org-defkey org-agenda-mode-map [(backtab)] #'org-agenda-switch-to)
>
> And, as a bonus, org-agenda-switch-to is bound to RET by default. I've
> happily been hitting return since 2008 to jump directly to timestamps.
> :)

:D


Thanks for the enlightenment!
                             Marco

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-08  3:23     ` Matt Lundin
  2017-10-08  6:25       ` Marco Wahl
@ 2017-10-09  6:54       ` Alan Schmitt
  2017-10-09  8:19         ` Eric S Fraga
  1 sibling, 1 reply; 10+ messages in thread
From: Alan Schmitt @ 2017-10-09  6:54 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

Hello,

On 2017-10-07 22:23, Matt Lundin <mdl@imapmail.org> writes:

> The only difference, if I remember correctly, is that
> org-agenda-switch-to replaces the agenda buffer with the target org
> buffer, whereas org-agenda-goto shows the target org buffer in another
> window. 

One thing I would really like is the timestamp behavior of
org-agenda-goto with the windows behavior of org-agenda-switch-to.

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-09: 403.38, 2016-09: 401.03

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-09  6:54       ` Alan Schmitt
@ 2017-10-09  8:19         ` Eric S Fraga
  2017-10-09  8:29           ` Alan Schmitt
  0 siblings, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2017-10-09  8:19 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: Marco Wahl, emacs-orgmode, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

On Monday,  9 Oct 2017 at 08:54, Alan Schmitt wrote:
> One thing I would really like is the timestamp behavior of
> org-agenda-goto with the windows behavior of org-agenda-switch-to.

You could "advise" the function?
https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html
-- 
: Eric S Fraga via Emacs 27.0.50, Org release_9.1.1-87-g3c83f1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-09  8:19         ` Eric S Fraga
@ 2017-10-09  8:29           ` Alan Schmitt
  2017-10-11 11:01             ` Detlef Steuer
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Schmitt @ 2017-10-09  8:29 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

On 2017-10-09 09:19, Eric S Fraga <esflists@gmail.com> writes:

> On Monday,  9 Oct 2017 at 08:54, Alan Schmitt wrote:
>> One thing I would really like is the timestamp behavior of
>> org-agenda-goto with the windows behavior of org-agenda-switch-to.
>
> You could "advise" the function?
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html

Yes, this is something I could do. Thanks for the suggestion.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-09: 403.38, 2016-09: 401.03

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-09  8:29           ` Alan Schmitt
@ 2017-10-11 11:01             ` Detlef Steuer
  2017-10-11 11:42               ` Marco Wahl
  0 siblings, 1 reply; 10+ messages in thread
From: Detlef Steuer @ 2017-10-11 11:01 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

Am Mon, 09 Oct 2017 10:29:39 +0200
schrieb Alan Schmitt <alan.schmitt@polytechnique.org>:

> On 2017-10-09 09:19, Eric S Fraga <esflists@gmail.com> writes:
> 
> > On Monday,  9 Oct 2017 at 08:54, Alan Schmitt wrote:  
> >> One thing I would really like is the timestamp behavior of
> >> org-agenda-goto with the windows behavior of
> >> org-agenda-switch-to.  
> >
> > You could "advise" the function?
> > https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html  
> 
> Yes, this is something I could do. Thanks for the suggestion.

... and maybe share the solution? I would like the same as you, but
emacs lisp is still unexplored territory to me.

Detlef


> 
> Alan
> 

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC] org-agenda: Jump directly to line in case of a timestamp
  2017-10-11 11:01             ` Detlef Steuer
@ 2017-10-11 11:42               ` Marco Wahl
  0 siblings, 0 replies; 10+ messages in thread
From: Marco Wahl @ 2017-10-11 11:42 UTC (permalink / raw)
  To: Detlef Steuer; +Cc: emacs-orgmode

Detlef Steuer <steuer@unibw-hamburg.de> writes:

> Am Mon, 09 Oct 2017 10:29:39 +0200
> schrieb Alan Schmitt <alan.schmitt@polytechnique.org>:
>
>> On 2017-10-09 09:19, Eric S Fraga <esflists@gmail.com> writes:
>> 
>> > On Monday,  9 Oct 2017 at 08:54, Alan Schmitt wrote:  
>> >> One thing I would really like is the timestamp behavior of
>> >> org-agenda-goto with the windows behavior of
>> >> org-agenda-switch-to.  
>> >
>> > You could "advise" the function?
>> > https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html  
>> 
>> Yes, this is something I could do. Thanks for the suggestion.
>
> ... and maybe share the solution? I would like the same as you, but
> emacs lisp is still unexplored territory to me.

I don't see how to realize the issue by using 'advise' but you could
use a new function which does it.

Put the code

--8<---------------cut here---------------start------------->8---
(defun org-agenda-switch-to-in-other-window (&optional delete-other-windows)
  "Go to the Org mode file which contains the item at point in other window.
When optional argument DELETE-OTHER-WINDOWS is non-nil, the
displayed Org file fills the frame."
  (interactive)
  (if (and org-return-follows-link
	   (not (org-get-at-bol 'org-marker))
	   (org-in-regexp org-bracket-link-regexp))
      (org-open-link-from-string (match-string 0))
    (let* ((marker (or (org-get-at-bol 'org-marker)
		       (org-agenda-error)))
	   (buffer (marker-buffer marker))
	   (pos (marker-position marker)))
      (unless buffer (user-error "Trying to switch to non-existent buffer"))
      (switch-to-buffer-other-window buffer)
      (when delete-other-windows (delete-other-windows))
      (widen)
      (goto-char pos)
      (when (derived-mode-p 'org-mode)
	(org-show-context 'agenda)
	(run-hooks 'org-agenda-after-show-hook)))))

(org-defkey org-agenda-mode-map "\C-u\C-m" #'org-agenda-switch-to-in-other-window)
--8<---------------cut here---------------end--------------->8---

into your emacs init file to get the the behavior you want with the key
C-u RET.

The function above is almost the same as `org-agenda-switch-to' which is
currently bound to RET in org agenda.


HTH
   Marco

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-10-11 11:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-07 14:45 [RFC] org-agenda: Jump directly to line in case of a timestamp Marco Wahl
2017-10-07 15:14 ` Nicolas Goaziou
2017-10-07 16:05   ` Marco Wahl
2017-10-08  3:23     ` Matt Lundin
2017-10-08  6:25       ` Marco Wahl
2017-10-09  6:54       ` Alan Schmitt
2017-10-09  8:19         ` Eric S Fraga
2017-10-09  8:29           ` Alan Schmitt
2017-10-11 11:01             ` Detlef Steuer
2017-10-11 11:42               ` Marco Wahl

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).