From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Piet van Oostrum Newsgroups: gmane.emacs.help Subject: Re: How to bind mouse-1 to find-file in dired? Date: Wed, 20 Feb 2008 17:17:34 +0100 Organization: Dept of Computer Science, Utrecht University, The Netherlands Message-ID: References: <622r53F1uskpiU1@mid.dfncis.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1203550749 20849 80.91.229.12 (20 Feb 2008 23:39:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 Feb 2008 23:39:09 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 21 00:39:33 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JRyX2-00033h-Il for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Feb 2008 00:39:20 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRyWX-00046n-M7 for geh-help-gnu-emacs@m.gmane.org; Wed, 20 Feb 2008 18:38:49 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!news.stack.nl!cs.uu.nl!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 49 Original-NNTP-Posting-Host: adonis.cs.uu.nl Original-X-Trace: prometheus.cs.uu.nl 1203524264 16055 131.211.80.24 (20 Feb 2008 16:17:44 GMT) Original-X-Complaints-To: news@cs.uu.nl Original-NNTP-Posting-Date: Wed, 20 Feb 2008 16:17:44 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.90 (darwin) Cancel-Lock: sha1:pTXcN+JKhdyXq+fWcEoJosO8YHA= Original-Xref: shelby.stanford.edu gnu.emacs.help:156337 X-Mailman-Approved-At: Wed, 20 Feb 2008 18:35:06 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:51713 Archived-At: >>>>> Arne Schmitz (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 "") '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 URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: piet@vanoostrum.org