aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorVinicius Jose Latorre2006-09-27 01:21:07 +0000
committerVinicius Jose Latorre2006-09-27 01:21:07 +0000
commited0aa46c73f65aebdc3f7597c2bedff6bf1adcdc (patch)
tree744a0c38a7e19771205fe8e18b35c084e378cd5c /lisp
parentabff631426870618f0743ed56ed788ea2e69c981 (diff)
downloademacs-ed0aa46c73f65aebdc3f7597c2bedff6bf1adcdc.tar.gz
emacs-ed0aa46c73f65aebdc3f7597c2bedff6bf1adcdc.zip
Implement arrow spacing and scaling. (v4.3)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/progmodes/ebnf2ps.el223
2 files changed, 139 insertions, 93 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ca56347c6cb..5f06baba448 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12006-09-26 Vinicius Jose Latorre <viniciusjl@ig.com.br>
2
3 * progmode/ebnf2ps.el: Doc fix. Implement arrow spacing and scaling.
4 (ebnf-version): New version 4.3.
5 (ebnf-arrow-extra-width, ebnf-arrow-scale): New options.
6 (ebnf-prologue): Adjust PostScript programming.
7 (ebnf-begin-file, ebnf-insert-ebnf-prologue, ebnf-terminal-dimension1)
8 (ebnf-repeat-dimension, ebnf-except-dimension): Adjust code.
9
12006-09-26 Stefan Monnier <monnier@iro.umontreal.ca> 102006-09-26 Stefan Monnier <monnier@iro.umontreal.ca>
2 11
3 * jit-lock.el (jit-lock-force-redisplay): Rename from 12 * jit-lock.el (jit-lock-force-redisplay): Rename from
diff --git a/lisp/progmodes/ebnf2ps.el b/lisp/progmodes/ebnf2ps.el
index 5cde775acc5..9f27c8a60f1 100644
--- a/lisp/progmodes/ebnf2ps.el
+++ b/lisp/progmodes/ebnf2ps.el
@@ -5,9 +5,9 @@
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: <2006/09/15 18:58:18 vinicius> 8;; Time-stamp: <2006/09/26 21:49:46 vinicius>
9;; Keywords: wp, ebnf, PostScript 9;; Keywords: wp, ebnf, PostScript
10;; Version: 4.2 10;; Version: 4.3
11;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre 11;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
12 12
13;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
@@ -27,8 +27,8 @@
27;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 27;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28;; Boston, MA 02110-1301, USA. 28;; Boston, MA 02110-1301, USA.
29 29
30(defconst ebnf-version "4.2" 30(defconst ebnf-version "4.3"
31 "ebnf2ps.el, v 4.2 <2004/04/04 vinicius> 31 "ebnf2ps.el, v 4.3 <2006/09/26 vinicius>
32 32
33Vinicius's last change version. When reporting bugs, please also 33Vinicius's last change version. When reporting bugs, please also
34report the version of Emacs, if any, that ebnf2ps was running with. 34report the version of Emacs, if any, that ebnf2ps was running with.
@@ -73,18 +73,18 @@ Please send all bug fixes and enhancements to
73;; ebnf2ps provides the following commands for generating PostScript syntactic 73;; ebnf2ps provides the following commands for generating PostScript syntactic
74;; chart images of Emacs buffers: 74;; chart images of Emacs buffers:
75;; 75;;
76;; ebnf-print-directory 76;; ebnf-print-directory
77;; ebnf-print-file 77;; ebnf-print-file
78;; ebnf-print-buffer 78;; ebnf-print-buffer
79;; ebnf-print-region 79;; ebnf-print-region
80;; ebnf-spool-directory 80;; ebnf-spool-directory
81;; ebnf-spool-file 81;; ebnf-spool-file
82;; ebnf-spool-buffer 82;; ebnf-spool-buffer
83;; ebnf-spool-region 83;; ebnf-spool-region
84;; ebnf-eps-directory 84;; ebnf-eps-directory
85;; ebnf-eps-file 85;; ebnf-eps-file
86;; ebnf-eps-buffer 86;; ebnf-eps-buffer
87;; ebnf-eps-region 87;; ebnf-eps-region
88;; 88;;
89;; These commands all perform essentially the same function: they generate 89;; These commands all perform essentially the same function: they generate
90;; PostScript syntactic chart images suitable for printing on a PostScript 90;; PostScript syntactic chart images suitable for printing on a PostScript
@@ -94,14 +94,14 @@ Please send all bug fixes and enhancements to
94;; The word "print", "spool" and "eps" in the command name determines when the 94;; The word "print", "spool" and "eps" in the command name determines when the
95;; PostScript image is sent to the printer (or file): 95;; PostScript image is sent to the printer (or file):
96;; 96;;
97;; print - The PostScript image is immediately sent to the printer; 97;; print - The PostScript image is immediately sent to the printer;
98;; 98;;
99;; spool - The PostScript image is saved temporarily in an Emacs buffer. 99;; spool - The PostScript image is saved temporarily in an Emacs buffer.
100;; Many images may be spooled locally before printing them. To 100;; Many images may be spooled locally before printing them. To
101;; send the spooled images to the printer, use the command 101;; send the spooled images to the printer, use the command
102;; `ebnf-despool'. 102;; `ebnf-despool'.
103;; 103;;
104;; eps - The PostScript image is immediately sent to a EPS file. 104;; eps - The PostScript image is immediately sent to a EPS file.
105;; 105;;
106;; The spooling mechanism is the same as used by ps-print and was designed for 106;; The spooling mechanism is the same as used by ps-print and was designed for
107;; printing lots of small files to save paper that would otherwise be wasted on 107;; printing lots of small files to save paper that would otherwise be wasted on
@@ -120,22 +120,22 @@ Please send all bug fixes and enhancements to
120;; The word "directory", "file", "buffer" or "region" in the command name 120;; The word "directory", "file", "buffer" or "region" in the command name
121;; determines how much of the buffer is printed: 121;; determines how much of the buffer is printed:
122;; 122;;
123;; directory - Read files in the directory and print them. 123;; directory - Read files in the directory and print them.
124;; 124;;
125;; file - Read file and print it. 125;; file - Read file and print it.
126;; 126;;
127;; buffer - Print the entire buffer. 127;; buffer - Print the entire buffer.
128;; 128;;
129;; region - Print just the current region. 129;; region - Print just the current region.
130;; 130;;
131;; Two ebnf- command examples: 131;; Two ebnf- command examples:
132;; 132;;
133;; ebnf-print-buffer - translate and print the entire buffer, and send it 133;; ebnf-print-buffer - translate and print the entire buffer, and send it
134;; immediately to the printer. 134;; immediately to the printer.
135;; 135;;
136;; ebnf-spool-region - translate and print just the current region, and 136;; ebnf-spool-region - translate and print just the current region, and
137;; spool the image in Emacs to send to the printer 137;; spool the image in Emacs to send to the printer
138;; later. 138;; later.
139;; 139;;
140;; Note that `ebnf-eps-directory', `ebnf-eps-file', `ebnf-eps-buffer' and 140;; Note that `ebnf-eps-directory', `ebnf-eps-file', `ebnf-eps-buffer' and
141;; `ebnf-eps-region' never spool the EPS image, so they don't use the ps-print 141;; `ebnf-eps-region' never spool the EPS image, so they don't use the ps-print
@@ -148,13 +148,13 @@ Please send all bug fixes and enhancements to
148;; 148;;
149;; To translate and print your buffer, type 149;; To translate and print your buffer, type
150;; 150;;
151;; M-x ebnf-print-buffer 151;; M-x ebnf-print-buffer
152;; 152;;
153;; or substitute one of the other four ebnf- commands. The command will 153;; or substitute one of the other four ebnf- commands. The command will
154;; generate the PostScript image and print or spool it as specified. By giving 154;; generate the PostScript image and print or spool it as specified. By giving
155;; the command a prefix argument 155;; the command a prefix argument
156;; 156;;
157;; C-u M-x ebnf-print-buffer 157;; C-u M-x ebnf-print-buffer
158;; 158;;
159;; it will save the PostScript image to a file instead of sending it to the 159;; it will save the PostScript image to a file instead of sending it to the
160;; printer; you will be prompted for the name of the file to save the image to. 160;; printer; you will be prompted for the name of the file to save the image to.
@@ -162,7 +162,7 @@ Please send all bug fixes and enhancements to
162;; you may save the spooled images to a file by giving a prefix argument to 162;; you may save the spooled images to a file by giving a prefix argument to
163;; `ebnf-despool': 163;; `ebnf-despool':
164;; 164;;
165;; C-u M-x ebnf-despool 165;; C-u M-x ebnf-despool
166;; 166;;
167;; When invoked this way, `ebnf-despool' will prompt you for the name of the 167;; When invoked this way, `ebnf-despool' will prompt you for the name of the
168;; file to save to. 168;; file to save to.
@@ -172,9 +172,9 @@ Please send all bug fixes and enhancements to
172;; 172;;
173;; Any of the `ebnf-' commands can be bound to keys. Here are some examples: 173;; Any of the `ebnf-' commands can be bound to keys. Here are some examples:
174;; 174;;
175;; (global-set-key 'f22 'ebnf-print-buffer) ;f22 is prsc 175;; (global-set-key 'f22 'ebnf-print-buffer) ;f22 is prsc
176;; (global-set-key '(shift f22) 'ebnf-print-region) 176;; (global-set-key '(shift f22) 'ebnf-print-region)
177;; (global-set-key '(control f22) 'ebnf-despool) 177;; (global-set-key '(control f22) 'ebnf-despool)
178;; 178;;
179;; 179;;
180;; Invoking Ebnf2ps in Batch 180;; Invoking Ebnf2ps in Batch
@@ -523,14 +523,14 @@ Please send all bug fixes and enhancements to
523;; 523;;
524;; The following table summarizes the results: 524;; The following table summarizes the results:
525;; 525;;
526;; EPS FILE NAME NO SORT ASCENDING SORT DESCENDING SORT 526;; EPS FILE NAME NO SORT ASCENDING SORT DESCENDING SORT
527;; ebnf--AA.eps A C A C C A 527;; ebnf--AA.eps A C A C C A
528;; ebnf--BB.eps C B B C C B 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 529;; ebnf--CC.eps A C B F A B C F F C B A
530;; ebnf--D.eps D D D 530;; ebnf--D.eps D D D
531;; ebnf--E.eps E E E 531;; ebnf--E.eps E E E
532;; ebnf--G.eps G G G 532;; ebnf--G.eps G G G
533;; ebnf--Z.eps Z Z Z 533;; ebnf--Z.eps Z Z Z
534;; 534;;
535;; As you can see if EPS actions is not used, each single production is 535;; As you can see if EPS actions is not used, each single production is
536;; generated per EPS file. To avoid overriding EPS files, use names in ;[ that 536;; generated per EPS file. To avoid overriding EPS files, use names in ;[ that
@@ -692,6 +692,11 @@ Please send all bug fixes and enhancements to
692;; 692;;
693;; `ebnf-line-color' Specify flow line color. 693;; `ebnf-line-color' Specify flow line color.
694;; 694;;
695;; `ebnf-arrow-extra-width' Specify extra width for arrow shape
696;; drawing.
697;;
698;; `ebnf-arrow-scale' Specify the arrow scale.
699;;
695;; `ebnf-user-arrow' Specify a sexp for user arrow shape (a 700;; `ebnf-user-arrow' Specify a sexp for user arrow shape (a
696;; PostScript code). 701;; PostScript code).
697;; 702;;
@@ -824,6 +829,8 @@ Please send all bug fixes and enhancements to
824;; entry is the vertical position used to know where it should 829;; entry is the vertical position used to know where it should
825;; be drawn the flow line in the current element. 830;; be drawn the flow line in the current element.
826;; 831;;
832;; extra is given by `ebnf-arrow-extra-width'.
833;;
827;; 834;;
828;; * SPECIAL, TERMINAL and NON-TERMINAL 835;; * SPECIAL, TERMINAL and NON-TERMINAL
829;; 836;;
@@ -835,17 +842,17 @@ Please send all bug fixes and enhancements to
835;; : | : : | : } font height / 2 } 842;; : | : : | : } font height / 2 }
836;; : +==============+...:............................... 843;; : +==============+...:...............................
837;; : : : : : : 844;; : : : : : :
838;; : : : : : :...................... 845;; : : : : : :.........................
839;; : : : : : } font height } 846;; : : : : : } font height }
840;; : : : : :....... } 847;; : : : : :....... }
841;; : : : : } font height / 2 } 848;; : : : : } font height / 2 }
842;; : : : :........... } 849;; : : : :........... }
843;; : : : } text width } width 850;; : : : } text width } width
844;; : : :.................. } 851;; : : :.................. }
845;; : : } font height / 2 } 852;; : : } font height / 2 }
846;; : :...................... } 853;; : :...................... }
847;; : } font height } 854;; : } font height + extra }
848;; :............................................. 855;; :.................................................
849;; 856;;
850;; 857;;
851;; * OPTIONAL 858;; * OPTIONAL
@@ -976,21 +983,21 @@ Please send all bug fixes and enhancements to
976;; : | : : : : | : } font height / 2 } 983;; : | : : : : | : } font height / 2 }
977;; : +================+...:............................... 984;; : +================+...:...............................
978;; : : : : : : : : 985;; : : : : : : : :
979;; : : : : : : : :...................... 986;; : : : : : : : :..........................
980;; : : : : : : : } font height } 987;; : : : : : : : } font height }
981;; : : : : : : :....... } 988;; : : : : : : :....... }
982;; : : : : : : } font height / 2 } 989;; : : : : : : } font height / 2 }
983;; : : : : : :........... } 990;; : : : : : :........... }
984;; : : : : : } X width } 991;; : : : : : } X width }
985;; : : : : :............... } 992;; : : : : :............... }
986;; : : : : } font height / 2 } width 993;; : : : : } font height / 2 } width
987;; : : : :.................. } 994;; : : : :.................. }
988;; : : : } text width } 995;; : : : } text width }
989;; : : :..................... } 996;; : : :..................... }
990;; : : } font height / 2 } 997;; : : } font height / 2 }
991;; : :........................ } 998;; : :........................ }
992;; : } font height } 999;; : } font height + extra }
993;; :............................................... 1000;; :...................................................
994;; 1001;;
995;; 1002;;
996;; * EXCEPT 1003;; * EXCEPT
@@ -1003,21 +1010,21 @@ Please send all bug fixes and enhancements to
1003;; : | : : : : | : } font height / 2 } 1010;; : | : : : : | : } font height / 2 }
1004;; : +==================+...:............................... 1011;; : +==================+...:...............................
1005;; : : : : : : : : 1012;; : : : : : : : :
1006;; : : : : : : : :...................... 1013;; : : : : : : : :..........................
1007;; : : : : : : : } font height } 1014;; : : : : : : : } font height }
1008;; : : : : : : :....... } 1015;; : : : : : : :....... }
1009;; : : : : : : } font height / 2 } 1016;; : : : : : : } font height / 2 }
1010;; : : : : : :........... } 1017;; : : : : : :........... }
1011;; : : : : : } Y width } 1018;; : : : : : } Y width }
1012;; : : : : :............... } 1019;; : : : : :............... }
1013;; : : : : } font height } width 1020;; : : : : } font height } width
1014;; : : : :................... } 1021;; : : : :................... }
1015;; : : : } X width } 1022;; : : : } X width }
1016;; : : :....................... } 1023;; : : :....................... }
1017;; : : } font height / 2 } 1024;; : : } font height / 2 }
1018;; : :.......................... } 1025;; : :.......................... }
1019;; : } font height } 1026;; : } font height + extra }
1020;; :................................................. 1027;; :.....................................................
1021;; 1028;;
1022;; NOTE: If Y element is empty, it's draw nothing at Y place. 1029;; NOTE: If Y element is empty, it's draw nothing at Y place.
1023;; 1030;;
@@ -1089,7 +1096,8 @@ Please send all bug fixes and enhancements to
1089;; ---------------- 1096;; ----------------
1090;; 1097;;
1091;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions: 1098;; 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',
1093;; `ebnf-file-suffix-regexp'and `ebnf-special-show-delimiter' variables. 1101;; `ebnf-file-suffix-regexp'and `ebnf-special-show-delimiter' variables.
1094;; - `ebnf-delete-style', `ebnf-eps-file' and `ebnf-eps-directory' 1102;; - `ebnf-delete-style', `ebnf-eps-file' and `ebnf-eps-directory'
1095;; commands. 1103;; commands.
@@ -1911,6 +1919,29 @@ special."
1911 :group 'ebnf2ps) 1919 :group 'ebnf2ps)
1912 1920
1913 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)
1943
1944
1914(defcustom ebnf-debug-ps nil 1945(defcustom ebnf-debug-ps nil
1915 "*Non-nil means to generate PostScript debug procedures. 1946 "*Non-nil means to generate PostScript debug procedures.
1916 1947
@@ -2859,9 +2890,9 @@ See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
2859/HeightNT FontHeight FontHeight add def 2890/HeightNT FontHeight FontHeight add def
2860 2891
2861/T HeightT HeightNT add 0.5 mul def 2892/T HeightT HeightNT add 0.5 mul def
2862/hT T 0.5 mul def 2893/hT T 0.5 mul def
2863/hT2 hT 0.5 mul def 2894/hT2 hT 0.5 mul ArrowScale mul def
2864/hT4 hT 0.25 mul def 2895/hT4 hT 0.25 mul ArrowScale mul def
2865 2896
2866/Er 0.1 def % Error factor 2897/Er 0.1 def % Error factor
2867 2898
@@ -2947,6 +2978,7 @@ See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
2947 RA-vector ArrowShape get exec 2978 RA-vector ArrowShape get exec
2948 Gstroke 2979 Gstroke
2949 moveto 2980 moveto
2981 ExtraWidth 0 rmoveto
2950}def 2982}def
2951 2983
2952% rotation DrawArrow 2984% rotation DrawArrow
@@ -3245,7 +3277,7 @@ See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
3245% string width prepare-width |- string 3277% string width prepare-width |- string
3246/prepare-width 3278/prepare-width
3247{/width exch def 3279{/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
3249 /w exch def 3281 /w exch def
3250}def 3282}def
3251 3283
@@ -4877,7 +4909,6 @@ killed after process termination."
4877 (progn 4909 (progn
4878 ;; adjust creator comment 4910 ;; adjust creator comment
4879 (end-of-line) 4911 (end-of-line)
4880 (backward-char)
4881 (insert " & ebnf2ps v" ebnf-version) 4912 (insert " & ebnf2ps v" ebnf-version)
4882 ;; insert ebnf settings & engine 4913 ;; insert ebnf settings & engine
4883 (goto-char (point-max)) 4914 (goto-char (point-max))
@@ -5066,6 +5097,10 @@ killed after process termination."
5066 (format "/ShadowR %s def\n" 5097 (format "/ShadowR %s def\n"
5067 (ebnf-boolean ebnf-repeat-shadow)) 5098 (ebnf-boolean ebnf-repeat-shadow))
5068 ;; miscellaneous 5099 ;; 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))
5069 (format "/DefaultWidth %s def\n" 5104 (format "/DefaultWidth %s def\n"
5070 (ebnf-format-float ebnf-default-width)) 5105 (ebnf-format-float ebnf-default-width))
5071 (format "/LineWidth %s def\n" 5106 (format "/LineWidth %s def\n"
@@ -5152,7 +5187,7 @@ killed after process termination."
5152 (len (length (ebnf-node-name node)))) 5187 (len (length (ebnf-node-name node))))
5153 (ebnf-node-entry node (* height 0.5)) 5188 (ebnf-node-entry node (* height 0.5))
5154 (ebnf-node-height node height) 5189 (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
5156 (* len font-width) 5191 (* len font-width)
5157 space ebnf-basic-width)))) 5192 space ebnf-basic-width))))
5158 5193
@@ -5173,6 +5208,7 @@ killed after process termination."
5173 ebnf-font-height-S) 5208 ebnf-font-height-S)
5174 ebnf-space-R ebnf-space-R)) 5209 ebnf-space-R ebnf-space-R))
5175 (ebnf-node-width repeat (+ (ebnf-node-width element) 5210 (ebnf-node-width repeat (+ (ebnf-node-width element)
5211 ebnf-arrow-extra-width
5176 ebnf-space-R ebnf-space-R ebnf-space-R 5212 ebnf-space-R ebnf-space-R ebnf-space-R
5177 ebnf-horizontal-space 5213 ebnf-horizontal-space
5178 (* (length times) ebnf-font-width-R))))) 5214 (* (length times) ebnf-font-width-R)))))
@@ -5194,6 +5230,7 @@ killed after process termination."
5194 ebnf-space-E ebnf-space-E)) 5230 ebnf-space-E ebnf-space-E))
5195 (ebnf-node-width except (+ (ebnf-node-width factor) 5231 (ebnf-node-width except (+ (ebnf-node-width factor)
5196 (ebnf-node-width element) 5232 (ebnf-node-width element)
5233 ebnf-arrow-extra-width
5197 ebnf-space-E ebnf-space-E 5234 ebnf-space-E ebnf-space-E
5198 ebnf-space-E ebnf-space-E 5235 ebnf-space-E ebnf-space-E
5199 ebnf-font-width-E 5236 ebnf-font-width-E