Show
Ignore:
Timestamp:
09/30/06 09:12:06 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp

    • Property svn:ignore changed from
      *.elc
      MANIFEST
      Makefile
      Makefile.unix
      makefile
      elc.tar.gz
      cus-load.el
      finder-inf.el
      subdirs.el
      loaddefs.el
      to
      *.elc
      MANIFEST
      Makefile
      Makefile.unix
      makefile
      elc.tar.gz
      cus-load.el
      finder-inf.el
      subdirs.el
      loaddefs.el
      pre-mh-loaddefs.el-CMD
  • trunk/lisp/progmodes/ebnf2ps.el

    r4037 r4169  
    66;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> 
    77;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> 
    8 ;; Time-stamp: <2005-09-18 07:27:20 deego
     8;; Time-stamp: <2006/09/26 21:49:46 vinicius
    99;; Keywords: wp, ebnf, PostScript 
    10 ;; Version: 4.2 
    11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ 
     10;; Version: 4.3 
     11;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre 
    1212 
    1313;; This file is part of GNU Emacs. 
     
    2828;; Boston, MA 02110-1301, USA. 
    2929 
    30 (defconst ebnf-version "4.2
    31   "ebnf2ps.el, v 4.2 <2004/04/04 vinicius> 
     30(defconst ebnf-version "4.3
     31  "ebnf2ps.el, v 4.3 <2006/09/26 vinicius> 
    3232 
    3333Vinicius's last change version.  When reporting bugs, please also 
     
    7474;; chart images of Emacs buffers: 
    7575;; 
    76 ;;     ebnf-print-directory 
    77 ;;     ebnf-print-file 
    78 ;;     ebnf-print-buffer 
    79 ;;     ebnf-print-region 
    80 ;;     ebnf-spool-directory 
    81 ;;     ebnf-spool-file 
    82 ;;     ebnf-spool-buffer 
    83 ;;     ebnf-spool-region 
    84 ;;     ebnf-eps-directory 
    85 ;;     ebnf-eps-file 
    86 ;;     ebnf-eps-buffer 
    87 ;;     ebnf-eps-region 
     76;;    ebnf-print-directory 
     77;;    ebnf-print-file 
     78;;    ebnf-print-buffer 
     79;;    ebnf-print-region 
     80;;    ebnf-spool-directory 
     81;;    ebnf-spool-file 
     82;;    ebnf-spool-buffer 
     83;;    ebnf-spool-region 
     84;;    ebnf-eps-directory 
     85;;    ebnf-eps-file 
     86;;    ebnf-eps-buffer 
     87;;    ebnf-eps-region 
    8888;; 
    8989;; These commands all perform essentially the same function: they generate 
     
    9595;; PostScript image is sent to the printer (or file): 
    9696;; 
    97 ;;     print  - The PostScript image is immediately sent to the printer; 
    98 ;; 
    99 ;;     spool  - The PostScript image is saved temporarily in an Emacs buffer. 
    100 ;;              Many images may be spooled locally before printing them.  To 
    101 ;;              send the spooled images to the printer, use the command 
    102 ;;              `ebnf-despool'. 
    103 ;; 
    104 ;;     eps    - The PostScript image is immediately sent to a EPS file. 
     97;;    print  - The PostScript image is immediately sent to the printer; 
     98;; 
     99;;    spool  - The PostScript image is saved temporarily in an Emacs buffer. 
     100;;            Many images may be spooled locally before printing them.  To 
     101;;            send the spooled images to the printer, use the command 
     102;;            `ebnf-despool'. 
     103;; 
     104;;    eps    - The PostScript image is immediately sent to a EPS file. 
    105105;; 
    106106;; The spooling mechanism is the same as used by ps-print and was designed for 
     
    121121;; determines how much of the buffer is printed: 
    122122;; 
    123 ;;     directory  - Read files in the directory and print them. 
    124 ;; 
    125 ;;     file       - Read file and print it. 
    126 ;; 
    127 ;;     buffer     - Print the entire buffer. 
    128 ;; 
    129 ;;     region     - Print just the current region. 
     123;;    directory  - Read files in the directory and print them. 
     124;; 
     125;;    file       - Read file and print it. 
     126;; 
     127;;    buffer     - Print the entire buffer. 
     128;; 
     129;;    region     - Print just the current region. 
    130130;; 
    131131;; Two ebnf- command examples: 
    132132;; 
    133 ;;     ebnf-print-buffer  - translate and print the entire buffer, and send it 
    134 ;;                          immediately to the printer. 
    135 ;; 
    136 ;;     ebnf-spool-region  - translate and print just the current region, and 
    137 ;;                          spool the image in Emacs to send to the printer 
    138 ;;                          later. 
     133;;    ebnf-print-buffer  - translate and print the entire buffer, and send it 
     134;;                         immediately to the printer. 
     135;; 
     136;;    ebnf-spool-region  - translate and print just the current region, and 
     137;;                         spool the image in Emacs to send to the printer 
     138;;                         later. 
    139139;; 
    140140;; Note that `ebnf-eps-directory', `ebnf-eps-file', `ebnf-eps-buffer' and 
     
    149149;; To translate and print your buffer, type 
    150150;; 
    151 ;;        M-x ebnf-print-buffer 
     151;;    M-x ebnf-print-buffer 
    152152;; 
    153153;; or substitute one of the other four ebnf- commands.  The command will 
     
    155155;; the command a prefix argument 
    156156;; 
    157 ;;        C-u M-x ebnf-print-buffer 
     157;;    C-u M-x ebnf-print-buffer 
    158158;; 
    159159;; it will save the PostScript image to a file instead of sending it to the 
     
    163163;; `ebnf-despool': 
    164164;; 
    165 ;;        C-u M-x ebnf-despool 
     165;;    C-u M-x ebnf-despool 
    166166;; 
    167167;; When invoked this way, `ebnf-despool' will prompt you for the name of the 
     
    173173;; Any of the `ebnf-' commands can be bound to keys.  Here are some examples: 
    174174;; 
    175 ;;   (global-set-key 'f22 'ebnf-print-buffer) ;f22 is prsc 
    176 ;;   (global-set-key '(shift f22) 'ebnf-print-region) 
    177 ;;   (global-set-key '(control f22) 'ebnf-despool) 
     175;;    (global-set-key 'f22 'ebnf-print-buffer) ;f22 is prsc 
     176;;    (global-set-key '(shift f22) 'ebnf-print-region) 
     177;;    (global-set-key '(control f22) 'ebnf-despool) 
    178178;; 
    179179;; 
     
    524524;; The following table summarizes the results: 
    525525;; 
    526 ;; EPS FILE NAME    NO SORT    ASCENDING SORT    DESCENDING SORT 
    527 ;; ebnf--AA.eps     A C        A C               C A 
    528 ;; ebnf--BB.eps     C B        B C               C B 
    529 ;; ebnf--CC.eps     A C B F    A B C F           F C B A 
    530 ;; ebnf--D.eps      D          D                 D 
    531 ;; ebnf--E.eps      E          E                 E 
    532 ;; ebnf--G.eps      G          G                 G 
    533 ;; ebnf--Z.eps      Z          Z                 Z 
     526;;    EPS FILE NAME    NO SORT    ASCENDING SORT    DESCENDING SORT 
     527;;    ebnf--AA.eps     A C        A C               C A 
     528;;    ebnf--BB.eps     C B        B C               C B 
     529;;    ebnf--CC.eps     A C B F    A B C F           F C B A 
     530;;    ebnf--D.eps      D          D                 D 
     531;;    ebnf--E.eps      E          E                 E 
     532;;    ebnf--G.eps      G          G                 G 
     533;;    ebnf--Z.eps      Z          Z                 Z 
    534534;; 
    535535;; As you can see if EPS actions is not used, each single production is 
     
    692692;; 
    693693;; `ebnf-line-color'                    Specify flow line color. 
     694;; 
     695;; `ebnf-arrow-extra-width'             Specify extra width for arrow shape 
     696;;                                      drawing. 
     697;; 
     698;; `ebnf-arrow-scale'                   Specify the arrow scale. 
    694699;; 
    695700;; `ebnf-user-arrow'                    Specify a sexp for user arrow shape (a 
     
    825830;;                      be drawn the flow line in the current element. 
    826831;; 
     832;;    extra             is given by `ebnf-arrow-extra-width'. 
     833;; 
    827834;; 
    828835;;    * SPECIAL, TERMINAL and NON-TERMINAL 
     
    836843;;       :   +==============+...:............................... 
    837844;;       :   :   :      :   :   : 
    838 ;;       :   :   :      :   :   :...................... 
    839 ;;       :   :   :      :   :      } font height     
    840 ;;       :   :   :      :   :.......                 
    841 ;;       :   :   :      :          } font height / 2 
    842 ;;       :   :   :      :...........                 
    843 ;;       :   :   :                 } text width       } width 
    844 ;;       :   :   :..................                 
    845 ;;       :   :                     } font height / 2 
    846 ;;       :   :......................                 
    847 ;;       :                         } font height      } 
    848 ;;       :............................................. 
     845;;       :   :   :      :   :   :......................... 
     846;;       :   :   :      :   :      } font height         
     847;;       :   :   :      :   :.......                     
     848;;       :   :   :      :          } font height / 2     
     849;;       :   :   :      :...........                     
     850;;       :   :   :                 } text width           } width 
     851;;       :   :   :..................                     
     852;;       :   :                     } font height / 2     
     853;;       :   :......................                     
     854;;       :                         } font height + extra  } 
     855;;       :................................................. 
    849856;; 
    850857;; 
     
    977984;;       :   +================+...:............................... 
    978985;;       :   :  :  :  :   :   :   : 
    979 ;;       :   :  :  :  :   :   :   :...................... 
    980 ;;       :   :  :  :  :   :   :      } font height     
    981 ;;       :   :  :  :  :   :   :.......                 
    982 ;;       :   :  :  :  :   :          } font height / 2 
    983 ;;       :   :  :  :  :   :...........                 
    984 ;;       :   :  :  :  :              } X width         
    985 ;;       :   :  :  :  :...............                 
    986 ;;       :   :  :  :                 } font height / 2  } width 
    987 ;;       :   :  :  :..................                 
    988 ;;       :   :  :                    } text width       
    989 ;;       :   :  :.....................                 
    990 ;;       :   :                       } font height / 2 
    991 ;;       :   :........................                 
    992 ;;       :                           } font height      } 
    993 ;;       :............................................... 
     986;;       :   :  :  :  :   :   :   :.......................... 
     987;;       :   :  :  :  :   :   :      } font height         
     988;;       :   :  :  :  :   :   :.......                     
     989;;       :   :  :  :  :   :          } font height / 2     
     990;;       :   :  :  :  :   :...........                     
     991;;       :   :  :  :  :              } X width             
     992;;       :   :  :  :  :...............                     
     993;;       :   :  :  :                 } font height / 2      } width 
     994;;       :   :  :  :..................                     
     995;;       :   :  :                    } text width          
     996;;       :   :  :.....................                     
     997;;       :   :                       } font height / 2     
     998;;       :   :........................                     
     999;;       :                           } font height + extra  } 
     1000;;       :................................................... 
    9941001;; 
    9951002;; 
     
    10041011;;       :   +==================+...:............................... 
    10051012;;       :   :  :   :   :   :   :   : 
    1006 ;;       :   :  :   :   :   :   :   :...................... 
    1007 ;;       :   :  :   :   :   :   :      } font height     
    1008 ;;       :   :  :   :   :   :   :.......                 
    1009 ;;       :   :  :   :   :   :          } font height / 2 
    1010 ;;       :   :  :   :   :   :...........                 
    1011 ;;       :   :  :   :   :              } Y width         
    1012 ;;       :   :  :   :   :...............                 
    1013 ;;       :   :  :   :                  } font height      } width 
    1014 ;;       :   :  :   :...................                 
    1015 ;;       :   :  :                      } X width         
    1016 ;;       :   :  :.......................                 
    1017 ;;       :   :                         } font height / 2 
    1018 ;;       :   :..........................                 
    1019 ;;       :                             } font height      } 
    1020 ;;       :................................................. 
     1013;;       :   :  :   :   :   :   :   :.......................... 
     1014;;       :   :  :   :   :   :   :      } font height         
     1015;;       :   :  :   :   :   :   :.......                     
     1016;;       :   :  :   :   :   :          } font height / 2     
     1017;;       :   :  :   :   :   :...........                     
     1018;;       :   :  :   :   :              } Y width             
     1019;;       :   :  :   :   :...............                     
     1020;;       :   :  :   :                  } font height          } width 
     1021;;       :   :  :   :...................                     
     1022;;       :   :  :                      } X width             
     1023;;       :   :  :.......................                     
     1024;;       :   :                         } font height / 2     
     1025;;       :   :..........................                     
     1026;;       :                             } font height + extra  } 
     1027;;       :..................................................... 
    10211028;; 
    10221029;;       NOTE: If Y element is empty, it's draw nothing at Y place. 
     
    10901097;; 
    10911098;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions: 
    1092 ;;    - `ebnf-production-name-p', `ebnf-stop-on-error', 
     1099;;    - `ebnf-arrow-extra-width', `ebnf-arrow-scale', 
     1100;;      `ebnf-production-name-p', `ebnf-stop-on-error', 
    10931101;;      `ebnf-file-suffix-regexp'and `ebnf-special-show-delimiter' variables. 
    10941102;;    - `ebnf-delete-style', `ebnf-eps-file' and `ebnf-eps-directory' 
     
    19101918  :version "20" 
    19111919  :group 'ebnf2ps) 
     1920 
     1921 
     1922(defcustom ebnf-arrow-extra-width 
     1923  (if (eq ebnf-arrow-shape 'none) 
     1924      0.0 
     1925    (* (sqrt 5.0) 0.65 ebnf-line-width)) 
     1926  "*Specify extra width for arrow shape drawing. 
     1927 
     1928The extra width is used to avoid that the arrowhead and the terminal border 
     1929overlap.  It depens on `ebnf-arrow-shape' and `ebnf-line-width'." 
     1930  :type 'number 
     1931  :version "22" 
     1932  :group 'ebnf-shape) 
     1933 
     1934 
     1935(defcustom ebnf-arrow-scale 1.0 
     1936  "*Specify the arrow scale. 
     1937 
     1938Values lower than 1.0, shrink the arrow. 
     1939Values greater than 1.0, expand the arrow." 
     1940  :type 'number 
     1941  :version "22" 
     1942  :group 'ebnf-shape) 
    19121943 
    19131944 
     
    28602891 
    28612892/T HeightT HeightNT add 0.5 mul def 
    2862 /hT T 0.5 mul def 
    2863 /hT2 hT 0.5 mul def 
    2864 /hT4 hT 0.25 mul def 
     2893/hT   T 0.5 mul def 
     2894/hT2 hT 0.5 mul ArrowScale mul def 
     2895/hT4 hT 0.25 mul ArrowScale mul def 
    28652896 
    28662897/Er 0.1 def     % Error factor 
     
    29482979 Gstroke 
    29492980 moveto 
     2981 ExtraWidth 0 rmoveto 
    29502982}def 
    29512983 
     
    32463278/prepare-width 
    32473279{/width exch def 
    3248  dup stringwidth pop space add space add width exch sub 0.5 mul 
     3280 dup stringwidth pop space add space add width exch sub ExtraWidth sub 0.5 mul 
    32493281 /w exch def 
    32503282}def 
     
    48784910           ;; adjust creator comment 
    48794911           (end-of-line) 
    4880            (backward-char) 
    48814912           (insert " & ebnf2ps v" ebnf-version) 
    48824913           ;; insert ebnf settings & engine 
     
    50675098                      (ebnf-boolean ebnf-repeat-shadow)) 
    50685099              ;; miscellaneous 
     5100              (format "/ExtraWidth    %s def\n" 
     5101                      (ebnf-format-float ebnf-arrow-extra-width)) 
     5102              (format "/ArrowScale    %s def\n" 
     5103                      (ebnf-format-float ebnf-arrow-scale)) 
    50695104              (format "/DefaultWidth  %s def\n" 
    50705105                      (ebnf-format-float ebnf-default-width)) 
     
    51535188    (ebnf-node-entry  node (* height 0.5)) 
    51545189    (ebnf-node-height node height) 
    5155     (ebnf-node-width  node (+ ebnf-basic-width space 
     5190    (ebnf-node-width  node (+ ebnf-basic-width ebnf-arrow-extra-width space 
    51565191                              (* len font-width) 
    51575192                              space ebnf-basic-width)))) 
     
    51745209                                ebnf-space-R ebnf-space-R)) 
    51755210    (ebnf-node-width  repeat (+ (ebnf-node-width element) 
     5211                                ebnf-arrow-extra-width 
    51765212                                ebnf-space-R ebnf-space-R ebnf-space-R 
    51775213                                ebnf-horizontal-space 
     
    51955231    (ebnf-node-width  except (+ (ebnf-node-width factor) 
    51965232                                (ebnf-node-width element) 
     5233                                ebnf-arrow-extra-width 
    51975234                                ebnf-space-E ebnf-space-E 
    51985235                                ebnf-space-E ebnf-space-E