Re: [Orgmode] org-follow-link-in-same-window

2009-06-27 Thread Nicolas Girard
2009/6/27 Carsten Dominik 
>
> On Jun 27, 2009, at 10:41 AM, Nicolas Girard wrote:

> (defun org-open-at-mouse-same-window (ev)
>  "Open file link or URL at mouse."
>  (interactive "e")
>  (mouse-set-point ev)
>  (if (eq major-mode 'org-agenda-mode)
>  (org-agenda-copy-local-variable 'org-link-abbrev-alist-local))
>  (let ((org-link-frame-setup
> '((vm . vm-visit-folder)
>   (gnus . gnus)
>   (file . find-file
>(org-open-at-point)))

Thanks ! This works great !

>>
>> I found none of them to work *but* the latest, [s-mouse-1].

Now, I must have been mistaken because none of the bindings I tried
actually worked. I'm sure I could trigger my own function thanks to a
debugging message, but it was after a bit of trial and error, and I
can't see how.

Here's what I tried and which didn't work:


(add-hook 'org-load-hook
  '(lambda ()
 (define-key org-mouse-map [s-mouse-1] 
'org-open-at-mouse-same-window)
 (define-key org-mouse-map [s-down-mouse-1] 
'org-open-at-mouse-same-window)
 (define-key org-mode-map [(control button1)]
'org-open-at-mouse-same-window)
 (define-key org-mouse-map [C-down-mouse-1]
'org-open-at-mouse-same-window)
 (define-key org-mouse-map [C-down-mouse-2] 
'org-open-at-mouse-same-window)
))

I could only get the behaviour I want by de-defining
org-mouse-move-tree-start with the body of your
org-open-at-mouse-same-window function.

Nicolas


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] org-follow-link-in-same-window

2009-06-27 Thread Carsten Dominik


On Jun 27, 2009, at 10:41 AM, Nicolas Girard wrote:


Hi all,
when clicking on a link, I whish I could choose between
- following it in another window (the current behaviour, which I'm  
often fine with, but not always);

- following it in the same window

I tried to create a new function, org-follow-link-in-same-window,  
and bind it to a key.


As for the key binding, I couldn't get down-mouse-2 to work, as  
initially expected. I tried the following bindings:


(add-hook 'org-load-hook
  '(lambda ()
 (define-key org-mouse-map [C-down-mouse-1]  'org-follow- 
link-in-same-window)
 (define-key org-mouse-map [down-mouse-2]'org-follow- 
link-in-same-window)
 (define-key org-mouse-map [C-down-mouse-2]  'org-follow- 
link-in-same-window)
 (define-key org-mouse-map [s-down-mouse-1]  'org-follow- 
link-in-same-window)
 (define-key org-mouse-map [s-mouse-1]   'org-follow- 
link-in-same-window)))


I found none of them to work *but* the latest, [s-mouse-1].
(I'm not fond of incantations, so when emacs leaves me under the  
impression that some kind of black magic is happening, I always feel  
a little upset.

Anyway, i'm digressing, and after all I'm fine with [s-mouse-1].)

Now, as for the function, I came to the following:

(defun org-follow-link-in-same-window (ev)
  (interactive "e")
  (let ((org-display-internal-link-with-indirect-buffer t))
(save-excursion
  (set-buffer (window-buffer (posn-window (event-end ev
(select-window (posn-window (event-end ev)))
(org-open-at-mouse ev)))

which doesn't work. I mean, it does follow the link, but not in the  
same window.



When following a link, Org does all kinds of things, including
possibly searching for a particular place in a file.  So it is best
to let Org do its thing, but to scope a different value of
org-link-frame-setup.  Like so:

(defun org-open-at-mouse-same-window (ev)
  "Open file link or URL at mouse."
  (interactive "e")
  (mouse-set-point ev)
  (if (eq major-mode 'org-agenda-mode)
  (org-agenda-copy-local-variable 'org-link-abbrev-alist-local))
  (let ((org-link-frame-setup
 '((vm . vm-visit-folder)
   (gnus . gnus)
   (file . find-file
(org-open-at-point)))


HTH

- Carsten



Could you please give me a hand on this ?

Thanks in advance,
Nicolas


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode




___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] org-follow-link-in-same-window

2009-06-27 Thread Nicolas Girard
Hi all,
when clicking on a link, I whish I could choose between
- following it in another window (the current behaviour, which I'm often
fine with, but not always);
- following it in the same window

I tried to create a new function, org-follow-link-in-same-window, and bind
it to a key.

As for the key binding, I couldn't get down-mouse-2 to work, as initially
expected. I tried the following bindings:

(add-hook 'org-load-hook
  '(lambda ()
 (define-key org-mouse-map [C-down-mouse-1]
'org-follow-link-in-same-window)
 (define-key org-mouse-map [down-mouse-2]
'org-follow-link-in-same-window)
 (define-key org-mouse-map [C-down-mouse-2]
'org-follow-link-in-same-window)
 (define-key org-mouse-map [s-down-mouse-1]
'org-follow-link-in-same-window)
 (define-key org-mouse-map [s-mouse-1]
'org-follow-link-in-same-window)))

I found none of them to work *but* the latest, [s-mouse-1].
(I'm not fond of incantations, so when emacs leaves me under the impression
that some kind of black magic is happening, I always feel a little upset.
Anyway, i'm digressing, and after all I'm fine with [s-mouse-1].)

Now, as for the function, I came to the following:

(defun org-follow-link-in-same-window (ev)
  (interactive "e")
  (let ((org-display-internal-link-with-indirect-buffer t))
(save-excursion
  (set-buffer (window-buffer (posn-window (event-end ev
(select-window (posn-window (event-end ev)))
(org-open-at-mouse ev)))

which doesn't work. I mean, it does follow the link, but not in the same
window.

Could you please give me a hand on this ?

Thanks in advance,
Nicolas
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode