Browse Source

.emacs: bug fixes around my-compress

pull/1/head
10sr 13 years ago
parent
commit
dd41a63a5d
1 changed files with 27 additions and 26 deletions
  1. +27
    -26
      .emacs

+ 27
- 26
.emacs View File

@@ -991,16 +991,17 @@ if arg is omitted use value of `buffer-list'."
(my-uncompress onefile) (my-uncompress onefile)
(revert-buffer)) (revert-buffer))
(let* ((dir-default (dired-dwim-target-directory)) (let* ((dir-default (dired-dwim-target-directory))
(outfile-default (my-compress-file-extension (concat dir-default
(file-name-nondirectory (car infiles)))))
(outfile (if (interactive-p)
(read-file-name (format "Output file to compress (default for %s) : "
outfile-default)
(archive-default (my-compress-file-extension (file-name-nondirectory (car infiles))))
(archive (if (interactive-p)
(read-file-name "Output file to compress : " ;; (format "Output file to compress (default for %s) : "
;; archive-default)
dir-default dir-default
outfile-default)
outfile-default)))
nil ;; archive-default
nil
archive-default)
(concat dir-default archive-default))))
(apply 'my-compress (apply 'my-compress
outfile
archive
infiles) infiles)
(revert-buffer))) (revert-buffer)))
(dired-unmark-all-marks))) (dired-unmark-all-marks)))
@@ -1036,32 +1037,32 @@ otherwise, return FILENAME with `my-compress-default-extension'"
("txz" "tar" "cJf" "tar" "xJf") ("txz" "tar" "cJf" "tar" "xJf")
("zip" "zip" "-r" "unzip" nil))) ("zip" "zip" "-r" "unzip" nil)))


(defun my-uncompress (file)
(defun my-uncompress (archive)
"" ""
(interactive "fFile to extract: ")
(let* ((efile (expand-file-name file))
(ext (file-name-extension efile))
(interactive "fArchive to extract: ")
(let* ((earchive (expand-file-name archive))
(ext (file-name-extension earchive))
(lst (assoc ext (lst (assoc ext
my-compress-program-alist)) my-compress-program-alist))
(com (nth 3 lst)) (com (nth 3 lst))
(op (nth 4 lst)) (op (nth 4 lst))
(args (if op (args (if op
(list op efile)
(list efile))))
(message "uncompressing %s..." file)
(list op earchive)
(list earchive))))
(message "uncompressing %s..." archive)
(apply 'call-process (apply 'call-process
com com
nil nil
(my-pop-to-buffer-erase-noselect "*compressing output*") (my-pop-to-buffer-erase-noselect "*compressing output*")
t t
args) args)
(message "uncompressing %s...done." file)))
(message "uncompressing %s...done." archive)))


(defun my-compress (outfile &rest infiles)
"if outfile have extension for compress, use it.
(defun my-compress (archive &rest files)
"if archive have extension for compress, use it.
otherwise, use `my-compress-default-extension'. for compress." otherwise, use `my-compress-default-extension'. for compress."
(let* ((outfile-ext (my-compress-file-extension (expand-file-name outfile)))
(ext (file-name-extension outfile-ext))
(let* ((archive-ext (my-compress-file-extension (expand-file-name archive)))
(ext (file-name-extension archive-ext))
(lst (assoc ext (lst (assoc ext
my-compress-program-alist)) my-compress-program-alist))
(com (nth 1 lst)) (com (nth 1 lst))
@@ -1069,19 +1070,19 @@ otherwise, use `my-compress-default-extension'. for compress."
(args (if op (args (if op
(apply 'list (apply 'list
op op
outfile-ext
infiles)
archive-ext
files)
(apply 'list (apply 'list
outfile-ext
infiles))))
(message "compressing to %s..." outfile)
archive-ext
files))))
(message "compressing to %s..." archive)
(apply 'call-process (apply 'call-process
com com
nil nil
(my-pop-to-buffer-erase-noselect "*compressing output*") (my-pop-to-buffer-erase-noselect "*compressing output*")
t t
args) args)
(message "compressing to %s...done." outfile)))
(message "compressing to %s...done." archive)))


(defun my-pop-to-buffer-erase-noselect (buffer-or-name) (defun my-pop-to-buffer-erase-noselect (buffer-or-name)
"pop up buffer using `display-buffer' and return that buffer." "pop up buffer using `display-buffer' and return that buffer."


Loading…
Cancel
Save