【问题标题】:Emacs: open large files in external apps automaticallyEmacs:自动在外部应用程序中打开大文件
【发布时间】:2015-10-06 23:05:21
【问题描述】:

我也想使用 Emacs 作为文件管理器并使用 xdg-open 打开大文件(在 dired 或 speedbar 中)。我可以将defadvice 用于abort-if-file-too-large 功能吗?如何正确使用?

【问题讨论】:

    标签: elisp


    【解决方案1】:

    通知abort-if-file-too-large 要求即使它从外部打开文件仍会引发错误,否则find-file-noselect 仍会尝试打开文件。此外,您只想在传递给abort-if-file-too-large 的操作类型指示正在打开文件时才调用外部程序。尽管您可能希望调整 call-process 的参数以使其更适合您的场景,但类似以下内容将起作用:

    (defun open-outside-emacs (orig-fun size op-type filename)
      (if (not (string-equal op-type "open"))
          (apply orig-fun size op-type filename)
        (call-process "/usr/bin/xdg-open" nil 0 nil (expand-file-name filename))
        (error "opened externally")))
    (advice-add 'abort-if-file-too-large :around #'open-outside-emacs)
    

    【讨论】:

      猜你喜欢
      • 2014-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-19
      • 1970-01-01
      • 1970-01-01
      • 2017-02-25
      • 1970-01-01
      相关资源
      最近更新 更多