How to automatically unzip a custom compressed file when opened in emacs?

I know that Emacs automatically opens compressed files such as .tar.gz. I am trying to figure out how to achieve this with my own compression script, not standard ones. Following this link , I added the following to my Emacs initialization 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.customcomwhen the file is opened, but with the addition of the above, it starts customcom -d < foo.cusotmcomand produces an error. How can I modify the above to invalidate input redirection so that it only accepts the file name and not the contents of the file, or is there another way to approach this problem?

+4
3

, . , , jka-compr filename .

/. cat , .cat .

(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))

:

http://debbugs.gnu.org/cgi/bugreport.cgi?msg=5;att=1;bug=16454

+2

, , , xargs, , Linux:

(if (fboundp 'auto-compression-mode)
    (auto-compression-mode 0)
  (require 'jka-compr))

(add-to-list 'jka-compr-compression-info-list
             ["\\.customcomm\\'"
              "custom compressing" "xargs" ("customcom" "-c")
              "custom decompressing" "xargs" ("customcom" "-d")
              nil t])

(auto-compression-mode 1)

, , STDOUT.

+1

You might want to try and use ("-d" "-")as an argument, if you customcomfollow the customary interpretation -to mean "use stdin". Or depending on your OS, you might try ("-d" "/dev/stdin"): it should work with at least GNU / Linux.

+1
source

All Articles