changeset 54659:31c6392d9307

Write a buffer if and only if the buffer was modified.
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Wed, 31 Mar 2004 01:33:26 +0000
parents 56a3cd25502c
children 122a60d4f165
files lisp/ChangeLog lisp/progmodes/ebnf2ps.el
diffstat 2 files changed, 53 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Mar 30 08:07:41 2004 +0000
+++ b/lisp/ChangeLog	Wed Mar 31 01:33:26 2004 +0000
@@ -1,3 +1,8 @@
+2004-03-30  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* progmodes/ebnf2ps.el (ebnf-eps-finish-and-write): Write a buffer if
+	and only if the buffer was modified.
+
 2004-03-30  Kenichi Handa  <handa@m17n.org>
 
 	* international/characters.el: Delete pairs for U+2308..U+230B.
--- a/lisp/progmodes/ebnf2ps.el	Tue Mar 30 08:07:41 2004 +0000
+++ b/lisp/progmodes/ebnf2ps.el	Wed Mar 31 01:33:26 2004 +0000
@@ -5,7 +5,7 @@
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2004/03/28 19:56:21 vinicius>
+;; Time-stamp: <2004/03/30 21:49:21 vinicius>
 ;; Keywords: wp, ebnf, PostScript
 ;; Version: 4.1
 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
@@ -4762,52 +4762,53 @@
 
 
 (defun ebnf-eps-finish-and-write (buffer filename)
-  (save-excursion
-    (set-buffer buffer)
-    (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width)
-	  ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y)
-			       ebnf-eps-max-height
-			     (+ ebnf-eps-upper-y
-				ebnf-production-vertical-space
-				ebnf-eps-max-height)))
-    ;; prologue
-    (goto-char (point-min))
-    (insert
-     "%!PS-Adobe-3.0 EPSF-3.0"
-     "\n%%BoundingBox: 0 0 "
-     (format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y))
-     "\n%%Title: " filename
-     "\n%%CreationDate: " (format-time-string "%T %b %d %Y")
-     "\n%%Creator: " (user-full-name) " (using ebnf2ps v" ebnf-version ")"
-     "\n%%DocumentNeededResources: font "
-     (or ebnf-fonts-required
-	 (setq ebnf-fonts-required
-	       (mapconcat 'identity
-			  (ps-remove-duplicates
-			   (mapcar 'ebnf-font-name-select
-				   (list ebnf-production-font
-					 ebnf-terminal-font
-					 ebnf-non-terminal-font
-					 ebnf-special-font
-					 ebnf-except-font
-					 ebnf-repeat-font)))
-			  "\n%%+ font ")))
-     "\n%%Pages: 0\n%%EndComments\n\n%%BeginProlog\n"
-     ebnf-eps-prologue)
-    (ebnf-insert-ebnf-prologue)
-    (insert ebnf-eps-begin
-	    "\n0 " (ebnf-format-float
-		    (- ebnf-eps-upper-y (* ebnf-font-height-P 0.7)))
-	    " #ebnf2ps#begin\n")
-    ;; epilogue
-    (goto-char (point-max))
-    (insert ebnf-eps-end)
-    ;; write file
-    (message "Saving...")
-    (setq filename (expand-file-name filename))
-    (let ((coding-system-for-write 'raw-text-unix))
-      (write-region (point-min) (point-max) filename))
-    (message "Wrote %s" filename)))
+  (when (buffer-modified-p buffer)
+    (save-excursion
+      (set-buffer buffer)
+      (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width)
+	    ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y)
+				 ebnf-eps-max-height
+			       (+ ebnf-eps-upper-y
+				  ebnf-production-vertical-space
+				  ebnf-eps-max-height)))
+      ;; prologue
+      (goto-char (point-min))
+      (insert
+       "%!PS-Adobe-3.0 EPSF-3.0"
+       "\n%%BoundingBox: 0 0 "
+       (format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y))
+       "\n%%Title: " filename
+       "\n%%CreationDate: " (format-time-string "%T %b %d %Y")
+       "\n%%Creator: " (user-full-name) " (using ebnf2ps v" ebnf-version ")"
+       "\n%%DocumentNeededResources: font "
+       (or ebnf-fonts-required
+	   (setq ebnf-fonts-required
+		 (mapconcat 'identity
+			    (ps-remove-duplicates
+			     (mapcar 'ebnf-font-name-select
+				     (list ebnf-production-font
+					   ebnf-terminal-font
+					   ebnf-non-terminal-font
+					   ebnf-special-font
+					   ebnf-except-font
+					   ebnf-repeat-font)))
+			    "\n%%+ font ")))
+       "\n%%Pages: 0\n%%EndComments\n\n%%BeginProlog\n"
+       ebnf-eps-prologue)
+      (ebnf-insert-ebnf-prologue)
+      (insert ebnf-eps-begin
+	      "\n0 " (ebnf-format-float
+		      (- ebnf-eps-upper-y (* ebnf-font-height-P 0.7)))
+	      " #ebnf2ps#begin\n")
+      ;; epilogue
+      (goto-char (point-max))
+      (insert ebnf-eps-end)
+      ;; write file
+      (message "Saving...")
+      (setq filename (expand-file-name filename))
+      (let ((coding-system-for-write 'raw-text-unix))
+	(write-region (point-min) (point-max) filename))
+      (message "Wrote %s" filename))))
 
 
 (defun ebnf-insert-ebnf-prologue ()