如何使用启动过程使用Skim打开* .pdf以使其具有焦点

时间:2013-09-04 00:39:52

标签: emacs

有没有人可以帮我用Skim打开一个* .pdf,以便它有焦点。 Skim正确打开文件,但仍保留在后台。我在OSX机器上使用了最新版本的Emacs Trunk。

如果我在Skim的绝对路径之前插入类似“open -a”或“open -o”的内容,那么Emacs会抱怨该名称没有应用程序。我已经尝试在文件名后放置“-o”,但这没有任何影响。

以下代码适用于Wanderlust,但我认为start-process是通用的。

(eval-after-load "mime-view"
  '(progn
     (ctree-set-calist-strictly
      'mime-acting-condition
      '((mode . "play")
        (type . application)(subtype . pdf)
        (method . lawlist-mime-view)))))

(defun lawlist-mime-view (&optional a b)
  (let* ((entity (get-text-property (point) 'mime-view-entity))
           (filename (mime-entity-safe-filename entity)))
  (mime-write-entity-content entity (concat "/tmp/" filename))
  (process-kill-without-query
    (start-process "hello-world" nil "/Applications/Skim.app/Contents/MacOS/Skim" filename))))

编辑 - 1 :这是一个简单的功能,可帮助诊断问题。我创建了一个* .pdf文件并将其保存为"/tmp/test.pdf"

(defun test-start-process ()
  (interactive)
    (start-process "hello-world" nil "open" "-a Skim" "/tmp/test.pdf"))

编辑 - 2 :感谢tungd的帮助,这是修改后的工作代码 - 非常感谢!

(eval-after-load "mime-view"
  '(progn
     (ctree-set-calist-strictly
      'mime-acting-condition
      '((mode . "play")
        (type . application)(subtype . pdf)
        (method . lawlist-mime-view)))))

(defun lawlist-mime-view (&optional a b)
  (let* (
    (entity (get-text-property (point) 'mime-view-entity))
    (name (mime-entity-safe-filename entity))
    (filename (concat "/tmp/" name)) )
  (mime-write-entity-content entity filename)
  (start-process "hello-world" nil "open" "-a" "Skim" filename)))

1 个答案:

答案 0 :(得分:2)

我认为open是最简单的方法。但是start-process的定义是:

(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)

所以你必须这样使用它:

(start-process "hello-world" nil "open" "-a" "Skim" filename)