emacscompressiondia

How to explicitly specify which archive-files should be handled by auto-compression-mode?


I use Dia to draw diagrams, however it's not sometimes very convenient when comes to text manipulation. Since *.dia files are just compressed XML-files, it can be edited in a text editor. Emacs has an auto-compression-mode which handles decompression/compression automatically, but it does so only for a set of specific extensions, so in order to modify .dia file I need to rename the filename to .gz first and after editing rename it back. I'd like to eliminate these two steps, and simply edit .dia files. Is there a way to configure auto-compression-mode to handle custom extensions?


Solution

  • The jka-compr-load-suffixes and jka-compr-compression-info-list variables can be customized to treat *.dia files the same way as *.gz.

    Try the following settings, but you may want to use the customize interface to set them permanently (as the docs note, jka-compr-update must be called when the variables are modified outside the customize interface)

    (add-to-list 'jka-compr-load-suffixes ".dia")
    ;; these are just the .gz settings in `jka-cmpr-hook`
    (add-to-list 'jka-compr-compression-info-list
                 ["\\.dia\\'"
                  "compressing"        "gzip"         ("-c" "-q")
                  "uncompressing"      "gzip"         ("-c" "-q" "-d")
                  t t "\037\213"])
    (jka-compr-update)