[OS X Emacs] Use "Open" command in Dired Mode

José Miguel Figueroa-O'Farrill j.m.figueroa at ed.ac.uk
Sat Mar 29 16:09:59 EDT 2008


On 29 Mar 2008, at 19:03, Johannes Brauer wrote:
> Hi!
>
> I gave the tip from Aquamacs wiki a try. But evaluating this:
>
> (define-key dired-mode-map "o" 'dired-open-mac)
>  (defun dired-open-mac ()
>     (interactive)
>     (let ((file-name (dired-get-file-for-visit)))
>       (if (file-exists-p file-name)
>           (shell-command (concat "open '" file-name "'" nil )))))
>
> I get the error message: Symbol's value as variable is void: dired- 
> mode-map.
> Is the tip outdated?

I have this code commented out in my Preferences.el and have the  
following instead:

(add-hook 'dired-mode-hook
  	  '(lambda ()
	     (define-key dired-mode-map "o" 'dired-open-mac)))

  (defun dired-open-mac ()
     (interactive)
     (let ((file-name (dired-get-file-for-visit)))
       (if (file-exists-p file-name)
           (call-process "/usr/bin/open" nil 0 nil file-name))))


which works for me.  It's the reverse operation which doesn't work  
for me, despite several unsuccessful attempts at debugging it; that  
is, opening Aquamacs documents from the Finder.

Cheers, José






More information about the MacOSX-Emacs mailing list