[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp ChangeLog tar-mode.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] emacs/lisp ChangeLog tar-mode.el |
Date: |
Tue, 30 Dec 2008 21:59:55 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 08/12/30 21:59:55
Modified files:
lisp : ChangeLog tar-mode.el
Log message:
(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).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.15014&r2=1.15015
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/tar-mode.el?cvsroot=emacs&r1=1.131&r2=1.132
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.15014
retrieving revision 1.15015
diff -u -b -r1.15014 -r1.15015
--- ChangeLog 30 Dec 2008 16:36:01 -0000 1.15014
+++ ChangeLog 30 Dec 2008 21:59:52 -0000 1.15015
@@ -1,3 +1,11 @@
+2008-12-30 Stefan Monnier <address@hidden>
+
+ * tar-mode.el (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).
+
2008-12-30 Ed Swarthout <address@hidden> (tiny change)
* textmodes/table.el (table-capture): Fix symbol quoting typo.
@@ -7,8 +15,7 @@
* follow.el (follow-select-if-visible): Improve the check for the
last line of the window.
(follow-post-command-hook): Perform redisplay in more
- circumstances, to avoid getting point stuck on partially visible
- lines.
+ circumstances, to avoid getting point stuck on partially visible lines.
2008-12-30 Chong Yidong <address@hidden>
@@ -28,8 +35,8 @@
2008-12-30 Andreas Schwab <address@hidden>
- * server.el (server-running-p): Remove interactive spec. Fix
- regexp.
+ * server.el (server-running-p): Remove interactive spec.
+ Fix regexp.
2008-12-30 Chong Yidong <address@hidden>
Index: tar-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/tar-mode.el,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -b -r1.131 -r1.132
--- tar-mode.el 26 Dec 2008 16:38:04 -0000 1.131
+++ tar-mode.el 30 Dec 2008 21:59:54 -0000 1.132
@@ -159,9 +159,20 @@
(defvar tar-data-buffer nil "Buffer that holds the actual raw tar bytes.")
(make-variable-buffer-local 'tar-data-buffer)
+(defvar tar-data-swapped nil
+ "If non-nil, `tar-data-buffer' indeed holds raw tar bytes.")
+(make-variable-buffer-local 'tar-data-swapped)
+
(defun tar-data-swapped-p ()
"Return non-nil if the tar-data is in `tar-data-buffer'."
- (buffer-live-p buffer-swapped-with))
+ (and (buffer-live-p tar-data-buffer)
+ ;; Sanity check to try and make sure tar-data-swapped tracks the swap
+ ;; state correctly: the raw data is expected to be always larger than
+ ;; the summary.
+ (progn
+ (assert (eq tar-data-swapped
+ (> (buffer-size tar-data-buffer) (buffer-size))))
+ tar-data-swapped)))
(defun tar-swap-data ()
"Swap buffer contents between current buffer and `tar-data-buffer'.
@@ -169,11 +180,10 @@
(let ((data-buffer-modified-p (buffer-modified-p tar-data-buffer))
(current-buffer-modified-p (buffer-modified-p)))
(buffer-swap-text tar-data-buffer)
- (setq buffer-swapped-with
- (if buffer-swapped-with nil tar-data-buffer))
- (set-buffer-modified-p data-buffer-modified-p)
+ (setq tar-data-swapped (not tar-data-swapped))
+ (restore-buffer-modified-p data-buffer-modified-p)
(with-current-buffer tar-data-buffer
- (set-buffer-modified-p current-buffer-modified-p))))
+ (restore-buffer-modified-p current-buffer-modified-p))))
;;; down to business.
@@ -268,7 +278,8 @@
;; -1 so as to strip the terminating 0 byte.
(name (buffer-substring pos (+ pos size -1)))
(descriptor (tar-header-block-tokenize
- (+ pos (tar-roundup-512 size)) coding)))
+ (+ pos (tar-roundup-512 size))
+ coding)))
(cond
((eq link-p (- ?L ?0)) ;GNUTYPE_LONGNAME.
(setf (tar-header-name descriptor) name))
@@ -626,6 +637,7 @@
;; buffer for the summary.
(assert (not (tar-data-swapped-p)))
(set (make-local-variable 'revert-buffer-function) 'tar-mode-revert)
+ (add-hook 'write-region-annotate-functions 'tar-write-region-annotate nil t)
(add-hook 'kill-buffer-hook 'tar-mode-kill-buffer-hook nil t)
(add-hook 'change-major-mode-hook 'tar-change-major-mode-hook nil t)
;; Tar data is made of bytes, not chars.
@@ -1200,6 +1212,17 @@
(goto-char (point-max))
(insert (make-string (- goal-end (point-max)) ?\0))))))))
+
+;; Used in write-region-annotate-functions to write tar-files out correctly.
+(defun tar-write-region-annotate (start end)
+ ;; When called from write-file (and auto-save), `start' is nil.
+ ;; When called from M-x write-region, we assume the user wants to save
+ ;; (part of) the summary, not the tar data.
+ (unless (or start (not (tar-data-swapped-p)))
+ (tar-clear-modification-flags)
+ (set-buffer tar-data-buffer)
+ nil))
+
(provide 'tar-mode)
;; arch-tag: 8a585a4a-340e-42c2-89e7-d3b1013a4b78