我想停止在OSX中使用finder并改用dired。 OSX有一个命令“打开”,用于打开cli中默认应用程序中的任何文件。 (例如:“open $ the_file”)。这适用于C-!然后我进入“开放”,但我想用关键组合做这两件事,比如C-0。
如何创建一个与“C-”相同的功能? - >当我用光标在文件路径上按C-0时,在“直接”中“打开”?
(编辑:我找到了一个解决方案,宏!)
答案 0 :(得分:1)
我在每个示例的末尾将lawlist-filename
重置为nil
,以便可以将其用于各种其他功能,包括但不限于dired-read-file-name
:{{ 3}}
编辑:在@phils的帮助下重写 - 使用let
绑定,而不是全局变量。
(eval-after-load "dired" '(progn
;; open anything externally with OSX default app -- Wide-Open-Throttle!
(define-key dired-mode-map (kbd "z") (lambda () (interactive)
(let ((lawlist-filename (dired-get-file-for-visit)))
(start-process "default-app" nil "open" lawlist-filename))))
;; open *.pdf file externally with the OSX default *.pdf viewer.
(define-key dired-mode-map (kbd "<SPC>") (lambda () (interactive)
(let ((lawlist-filename (dired-get-file-for-visit)))
(if (equal (file-name-extension lawlist-filename) "pdf")
(start-process "default-pdf-app" nil "open" lawlist-filename)))))
;; open *.pdf file externally using Skim.
(define-key dired-mode-map (kbd "v") (lambda () (interactive)
(let* (
(lawlist-filename (dired-get-file-for-visit))
(skim "/Applications/Skim.app/Contents/MacOS/Skim") )
(if (equal (file-name-extension lawlist-filename) "pdf")
(start-process "pdf-with-skim" nil "open" "-a" skim lawlist-filename)))))
))
答案 1 :(得分:0)
这很有效,但看起来不太优雅:
http://www.emacswiki.org/emacs/KeyboardMacros
我使用了一个宏:
(fset'my_macro
[?! ?o ?p ?e ?n ? return])