diff options
| author | Eli Zaretskii | 2007-05-23 17:32:46 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2007-05-23 17:32:46 +0000 |
| commit | db2ccbc2a82836fdeefef3d29c1d613c79b7d476 (patch) | |
| tree | 06668b96d7768b84111ddb4f0fe12c07a61bb474 | |
| parent | 3c71f17a1cc49223da45c66bf6be81416f11c04c (diff) | |
| download | emacs-db2ccbc2a82836fdeefef3d29c1d613c79b7d476.tar.gz emacs-db2ccbc2a82836fdeefef3d29c1d613c79b7d476.zip | |
(tar-file-name-handler): New function.
(tar-extract): Bind file-name-handler-alist to it to force
find-buffer-file-type-coding-system behave as if the file being extracted
existed. Use last-coding-system-used to force buffer-file-coding-system to
what decode-coding-region actually used to decode the file.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/tar-mode.el | 26 |
2 files changed, 31 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 88ccc684542..b1763abd2ef 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2007-05-23 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * tar-mode.el (tar-file-name-handler): New function. | ||
| 4 | (tar-extract): Bind file-name-handler-alist to it to force | ||
| 5 | find-buffer-file-type-coding-system behave as if the file being | ||
| 6 | extracted existed. Use last-coding-system-used to force | ||
| 7 | buffer-file-coding-system to what decode-coding-region actually | ||
| 8 | used to decode the file. | ||
| 9 | |||
| 1 | 2007-05-23 Nikolaj Schumacher <n_schumacher@web.de> (tiny change) | 10 | 2007-05-23 Nikolaj Schumacher <n_schumacher@web.de> (tiny change) |
| 2 | 11 | ||
| 3 | * progmodes/compile.el (compilation-handle-exit): | 12 | * progmodes/compile.el (compilation-handle-exit): |
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index cffc8a4cccc..31854e60407 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el | |||
| @@ -681,6 +681,12 @@ appear on disk when you save the tar-file's buffer." | |||
| 681 | (goto-char (posn-point (event-end event))) | 681 | (goto-char (posn-point (event-end event))) |
| 682 | (tar-extract)) | 682 | (tar-extract)) |
| 683 | 683 | ||
| 684 | (defun tar-file-name-handler (op &rest args) | ||
| 685 | "Helper function for `tar-extract'." | ||
| 686 | (or (eq op 'file-exists-p) | ||
| 687 | (let ((file-name-handler-alist nil)) | ||
| 688 | (apply op args)))) | ||
| 689 | |||
| 684 | (defun tar-extract (&optional other-window-p) | 690 | (defun tar-extract (&optional other-window-p) |
| 685 | "In Tar mode, extract this entry of the tar file into its own buffer." | 691 | "In Tar mode, extract this entry of the tar file into its own buffer." |
| 686 | (interactive) | 692 | (interactive) |
| @@ -735,9 +741,19 @@ appear on disk when you save the tar-file's buffer." | |||
| 735 | (save-excursion | 741 | (save-excursion |
| 736 | (funcall set-auto-coding-function | 742 | (funcall set-auto-coding-function |
| 737 | name (- (point-max) (point))))) | 743 | name (- (point-max) (point))))) |
| 738 | (car (find-operation-coding-system | 744 | ;; The following binding causes |
| 739 | 'insert-file-contents | 745 | ;; find-buffer-file-type-coding-system |
| 740 | (cons name (current-buffer)) t)))) | 746 | ;; (defined on dos-w32.el) to act as if |
| 747 | ;; the file being extracted existed, so | ||
| 748 | ;; that the file's contents' encoding and | ||
| 749 | ;; EOL format are auto-detected. | ||
| 750 | (let ((file-name-handler-alist | ||
| 751 | (if (featurep 'dos-w32) | ||
| 752 | '(("" . tar-file-name-handler)) | ||
| 753 | file-name-handler-alist))) | ||
| 754 | (car (find-operation-coding-system | ||
| 755 | 'insert-file-contents | ||
| 756 | (cons name (current-buffer)) t))))) | ||
| 741 | (multibyte enable-multibyte-characters) | 757 | (multibyte enable-multibyte-characters) |
| 742 | (detected (detect-coding-region | 758 | (detected (detect-coding-region |
| 743 | (point-min) | 759 | (point-min) |
| @@ -758,7 +774,9 @@ appear on disk when you save the tar-file's buffer." | |||
| 758 | (coding-system-change-text-conversion | 774 | (coding-system-change-text-conversion |
| 759 | coding 'raw-text))) | 775 | coding 'raw-text))) |
| 760 | (decode-coding-region (point-min) (point-max) coding) | 776 | (decode-coding-region (point-min) (point-max) coding) |
| 761 | (set-buffer-file-coding-system coding)) | 777 | ;; Force buffer-file-coding-system to what |
| 778 | ;; decode-coding-region actually used. | ||
| 779 | (set-buffer-file-coding-system last-coding-system-used t)) | ||
| 762 | ;; Set the default-directory to the dir of the | 780 | ;; Set the default-directory to the dir of the |
| 763 | ;; superior buffer. | 781 | ;; superior buffer. |
| 764 | (setq default-directory | 782 | (setq default-directory |