emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* following org links to gnus messages and window management
@ 2014-03-19  8:01 Alan Schmitt
  2014-03-19 10:18 ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2014-03-19  8:01 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I'm using escreen (http://www.emacswiki.org/emacs/EmacsScreen) to manage
my windows in emacs, typically keeping gnus on screen 0, org agenda and
related todo files on screen 2, and so on.

When I follow a link in a task to a gnus file, this takes over the
current frame, and when I'm done dealing with the message, I have to
"winner-undo" my way until I restore my window configuration. This is
not very convenient.

My questions are:
- is there a way to run some code before following a link (for instance
  "save the current window configuration", or "switch to screen 0")?
- if not, is there a way to copy a link then open it using the
  minibuffer (I would then do the switch to screen 0 manually)?
- finally, do you have alternative window management options to suggest
  that would work well with following links to gnus messages? I remember
  seeing something nice in Sacha Chua's interview of Magna Sveen
  mentioning "perspective-mode", but I have not tried it yet.

Thanks,

Alan

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

* Re: following org links to gnus messages and window management
  2014-03-19  8:01 following org links to gnus messages and window management Alan Schmitt
@ 2014-03-19 10:18 ` Bastien
  2014-03-19 10:48   ` Alan Schmitt
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien @ 2014-03-19 10:18 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Hi Alan,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> When I follow a link in a task to a gnus file, this takes over the
> current frame, and when I'm done dealing with the message, I have to
> "winner-undo" my way until I restore my window configuration. This is
> not very convenient.
>
> My questions are:
> - is there a way to run some code before following a link (for instance
>   "save the current window configuration", or "switch to screen 0")?

Nope.

> - if not, is there a way to copy a link then open it using the
>   minibuffer (I would then do the switch to screen 0 manually)?

This does not use the minibuffer but you could add that:

(progn
  (org-next-link)
  (org-open-link-from-string
   (org-element-property :raw-link (org-element-link-parser))))

> - finally, do you have alternative window management options to suggest
>   that would work well with following links to gnus messages?

Well, all I can think of now is

(setq org-agenda-window-setup 'other-frame)

>   I remember
>   seeing something nice in Sacha Chua's interview of Magna Sveen
>   mentioning "perspective-mode", but I have not tried it yet.

Me neither!

Hope that helps,

-- 
 Bastien

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

* Re: following org links to gnus messages and window management
  2014-03-19 10:18 ` Bastien
@ 2014-03-19 10:48   ` Alan Schmitt
  2014-03-20  4:14     ` Eric Abrahamsen
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2014-03-19 10:48 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

Bastien <bzg@gnu.org> writes:

>> - if not, is there a way to copy a link then open it using the
>>   minibuffer (I would then do the switch to screen 0 manually)?
>
> This does not use the minibuffer but you could add that:
>
> (progn
>   (org-next-link)
>   (org-open-link-from-string
>    (org-element-property :raw-link (org-element-link-parser))))

This was most helpful: I just need to copy the link I want to follow, go
to the first screen, and interactively call `org-open-link-from-string'.
This works great for the moment.

>> - finally, do you have alternative window management options to suggest
>>   that would work well with following links to gnus messages?
>
> Well, all I can think of now is
>
> (setq org-agenda-window-setup 'other-frame)

Thanks, but I'm trying to avoid using several frames. (OS
X unfortunately does not come with a window manager that I like ...)

Thanks again,

Alan

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

* Re: following org links to gnus messages and window management
  2014-03-19 10:48   ` Alan Schmitt
@ 2014-03-20  4:14     ` Eric Abrahamsen
  2014-03-20 14:27       ` Alan Schmitt
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Abrahamsen @ 2014-03-20  4:14 UTC (permalink / raw)
  To: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Hi Bastien,
>
> Bastien <bzg@gnu.org> writes:
>
>>> - if not, is there a way to copy a link then open it using the
>>>   minibuffer (I would then do the switch to screen 0 manually)?
>>
>> This does not use the minibuffer but you could add that:
>>
>> (progn
>>   (org-next-link)
>>   (org-open-link-from-string
>>    (org-element-property :raw-link (org-element-link-parser))))
>
> This was most helpful: I just need to copy the link I want to follow, go
> to the first screen, and interactively call `org-open-link-from-string'.
> This works great for the moment.
>
>>> - finally, do you have alternative window management options to suggest
>>>   that would work well with following links to gnus messages?
>>
>> Well, all I can think of now is
>>
>> (setq org-agenda-window-setup 'other-frame)
>
> Thanks, but I'm trying to avoid using several frames. (OS
> X unfortunately does not come with a window manager that I like ...)
>
> Thanks again,
>
> Alan

I have a setup that's probably more complicated than what you want, but
maybe you'll find something interesting in it. The problem is, you need
to somehow specify when or under what conditions you do away with the
opened windows and return to your org file or agenda. In my case, I use
the following to answer emails. When I open the link it stores the
current window configuration, and when the email is sent it triggers the
restore.

I believe I've confused myself slightly while trying to set up
interactive vs non-interactive versions, but so far I've never wanted to
use it non-interactively, so it works fine.

#+BEGIN_SRC org

(defvar org-mail-window-conf nil
  "Save org-buffer window configuration here, for later
  restoration.")

(defun org-mail-restore-after-send ()
  (gnus-summary-exit nil t)
  (when (window-configuration-p org-mail-window-conf)
    (set-window-configuration org-mail-window-conf))
  ; Should check here that we actually made it back to the org
  ; heading. Could save an ID prop on the heading and check for that.
  (call-interactively 'org-agenda-todo))

(defun org-mail-handle-mail (&optional interactive-p)
  "Handle mail-related links for current headline."
  (interactive "p")
  (unless (org-back-to-heading t)
    (error "Not in an org item"))
  (when interactive-p
    (setq org-mail-window-conf (current-window-configuration)))
  (let (message mailto)
    (while (re-search-forward org-any-link-re (line-end-position) t) 
      (let ((addr (or (match-string-no-properties 2)
		      (match-string-no-properties 0))))
	(cond
	 ((string-match "^<?gnus:" addr)
	  (push (substring addr (match-end 0)) message))
	 ((string-match "^<?mailto:" addr)
	  (push (substring addr (match-end 0)) mailto))
	 ((and (featurep 'bbdb)
	       (string-match-p "^<?bbdb:" addr))
	  (with-current-buffer bbdb-buffer-name
	    (let ((recs bbdb-records))
	      (org-open-link-from-string addr)
	      (let ((mail (bbdb-mail-address (bbdb-current-record))))
		(bbdb-display-records recs)
		(push mail mailto))))))))
    (cond
     (message
      (org-gnus-open (org-link-unescape (car message)))
      (call-interactively
       'gnus-summary-wide-reply-with-original)
      (when mailto
	(message-goto-to)
	(insert ", ")
	(insert (mapconcat 'identity mailto ", "))
	(message-goto-body))
      (add-to-list 'message-exit-actions
		   'org-mail-restore-after-send t))
     (mailto
      (compose-mail (mapconcat 'identity mailto ", ")
		    nil nil nil nil nil nil 
		    'org-mail-restore-after-send))
     (t
      (error "No mail-related links in headline")))))

(defun org-mail-handle-mail-agenda ()
  "Examine item at point for mail-related links, and handle them."
  (interactive)
  (org-agenda-check-type t 'agenda 'timeline 'todo 'tags)
  (org-agenda-check-no-diary)
  (let* ((marker (or (org-get-at-bol 'org-hd-marker)
		     (org-agenda-error)))
	 (buffer (marker-buffer marker))
	 (pos (marker-position marker)))
    (setq org-mail-window-conf (current-window-configuration))
    (with-current-buffer buffer
      (widen)
      (goto-char pos)
      (org-mail-handle-mail))))

(eval-after-load 'org-agenda
  '(org-defkey org-agenda-mode-map (kbd "H") 'org-mail-handle-mail-agenda))
#+END_SRC

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

* Re: following org links to gnus messages and window management
  2014-03-20  4:14     ` Eric Abrahamsen
@ 2014-03-20 14:27       ` Alan Schmitt
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Schmitt @ 2014-03-20 14:27 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

Hi Eric,

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> I have a setup that's probably more complicated than what you want, but
> maybe you'll find something interesting in it. The problem is, you need
> to somehow specify when or under what conditions you do away with the
> opened windows and return to your org file or agenda. In my case, I use
> the following to answer emails. When I open the link it stores the
> current window configuration, and when the email is sent it triggers the
> restore.

Thanks a lot, it gives me many ideas to explore.

Alan

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

end of thread, other threads:[~2014-03-20 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19  8:01 following org links to gnus messages and window management Alan Schmitt
2014-03-19 10:18 ` Bastien
2014-03-19 10:48   ` Alan Schmitt
2014-03-20  4:14     ` Eric Abrahamsen
2014-03-20 14:27       ` Alan Schmitt

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).