From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Girard Subject: org-follow-link-in-same-window Date: Sat, 27 Jun 2009 10:41:52 +0200 Message-ID: <51b0095d0906270141s598f5a8fq8aac0f928cccf10d@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0342500527==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MKTTz-0000ly-KD for emacs-orgmode@gnu.org; Sat, 27 Jun 2009 04:41:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MKTTu-0000lm-Lc for emacs-orgmode@gnu.org; Sat, 27 Jun 2009 04:41:58 -0400 Received: from [199.232.76.173] (port=47004 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKTTu-0000lj-IF for emacs-orgmode@gnu.org; Sat, 27 Jun 2009 04:41:54 -0400 Received: from mail-fx0-f223.google.com ([209.85.220.223]:50218) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MKTTu-0005nO-2I for emacs-orgmode@gnu.org; Sat, 27 Jun 2009 04:41:54 -0400 Received: by fxm23 with SMTP id 23so2749984fxm.42 for ; Sat, 27 Jun 2009 01:41:52 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --===============0342500527== Content-Type: multipart/alternative; boundary=000e0cd24182b7a6e0046d506d8d --000e0cd24182b7a6e0046d506d8d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --000e0cd24182b7a6e0046d506d8d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi all,
when clicking on a link, I whish I could choose between
- fol= lowing it in another window (the current behaviour, which I'm often fin= e with, but not always);
- following it in the same window

I trie= d 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 ini= tially expected. I tried the following bindings:

(add-hook 'org-= load-hook
=A0=A0=A0=A0=A0 '(lambda ()
=A0=A0=A0=A0=A0=A0=A0=A0 (d= efine-key org-mouse-map [C-down-mouse-1]=A0 'org-follow-link-in-same-wi= ndow)
=A0=A0=A0=A0=A0=A0=A0=A0 (define-key org-mouse-map [down-mouse-2]=A0=A0=A0 = 'org-follow-link-in-same-window)
=A0=A0=A0=A0=A0=A0=A0=A0 (define-ke= y org-mouse-map [C-down-mouse-2]=A0 'org-follow-link-in-same-window)=A0=A0=A0=A0=A0=A0=A0=A0 (define-key org-mouse-map [s-down-mouse-1]=A0 = 9;org-follow-link-in-same-window)
=A0=A0=A0=A0=A0=A0=A0=A0 (define-key org-mouse-map [s-mouse-1]=A0=A0=A0=A0= =A0=A0 'org-follow-link-in-same-window)))

I found none of them t= o 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 magi= c 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)
=A0 (interactive "e")
=A0 (= let ((org-display-internal-link-with-indirect-buffer t))
=A0=A0=A0 (save-excursion
=A0=A0=A0=A0=A0 (set-buffer (window-buffer (po= sn-window (event-end ev))))
=A0=A0=A0 (select-window (posn-window (event= -end ev)))
=A0=A0=A0 (org-open-at-mouse ev)))

which doesn't w= ork. 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


--000e0cd24182b7a6e0046d506d8d-- --===============0342500527== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============0342500527==--