Mercurial > emacs
comparison lisp/tar-mode.el @ 4260:e0713a13f2d7
(tar-parse-info, tar-header-offset, tar-superior-buffer)
(tar-superior-descriptor): Make them permanent locals.
(tar-mode): Call kill-all-local-variables.
Locally set enable-local-variables to nil.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 24 Jul 1993 08:42:00 +0000 |
parents | 872d8ef4bb62 |
children | 3e18f6a1915b |
comparison
equal
deleted
inserted
replaced
4259:085095792d99 | 4260:e0713a13f2d7 |
---|---|
34 ;;; It is also possible to delete sub-files from within the tar file and write | 34 ;;; It is also possible to delete sub-files from within the tar file and write |
35 ;;; the modified archive back to disk, or to edit sub-files within the archive | 35 ;;; the modified archive back to disk, or to edit sub-files within the archive |
36 ;;; and re-insert the modified files into the archive. See the documentation | 36 ;;; and re-insert the modified files into the archive. See the documentation |
37 ;;; string of tar-mode for more info. | 37 ;;; string of tar-mode for more info. |
38 | 38 |
39 ;;; To autoload, add this to your .emacs file: | |
40 ;;; | |
41 ;;; (setq auto-mode-alist (cons '("\\.tar$" . tar-mode) auto-mode-alist)) | |
42 ;;; (autoload 'tar-mode "tar-mode") | |
43 ;;; | |
44 ;;; But beware: for certain tar files - those whose very first file has | |
45 ;;; a -*- property line - autoloading won't work. See the function | |
46 ;;; "tar-normal-mode" to understand why. | |
47 | |
48 ;;; This code now understands the extra fields that GNU tar adds to tar files. | 39 ;;; This code now understands the extra fields that GNU tar adds to tar files. |
49 | 40 |
50 ;;; This interacts correctly with "uncompress.el" in the Emacs library, | 41 ;;; This interacts correctly with "uncompress.el" in the Emacs library, |
51 ;;; which you get with | 42 ;;; which you get with |
52 ;;; | 43 ;;; |
113 (defvar tar-parse-info nil) | 104 (defvar tar-parse-info nil) |
114 (defvar tar-header-offset nil) | 105 (defvar tar-header-offset nil) |
115 (defvar tar-superior-buffer nil) | 106 (defvar tar-superior-buffer nil) |
116 (defvar tar-superior-descriptor nil) | 107 (defvar tar-superior-descriptor nil) |
117 (defvar tar-subfile-mode nil) | 108 (defvar tar-subfile-mode nil) |
109 | |
110 (put 'tar-parse-info 'permanent-local t) | |
111 (put 'tar-header-offset 'permanent-local t) | |
112 (put 'tar-superior-buffer 'permanent-local t) | |
113 (put 'tar-superior-descriptor 'permanent-local t) | |
118 | 114 |
119 ;;; First, duplicate some Common Lisp functions; I used to just (require 'cl) | 115 ;;; First, duplicate some Common Lisp functions; I used to just (require 'cl) |
120 ;;; but "cl.el" was messing some people up (also it's really big). | 116 ;;; but "cl.el" was messing some people up (also it's really big). |
121 | 117 |
122 (defmacro tar-setf (form val) | 118 (defmacro tar-setf (form val) |
485 | 481 |
486 See also: variables tar-update-datestamp and tar-anal-blocksize. | 482 See also: variables tar-update-datestamp and tar-anal-blocksize. |
487 \\{tar-mode-map}" | 483 \\{tar-mode-map}" |
488 ;; this is not interactive because you shouldn't be turning this | 484 ;; this is not interactive because you shouldn't be turning this |
489 ;; mode on and off. You can corrupt things that way. | 485 ;; mode on and off. You can corrupt things that way. |
486 ;; rms: with permanent locals, it should now be possible to make this work | |
487 ;; interactively in some reasonable fashion. | |
488 (kill-all-local-variables) | |
490 (make-local-variable 'tar-header-offset) | 489 (make-local-variable 'tar-header-offset) |
491 (make-local-variable 'tar-parse-info) | 490 (make-local-variable 'tar-parse-info) |
492 (make-local-variable 'require-final-newline) | 491 (make-local-variable 'require-final-newline) |
493 (setq require-final-newline nil) ; binary data, dude... | 492 (setq require-final-newline nil) ; binary data, dude... |
494 (make-local-variable 'revert-buffer-function) | 493 (make-local-variable 'revert-buffer-function) |
495 (setq revert-buffer-function 'tar-mode-revert) | 494 (setq revert-buffer-function 'tar-mode-revert) |
495 (make-local-variable 'enable-local-variables) | |
496 (setq enable-local-variables nil) | |
496 (setq major-mode 'tar-mode) | 497 (setq major-mode 'tar-mode) |
497 (setq mode-name "Tar") | 498 (setq mode-name "Tar") |
498 (use-local-map tar-mode-map) | 499 (use-local-map tar-mode-map) |
499 (auto-save-mode 0) | 500 (auto-save-mode 0) |
500 (widen) | 501 (widen) |
503 (tar-summarize-buffer)) | 504 (tar-summarize-buffer)) |
504 (run-hooks 'tar-mode-hook) | 505 (run-hooks 'tar-mode-hook) |
505 ) | 506 ) |
506 | 507 |
507 | 508 |
509 ;; This should be converted to use a minor mode keymap. | |
510 | |
508 (defun tar-subfile-mode (p) | 511 (defun tar-subfile-mode (p) |
509 "Minor mode for editing an element of a tar-file. | 512 "Minor mode for editing an element of a tar-file. |
510 This mode redefines ^X^S to save the current buffer back into its | 513 This mode redefines C-x C-s to save the current buffer back into its |
511 associated tar-file buffer. You must save that buffer to actually | 514 associated tar-file buffer. You must save that buffer to actually |
512 save your changes to disk." | 515 save your changes to disk." |
513 (interactive "P") | 516 (interactive "P") |
514 (or (and (boundp 'tar-superior-buffer) tar-superior-buffer) | 517 (or (and (boundp 'tar-superior-buffer) tar-superior-buffer) |
515 (error "This buffer is not an element of a tar file.")) | 518 (error "This buffer is not an element of a tar file.")) |
526 ;; copy the local keymap so that we don't accidentally | 529 ;; copy the local keymap so that we don't accidentally |
527 ;; alter a keymap like 'lisp-mode-map' which is shared | 530 ;; alter a keymap like 'lisp-mode-map' which is shared |
528 ;; by all buffers in that mode. | 531 ;; by all buffers in that mode. |
529 (let ((m (current-local-map))) | 532 (let ((m (current-local-map))) |
530 (if m (use-local-map (copy-keymap m)))) | 533 (if m (use-local-map (copy-keymap m)))) |
531 (local-set-key "\^X\^S" 'tar-subfile-save-buffer) | 534 (local-set-key "\C-X\C-S" 'tar-subfile-save-buffer) |
532 ;; turn off auto-save. | 535 ;; turn off auto-save. |
533 (auto-save-mode nil) | 536 (auto-save-mode nil) |
534 (setq buffer-auto-save-file-name nil) | 537 (setq buffer-auto-save-file-name nil) |
535 (run-hooks 'tar-subfile-mode-hook)) | 538 (run-hooks 'tar-subfile-mode-hook)) |
536 (t (local-set-key "\^X\^S" 'save-buffer))) | 539 (t (local-set-key "\C-X\C-S" 'save-buffer))) |
537 ) | 540 ) |
538 | 541 |
539 | 542 |
540 (defun tar-mode-revert (&optional no-autosave no-confirm) | 543 (defun tar-mode-revert (&optional no-autosave no-confirm) |
541 "Revert this buffer and turn on tar mode again, to re-compute the | 544 "Revert this buffer and turn on tar mode again, to re-compute the |