diff options
| author | Stefan Monnier | 2005-06-30 22:17:01 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-06-30 22:17:01 +0000 |
| commit | fdaaf743881d234a5bbf712df487342a278388f2 (patch) | |
| tree | acde967dd41a6a8c9d417429036b3ace8a2ef828 | |
| parent | a082b0df6fd8b2236e8c355a4dc5cbaa998a5e66 (diff) | |
| download | emacs-fdaaf743881d234a5bbf712df487342a278388f2.tar.gz emacs-fdaaf743881d234a5bbf712df487342a278388f2.zip | |
(archive-extract): Make it work as a mouse binding.
(archive-mouse-extract): Make it an obsolete alias.
(archive-mode-map): Don't use archive-mouse-extract any more.
(archive-mode, archive-extract): write-contents-hooks ->
write-contents-functions.
(archive-arc-rename-entry, archive-lzh-rename-entry): Remove unused
first arg.
(archive-rename-entry): Update the call.
(archive-zip-summarize): Remove unused var `method'.
(archive-lzh-summarize): Remove unused var `creator'.
| -rw-r--r-- | lisp/arc-mode.el | 99 |
1 files changed, 41 insertions, 58 deletions
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 5ed0eb494c0..ce2100c4f08 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el | |||
| @@ -131,7 +131,7 @@ | |||
| 131 | (make-temp-name | 131 | (make-temp-name |
| 132 | (expand-file-name (if (eq system-type 'ms-dos) "ar" "archive.tmp") | 132 | (expand-file-name (if (eq system-type 'ms-dos) "ar" "archive.tmp") |
| 133 | temporary-file-directory)) | 133 | temporary-file-directory)) |
| 134 | "*Directory for temporary files made by arc-mode.el" | 134 | "Directory for temporary files made by arc-mode.el." |
| 135 | :type 'directory | 135 | :type 'directory |
| 136 | :group 'archive) | 136 | :group 'archive) |
| 137 | 137 | ||
| @@ -367,7 +367,7 @@ Archive and member name will be added." | |||
| 367 | (substitute-key-definition 'undo 'archive-undo map global-map)) | 367 | (substitute-key-definition 'undo 'archive-undo map global-map)) |
| 368 | 368 | ||
| 369 | (define-key map | 369 | (define-key map |
| 370 | (if (featurep 'xemacs) 'button2 [mouse-2]) 'archive-mouse-extract) | 370 | (if (featurep 'xemacs) 'button2 [mouse-2]) 'archive-extract) |
| 371 | 371 | ||
| 372 | (if (featurep 'xemacs) | 372 | (if (featurep 'xemacs) |
| 373 | () ; out of luck | 373 | () ; out of luck |
| @@ -633,8 +633,7 @@ archive. | |||
| 633 | 633 | ||
| 634 | ;; Remote archives are not written by a hook. | 634 | ;; Remote archives are not written by a hook. |
| 635 | (if archive-remote nil | 635 | (if archive-remote nil |
| 636 | (make-local-variable 'write-contents-hooks) | 636 | (add-hook 'write-contents-functions 'archive-write-file nil t)) |
| 637 | (add-hook 'write-contents-hooks 'archive-write-file)) | ||
| 638 | 637 | ||
| 639 | (make-local-variable 'require-final-newline) | 638 | (make-local-variable 'require-final-newline) |
| 640 | (setq require-final-newline nil) | 639 | (setq require-final-newline nil) |
| @@ -747,19 +746,18 @@ when parsing the archive." | |||
| 747 | (apply | 746 | (apply |
| 748 | (function concat) | 747 | (function concat) |
| 749 | (mapcar | 748 | (mapcar |
| 750 | (function | 749 | (lambda (fil) |
| 751 | (lambda (fil) | 750 | ;; Using `concat' here copies the text also, so we can add |
| 752 | ;; Using `concat' here copies the text also, so we can add | 751 | ;; properties without problems. |
| 753 | ;; properties without problems. | 752 | (let ((text (concat (aref fil 0) "\n"))) |
| 754 | (let ((text (concat (aref fil 0) "\n"))) | 753 | (if (featurep 'xemacs) |
| 755 | (if (featurep 'xemacs) | 754 | () ; out of luck |
| 756 | () ; out of luck | 755 | (add-text-properties |
| 757 | (add-text-properties | 756 | (aref fil 1) (aref fil 2) |
| 758 | (aref fil 1) (aref fil 2) | 757 | '(mouse-face highlight |
| 759 | '(mouse-face highlight | 758 | help-echo "mouse-2: extract this file into a buffer") |
| 760 | help-echo "mouse-2: extract this file into a buffer") | 759 | text)) |
| 761 | text)) | 760 | text)) |
| 762 | text))) | ||
| 763 | files))) | 761 | files))) |
| 764 | (setq archive-file-list-end (point-marker))) | 762 | (setq archive-file-list-end (point-marker))) |
| 765 | 763 | ||
| @@ -894,18 +892,12 @@ using `make-temp-file', and the generated name is returned." | |||
| 894 | (kill-local-variable 'buffer-file-coding-system) | 892 | (kill-local-variable 'buffer-file-coding-system) |
| 895 | (after-insert-file-set-coding (- (point-max) (point-min)))))) | 893 | (after-insert-file-set-coding (- (point-max) (point-min)))))) |
| 896 | 894 | ||
| 897 | (defun archive-mouse-extract (event) | 895 | (define-obsolete-function-alias 'archive-mouse-extract 'archive-extract "22.1") |
| 898 | "Extract a file whose name you click on." | ||
| 899 | (interactive "e") | ||
| 900 | (mouse-set-point event) | ||
| 901 | (switch-to-buffer | ||
| 902 | (save-excursion | ||
| 903 | (archive-extract) | ||
| 904 | (current-buffer)))) | ||
| 905 | 896 | ||
| 906 | (defun archive-extract (&optional other-window-p) | 897 | (defun archive-extract (&optional other-window-p event) |
| 907 | "In archive mode, extract this entry of the archive into its own buffer." | 898 | "In archive mode, extract this entry of the archive into its own buffer." |
| 908 | (interactive) | 899 | (interactive (list nil last-input-event)) |
| 900 | (if event (mouse-set-point event)) | ||
| 909 | (let* ((view-p (eq other-window-p 'view)) | 901 | (let* ((view-p (eq other-window-p 'view)) |
| 910 | (descr (archive-get-descr)) | 902 | (descr (archive-get-descr)) |
| 911 | (ename (aref descr 0)) | 903 | (ename (aref descr 0)) |
| @@ -937,8 +929,7 @@ using `make-temp-file', and the generated name is returned." | |||
| 937 | (setq default-directory arcdir) | 929 | (setq default-directory arcdir) |
| 938 | (make-local-variable 'archive-superior-buffer) | 930 | (make-local-variable 'archive-superior-buffer) |
| 939 | (setq archive-superior-buffer archive-buffer) | 931 | (setq archive-superior-buffer archive-buffer) |
| 940 | (make-local-variable 'local-write-file-hooks) | 932 | (add-hook 'write-file-functions 'archive-write-file-member nil t) |
| 941 | (add-hook 'local-write-file-hooks 'archive-write-file-member) | ||
| 942 | (setq archive-subfile-mode descr) | 933 | (setq archive-subfile-mode descr) |
| 943 | (if (and | 934 | (if (and |
| 944 | (null | 935 | (null |
| @@ -972,26 +963,22 @@ using `make-temp-file', and the generated name is returned." | |||
| 972 | (setq buffer-saved-size (buffer-size)) | 963 | (setq buffer-saved-size (buffer-size)) |
| 973 | (normal-mode) | 964 | (normal-mode) |
| 974 | ;; Just in case an archive occurs inside another archive. | 965 | ;; Just in case an archive occurs inside another archive. |
| 975 | (if (eq major-mode 'archive-mode) | 966 | (when (derived-mode-p 'archive-mode) |
| 976 | (progn | 967 | (setq archive-remote t) |
| 977 | (setq archive-remote t) | 968 | (if read-only-p (setq archive-read-only t)) |
| 978 | (if read-only-p (setq archive-read-only t)) | 969 | ;; We will write out the archive ourselves if it is |
| 979 | ;; We will write out the archive ourselves if it is | 970 | ;; part of another archive. |
| 980 | ;; part of another archive. | 971 | (remove-hook 'write-contents-functions 'archive-write-file t)) |
| 981 | (remove-hook 'write-contents-hooks 'archive-write-file t))) | 972 | (run-hooks 'archive-extract-hooks) |
| 982 | (run-hooks 'archive-extract-hooks) | ||
| 983 | (if archive-read-only | 973 | (if archive-read-only |
| 984 | (message "Note: altering this archive is not implemented.")))) | 974 | (message "Note: altering this archive is not implemented.")))) |
| 985 | (archive-maybe-update t)) | 975 | (archive-maybe-update t)) |
| 986 | (or (not (buffer-name buffer)) | 976 | (or (not (buffer-name buffer)) |
| 987 | (progn | 977 | (cond |
| 988 | (if view-p | 978 | (view-p (view-buffer buffer (and just-created 'kill-buffer))) |
| 989 | (view-buffer buffer (and just-created 'kill-buffer)) | 979 | ((eq other-window-p 'display) (display-buffer buffer)) |
| 990 | (if (eq other-window-p 'display) | 980 | (other-window-p (switch-to-buffer-other-window buffer)) |
| 991 | (display-buffer buffer) | 981 | (t (switch-to-buffer buffer)))))) |
| 992 | (if other-window-p | ||
| 993 | (switch-to-buffer-other-window buffer) | ||
| 994 | (switch-to-buffer buffer)))))))) | ||
| 995 | 982 | ||
| 996 | (defun archive-*-extract (archive name command) | 983 | (defun archive-*-extract (archive name command) |
| 997 | (let* ((default-directory (file-name-as-directory archive-tmpdir)) | 984 | (let* ((default-directory (file-name-as-directory archive-tmpdir)) |
| @@ -1298,7 +1285,7 @@ as a relative change like \"g+rw\" as for chmod(2)" | |||
| 1298 | (append (cdr command) (cons archive files)))) | 1285 | (append (cdr command) (cons archive files)))) |
| 1299 | 1286 | ||
| 1300 | (defun archive-rename-entry (newname) | 1287 | (defun archive-rename-entry (newname) |
| 1301 | "Change the name associated with this entry in the tar file." | 1288 | "Change the name associated with this entry in the archive file." |
| 1302 | (interactive "sNew name: ") | 1289 | (interactive "sNew name: ") |
| 1303 | (if archive-read-only (error "Archive is read-only")) | 1290 | (if archive-read-only (error "Archive is read-only")) |
| 1304 | (if (string= newname "") | 1291 | (if (string= newname "") |
| @@ -1307,7 +1294,7 @@ as a relative change like \"g+rw\" as for chmod(2)" | |||
| 1307 | (descr (archive-get-descr))) | 1294 | (descr (archive-get-descr))) |
| 1308 | (if (fboundp func) | 1295 | (if (fboundp func) |
| 1309 | (progn | 1296 | (progn |
| 1310 | (funcall func (buffer-file-name) | 1297 | (funcall func |
| 1311 | (if enable-multibyte-characters | 1298 | (if enable-multibyte-characters |
| 1312 | (encode-coding-string newname file-name-coding-system) | 1299 | (encode-coding-string newname file-name-coding-system) |
| 1313 | newname) | 1300 | newname) |
| @@ -1383,7 +1370,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1383 | "\n")) | 1370 | "\n")) |
| 1384 | (apply 'vector (nreverse files)))) | 1371 | (apply 'vector (nreverse files)))) |
| 1385 | 1372 | ||
| 1386 | (defun archive-arc-rename-entry (archive newname descr) | 1373 | (defun archive-arc-rename-entry (newname descr) |
| 1387 | (if (string-match "[:\\\\/]" newname) | 1374 | (if (string-match "[:\\\\/]" newname) |
| 1388 | (error "File names in arc files must not contain a directory component")) | 1375 | (error "File names in arc files must not contain a directory component")) |
| 1389 | (if (> (length newname) 12) | 1376 | (if (> (length newname) 12) |
| @@ -1417,7 +1404,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1417 | (time2 (archive-l-e (+ p 17) 2)) ;and UNIX format in level 2 header.) | 1404 | (time2 (archive-l-e (+ p 17) 2)) ;and UNIX format in level 2 header.) |
| 1418 | (hdrlvl (char-after (+ p 20))) ;header level | 1405 | (hdrlvl (char-after (+ p 20))) ;header level |
| 1419 | thsize ;total header size (base + extensions) | 1406 | thsize ;total header size (base + extensions) |
| 1420 | fnlen efnname fiddle ifnname width p2 creator | 1407 | fnlen efnname fiddle ifnname width p2 |
| 1421 | neh ;beginning of next extension header (level 1 and 2) | 1408 | neh ;beginning of next extension header (level 1 and 2) |
| 1422 | mode modestr uid gid text dir prname | 1409 | mode modestr uid gid text dir prname |
| 1423 | gname uname modtime moddate) | 1410 | gname uname modtime moddate) |
| @@ -1430,13 +1417,9 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1430 | (string-as-multibyte str)))) | 1417 | (string-as-multibyte str)))) |
| 1431 | (setq p2 (+ p 22 fnlen))) ; | 1418 | (setq p2 (+ p 22 fnlen))) ; |
| 1432 | (if (= hdrlvl 1) | 1419 | (if (= hdrlvl 1) |
| 1433 | (progn ;specific to level 1 header | 1420 | (setq neh (+ p2 3)) ;specific to level 1 header |
| 1434 | (setq creator (if (>= (- hsize fnlen) 24) (char-after (+ p2 2)) 0)) | ||
| 1435 | (setq neh (+ p2 3))) | ||
| 1436 | (if (= hdrlvl 2) | 1421 | (if (= hdrlvl 2) |
| 1437 | (progn ;specific to level 2 header | 1422 | (setq neh (+ p 24)))) ;specific to level 2 header |
| 1438 | (setq creator (char-after (+ p 23)) ) | ||
| 1439 | (setq neh (+ p 24))))) | ||
| 1440 | (if neh ;if level 1 or 2 we expect extension headers to follow | 1423 | (if neh ;if level 1 or 2 we expect extension headers to follow |
| 1441 | (let* ((ehsize (archive-l-e neh 2)) ;size of the extension header | 1424 | (let* ((ehsize (archive-l-e neh 2)) ;size of the extension header |
| 1442 | (etype (char-after (+ neh 2)))) ;extension type | 1425 | (etype (char-after (+ neh 2)))) ;extension type |
| @@ -1552,7 +1535,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1552 | p (1+ p))) | 1535 | p (1+ p))) |
| 1553 | (logand sum 255))) | 1536 | (logand sum 255))) |
| 1554 | 1537 | ||
| 1555 | (defun archive-lzh-rename-entry (archive newname descr) | 1538 | (defun archive-lzh-rename-entry (newname descr) |
| 1556 | (save-restriction | 1539 | (save-restriction |
| 1557 | (save-excursion | 1540 | (save-excursion |
| 1558 | (widen) | 1541 | (widen) |
| @@ -1606,7 +1589,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1606 | (defun archive-lzh-chmod-entry (newmode files) | 1589 | (defun archive-lzh-chmod-entry (newmode files) |
| 1607 | (archive-lzh-ogm | 1590 | (archive-lzh-ogm |
| 1608 | ;; This should work even though newmode will be dynamically accessed. | 1591 | ;; This should work even though newmode will be dynamically accessed. |
| 1609 | (function (lambda (old) (archive-calc-mode old newmode t))) | 1592 | (lambda (old) (archive-calc-mode old newmode t)) |
| 1610 | files "a unix-style mode" 8)) | 1593 | files "a unix-style mode" 8)) |
| 1611 | ;; ------------------------------------------------------------------------- | 1594 | ;; ------------------------------------------------------------------------- |
| 1612 | ;; Section: Zip Archives | 1595 | ;; Section: Zip Archives |
| @@ -1621,7 +1604,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." | |||
| 1621 | visual) | 1604 | visual) |
| 1622 | (while (string= "PK\001\002" (buffer-substring p (+ p 4))) | 1605 | (while (string= "PK\001\002" (buffer-substring p (+ p 4))) |
| 1623 | (let* ((creator (char-after (+ p 5))) | 1606 | (let* ((creator (char-after (+ p 5))) |
| 1624 | (method (archive-l-e (+ p 10) 2)) | 1607 | ;; (method (archive-l-e (+ p 10) 2)) |
| 1625 | (modtime (archive-l-e (+ p 12) 2)) | 1608 | (modtime (archive-l-e (+ p 12) 2)) |
| 1626 | (moddate (archive-l-e (+ p 14) 2)) | 1609 | (moddate (archive-l-e (+ p 14) 2)) |
| 1627 | (ucsize (archive-l-e (+ p 24) 4)) | 1610 | (ucsize (archive-l-e (+ p 24) 4)) |