โ 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)))