* How to bind mouse-1 to find-file in dired?
@ 2008-02-20 14:18 Arne Schmitz
2008-02-20 15:55 ` Johan Bockgård
2008-02-20 16:17 ` Piet van Oostrum
0 siblings, 2 replies; 7+ messages in thread
From: Arne Schmitz @ 2008-02-20 14:18 UTC (permalink / raw)
To: help-gnu-emacs
I want to get rid of dired-find-file-other-window. I tried the following in
my .emacs:
(eval-after-load "dired" '(progn (define-key dired-mode-map
(kbd "<mouse-1>") 'dired-find-file)))
But this does not seem to work. What should I do?
Arne
--
[--- PGP key FD05BED7 --- http://www.root42.de/ ---]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to bind mouse-1 to find-file in dired?
2008-02-20 14:18 How to bind mouse-1 to find-file in dired? Arne Schmitz
@ 2008-02-20 15:55 ` Johan Bockgård
2008-02-20 16:28 ` Arne Schmitz
2008-02-20 16:17 ` Piet van Oostrum
1 sibling, 1 reply; 7+ messages in thread
From: Johan Bockgård @ 2008-02-20 15:55 UTC (permalink / raw)
To: help-gnu-emacs
Arne Schmitz <arne.schmitz@gmx.net> writes:
> I want to get rid of dired-find-file-other-window. I tried the following in
> my .emacs:
>
> (eval-after-load "dired" '(progn (define-key dired-mode-map
> (kbd "<mouse-1>") 'dired-find-file)))
>
> But this does not seem to work. What should I do?
Use "<mouse-2>".
--
Johan Bockgård
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to bind mouse-1 to find-file in dired?
2008-02-20 14:18 How to bind mouse-1 to find-file in dired? Arne Schmitz
2008-02-20 15:55 ` Johan Bockgård
@ 2008-02-20 16:17 ` Piet van Oostrum
1 sibling, 0 replies; 7+ messages in thread
From: Piet van Oostrum @ 2008-02-20 16:17 UTC (permalink / raw)
To: help-gnu-emacs
>>>>> Arne Schmitz <arne.schmitz@gmx.net> (AS) wrote:
>AS> I want to get rid of dired-find-file-other-window. I tried the following in
>AS> my .emacs:
>AS> (eval-after-load "dired" '(progn (define-key dired-mode-map
>AS> (kbd "<mouse-1>") 'dired-find-file)))
>AS> But this does not seem to work. What should I do?
You can't just bind a mouse event to dired-find-file; you need a function
that finds out where the mouse clicked.
I have just cut and pasted something from my .emacs. I hope I didn't forget
anything (actually I myself bind mouse-2 and then I have
mouse-1-click-follows-link set)
(defun dired-mouse-find-file (event)
"In Dired, visit the file or directory name you click on."
(interactive "e")
(let (window pos file)
(save-excursion
(setq window (posn-window (event-end event))
pos (posn-point (event-end event)))
(if (not (windowp window))
(error "No file chosen"))
(set-buffer (window-buffer window))
(goto-char pos)
(setq file (dired-get-file-for-visit)))
(if (file-directory-p file)
(or (and (cdr dired-subdir-alist)
(dired-goto-subdir file))
(progn
(select-window window)
(dired file)))
(select-window window)
(find-file (file-name-sans-versions file t)))))
(defun set-my-dired-keys-hook ()
"My favorite dired keys."
(local-set-key [mouse-1] 'dired-mouse-find-file)
; other keybindings if desired
)
(add-hook 'dired-mode-hook 'set-my-dired-keys-hook)
--
Piet van Oostrum <piet@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet@vanoostrum.org
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-02-24 15:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-20 14:18 How to bind mouse-1 to find-file in dired? Arne Schmitz
2008-02-20 15:55 ` Johan Bockgård
2008-02-20 16:28 ` Arne Schmitz
2008-02-21 3:12 ` Kevin Rodgers
[not found] ` <mailman.7724.1203563559.18990.help-gnu-emacs@gnu.org>
2008-02-21 10:59 ` Arne Schmitz
2008-02-24 15:33 ` Kevin Rodgers
2008-02-20 16:17 ` Piet van Oostrum
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).