emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [RFC] org-agenda: Jump directly to line in case of a timestamp


From: Marco Wahl
Subject: Re: [O] [RFC] org-agenda: Jump directly to line in case of a timestamp
Date: Wed, 11 Oct 2017 13:42:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Detlef Steuer <address@hidden> writes:

> Am Mon, 09 Oct 2017 10:29:39 +0200
> schrieb Alan Schmitt <address@hidden>:
>
>> On 2017-10-09 09:19, Eric S Fraga <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]