comparison lisp/progmodes/ebnf2ps.el @ 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 0018770bf0b3
children fc6e53c00fcf
comparison
equal deleted inserted replaced
54658:56a3cd25502c 54659:31c6392d9307
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4 ;; Free Software Foundation, Inc. 4 ;; Free Software Foundation, Inc.
5 5
6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> 6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> 7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8 ;; Time-stamp: <2004/03/28 19:56:21 vinicius> 8 ;; Time-stamp: <2004/03/30 21:49:21 vinicius>
9 ;; Keywords: wp, ebnf, PostScript 9 ;; Keywords: wp, ebnf, PostScript
10 ;; Version: 4.1 10 ;; Version: 4.1
11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ 11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
12 12
13 ;; This file is part of GNU Emacs. 13 ;; This file is part of GNU Emacs.
4760 (ebnf-insert-ebnf-prologue) 4760 (ebnf-insert-ebnf-prologue)
4761 (ps-output "\n"))))) 4761 (ps-output "\n")))))
4762 4762
4763 4763
4764 (defun ebnf-eps-finish-and-write (buffer filename) 4764 (defun ebnf-eps-finish-and-write (buffer filename)
4765 (save-excursion 4765 (when (buffer-modified-p buffer)
4766 (set-buffer buffer) 4766 (save-excursion
4767 (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width) 4767 (set-buffer buffer)
4768 ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y) 4768 (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width)
4769 ebnf-eps-max-height 4769 ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y)
4770 (+ ebnf-eps-upper-y 4770 ebnf-eps-max-height
4771 ebnf-production-vertical-space 4771 (+ ebnf-eps-upper-y
4772 ebnf-eps-max-height))) 4772 ebnf-production-vertical-space
4773 ;; prologue 4773 ebnf-eps-max-height)))
4774 (goto-char (point-min)) 4774 ;; prologue
4775 (insert 4775 (goto-char (point-min))
4776 "%!PS-Adobe-3.0 EPSF-3.0" 4776 (insert
4777 "\n%%BoundingBox: 0 0 " 4777 "%!PS-Adobe-3.0 EPSF-3.0"
4778 (format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y)) 4778 "\n%%BoundingBox: 0 0 "
4779 "\n%%Title: " filename 4779 (format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y))
4780 "\n%%CreationDate: " (format-time-string "%T %b %d %Y") 4780 "\n%%Title: " filename
4781 "\n%%Creator: " (user-full-name) " (using ebnf2ps v" ebnf-version ")" 4781 "\n%%CreationDate: " (format-time-string "%T %b %d %Y")
4782 "\n%%DocumentNeededResources: font " 4782 "\n%%Creator: " (user-full-name) " (using ebnf2ps v" ebnf-version ")"
4783 (or ebnf-fonts-required 4783 "\n%%DocumentNeededResources: font "
4784 (setq ebnf-fonts-required 4784 (or ebnf-fonts-required
4785 (mapconcat 'identity 4785 (setq ebnf-fonts-required
4786 (ps-remove-duplicates 4786 (mapconcat 'identity
4787 (mapcar 'ebnf-font-name-select 4787 (ps-remove-duplicates
4788 (list ebnf-production-font 4788 (mapcar 'ebnf-font-name-select
4789 ebnf-terminal-font 4789 (list ebnf-production-font
4790 ebnf-non-terminal-font 4790 ebnf-terminal-font
4791 ebnf-special-font 4791 ebnf-non-terminal-font
4792 ebnf-except-font 4792 ebnf-special-font
4793 ebnf-repeat-font))) 4793 ebnf-except-font
4794 "\n%%+ font "))) 4794 ebnf-repeat-font)))
4795 "\n%%Pages: 0\n%%EndComments\n\n%%BeginProlog\n" 4795 "\n%%+ font ")))
4796 ebnf-eps-prologue) 4796 "\n%%Pages: 0\n%%EndComments\n\n%%BeginProlog\n"
4797 (ebnf-insert-ebnf-prologue) 4797 ebnf-eps-prologue)
4798 (insert ebnf-eps-begin 4798 (ebnf-insert-ebnf-prologue)
4799 "\n0 " (ebnf-format-float 4799 (insert ebnf-eps-begin
4800 (- ebnf-eps-upper-y (* ebnf-font-height-P 0.7))) 4800 "\n0 " (ebnf-format-float
4801 " #ebnf2ps#begin\n") 4801 (- ebnf-eps-upper-y (* ebnf-font-height-P 0.7)))
4802 ;; epilogue 4802 " #ebnf2ps#begin\n")
4803 (goto-char (point-max)) 4803 ;; epilogue
4804 (insert ebnf-eps-end) 4804 (goto-char (point-max))
4805 ;; write file 4805 (insert ebnf-eps-end)
4806 (message "Saving...") 4806 ;; write file
4807 (setq filename (expand-file-name filename)) 4807 (message "Saving...")
4808 (let ((coding-system-for-write 'raw-text-unix)) 4808 (setq filename (expand-file-name filename))
4809 (write-region (point-min) (point-max) filename)) 4809 (let ((coding-system-for-write 'raw-text-unix))
4810 (message "Wrote %s" filename))) 4810 (write-region (point-min) (point-max) filename))
4811 (message "Wrote %s" filename))))
4811 4812
4812 4813
4813 (defun ebnf-insert-ebnf-prologue () 4814 (defun ebnf-insert-ebnf-prologue ()
4814 (insert 4815 (insert
4815 (or ebnf-settings 4816 (or ebnf-settings