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

> Am Mon, 09 Oct 2017 10:29:39 +0200
> schrieb Alan Schmitt <alan.schm...@polytechnique.org>:
>
>> On 2017-10-09 09:19, Eric S Fraga <esfli...@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


Reply via email to