我也想使用Emacs作为文件管理器,并用xdg-open打开大文件(在dired或speedbar中)。我可以为abort-if-file-too-large函数使用defadvice吗?如何正确使用?
发布于 2015-10-06 23:05:22
建议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)https://stackoverflow.com/questions/32919308
复制相似问题