aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-12-30 21:59:52 +0000
committerStefan Monnier2008-12-30 21:59:52 +0000
commit19eb68d04b87d468df765da8b0fa2d9d2ad2322f (patch)
treecea6c94f76f29082a6a51c1af91d76eb17ec01e2
parent3fef330a88cc6617ac266b1077ada85fdd765996 (diff)
downloademacs-19eb68d04b87d468df765da8b0fa2d9d2ad2322f.tar.gz
emacs-19eb68d04b87d468df765da8b0fa2d9d2ad2322f.zip
(tar-data-swapped): New var.
(tar-data-swapped-p, tar-swap-data): Use it instead of buffer-swapped-with. (tar-write-region-annotate): Re-add (partial undo of last change). (tar-mode): Use it again (partial undo as well).
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/tar-mode.el37
2 files changed, 41 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 11c02158fdb..a172cd5d531 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12008-12-30 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * tar-mode.el (tar-data-swapped): New var.
4 (tar-data-swapped-p, tar-swap-data):
5 Use it instead of buffer-swapped-with.
6 (tar-write-region-annotate): Re-add (partial undo of last change).
7 (tar-mode): Use it again (partial undo as well).
8
12008-12-30 Ed Swarthout <Ed.Swarthout@hwdebug.com> (tiny change) 92008-12-30 Ed Swarthout <Ed.Swarthout@hwdebug.com> (tiny change)
2 10
3 * textmodes/table.el (table-capture): Fix symbol quoting typo. 11 * textmodes/table.el (table-capture): Fix symbol quoting typo.
@@ -7,8 +15,7 @@
7 * follow.el (follow-select-if-visible): Improve the check for the 15 * follow.el (follow-select-if-visible): Improve the check for the
8 last line of the window. 16 last line of the window.
9 (follow-post-command-hook): Perform redisplay in more 17 (follow-post-command-hook): Perform redisplay in more
10 circumstances, to avoid getting point stuck on partially visible 18 circumstances, to avoid getting point stuck on partially visible lines.
11 lines.
12 19
132008-12-30 Chong Yidong <cyd@stupidchicken.com> 202008-12-30 Chong Yidong <cyd@stupidchicken.com>
14 21
@@ -28,8 +35,8 @@
28 35
292008-12-30 Andreas Schwab <schwab@suse.de> 362008-12-30 Andreas Schwab <schwab@suse.de>
30 37
31 * server.el (server-running-p): Remove interactive spec. Fix 38 * server.el (server-running-p): Remove interactive spec.
32 regexp. 39 Fix regexp.
33 40
342008-12-30 Chong Yidong <cyd@stupidchicken.com> 412008-12-30 Chong Yidong <cyd@stupidchicken.com>
35 42
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index ba4ded36a83..f743a80f2b1 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -159,9 +159,20 @@ This information is useful, but it takes screen space away from file names."
159(defvar tar-data-buffer nil "Buffer that holds the actual raw tar bytes.") 159(defvar tar-data-buffer nil "Buffer that holds the actual raw tar bytes.")
160(make-variable-buffer-local 'tar-data-buffer) 160(make-variable-buffer-local 'tar-data-buffer)
161 161
162(defvar tar-data-swapped nil
163 "If non-nil, `tar-data-buffer' indeed holds raw tar bytes.")
164(make-variable-buffer-local 'tar-data-swapped)
165
162(defun tar-data-swapped-p () 166(defun tar-data-swapped-p ()
163 "Return non-nil if the tar-data is in `tar-data-buffer'." 167 "Return non-nil if the tar-data is in `tar-data-buffer'."
164 (buffer-live-p buffer-swapped-with)) 168 (and (buffer-live-p tar-data-buffer)
169 ;; Sanity check to try and make sure tar-data-swapped tracks the swap
170 ;; state correctly: the raw data is expected to be always larger than
171 ;; the summary.
172 (progn
173 (assert (eq tar-data-swapped
174 (> (buffer-size tar-data-buffer) (buffer-size))))
175 tar-data-swapped)))
165 176
166(defun tar-swap-data () 177(defun tar-swap-data ()
167 "Swap buffer contents between current buffer and `tar-data-buffer'. 178 "Swap buffer contents between current buffer and `tar-data-buffer'.
@@ -169,11 +180,10 @@ Preserve the modified states of the buffers and set `buffer-swapped-with'."
169 (let ((data-buffer-modified-p (buffer-modified-p tar-data-buffer)) 180 (let ((data-buffer-modified-p (buffer-modified-p tar-data-buffer))
170 (current-buffer-modified-p (buffer-modified-p))) 181 (current-buffer-modified-p (buffer-modified-p)))
171 (buffer-swap-text tar-data-buffer) 182 (buffer-swap-text tar-data-buffer)
172 (setq buffer-swapped-with 183 (setq tar-data-swapped (not tar-data-swapped))
173 (if buffer-swapped-with nil tar-data-buffer)) 184 (restore-buffer-modified-p data-buffer-modified-p)
174 (set-buffer-modified-p data-buffer-modified-p)
175 (with-current-buffer tar-data-buffer 185 (with-current-buffer tar-data-buffer
176 (set-buffer-modified-p current-buffer-modified-p)))) 186 (restore-buffer-modified-p current-buffer-modified-p))))
177 187
178;;; down to business. 188;;; down to business.
179 189
@@ -268,7 +278,8 @@ write-date, checksum, link-type, and link-name."
268 ;; -1 so as to strip the terminating 0 byte. 278 ;; -1 so as to strip the terminating 0 byte.
269 (name (buffer-substring pos (+ pos size -1))) 279 (name (buffer-substring pos (+ pos size -1)))
270 (descriptor (tar-header-block-tokenize 280 (descriptor (tar-header-block-tokenize
271 (+ pos (tar-roundup-512 size)) coding))) 281 (+ pos (tar-roundup-512 size))
282 coding)))
272 (cond 283 (cond
273 ((eq link-p (- ?L ?0)) ;GNUTYPE_LONGNAME. 284 ((eq link-p (- ?L ?0)) ;GNUTYPE_LONGNAME.
274 (setf (tar-header-name descriptor) name)) 285 (setf (tar-header-name descriptor) name))
@@ -626,6 +637,7 @@ See also: variables `tar-update-datestamp' and `tar-anal-blocksize'.
626 ;; buffer for the summary. 637 ;; buffer for the summary.
627 (assert (not (tar-data-swapped-p))) 638 (assert (not (tar-data-swapped-p)))
628 (set (make-local-variable 'revert-buffer-function) 'tar-mode-revert) 639 (set (make-local-variable 'revert-buffer-function) 'tar-mode-revert)
640 (add-hook 'write-region-annotate-functions 'tar-write-region-annotate nil t)
629 (add-hook 'kill-buffer-hook 'tar-mode-kill-buffer-hook nil t) 641 (add-hook 'kill-buffer-hook 'tar-mode-kill-buffer-hook nil t)
630 (add-hook 'change-major-mode-hook 'tar-change-major-mode-hook nil t) 642 (add-hook 'change-major-mode-hook 'tar-change-major-mode-hook nil t)
631 ;; Tar data is made of bytes, not chars. 643 ;; Tar data is made of bytes, not chars.
@@ -1199,7 +1211,18 @@ Leaves the region wide."
1199 (delete-region goal-end (point-max)) 1211 (delete-region goal-end (point-max))
1200 (goto-char (point-max)) 1212 (goto-char (point-max))
1201 (insert (make-string (- goal-end (point-max)) ?\0)))))))) 1213 (insert (make-string (- goal-end (point-max)) ?\0))))))))
1202 1214
1215
1216;; Used in write-region-annotate-functions to write tar-files out correctly.
1217(defun tar-write-region-annotate (start end)
1218 ;; When called from write-file (and auto-save), `start' is nil.
1219 ;; When called from M-x write-region, we assume the user wants to save
1220 ;; (part of) the summary, not the tar data.
1221 (unless (or start (not (tar-data-swapped-p)))
1222 (tar-clear-modification-flags)
1223 (set-buffer tar-data-buffer)
1224 nil))
1225
1203(provide 'tar-mode) 1226(provide 'tar-mode)
1204 1227
1205;; arch-tag: 8a585a4a-340e-42c2-89e7-d3b1013a4b78 1228;; arch-tag: 8a585a4a-340e-42c2-89e7-d3b1013a4b78