In Emacs, how to show the current file in Finder?

Is there a feature in Emacs on Mac OSX to open the current file in Finder?

+4
source share
7 answers

A bit late, but I just created a script based on this. When called from the buffer, the folder opens.

https://github.com/kaz-yos/reveal-in-osx-finder (new link)

EDIT 2014-02-06 Now on MELPA: Mx list-packages should display the layout in other packages.

See here for use. https://github.com/kaz-yos/reveal-in-osx-finder

EDIT 2014-04-08 I updated the script a bit (below). This should be useful in a bottled buffer.

(NEW 0.3.0). M-x --finder , OS X Finder. , .

EDIT 2015-08-03 open-in-osx-finder.el, "".

+7

โ„– 1:. , , Finder. , ( ):

(defun dired-open-in-finder ()
"This function contemplates that we are in columns view in Finder (Command+3),
rather than list view (Command+2)."
(interactive)
  (let ((path (dired-get-file-for-visit))
        (display-pixel-height (number-to-string (display-pixel-height)))
        (display-pixel-width (number-to-string (display-pixel-width))))
    (when path
      (let* ((maximize
              (concat
                "tell application \"Finder\" to set the bounds of the front Finder window to "
                "{0, 0, " display-pixel-width ", " display-pixel-height "}\n"))
             (script
               (concat
                 "tell application \"Finder\"\n"
                 " set frontmost to true\n"
                 " make new Finder window to (POSIX file \"" path "\")\n"
                 maximize
                 "end tell\n")))
        (start-process "finder" nil "osascript" "-e" script)))))

โ„–2: , - - , , - .

(defun open-finder ()
(interactive)
  (let ((path (or (buffer-file-name) (dired-file-name-at-point)))
          dir file)
    (when path
      (setq dir (file-name-directory path))
      (setq file (file-name-nondirectory path)))
    (open-finder-1 dir file)))

(defun open-finder-1 (dir file)
  (let ((script
      (if file
        (concat
          "tell application \"Finder\"\n"
          " set frontmost to true\n"
          " make new Finder window to (POSIX file \"" (expand-file-name dir) "\")\n"
          " select file \"" file "\"\n"
          "end tell\n")
        (concat
          "tell application \"Finder\"\n"
          " set frontmost to true\n"
          " make new Finder window to {path to desktop folder}\n"
          "end tell\n"))))
    (start-process "osascript-getinfo" nil "osascript" "-e" script)))
+4

Emacs , , , , Cocoa - Emacs (apple-appkit), โŒ˜-click ^-click filename , , Finder.

+3

, . .

(defun open-current-file-in-finder ()
  (interactive)
  (shell-command "open -R ."))
+1

. OSX. unix gnu.

( , )

(defun open-current-file-in-finder ()
  (interactive)
  (shell-command "open -R ."))

, . , .

(defun open-current-file-directory ()
  (interactive)
  (shell-command "open ."))

(defun show-in-finder ()
  (interactive)
  (shell-command (concat "open -R " buffer-file-name)))

Emacs 25.1.1

0

In standby mode, enter "!" Instead of "e" or "f" to open the file in the emacs buffer and then "open -R." A new Finder window opens, pointing to your file.

0
source

You can also simply enter the following.

M-:
open .

when the file is open in the current buffer.

The advantage is that you donโ€™t have to remember the name of the function, not even a part of it, in order to get automatic completion.

0
source

All Articles