如何在emacs中打开时自动解压缩自定义压缩文件? [英] How to automatically decompress a custom compressed file when opened in emacs?
问题描述
.tar.gz
。我正在试图用自己的压缩脚本而不是标准来实现这一点。 按照此链接,我将以下内容添加到我的Emacs初始化文件
(if(fboundp'auto-compression-mode)
(auto-compression-mode 0 )
(require'jka-compr))
(add-to-list'jka-compr-compression-info-list
[\\.customcom\\'
自定义压缩customcom(-c)
自定义解压缩customcom(-d)
nil t])
(自动压缩模式1 )
理想情况下,我想运行命令 customcom -d foo.customcom
当文件被打开但是上述添加时,它运行 customcom -d< foo.cusotmcom
并给出错误。如何修改以上内容以使输入重定向无效,以便仅使用文件名而不是文件的内容,或者有不同的方法来解决此问题?
也许,以下代码是有帮助的。顺便说一句,有趣的是, jka-compr
的作者没有考虑到程序参数的评估,并没有提供 filename
作为可能的可评估参数之一。
我不知道你的压缩/解压缩程序。因此,我只是以 .cat
结尾的文件使用 cat
来进行测试。
(defadvice jka-compr-info-compress-args(在eval-args激活周围)
评估程序参数
(setq ad-return-value(mapcar'eval(aref info 3))))
(defadvice jka-compr-info-uncompress-args(around eval-args activate)
评估程序参数
(setq ad-return-value(mapcar'eval(aref info 6))))
(add-to-list' jka-compr-compression-info-list [\\.cat\\catcat( - )
cat uncompresscat(filename) ))
(add-to-list'auto-mode-alist'(\\.cat\\\'nil jka-compr))
(add-to-list'file-name-handler-alist'(\\.cat\\。jka-compr-handler))
相应的增强请求:
http://debbugs.gnu.org/ cgi / bugreport.cgi?msg = 5; att = 1; bug = 16454
I know Emacs automatically opens compressed files like .tar.gz
. I'm trying to figure how to achieve this with my own compression script rather than the standard ones.
Following this link, I added the following to my Emacs init file
(if (fboundp 'auto-compression-mode)
(auto-compression-mode 0)
(require 'jka-compr))
(add-to-list 'jka-compr-compression-info-list
["\\.customcom\\'"
"custom compressing" "customcom" (-c)
"custom decompressing" "customcom" (-d)
nil t])
(auto-compression-mode 1)
Ideally, i want to run the command customcom -d foo.customcom
when the file is opened but with the above addition, its running customcom -d < foo.cusotmcom
and giving an error. How can I modify the above to nullify the input redirection so that it takes the filename only rather than the contents of the file or is there a different way of approaching this problem?
Maybe, the following code is helpful. By the way, it is interesting that the author of jka-compr
did not take the evaluation of the program arguments into consideration and did not provide filename
as one of the possible evaluable arguments.
I do not know your compression/uncompression program. Therefore, I just used cat
for files ending with .cat
instead for testing.
(defadvice jka-compr-info-compress-args (around eval-args activate)
"Evaluate program arguments"
(setq ad-return-value (mapcar 'eval (aref info 3))))
(defadvice jka-compr-info-uncompress-args (around eval-args activate)
"Evaluate program arguments"
(setq ad-return-value (mapcar 'eval (aref info 6))))
(add-to-list 'jka-compr-compression-info-list ["\\.cat\\'" "cat" "cat" ("-")
"cat uncompress" "cat" (filename) nil t ""])
(add-to-list 'auto-mode-alist '("\\.cat\\'" nil jka-compr))
(add-to-list 'file-name-handler-alist '("\\.cat\\'" . jka-compr-handler))
Corresponding enhancement-request:
http://debbugs.gnu.org/cgi/bugreport.cgi?msg=5;att=1;bug=16454
这篇关于如何在emacs中打开时自动解压缩自定义压缩文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!