Browse Source

modify pack functions

pull/1/head
10sr 12 years ago
parent
commit
887c1c6b9a
1 changed files with 19 additions and 19 deletions
  1. +19
    -19
      .emacs.el

+ 19
- 19
.emacs.el View File

@@ -1151,25 +1151,27 @@ if arg is omitted use value of `buffer-list'."
(let* ((dir-default (dired-dwim-target-directory)) (let* ((dir-default (dired-dwim-target-directory))
(archive-default (my-pack-file-extension (file-name-nondirectory (car infiles)))) (archive-default (my-pack-file-extension (file-name-nondirectory (car infiles))))
(archive ;; (if (interactive-p) (archive ;; (if (interactive-p)
(read-file-name "Output file to pack : " ;; (format "Output file to pack (default for %s) : "
;; archive-default)
(read-file-name "Output file to pack : "
dir-default dir-default
nil ;; archive-default
nil
nil nil
archive-default) archive-default)
;; (concat dir-default archive-default) ;; (concat dir-default archive-default)
)))
(apply 'my-pack
archive
infiles)))
))
(apply 'my-pack
archive
infiles))))
(revert-buffer) (revert-buffer)
;; (dired-unmark-all-marks) ;; (dired-unmark-all-marks)
) )


(defun my-pack-file-name-association (filename) (defun my-pack-file-name-association (filename)
"" ""
(assoc (my-file-name-extension-with-tar filename)
my-pack-program-alist))
(let ((case-fold-search nil))
(assoc-default filename
my-pack-program-alist
'string-match-p
nil)))


(defun my-file-name-extension-with-tar (filename) (defun my-file-name-extension-with-tar (filename)
"if FILENAME has extension with tar, like \"tar.gz\", return that. "if FILENAME has extension with tar, like \"tar.gz\", return that.
@@ -1195,13 +1197,11 @@ otherwise, return FILENAME with `my-pack-default-extension'"
"7z") "7z")


(defvar my-pack-program-alist (defvar my-pack-program-alist
(list (list "7z" (concat my-7z-program-name " a") (concat my-7z-program-name " x"))
'("tar" "tar cf" "tar xf")
'("tgz" "tar czf" "tar xzf")
'("txz" "tar cJf" "tar xJf")
'("zip" "zip -r" "unzip")))
(string-match-p "\\.gz\\'" "aaa.gz") ; \' matches string end, $ may match the point before newline.
;; (case-fold-search nil)
`(("\\.7z\\'" ,(concat my-7z-program-name " a"), (concat my-7z-program-name " x"))
("\\.tar\\'" "tar cf" "tar xf")
("\\.tgz\\'" "tar czf" "tar xzf")
("\\.zip\\'" "zip -r" "unzip")))
(string-match-p "\\.gz\\'" "aaa.gz") ; \' matches string end, $ also matches the point before newline.


(defun my-unpack (archive) (defun my-unpack (archive)
"" ""
@@ -1210,7 +1210,7 @@ otherwise, return FILENAME with `my-pack-default-extension'"
(lst (my-pack-file-name-association earchive)) (lst (my-pack-file-name-association earchive))
) )
(if lst (if lst
(shell-command (concat (nth 2
(shell-command (concat (nth 1
lst) lst)
" " " "
(shell-quote-argument earchive))) (shell-quote-argument earchive)))
@@ -1219,12 +1219,12 @@ otherwise, return FILENAME with `my-pack-default-extension'"
(defun my-pack (archive &rest files) (defun my-pack (archive &rest files)
"pack files FILES into file ARCHIVE. "pack files FILES into file ARCHIVE.
if ARCHIVE have extension defined in `pack-program-alist', use that command. if ARCHIVE have extension defined in `pack-program-alist', use that command.
otherwise, use `pack-default-extension'. for pack."
otherwise, use `pack-default-extension' for pack."
(let* ((archive-ext (my-pack-file-extension (expand-file-name archive))) (let* ((archive-ext (my-pack-file-extension (expand-file-name archive)))
(lst (my-pack-file-name-association archive-ext)) (lst (my-pack-file-name-association archive-ext))
) )
(if lst (if lst
(shell-command (concat (nth 1 lst)
(shell-command (concat (nth 0 lst)
" " " "
(shell-quote-argument archive-ext) (shell-quote-argument archive-ext)
" " " "


Loading…
Cancel
Save