Add arch taglines
[bpt/emacs.git] / lisp / progmodes / ebnf2ps.el
index b1e5344..a069b83 100644 (file)
@@ -1,12 +1,13 @@
-;;; ebnf2ps --- Translate an EBNF to a syntatic chart on PostScript
+;;; ebnf2ps.el --- translate an EBNF to a syntactic chart on PostScript
 
-;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
 
-;; Author:     Vinicius Jose Latorre <vinicius@cpqd.com.br>
+;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
-;; Keywords:   wp, ebnf, PostScript
-;; Time-stamp: <99/12/11 21:41:24 vinicius>
-;; Version:    3.1
+;; Keywords: wp, ebnf, PostScript
+;; Time-stamp: <2003/08/08 23:09:36 vinicius>
+;; Version: 3.6.1
+;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
 
 ;; This file is part of GNU Emacs.
 
@@ -25,8 +26,8 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-(defconst ebnf-version "3.1"
-  "ebnf2ps.el, v 3.1 <99/12/11 vinicius>
+(defconst ebnf-version "3.6.1"
+  "ebnf2ps.el, v 3.6.1 <2001/09/24 vinicius>
 
 Vinicius's last change version.  When reporting bugs, please also
 report the version of Emacs, if any, that ebnf2ps was running with.
@@ -43,14 +44,15 @@ Please send all bug fixes and enhancements to
 ;; Introduction
 ;; ------------
 ;;
-;; This package translates an EBNF to a syntatic chart on PostScript.
+;; This package translates an EBNF to a syntactic chart on PostScript.
 ;;
 ;; To use ebnf2ps, insert in your ~/.emacs:
 ;;
 ;;        (require 'ebnf2ps)
 ;;
-;; ebnf2ps uses ps-print package (version 3.05.1 or later), so see ps-print to
-;; know how to set options like landscape printing, page headings, margins, etc.
+;; ebnf2ps uses ps-print package (version 5.2.3 or later), so see ps-print to
+;; know how to set options like landscape printing, page headings, margins,
+;; etc.
 ;;
 ;; NOTE: ps-print zebra stripes and line number options doesn't have effect on
 ;;       ebnf2ps, they behave as it's turned off.
@@ -67,32 +69,32 @@ Please send all bug fixes and enhancements to
 ;; Using ebnf2ps
 ;; -------------
 ;;
-;; ebnf2ps provides six commands for generating PostScript syntatic chart images
-;; of Emacs buffers:
+;; ebnf2ps provides six commands for generating PostScript syntactic chart
+;; images of Emacs buffers:
 ;;
-;;        ebnf-print-buffer
-;;        ebnf-print-region
-;;        ebnf-spool-buffer
-;;        ebnf-spool-region
-;;        ebnf-eps-buffer
-;;        ebnf-eps-region
+;;     ebnf-print-buffer
+;;     ebnf-print-region
+;;     ebnf-spool-buffer
+;;     ebnf-spool-region
+;;     ebnf-eps-buffer
+;;     ebnf-eps-region
 ;;
 ;; These commands all perform essentially the same function: they generate
-;; PostScript syntatic chart images suitable for printing on a PostScript
+;; PostScript syntactic chart images suitable for printing on a PostScript
 ;; printer or displaying with GhostScript.  These commands are collectively
 ;; referred to as "ebnf- commands".
 ;;
 ;; The word "print", "spool" and "eps" in the command name determines when the
 ;; PostScript image is sent to the printer (or file):
 ;;
-;;        print  - The PostScript image is immediately sent to the printer;
+;;     print  - The PostScript image is immediately sent to the printer;
 ;;
-;;        spool  - The PostScript image is saved temporarily in an Emacs buffer.
-;;                 Many images may be spooled locally before printing them.  To
-;;                 send the spooled images to the printer, use the command
-;;                 `ebnf-despool'.
+;;     spool  - The PostScript image is saved temporarily in an Emacs buffer.
+;;              Many images may be spooled locally before printing them.  To
+;;              send the spooled images to the printer, use the command
+;;              `ebnf-despool'.
 ;;
-;;        eps    - The PostScript image is immediately sent to a EPS file.
+;;     eps    - The PostScript image is immediately sent to a EPS file.
 ;;
 ;; The spooling mechanism is the same as used by ps-print and was designed for
 ;; printing lots of small files to save paper that would otherwise be wasted on
@@ -105,24 +107,24 @@ Please send all bug fixes and enhancements to
 ;; won't accidentally quit from Emacs while you have unprinted PostScript
 ;; waiting in the spool buffer.  If you do attempt to exit with spooled
 ;; PostScript, you'll be asked if you want to print it, and if you decline,
-;; you'll be asked to confirm the exit; this is modeled on the confirmation that
-;; Emacs uses for modified buffers.
+;; you'll be asked to confirm the exit; this is modeled on the confirmation
+;; that Emacs uses for modified buffers.
 ;;
 ;; The word "buffer" or "region" in the command name determines how much of the
 ;; buffer is printed:
 ;;
-;;        buffer  - Print the entire buffer.
+;;     buffer  - Print the entire buffer.
 ;;
-;;        region  - Print just the current region.
+;;     region  - Print just the current region.
 ;;
 ;; Two ebnf- command examples:
 ;;
-;;        ebnf-print-buffer  - translate and print the entire buffer, and send
-;;                             it immediately to the printer.
+;;     ebnf-print-buffer  - translate and print the entire buffer, and send it
+;;                          immediately to the printer.
 ;;
-;;        ebnf-spool-region  - translate and print just the current region, and
-;;                             spool the image in Emacs to send to the printer
-;;                             later.
+;;     ebnf-spool-region  - translate and print just the current region, and
+;;                          spool the image in Emacs to send to the printer
+;;                          later.
 ;;
 ;; Note that `ebnf-eps-buffer' and `ebnf-eps-region' never spool the EPS image,
 ;; so they don't use the ps-print spooling mechanism.  See section "Actions in
@@ -220,7 +222,7 @@ Please send all bug fixes and enhancements to
 ;;           | "{" body [ "||" body ] "}"       ;; zero-or-more
 ;;           .
 ;;
-;;    non_terminal = "[A-Za-z\\240-\\377][!#%&'*-,0-:<>@-Z\\^-z~\\240-\\377]*".
+;;    non_terminal = "[!#%&'*-,0-:<>@-Z\\\\^-z~\\240-\\377]+".
 ;;
 ;;    terminal = "\\([^\"\\]\\|\\\\[ -~\\240-\\377]\\)+".
 ;;
@@ -257,8 +259,8 @@ Please send all bug fixes and enhancements to
 ;;    Logical  Expression              non-terminal
 ;;    "("  OR  AND  "XOR"  ")"         terminal
 ;;
-;; The line comment is controlled by `ebnf-lex-comment-char'.  The default value
-;; is ?\; (character `;').
+;; The line comment is controlled by `ebnf-lex-comment-char'.  The default
+;; value is ?\; (character `;').
 ;;
 ;; The end of production is controlled by `ebnf-lex-eop-char'.  The default
 ;; value is ?. (character `.').
@@ -332,8 +334,8 @@ Please send all bug fixes and enhancements to
 ;; Form Feed
 ;; ---------
 ;;
-;; You may use form feed (^L \014) to force a production to start on a new page,
-;; for example:
+;; You may use form feed (^L \014) to force a production to start on a new
+;; page, for example:
 ;;
 ;;    a) A = B | C.
 ;;      ^L
@@ -362,9 +364,9 @@ Please send all bug fixes and enhancements to
 ;;
 ;;    ;[EPS    open a new EPS file.  The EPS file name has the form:
 ;;                     <PREFIX><NAME>.eps
-;;             where <PREFIX> is given by variable `ebnf-eps-prefix' and <NAME>
-;;             is the string given by ;[ action comment, this string is mapped
-;;             to form a valid file name (see documentation for
+;;             where <PREFIX> is given by variable `ebnf-eps-prefix' and
+;;             <NAME> is the string given by ;[ action comment, this string is
+;;             mapped to form a valid file name (see documentation for
 ;;             `ebnf-eps-buffer' or `ebnf-eps-region').
 ;;             It has effect only during `ebnf-eps-buffer' or
 ;;             `ebnf-eps-region' execution.
@@ -406,7 +408,8 @@ Please send all bug fixes and enhancements to
 ;; Note that if ascending production sort is used, the productions A and B will
 ;; be drawn in the same line instead of C and B.
 ;;
-;; If consecutive actions occur, only the last one takes effect, so if you have:
+;; If consecutive actions occur, only the last one takes effect, so if you
+;; have:
 ;;
 ;;    A = X.
 ;;    ;<
@@ -479,10 +482,10 @@ Please send all bug fixes and enhancements to
 ;;
 ;; `ebnf-setup' returns the current setup.
 ;;
-;; `ebnf-syntax-buffer' does a syntatic analysis of your EBNF in the current
+;; `ebnf-syntax-buffer' does a syntactic analysis of your EBNF in the current
 ;; buffer.
 ;;
-;; `ebnf-syntax-region' does a syntatic analysis of your EBNF in the current
+;; `ebnf-syntax-region' does a syntactic analysis of your EBNF in the current
 ;; region.
 ;;
 ;; `ebnf-customize' activates a customization buffer for ebnf2ps options.
@@ -521,8 +524,8 @@ Please send all bug fixes and enhancements to
 ;; `ebnf-production-horizontal-space'  Specify horizontal space in points
 ;;                                     between productions.
 ;;
-;; `ebnf-production-vertical-space'    Specify vertical space in points between
-;;                                     productions.
+;; `ebnf-production-vertical-space'    Specify vertical space in points
+;;                                     between productions.
 ;;
 ;; `ebnf-justify-sequence'             Specify justification of terms in a
 ;;                                     sequence inside alternatives.
@@ -550,8 +553,8 @@ Please send all bug fixes and enhancements to
 ;;
 ;; `ebnf-non-terminal-shape'           Specify non-terminal box shape.
 ;;
-;; `ebnf-non-terminal-shadow'          Non-nil means non-terminal box will have
-;;                                     a shadow.
+;; `ebnf-non-terminal-shadow'          Non-nil means non-terminal box will
+;;                                     have a shadow.
 ;;
 ;; `ebnf-non-terminal-border-width'    Specify border width for non-terminal
 ;;                                     box.
@@ -604,15 +607,16 @@ Please send all bug fixes and enhancements to
 ;;
 ;; `ebnf-line-color'                   Specify flow line color.
 ;;
-;; `ebnf-user-arrow'                   Specify a user arrow shape (a PostScript
-;;                                     code).
+;; `ebnf-user-arrow'                   Specify a sexp for user arrow shape (a
+;;                                     PostScript code).
 ;;
 ;; `ebnf-debug-ps'                     Non-nil means to generate PostScript
 ;;                                     debug procedures.
 ;;
 ;; `ebnf-lex-comment-char'             Specify the line comment character.
 ;;
-;; `ebnf-lex-eop-char'                 Specify the end of production character.
+;; `ebnf-lex-eop-char'                 Specify the end of production
+;;                                     character.
 ;;
 ;; `ebnf-syntax'                       Specify syntax to be recognized.
 ;;
@@ -633,8 +637,8 @@ Please send all bug fixes and enhancements to
 ;;
 ;; `ebnf-ignore-empty-rule'            Non-nil means ignore empty rules.
 ;;
-;; `ebnf-optimize'                     Non-nil means optimize syntatic chart of
-;;                                     rules.
+;; `ebnf-optimize'                     Non-nil means optimize syntactic chart
+;;                                     of rules.
 ;;
 ;; To set the above options you may:
 ;;
@@ -705,10 +709,10 @@ Please send all bug fixes and enhancements to
 ;; and name this group.  So when you wish to apply these settings it's only
 ;; needed to give the name.
 ;;
-;; There is also a notion of simple inheritance of style; so if you declare that
-;; a style A inherits from a style B, all settings of B is applied first and
-;; then the settings of A is applied.  This is useful when you wish to modify
-;; some aspects of an existing style, but at same time wish to keep it
+;; There is also a notion of simple inheritance of style; so if you declare
+;; that a style A inherits from a style B, all settings of B is applied first
+;; and then the settings of A is applied.  This is useful when you wish to
+;; modify some aspects of an existing style, but at same time wish to keep it
 ;; unmodified.
 ;;
 ;; See documentation for `ebnf-style-database'.
@@ -723,8 +727,8 @@ Please send all bug fixes and enhancements to
 ;;    font height      is given by:
 ;;                     (terminal font height + non-terminal font height) / 2
 ;;
-;;    entry            is the vertical position used to know where it should be
-;;                     drawn the flow line in the current element.
+;;    entry            is the vertical position used to know where it should
+;;                     be drawn the flow line in the current element.
 ;;
 ;;
 ;;    * SPECIAL, TERMINAL and NON-TERMINAL
@@ -927,16 +931,16 @@ Please send all bug fixes and enhancements to
 ;; Internal Structures
 ;; -------------------
 ;;
-;; ebnf2ps has two passes.  The first pass does a lexical and syntatic analysis
+;; ebnf2ps has two passes.  The first pass does a lexical and syntactic analysis
 ;; of current buffer and generates an intermediate representation.  The second
-;; pass uses the intermediate representation to generate the PostScript syntatic
-;; chart.
+;; pass uses the intermediate representation to generate the PostScript
+;; syntactic chart.
 ;;
 ;; The intermediate representation is a list of vectors, the vector element
-;; represents a syntatic chart element.  Below is a vector representation for
-;; each syntatic chart element.
+;; represents a syntactic chart element.  Below is a vector representation for
+;; each syntactic chart element.
 ;;
-;; [production   WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME    PRODUCTION ACTION]
+;; [production   WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME   PRODUCTION ACTION]
 ;; [alternative  WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST]
 ;; [sequence     WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST]
 ;; [terminal     WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME    DEFAULT]
@@ -982,7 +986,7 @@ Please send all bug fixes and enhancements to
 ;; Things To Change
 ;; ----------------
 ;;
-;; . Handle situations when syntatic chart is out of paper.
+;; . Handle situations when syntactic chart is out of paper.
 ;; . Use other alphabet than ascii.
 ;; . Optimizations...
 ;;
@@ -995,29 +999,13 @@ Please send all bug fixes and enhancements to
 ;;
 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-;;; code:
+;;; Code:
 
 
 (require 'ps-print)
 
-(and (string< ps-print-version "3.05.1")
-     (error "`ebnf2ps' requires `ps-print' package version 3.05.1 or later"))
-
-
-;; temporary fix for ps-print
-(or (fboundp 'set-buffer-multibyte)
-    (defun set-buffer-multibyte (arg)
-      (setq enable-multibyte-characters arg)))
-
-(or (fboundp 'string-as-unibyte)
-    (defun string-as-unibyte (arg) arg))
-
-(or (fboundp 'string-as-multibyte)
-    (defun string-as-multibyte (arg) arg))
-
-(or (fboundp 'charset-after)
-    (defun charset-after (&optional arg)
-      (char-charset (char-after arg))))
+(and (string< ps-print-version "5.2.3")
+     (error "`ebnf2ps' requires `ps-print' package version 5.2.3 or later"))
 
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1033,7 +1021,7 @@ Please send all bug fixes and enhancements to
 
 
 (defgroup ebnf2ps nil
-  "Translate an EBNF to a syntatic chart on PostScript"
+  "Translate an EBNF to a syntactic chart on PostScript"
   :prefix "ebnf-"
   :group 'wp
   :group 'postscript)
@@ -1095,10 +1083,10 @@ Please send all bug fixes and enhancements to
   :group 'ebnf2ps)
 
 
-(defgroup ebnf-syntatic nil
-  "Syntatic customization"
+(defgroup ebnf-syntactic nil
+  "Syntactic customization"
   :prefix "ebnf-"
-  :tag "Syntatic"
+  :tag "Syntactic"
   :group 'ebnf2ps)
 
 
@@ -1515,9 +1503,10 @@ See documentation for `ebnf-non-terminal-shape'."
 
 
 (defcustom ebnf-user-arrow nil
-  "*Specify a user arrow shape (a PostScript code).
+  "*Specify a sexp for user arrow shape (a PostScript code).
 
-PostScript code should draw a right arrow.
+When evaluated, the sexp should return nil or a string containing PostScript
+code.  PostScript code should draw a right arrow.
 
 The anatomy of a right arrow is:
 
@@ -1539,25 +1528,16 @@ The anatomy of a right arrow is:
    :               } hT2  }
    :.......................
 
-Where `hT', `hT2' and `hT4' are predefined PostScript variable names that can be
-used to generate your own arrow.  As these variables are used along PostScript
-execution, *DON'T* modify the values of them.  Instead, copy the values, if you
-need to modify them.
+Where `hT', `hT2' and `hT4' are predefined PostScript variable names that can
+be used to generate your own arrow.  As these variables are used along
+PostScript execution, *DON'T* modify the values of them.  Instead, copy the
+values, if you need to modify them.
 
 The relation between these variables is: hT = 2 * hT2 = 4 * hT4.
 
 The variable `ebnf-user-arrow' is only used when `ebnf-arrow-shape' is set to
-symbol `user'.
-
-See function `ebnf-user-arrow' for valid values and how values are processed."
-  :type '(radio :tag "User Arrow Shape"
-               (const nil)
-               string
-               symbol
-               (repeat :tag "List"
-                       (radio string
-                              symbol
-                              sexp)))
+symbol `user'."
+  :type '(sexp :tag "User Arrow Shape")
   :group 'ebnf-shape)
 
 
@@ -1588,7 +1568,7 @@ Valid values are:
 Any other value is treated as `ebnf'."
   :type '(radio :tag "Syntax"
                (const ebnf) (const iso-ebnf) (const yacc))
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-lex-comment-char ?\;
@@ -1596,7 +1576,7 @@ Any other value is treated as `ebnf'."
 
 It's used only when `ebnf-syntax' is `ebnf'."
   :type 'character
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-lex-eop-char ?.
@@ -1604,7 +1584,7 @@ It's used only when `ebnf-syntax' is `ebnf'."
 
 It's used only when `ebnf-syntax' is `ebnf'."
   :type 'character
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-terminal-regexp nil
@@ -1617,7 +1597,7 @@ terminal name; terminal name may also be enclosed by `\"'.
 It's used only when `ebnf-syntax' is `ebnf'."
   :type '(radio :tag "Terminal Name"
                (const nil) regexp)
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-case-fold-search nil
@@ -1626,7 +1606,7 @@ It's used only when `ebnf-syntax' is `ebnf'."
 It's only used when `ebnf-terminal-regexp' is non-nil and when `ebnf-syntax' is
 `ebnf'."
   :type 'boolean
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-iso-alternative-p nil
@@ -1644,7 +1624,7 @@ This variable affects the following symbol set:
       }    ==>   :)
       ;    ==>   ."
   :type 'boolean
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-iso-normalize-p nil
@@ -1655,7 +1635,7 @@ single space, so \"A  B   C\" is normalized to  \"A B C\".
 
 It's only used when `ebnf-syntax' is `iso-ebnf'."
   :type 'boolean
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-eps-prefix "ebnf--"
@@ -1729,7 +1709,7 @@ when executing ebnf2ps, set `ebnf-use-float-format' to nil."
 
 It's only used when `ebnf-syntax' is `yacc'."
   :type 'boolean
-  :group 'ebnf-syntatic)
+  :group 'ebnf-syntactic)
 
 
 (defcustom ebnf-ignore-empty-rule nil
@@ -1742,7 +1722,7 @@ middle action rule."
 
 
 (defcustom ebnf-optimize nil
-  "*Non-nil means optimize syntatic chart of rules.
+  "*Non-nil means optimize syntactic chart of rules.
 
 The following optimizations are done:
 
@@ -1784,7 +1764,7 @@ The above optimizations are specially useful when `ebnf-syntax' is `yacc'."
 
 ;;;###autoload
 (defun ebnf-print-buffer (&optional filename)
-  "Generate and print a PostScript syntatic chart image of the buffer.
+  "Generate and print a PostScript syntactic chart image of the buffer.
 
 When called with a numeric prefix argument (C-u), prompts the user for
 the name of a file to save the PostScript image in, instead of sending
@@ -1800,7 +1780,7 @@ number, prompt the user for the name of the file to save in."
 
 ;;;###autoload
 (defun ebnf-print-region (from to &optional filename)
-  "Generate and print a PostScript syntatic chart image of the region.
+  "Generate and print a PostScript syntactic chart image of the region.
 Like `ebnf-print-buffer', but prints just the current region."
   (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
   (run-hooks 'ebnf-hook)
@@ -1810,7 +1790,7 @@ Like `ebnf-print-buffer', but prints just the current region."
 
 ;;;###autoload
 (defun ebnf-spool-buffer ()
-  "Generate and spool a PostScript syntatic chart image of the buffer.
+  "Generate and spool a PostScript syntactic chart image of the buffer.
 Like `ebnf-print-buffer' except that the PostScript image is saved in a
 local buffer to be sent to the printer later.
 
@@ -1821,7 +1801,7 @@ Use the command `ebnf-despool' to send the spooled images to the printer."
 
 ;;;###autoload
 (defun ebnf-spool-region (from to)
-  "Generate a PostScript syntatic chart image of the region and spool locally.
+  "Generate a PostScript syntactic chart image of the region and spool locally.
 Like `ebnf-spool-buffer', but spools just the current region.
 
 Use the command `ebnf-despool' to send the spooled images to the printer."
@@ -1831,7 +1811,7 @@ Use the command `ebnf-despool' to send the spooled images to the printer."
 
 ;;;###autoload
 (defun ebnf-eps-buffer ()
-  "Generate a PostScript syntatic chart image of the buffer in a EPS file.
+  "Generate a PostScript syntactic chart image of the buffer in a EPS file.
 
 Indeed, for each production is generated a EPS file.
 The EPS file name has the following form:
@@ -1853,7 +1833,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
 
 ;;;###autoload
 (defun ebnf-eps-region (from to)
-  "Generate a PostScript syntatic chart image of the region in a EPS file.
+  "Generate a PostScript syntactic chart image of the region in a EPS file.
 
 Indeed, for each production is generated a EPS file.
 The EPS file name has the following form:
@@ -1880,14 +1860,14 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
 
 ;;;###autoload
 (defun ebnf-syntax-buffer ()
-  "Does a syntatic analysis of the current buffer."
+  "Does a syntactic analysis of the current buffer."
   (interactive)
   (ebnf-syntax-region (point-min) (point-max)))
 
 
 ;;;###autoload
 (defun ebnf-syntax-region (from to)
-  "Does a syntatic analysis of a region."
+  "Does a syntactic analysis of a region."
   (interactive "r")
   (ebnf-generate-region from to nil))
 
@@ -1901,6 +1881,8 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
   "Return the current ebnf2ps setup."
   (format
    "
+;;; ebnf2ps.el version %s
+
 \(setq ebnf-special-font                %s
       ebnf-special-shape               %s
       ebnf-special-shadow              %S
@@ -1953,7 +1935,10 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
       ebnf-yac-ignore-error-recovery   %S
       ebnf-ignore-empty-rule           %S
       ebnf-optimize                    %S)
+
+;;; ebnf2ps.el - end of settings
 "
+   ebnf-version
    (ps-print-quote ebnf-special-font)
    (ps-print-quote ebnf-special-shape)
    ebnf-special-shadow
@@ -2158,8 +2143,8 @@ Each element has the following form:
 CUSTOM is a symbol name style.
 INHERITS is a symbol name style from which the current style inherits the
 context.  If INHERITS is nil, means that there is no inheritance.
-VAR is a valid ebnf2ps symbol custom variable.  See `ebnf-style-custom-list' for
-valid symbol variable.
+VAR is a valid ebnf2ps symbol custom variable.  See `ebnf-style-custom-list'
+for valid symbol variable.
 VALUE is a sexp which it'll be evaluated to set the value to VAR.  So, don't
 forget to quote symbols and constant lists.  See `default' style for an
 example.
@@ -2274,11 +2259,6 @@ It returns the old style symbol."
 ;; Internal variables
 
 
-(make-local-hook 'ebnf-hook)
-(make-local-hook 'ebnf-production-hook)
-(make-local-hook 'ebnf-page-hook)
-
-
 (defvar ebnf-eps-buffer-name " *EPS*")
 (defvar ebnf-parser-func     nil)
 (defvar ebnf-eps-executing   nil)
@@ -3569,7 +3549,7 @@ end
 
 /#ebnf2ps#end{showpage #ebnf2ps#save restore end}def
 
-%%EndPrologue
+%%EndProlog
 "
   "EBNF EPS begin")
 
@@ -3598,7 +3578,7 @@ end
 
 (defun ebnf-format-color (format-str color default)
   (let* ((the-color (or color default))
-        (rgb (mapcar 'ps-color-value (ps-color-values the-color))))
+        (rgb (ps-color-scale the-color)))
     (format format-str
            (concat "["
                    (ebnf-format-float (nth 0 rgb) (nth 1 rgb) (nth 2 rgb))
@@ -3614,6 +3594,10 @@ end
           (format ebnf-message-float value)))
 
 
+(defvar ebnf-total 0)
+(defvar ebnf-nprod 0)
+
+
 (defsubst ebnf-message-info (messag)
   (message "%s...%3d%%"
           messag
@@ -3729,7 +3713,8 @@ end
                    prod-name   (ebnf-node-name prod)
                    prod-width  (ebnf-max-width prod)
                    prod-height (ebnf-node-height prod)
-                   horizontal  (memq (ebnf-node-action prod) ebnf-action-list))
+                   horizontal  (memq (ebnf-node-action prod)
+                                     ebnf-action-list))
              ;; generate production in EPS buffer
              (save-excursion
                (set-buffer eps-buffer)
@@ -3833,8 +3818,6 @@ end
 
 (defvar ebnf-tree      nil)
 (defvar ebnf-direction "R")
-(defvar ebnf-total     0)
-(defvar ebnf-nprod     0)
 
 
 (defun ebnf-generate-postscript (from to)
@@ -4119,6 +4102,18 @@ end
 ;; Internal functions
 
 
+;; function `ebnf-range-regexp' is used to avoid a bug of `skip-chars-forward'
+;; on version 20.4.1, that is, it doesn't accept ranges like "\240-\377" (or
+;; "\177-\237"), but it accepts the character sequence from \240 to \377 (or
+;; from \177 to \237).  It seems that version 20.7 has the same problem.
+(defun ebnf-range-regexp (prefix from to)
+  (let (str)
+    (while (<= from to)
+      (setq str  (concat str (char-to-string from))
+           from (1+ from)))
+    (concat prefix str)))
+
+
 (defvar ebnf-map-name
   (let ((map (make-vector 256 ?\_)))
     (mapcar #'(lambda (char)
@@ -4170,7 +4165,7 @@ end
      (gen-func
       nil)
      (t
-      (message "EBNF syntatic analysis: NO ERRORS.")))))
+      (message "EBNF syntactic analysis: NO ERRORS.")))))
 
 
 (defun ebnf-parse-and-sort (start)
@@ -4273,7 +4268,7 @@ end
 
 
 (defun ebnf-begin-job ()
-  (ps-printing-region nil)
+  (ps-printing-region nil nil nil)
   (if ebnf-use-float-format
       (setq ebnf-format-float  "%1.3f"
            ebnf-message-float "%3.2f")
@@ -4365,7 +4360,7 @@ end
           (insert " & ebnf2ps v" ebnf-version)
           ;; insert ebnf settings & engine
           (goto-char (point-max))
-          (search-backward "\n%%EndPrologue\n")
+          (search-backward "\n%%EndProlog\n")
           (ebnf-insert-ebnf-prologue)
           (ps-output "\n")))))
 
@@ -4386,23 +4381,22 @@ end
      "\n%%BoundingBox: 0 0 "
      (format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y))
      "\n%%Title: " filename
-     "\n%%CreationDate: " (time-stamp-hh:mm:ss) " " (time-stamp-mon-dd-yyyy)
+     "\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
-              (let ((fonts (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)))))
-                (concat (car fonts)
-                        (and (cdr fonts) "\n%%+ font ")
-                        (mapconcat 'identity (cdr fonts) "\n%%+ font ")))))
-     "\n%%Pages: 0\n%%EndComments\n\n%%BeginPrologue\n"
+              (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
@@ -4564,57 +4558,14 @@ end
                      (ebnf-shape-value ebnf-chart-shape
                                        ebnf-terminal-shape-alist))
              (format "/UserArrow{%s}def\n"
-                     (ebnf-user-arrow ebnf-user-arrow))
+                     (let ((arrow (eval ebnf-user-arrow)))
+                       (if (stringp arrow)
+                           arrow
+                         "")))
              "\n% === end   EBNF settings\n\n"
              (and ebnf-debug-ps ebnf-debug))))
    ebnf-prologue))
 
-
-(defun ebnf-user-arrow (user-arrow)
-  "Return a user arrow shape from USER-ARROW (a PostScript code).
-
-This function is only called when `ebnf-arrow-shape' is set to symbol `user'.
-
-If is a string, should be a PostScript procedure body.
-If is a variable symbol, should contain a string.
-If is a function symbol, it is called and the result is applied recursively.
-If is a cons and car is a function symbol, it is called as:
-   (funcall (car cons) (cdr cons))
-and the result is applied recursively.
-If is a cons and car is not a function symbol, it is applied recursively on
-car and cdr, and the results are concatened as:
-   (concat RESULT-FROM-CAR \" \" RESULT-FROM-CDR)
-If is a list and car is a function symbol, it is called as:
-   (apply (car list) (cdr list))
-and the result is applied recursively.
-If is a list and car is not a function symbol, it is applied recursively on
-each element and the resulting list is concatened as:
-   (mapconcat 'identity RESULTING-LIST \" \")
-Otherwise, it is treated as an empty string."
-  (cond
-   ((null user-arrow)
-    "")
-   ((stringp user-arrow)
-    user-arrow)
-   ((and (symbolp user-arrow) (fboundp user-arrow))
-    (ebnf-user-arrow (funcall user-arrow)))
-   ((and (symbolp user-arrow) (boundp user-arrow))
-    (ebnf-user-arrow (symbol-value user-arrow)))
-   ((consp user-arrow)
-    (if (and (symbolp (car user-arrow)) (fboundp (car user-arrow)))
-       (ebnf-user-arrow (funcall (car user-arrow) (cdr user-arrow)))
-      (concat (ebnf-user-arrow (car user-arrow))
-             " "
-             (ebnf-user-arrow (cdr user-arrow)))))
-   ((listp user-arrow)
-    (if (and (symbolp (car user-arrow))
-            (fboundp (car user-arrow)))
-       (ebnf-user-arrow (apply (car user-arrow) (cdr user-arrow)))
-      (mapconcat 'ebnf-user-arrow user-arrow " ")))
-   (t
-    "")
-   ))
-
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Adjusting dimensions
@@ -4914,7 +4865,9 @@ Otherwise, it is treated as an empty string."
 ;; [sequence width-fun dim-fun entry height width list]
 (defun ebnf-sequence-width (sequence width)
   (ebnf-node-list sequence
-                 (ebnf-justify-list sequence (ebnf-node-list sequence) width)))
+                 (ebnf-justify-list sequence
+                                    (ebnf-node-list sequence)
+                                    width)))
 
 
 (defun ebnf-justify-list (node seq width)
@@ -5005,14 +4958,19 @@ Otherwise, it is treated as an empty string."
      (point))))
 
 
+;; replace the range "\240-\377" (see `ebnf-range-regexp').
+(defconst ebnf-8-bit-chars (ebnf-range-regexp "" ?\240 ?\377))
+
+
 (defun ebnf-string (chars eos-char kind)
   (forward-char)
   (buffer-substring-no-properties
    (point)
    (progn
-     (skip-chars-forward (concat chars "\240-\377") ebnf-limit)
+     ;;(skip-chars-forward (concat chars "\240-\377") ebnf-limit)
+     (skip-chars-forward (concat chars ebnf-8-bit-chars) ebnf-limit)
      (if (or (eobp) (/= (following-char) eos-char))
-        (error "Illegal %s: missing `%c'." kind eos-char)
+        (error "Illegal %s: missing `%c'" kind eos-char)
        (forward-char)
        (1- (point))))))
 
@@ -5030,7 +4988,7 @@ Otherwise, it is treated as an empty string."
       (goto-char (+ (point) n 1))))
   (if (= (preceding-char) ?\")
       (1- (point))
-    (error "Missing `\"'.")))
+    (error "Missing `\"'")))
 
 
 (defun ebnf-trim-right (str)
@@ -5217,7 +5175,8 @@ Otherwise, it is treated as an empty string."
                ;; ( A | B | EMPTY )-  ==> A | B
                ((and (null exception)
                      (eq kind 'ebnf-generate-alternative)
-                     (eq (ebnf-node-kind (car (last (ebnf-node-list element))))
+                     (eq (ebnf-node-kind
+                          (car (last (ebnf-node-list element))))
                          'ebnf-generate-empty))
                 (let ((elt (ebnf-node-list element))
                       bef)
@@ -5326,7 +5285,7 @@ Otherwise, it is treated as an empty string."
   "Eliminate empty rules.")
 
 (autoload 'ebnf-optimize              "ebnf-otz"
-  "Syntatic chart optimizer.")
+  "Syntactic chart optimizer.")
 
 (autoload 'ebnf-otz-initialize        "ebnf-otz"
   "Initialize optimizer.")
@@ -5337,5 +5296,5 @@ Otherwise, it is treated as an empty string."
 
 (provide 'ebnf2ps)
 
-
+;;; arch-tag: 148bc8af-5398-468b-b922-eeb7afef3e4f
 ;;; ebnf2ps.el ends here