comparison lisp/progmodes/ebnf2ps.el @ 90751:52a7f3f50b89

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 624-636) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 200-201) - Merge from emacs--devo--0 - Update from CVS: lisp/nnweb.el (nnweb-google-parse-1): Update parser. Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-171
author Miles Bader <miles@gnu.org>
date Tue, 13 Feb 2007 12:14:16 +0000
parents 95d0cdf160ea 287a9e827176
children 4ef338cf4478
comparison
equal deleted inserted replaced
90750:f8cc067aba62 90751:52a7f3f50b89
98 ;; spool - The PostScript image is saved temporarily in an Emacs buffer. 98 ;; spool - The PostScript image is saved temporarily in an Emacs buffer.
99 ;; Many images may be spooled locally before printing them. To 99 ;; Many images may be spooled locally before printing them. To
100 ;; send the spooled images to the printer, use the command 100 ;; send the spooled images to the printer, use the command
101 ;; `ebnf-despool'. 101 ;; `ebnf-despool'.
102 ;; 102 ;;
103 ;; eps - The PostScript image is immediately sent to a EPS file. 103 ;; eps - The PostScript image is immediately sent to an EPS file.
104 ;; 104 ;;
105 ;; The spooling mechanism is the same as used by ps-print and was designed for 105 ;; The spooling mechanism is the same as used by ps-print and was designed for
106 ;; printing lots of small files to save paper that would otherwise be wasted on 106 ;; printing lots of small files to save paper that would otherwise be wasted on
107 ;; banner pages, and to make it easier to find your output at the printer (it's 107 ;; banner pages, and to make it easier to find your output at the printer (it's
108 ;; easier to pick up one 50-page printout than to find 50 single-page 108 ;; easier to pick up one 50-page printout than to find 50 single-page
805 ;; 805 ;;
806 ;; These commands help to put together a lot of variable settings in a group 806 ;; These commands help to put together a lot of variable settings in a group
807 ;; and name this group. So when you wish to apply these settings it's only 807 ;; and name this group. So when you wish to apply these settings it's only
808 ;; needed to give the name. 808 ;; needed to give the name.
809 ;; 809 ;;
810 ;; There is also a notion of simple inheritance of style; so, if you declare 810 ;; There is also a notion of simple inheritance of style: if you declare that
811 ;; that a style A inherits from a style B, all settings of B is applied first 811 ;; style A inherits from style B, all settings of B are applied first and then
812 ;; and then the settings of A is applied. This is useful when you wish to 812 ;; the settings of A are applied. This is useful when you wish to modify some
813 ;; modify some aspects of an existing style, but at same time wish to keep it 813 ;; aspects of an existing style, but at same time wish to keep it unmodified.
814 ;; unmodified.
815 ;; 814 ;;
816 ;; See documentation for `ebnf-style-database'. 815 ;; See documentation for `ebnf-style-database'.
817 ;; 816 ;;
818 ;; 817 ;;
819 ;; Layout 818 ;; Layout
1092 ;; 1091 ;;
1093 ;; 1092 ;;
1094 ;; Acknowledgements 1093 ;; Acknowledgements
1095 ;; ---------------- 1094 ;; ----------------
1096 ;; 1095 ;;
1096 ;; Thanks to Eli Zaretskii <eliz@gnu.org> for some doc fixes.
1097 ;;
1097 ;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions: 1098 ;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions:
1098 ;; - `ebnf-arrow-extra-width', `ebnf-arrow-scale', 1099 ;; - `ebnf-arrow-extra-width', `ebnf-arrow-scale',
1099 ;; `ebnf-production-name-p', `ebnf-stop-on-error', 1100 ;; `ebnf-production-name-p', `ebnf-stop-on-error',
1100 ;; `ebnf-file-suffix-regexp'and `ebnf-special-show-delimiter' variables. 1101 ;; `ebnf-file-suffix-regexp'and `ebnf-special-show-delimiter' variables.
1101 ;; - `ebnf-delete-style', `ebnf-eps-file' and `ebnf-eps-directory' 1102 ;; - `ebnf-delete-style', `ebnf-eps-file' and `ebnf-eps-directory'
2180 (ebnf-file 'ebnf-eps-buffer file do-not-kill-buffer-when-done)) 2181 (ebnf-file 'ebnf-eps-buffer file do-not-kill-buffer-when-done))
2181 2182
2182 2183
2183 ;;;###autoload 2184 ;;;###autoload
2184 (defun ebnf-eps-buffer () 2185 (defun ebnf-eps-buffer ()
2185 "Generate a PostScript syntactic chart image of the buffer in a EPS file. 2186 "Generate a PostScript syntactic chart image of the buffer in an EPS file.
2186 2187
2187 Indeed, for each production is generated a EPS file. 2188 Generate an EPS file for each production in the buffer.
2188 The EPS file name has the following form: 2189 The EPS file name has the following form:
2189 2190
2190 <PREFIX><PRODUCTION>.eps 2191 <PREFIX><PRODUCTION>.eps
2191 2192
2192 <PREFIX> is given by variable `ebnf-eps-prefix'. 2193 <PREFIX> is given by variable `ebnf-eps-prefix'.
2193 The default value is \"ebnf--\". 2194 The default value is \"ebnf--\".
2194 2195
2195 <PRODUCTION> is the production name. 2196 <PRODUCTION> is the production name.
2196 The production name is mapped to form a valid file name. 2197 Some characters in the production file name are replaced to
2197 For example, the production name \"A/B + C\" is mapped to 2198 produce a valid file name. For example, the production name
2198 \"A_B_+_C\" and the EPS file name used is \"ebnf--A_B_+_C.eps\". 2199 \"A/B + C\" is modified to produce \"A_B_+_C\", and the EPS
2199 2200 file name used in this case will be \"ebnf--A_B_+_C.eps\".
2200 WARNING: It's *NOT* asked any confirmation to override an existing file." 2201
2202 WARNING: This function does *NOT* ask any confirmation to override existing
2203 files."
2201 (interactive) 2204 (interactive)
2202 (ebnf-eps-region (point-min) (point-max))) 2205 (ebnf-eps-region (point-min) (point-max)))
2203 2206
2204 2207
2205 ;;;###autoload 2208 ;;;###autoload
2206 (defun ebnf-eps-region (from to) 2209 (defun ebnf-eps-region (from to)
2207 "Generate a PostScript syntactic chart image of the region in a EPS file. 2210 "Generate a PostScript syntactic chart image of the region in an EPS file.
2208 2211
2209 Indeed, for each production is generated a EPS file. 2212 Generate an EPS file for each production in the region.
2210 The EPS file name has the following form: 2213 The EPS file name has the following form:
2211 2214
2212 <PREFIX><PRODUCTION>.eps 2215 <PREFIX><PRODUCTION>.eps
2213 2216
2214 <PREFIX> is given by variable `ebnf-eps-prefix'. 2217 <PREFIX> is given by variable `ebnf-eps-prefix'.
2215 The default value is \"ebnf--\". 2218 The default value is \"ebnf--\".
2216 2219
2217 <PRODUCTION> is the production name. 2220 <PRODUCTION> is the production name.
2218 The production name is mapped to form a valid file name. 2221 Some characters in the production file name are replaced to
2219 For example, the production name \"A/B + C\" is mapped to 2222 produce a valid file name. For example, the production name
2220 \"A_B_+_C\" and the EPS file name used is \"ebnf--A_B_+_C.eps\". 2223 \"A/B + C\" is modified to produce \"A_B_+_C\", and the EPS
2221 2224 file name used in this case will be \"ebnf--A_B_+_C.eps\".
2222 WARNING: It's *NOT* asked any confirmation to override an existing file." 2225
2226 WARNING: This function does *NOT* ask any confirmation to override existing
2227 files."
2223 (interactive "r") 2228 (interactive "r")
2224 (let ((ebnf-eps-executing t)) 2229 (let ((ebnf-eps-executing t))
2225 (ebnf-generate-region from to 'ebnf-generate-eps))) 2230 (ebnf-generate-region from to 'ebnf-generate-eps)))
2226 2231
2227 2232
2229 (defalias 'ebnf-despool 'ps-despool) 2234 (defalias 'ebnf-despool 'ps-despool)
2230 2235
2231 2236
2232 ;;;###autoload 2237 ;;;###autoload
2233 (defun ebnf-syntax-directory (&optional directory) 2238 (defun ebnf-syntax-directory (&optional directory)
2234 "Does a syntactic analysis of the files in DIRECTORY. 2239 "Do a syntactic analysis of the files in DIRECTORY.
2235 2240
2236 If DIRECTORY is nil, it's used `default-directory'. 2241 If DIRECTORY is nil, use `default-directory'.
2237 2242
2238 The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are 2243 Only the files in DIRECTORY that match `ebnf-file-suffix-regexp' (which see)
2239 processed. 2244 are processed.
2240 2245
2241 See also `ebnf-syntax-buffer'." 2246 See also `ebnf-syntax-buffer'."
2242 (interactive 2247 (interactive
2243 (list (read-file-name "Directory containing EBNF files (syntax): " 2248 (list (read-file-name "Directory containing EBNF files (syntax): "
2244 nil default-directory))) 2249 nil default-directory)))
2245 (ebnf-directory 'ebnf-syntax-buffer directory)) 2250 (ebnf-directory 'ebnf-syntax-buffer directory))
2246 2251
2247 2252
2248 ;;;###autoload 2253 ;;;###autoload
2249 (defun ebnf-syntax-file (file &optional do-not-kill-buffer-when-done) 2254 (defun ebnf-syntax-file (file &optional do-not-kill-buffer-when-done)
2250 "Does a syntactic analysis of the FILE. 2255 "Do a syntactic analysis of the named FILE.
2251 2256
2252 If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't 2257 If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't
2253 killed after syntax checking. 2258 killed after syntax checking.
2254 2259
2255 See also `ebnf-syntax-buffer'." 2260 See also `ebnf-syntax-buffer'."
2257 (ebnf-file 'ebnf-syntax-buffer file do-not-kill-buffer-when-done)) 2262 (ebnf-file 'ebnf-syntax-buffer file do-not-kill-buffer-when-done))
2258 2263
2259 2264
2260 ;;;###autoload 2265 ;;;###autoload
2261 (defun ebnf-syntax-buffer () 2266 (defun ebnf-syntax-buffer ()
2262 "Does a syntactic analysis of the current buffer." 2267 "Do a syntactic analysis of the current buffer."
2263 (interactive) 2268 (interactive)
2264 (ebnf-syntax-region (point-min) (point-max))) 2269 (ebnf-syntax-region (point-min) (point-max)))
2265 2270
2266 2271
2267 ;;;###autoload 2272 ;;;###autoload
2268 (defun ebnf-syntax-region (from to) 2273 (defun ebnf-syntax-region (from to)
2269 "Does a syntactic analysis of a region." 2274 "Do a syntactic analysis of region."
2270 (interactive "r") 2275 (interactive "r")
2271 (ebnf-generate-region from to nil)) 2276 (ebnf-generate-region from to nil))
2272 2277
2273 2278
2274 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2570 Where: 2575 Where:
2571 2576
2572 NAME is a symbol name style. 2577 NAME is a symbol name style.
2573 2578
2574 INHERITS is a symbol name style from which the current style inherits 2579 INHERITS is a symbol name style from which the current style inherits
2575 the context. If INHERITS is nil, means that there is no 2580 the context. If INHERITS is nil, then there is no inheritance.
2576 inheritance. 2581
2577 2582 This is a simple inheritance of style: if you declare that
2578 This is a simple inheritance of style; so if you declare that a 2583 style A inherits from style B, all settings of B are applied
2579 style A inherits from a style B, all settings of B is applied 2584 first, and then the settings of A are applied. This is useful
2580 first and then the settings of A is applied. This is useful
2581 when you wish to modify some aspects of an existing style, but 2585 when you wish to modify some aspects of an existing style, but
2582 at same time wish to keep it unmodified. 2586 at the same time wish to keep it unmodified.
2583 2587
2584 VAR is a valid ebnf2ps symbol custom variable. 2588 VAR is a valid ebnf2ps symbol custom variable.
2585 See `ebnf-style-custom-list' for valid symbol variable. 2589 See `ebnf-style-custom-list' for valid symbol variables.
2586 2590
2587 VALUE is a sexp which it'll be evaluated to set the value to VAR. 2591 VALUE is a sexp which will be evaluated to set the value of VAR.
2588 So, don't forget to quote symbols and constant lists. 2592 Don't forget to quote symbols and constant lists.
2589 See `default' style for an example. 2593 See `default' style for an example.
2590 2594
2591 Don't handle this variable directly. Use functions `ebnf-insert-style', 2595 Don't use this variable directly. Use functions `ebnf-insert-style',
2592 `ebnf-delete-style' and `ebnf-merge-style'.") 2596 `ebnf-delete-style' and `ebnf-merge-style'.")
2593 2597
2594 2598
2595 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2599 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2596 ;; Style commands 2600 ;; Style commands
2653 2657
2654 ;;;###autoload 2658 ;;;###autoload
2655 (defun ebnf-apply-style (style) 2659 (defun ebnf-apply-style (style)
2656 "Set STYLE as the current style. 2660 "Set STYLE as the current style.
2657 2661
2658 It returns the old style symbol. 2662 Returns the old style symbol.
2659 2663
2660 See `ebnf-style-database' documentation." 2664 See `ebnf-style-database' documentation."
2661 (interactive "SApply style: ") 2665 (interactive "SApply style: ")
2662 (prog1 2666 (prog1
2663 ebnf-current-style 2667 ebnf-current-style
2667 2671
2668 ;;;###autoload 2672 ;;;###autoload
2669 (defun ebnf-reset-style (&optional style) 2673 (defun ebnf-reset-style (&optional style)
2670 "Reset current style. 2674 "Reset current style.
2671 2675
2672 It returns the old style symbol. 2676 Returns the old style symbol.
2673 2677
2674 See `ebnf-style-database' documentation." 2678 See `ebnf-style-database' documentation."
2675 (interactive "SReset style: ") 2679 (interactive "SReset style: ")
2676 (setq ebnf-stack-style nil) 2680 (setq ebnf-stack-style nil)
2677 (ebnf-apply-style (or style 'default))) 2681 (ebnf-apply-style (or style 'default)))
2678 2682
2679 2683
2680 ;;;###autoload 2684 ;;;###autoload
2681 (defun ebnf-push-style (&optional style) 2685 (defun ebnf-push-style (&optional style)
2682 "Push the current style and set STYLE as the current style. 2686 "Push the current style onto a stack and set STYLE as the current style.
2683 2687
2684 It returns the old style symbol. 2688 Returns the old style symbol.
2689
2690 See also `ebnf-pop-style'.
2685 2691
2686 See `ebnf-style-database' documentation." 2692 See `ebnf-style-database' documentation."
2687 (interactive "SPush style: ") 2693 (interactive "SPush style: ")
2688 (prog1 2694 (prog1
2689 ebnf-current-style 2695 ebnf-current-style
2692 (ebnf-apply-style style)))) 2698 (ebnf-apply-style style))))
2693 2699
2694 2700
2695 ;;;###autoload 2701 ;;;###autoload
2696 (defun ebnf-pop-style () 2702 (defun ebnf-pop-style ()
2697 "Pop a style and set it as the current style. 2703 "Pop a style from the stack of pushed styles and set it as the current style.
2698 2704
2699 It returns the old style symbol. 2705 Returns the old style symbol.
2706
2707 See also `ebnf-push-style'.
2700 2708
2701 See `ebnf-style-database' documentation." 2709 See `ebnf-style-database' documentation."
2702 (interactive) 2710 (interactive)
2703 (prog1 2711 (prog1
2704 (ebnf-apply-style (car ebnf-stack-style)) 2712 (ebnf-apply-style (car ebnf-stack-style))
2756 (PRODUCTION EPS-FILENAME...) 2764 (PRODUCTION EPS-FILENAME...)
2757 2765
2758 PRODUCTION is the production name. 2766 PRODUCTION is the production name.
2759 EPS-FILENAME is the EPS file name. 2767 EPS-FILENAME is the EPS file name.
2760 2768
2761 It's generated during parsing and used during EPS generation. 2769 This is generated during parsing and used during EPS generation.
2762 2770
2763 See `ebnf-eps-context' and section \"Actions in Comments\" in ebnf2ps 2771 See `ebnf-eps-context' and section \"Actions in Comments\" in ebnf2ps
2764 documentation.") 2772 documentation.")
2765 2773
2766 2774
4601 4609
4602 4610
4603 (defun ebnf-directory (fun &optional directory) 4611 (defun ebnf-directory (fun &optional directory)
4604 "Process files in DIRECTORY applying function FUN on each file. 4612 "Process files in DIRECTORY applying function FUN on each file.
4605 4613
4606 If DIRECTORY is nil, it's used `default-directory'. 4614 If DIRECTORY is nil, use `default-directory'.
4607 4615
4608 The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are 4616 Only files in DIRECTORY that match `ebnf-file-suffix-regexp' (which see) are
4609 processed." 4617 processed."
4610 (let ((files (directory-files (or directory default-directory) 4618 (let ((files (directory-files (or directory default-directory)
4611 t ebnf-file-suffix-regexp))) 4619 t ebnf-file-suffix-regexp)))
4612 (while files 4620 (while files
4613 (set-buffer (find-file-noselect (car files))) 4621 (set-buffer (find-file-noselect (car files)))
4617 (kill-buffer (current-buffer)) 4625 (kill-buffer (current-buffer))
4618 (setq files (cdr files))))) 4626 (setq files (cdr files)))))
4619 4627
4620 4628
4621 (defun ebnf-file (fun file &optional do-not-kill-buffer-when-done) 4629 (defun ebnf-file (fun file &optional do-not-kill-buffer-when-done)
4622 "Process file FILE applying function FUN. 4630 "Process the named FILE applying function FUN.
4623 4631
4624 If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't 4632 If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't
4625 killed after process termination." 4633 killed after process termination."
4626 (set-buffer (find-file-noselect file)) 4634 (set-buffer (find-file-noselect file))
4627 (funcall fun) 4635 (funcall fun)
4819 (yacc ebnf-yac-parser ebnf-yac-initialize) 4827 (yacc ebnf-yac-parser ebnf-yac-initialize)
4820 (abnf ebnf-abn-parser ebnf-abn-initialize) 4828 (abnf ebnf-abn-parser ebnf-abn-initialize)
4821 (ebnf ebnf-bnf-parser ebnf-bnf-initialize) 4829 (ebnf ebnf-bnf-parser ebnf-bnf-initialize)
4822 (ebnfx ebnf-ebx-parser ebnf-ebx-initialize) 4830 (ebnfx ebnf-ebx-parser ebnf-ebx-initialize)
4823 (dtd ebnf-dtd-parser ebnf-dtd-initialize)) 4831 (dtd ebnf-dtd-parser ebnf-dtd-initialize))
4824 "Alist associating ebnf syntax with a parser and a initializer.") 4832 "Alist associating EBNF syntax with a parser and an initializer.")
4825 4833
4826 4834
4827 (defun ebnf-begin-job () 4835 (defun ebnf-begin-job ()
4828 (ps-printing-region nil nil nil) 4836 (ps-printing-region nil nil nil)
4829 (if ebnf-use-float-format 4837 (if ebnf-use-float-format