annotate lisp/progmodes/vhdl-mode.el @ 21940:f7e788ea680b

new version
author Michael Kifer <kifer@cs.stonybrook.edu>
date Mon, 04 May 1998 22:42:59 +0000
parents e95a88dc6110
children e03f87c938ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; vhdl-mode.el --- major mode for editing VHDL code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5 ;; Authors: Reto Zimmermann <mailto:Reto.Zimmermann@iaeth.ch>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; <http://www.iis.ee.ethz.ch/~zimmi/>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7 ;; Rodney J. Whitby <mailto:rwhitby@geocities.com>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; <http://www.geocities.com/SiliconValley/Park/8287/>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9 ;; Maintainer: vhdl-mode@geocities.com
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; Maintainers' Version: 3.19
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; Keywords: languages vhdl
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; This file is part of GNU Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; it under the terms of the GNU General Public License as published by
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; the Free Software Foundation; either version 2, or (at your option)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; any later version.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; GNU Emacs is distributed in the hope that it will be useful,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 ;; GNU General Public License for more details.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;; You should have received a copy of the GNU General Public License
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;; Boston, MA 02111-1307, USA.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;;; Commentary:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;; This package provides an Emacs major mode for editing VHDL code.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 ;; It includes the following features:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 ;; - Highlighting of VHDL syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 ;; - Indentation based on versatile syntax analysis
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 ;; - Template insertion (electrification) for most VHDL constructs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 ;; - Insertion of customizable VHDL file headers
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 ;; - Word completion (dynamic abbreviations)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 ;; - Menu containing all VHDL Mode commands
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 ;; - Index menu (jump index to main units and blocks in a file)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 ;; - Source file menu (menu of all source files in current directory)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 ;; - Source file compilation (syntax analysis)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;; - Postscript printing with fontification
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 ;; - Lower and upper case keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 ;; - Hiding blocks of code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 ;; - Alignment functions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 ;; - Easy customization
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;; - Works under GNU Emacs and XEmacs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 ;; Usage
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 ;; see below (comment in vhdl-mode function) or type `C-c C-h' in Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 ;; Emacs Versions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 ;; - Emacs 20
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 ;; - XEmacs 19.15
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 ;; - This version does not support Emacs 19 (use VHDL Mode 3.10 instead)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 ;; Acknowledgements
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 ;; Electrification ideas by Bob Pack <rlpst@cislabs.pitt.edu>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 ;; and Steve Grout
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 ;; Fontification approach suggested by Ken Wood <ken@eda.com.au>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 ;; Source file menu suggested by Michael Laajanen <mila@enea.se>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 ;; Ideas about alignment from John Wiegley <johnw@borland.com>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 ;; Many thanks to all the users who sent me bug reports and enhancement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 ;; requests.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 ;; Special thanks go to Dan Nicolaescu <done@ece.arizona.edu> for reviewing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 ;; the code and for his valuable hints.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 ;;; Code:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 ;; User definable variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 ;; Variables for customization
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 (defgroup vhdl nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 "Customizations for VHDL Mode."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 :prefix "vhdl-"
21651
86fcccceba7b *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21466
diff changeset
96 :group 'languages
86fcccceba7b *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21466
diff changeset
97 :version "20.3")
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 (defgroup vhdl-mode nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 "Customizations for modes."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 (defcustom vhdl-electric-mode t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 "*If non-nil, electrification (automatic template generation) is enabled.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 If nil, template generators can still be invoked through key bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 and menu. Can be toggled by `\\[vhdl-electric-mode]'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 :group 'vhdl-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 (defcustom vhdl-stutter-mode t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 "*If non-nil, stuttering is enabled.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 Can be toggled by `\\[vhdl-stutter-mode]'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 :group 'vhdl-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 (defcustom vhdl-indent-tabs-mode t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 "*Indentation can insert tabs if this is non-nil.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 Overrides local variable `indent-tabs-mode'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 :group 'vhdl-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 (defgroup vhdl-compile nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 "Customizations for compilation."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 (defcustom vhdl-compiler 'v-system
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 "*VHDL compiler to be used for syntax analysis.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 cadence Cadence Design Systems (`cv -file')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 ikos Ikos Voyager (`analyze')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 quickhdl QuickHDL, Mentor Graphics (`qvhcom')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 synopsys Synopsys, VHDL Analyzer (`vhdlan')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 vantage Vantage Analysis Systems (`analyze -libfile vsslib.ini -src')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 viewlogic Viewlogic (`analyze -libfile vsslib.ini -src')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 v-system V-System, Model Technology (`vcom')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 For incorporation of additional compilers, please send me their command syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 and some example error messages."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 :type '(choice
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 (const cadence)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 (const ikos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 (const quickhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 (const synopsys)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 (const vantage)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 (const viewlogic)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 (const v-system)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 :group 'vhdl-compile)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 (defcustom vhdl-compiler-options ""
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 "*Options to be added to the compile command."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 :type 'string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 :group 'vhdl-compile)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 (defgroup vhdl-style nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 "Customizations for code styles."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 (defcustom vhdl-basic-offset 4
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 "*Amount of basic offset used for indentation.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 This value is used by + and - symbols in `vhdl-offsets-alist'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 :type 'integer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 :group 'vhdl-style)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 (defgroup vhdl-word-case nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 "Customizations for case of VHDL words."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 :group 'vhdl-style)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (defcustom vhdl-upper-case-keywords nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 "*If non-nil, keywords are converted to upper case
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 when typed or by the fix case functions."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 :group 'vhdl-word-case)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (defcustom vhdl-upper-case-types nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 "*If non-nil, standardized types are converted to upper case
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 by the fix case functions."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 :group 'vhdl-word-case)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 (defcustom vhdl-upper-case-attributes nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 "*If non-nil, standardized attributes are converted to upper case
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 by the fix case functions."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 :group 'vhdl-word-case)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 (defcustom vhdl-upper-case-enum-values nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 "*If non-nil, standardized enumeration values are converted to upper case
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 by the fix case functions."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 :group 'vhdl-word-case)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 (defgroup vhdl-electric nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 "Customizations for comments."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 (defcustom vhdl-auto-align nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 "*If non-nil, some templates are automatically aligned after generation."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 (defcustom vhdl-additional-empty-lines t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 "*If non-nil, additional empty lines are inserted in some templates.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207 This improves readability of code."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 (defcustom vhdl-argument-list-indent t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 "*If non-nil, argument lists are indented relative to the opening paren.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 Normal indentation is applied otherwise."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 (defcustom vhdl-conditions-in-parenthesis nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 "*If non-nil, parenthesis are placed around condition expressions."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 (defcustom vhdl-date-format 'scientific
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223 "*Specifies date format to be used in header.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224 Date formats are:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225 american (09/17/1997)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 european (17.09.1997)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227 scientific (1997/09/17)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228 :type '(choice (const american)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 (const european)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
230 (const scientific))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
232
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233 (defcustom vhdl-header-file nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
234 "*Pathname/filename of the file to be inserted as header.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
235 If the header contains RCS keywords, they may be written as <RCS>Keyword<RCS>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236 if the header needs to be version controlled.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
237
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238 The following keywords for template generation are supported:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 <filename> : replaced by the name of the buffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240 <author> : replaced by the user name and email address
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
241 <date> : replaced by the current date
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242 <... string> : replaced by a prompted string (... is the prompt word)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 <cursor> : final cursor position
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245 Example:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 -----------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247 -- Title : <title string>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 -- File : <filename>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 -- Author : <author>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250 -- Created : <date>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 -- Description : <cursor>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252 -----------------------------------------"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253 :type 'string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256 (defcustom vhdl-modify-date-prefix-string "-- Last modified : "
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 "*Prefix string of modification date in VHDL file header.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258 If actualization of the modification date is called (menu, `\\[vhdl-modify]'),
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259 this string is searched and the rest of the line replaced by the current date."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
260 :type 'string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
263 (defcustom vhdl-zero-string "'0'"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264 "*String to use for a logic zero."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 :type 'string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
267
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
268 (defcustom vhdl-one-string "'1'"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
269 "*String to use for a logic one."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270 :type 'string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 (defgroup vhdl-comment nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 "Customizations for comments."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 :group 'vhdl-electric)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 (defcustom vhdl-self-insert-comments t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 "*If non-nil, variables templates automatically insert help comments."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 :group 'vhdl-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 (defcustom vhdl-prompt-for-comments t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 "*If non-nil, various templates prompt for user definable comments."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 :group 'vhdl-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 (defcustom vhdl-comment-column 40
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 "*Column to indent right-margin comments to.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 Overrides local variable `comment-column'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 :type 'integer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292 :group 'vhdl-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 (defcustom vhdl-end-comment-column 79
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 "*End of comment column."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 :type 'integer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 :group 'vhdl-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 (defvar end-comment-column 79
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 "*End of comment column.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 (defgroup vhdl-highlight nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 "Customizations for highlighting."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 (defcustom vhdl-highlight-names t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 "*If non-nil, unit names, subprogram names, and labels are highlighted."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 (defcustom vhdl-highlight-keywords t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 "*If non-nil, VHDL keywords and other predefined words are highlighted.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 That is, keywords, predefined types, predefined attributes, and predefined
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 enumeration values are highlighted."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 (defcustom vhdl-highlight-signals nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 "*If non-nil, signals of different classes are highlighted using colors.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 Signal classes are: clock, reset, status/control, data, and test."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 (defcustom vhdl-highlight-case-sensitive nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 "*If non-nil, case is considered for highlighting.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 Possible trade-off:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 non-nil also upper-case VHDL words are highlighted, but case of signal names
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 is not considered (may lead to highlighting of unwanted words),
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 nil only lower-case VHDL words are highlighted, but case of signal names
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 is considered.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 Overrides local variable `font-lock-keywords-case-fold-search'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
334 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 (defcustom vhdl-use-default-colors nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 "*If non-nil, the default colors are taken for syntax highlighting.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338 If nil, all colors are customized in VHDL Mode for better matching with the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 additional signal colors."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 (defcustom vhdl-use-default-faces nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 "*If non-nil, the default faces are taken for syntax highlighting.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 If nil, all faces are customized for better matching with the additional faces
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 used in VHDL Mode. This variable comes only into effect if no colors are used
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 for highlighting or printing (i.e. variable `ps-print-color-p' is nil)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 (defgroup vhdl-signal-syntax nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 "Customizations of signal syntax for highlighting."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 (defcustom vhdl-signal-syntax-doc-string "
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 Must be of the form \"\\ \<\\\(...\\\)\\\>\", where ... specifies the actual syntax.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 (delete this space ^ , it's only a workaround to get this doc string.)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 The basic regexp elements are:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 [A-Z] any upper case letter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 [A-Za-z] any letter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 [0-9] any digit
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 \\w any letter or digit (corresponds to [A-Za-z0-9])
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 [XY] letter \"X\" or \"Y\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 [^XY] neither letter \"X\" nor \"Y\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 x letter \"x\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 * postfix operator for matching previous regexp element any times
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 + postfix operator for matching previous regexp element at least once
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 ? postfix operator for matching previous regexp element at most once"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 "Common document string used for the custom variables below. Must be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 defined as custom variable due to a bug in XEmacs.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 (defcustom vhdl-clock-signal-syntax "\\<\\([A-Z]\\w*xC\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 "*Regular expression (regexp) for syntax of clock signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 (defcustom vhdl-reset-signal-syntax "\\<\\([A-Z]\\w*xR\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 "*Regular expression (regexp) for syntax of (asynchronous) reset signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387 (defcustom vhdl-control-signal-syntax "\\<\\([A-Z]\\w*x[IS]\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 "*Regular expression (regexp) for syntax of status/control signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 (defcustom vhdl-data-signal-syntax "\\<\\([A-Z]\\w*xD\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 "*Regular expression (regexp) for syntax of data signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 (defcustom vhdl-test-signal-syntax "\\<\\([A-Z]\\w*xT\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 "*Regular expression (regexp) for syntax of test signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
405 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409 (defgroup vhdl-menu nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 "Customizations for menues."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
412
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 (defcustom vhdl-source-file-menu t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414 "*If non-nil, a menu of all source files in the current directory is created."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 :group 'vhdl-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 (defcustom vhdl-index-menu t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419 "*If non-nil, an index menu for the current source file is created."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 :group 'vhdl-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423 (defcustom vhdl-hideshow-menu (not (string-match "XEmacs" emacs-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424 "*If non-nil, hideshow menu and functionality is added.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 Hideshow allows hiding code of VHDL processes and blocks.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 (Does not work under XEmacs.)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
428 :group 'vhdl-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
431 (defgroup vhdl-print nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
432 "Customizations for printing."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
433 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 (defcustom vhdl-print-two-column t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 "*If non-nil, code is printed in two columns and landscape format."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438 :group 'vhdl-print)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
440
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441 (defgroup vhdl-misc nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442 "Miscellaneous customizations."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
445 (defcustom vhdl-intelligent-tab t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446 "*If non-nil, `TAB' does indentation, word completion, and tab insertion.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 That is, if preceeding character is part of a word then complete word,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 else if not at beginning of line then insert tab,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449 else if last command was a `TAB' or `RET' then dedent one step,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 else indent current line (i.e. `TAB' is bound to `vhdl-tab').
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
451 If nil, TAB always indents current line (i.e. `TAB' is bound to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
452 `vhdl-indent-line')."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
453 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 (defcustom vhdl-template-key-binding-prefix "\C-t"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
457 "*`C-c' plus this key gives the key binding prefix for all VHDL templates.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
458 Default key binding prefix for templates is `C-c C-t' (example: architecture
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 `C-c C-t a'). If you have no own `C-c LETTER' bindings, you can shorten the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 template key binding prefix to `C-c' (example: architecture `C-c a') by
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 assigning the empty character (\"\") to this variable. The syntax to enter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 control keys is \"\\C-t\"."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 :type 'sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
464 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 (defcustom vhdl-word-completion-in-minibuffer t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467 "*If non-nil, word completion works in minibuffer (for template prompts)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 (defcustom vhdl-underscore-is-part-of-word nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472 "*If non-nil, the underscore character `_' is considered as part of word.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 An identifier containing underscores is then treated as a single word in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474 select and move operations. All parts of an identifier separated by underscore
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 are treated as single words otherwise."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480 ;; Other variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 (defvar vhdl-inhibit-startup-warnings-p nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 "*If non-nil, inhibits start up compatibility warnings.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485 (defvar vhdl-strict-syntax-p nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486 "*If non-nil, all syntactic symbols must be found in `vhdl-offsets-alist'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
487 If the syntactic symbol for a particular line does not match a symbol
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488 in the offsets alist, an error is generated, otherwise no error is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 reported and the syntactic symbol is ignored.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491 (defvar vhdl-echo-syntactic-information-p nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492 "*If non-nil, syntactic info is echoed when the line is indented.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
493
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
494 (defconst vhdl-offsets-alist-default
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
495 '((string . -1000)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 (block-open . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
497 (block-close . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
498 (statement . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499 (statement-cont . vhdl-lineup-statement-cont)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 (statement-block-intro . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 (statement-case-intro . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502 (case-alternative . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 (comment . vhdl-lineup-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 (arglist-intro . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505 (arglist-cont . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
506 (arglist-cont-nonempty . vhdl-lineup-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
507 (arglist-close . vhdl-lineup-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
508 (entity . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
509 (configuration . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510 (package . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 (architecture . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 (package-body . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 "Default settings for offsets of syntactic elements.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 Do not change this constant! See the variable `vhdl-offsets-alist' for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 more information.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518 (defvar vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519 "*Association list of syntactic element symbols and indentation offsets.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 As described below, each cons cell in this list has the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 (SYNTACTIC-SYMBOL . OFFSET)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524 When a line is indented, vhdl-mode first determines the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525 context of the line by generating a list of symbols called syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 elements. This list can contain more than one syntactic element and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
527 the global variable `vhdl-syntactic-context' contains the context list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 for the line being indented. Each element in this list is actually a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 cons cell of the syntactic symbol and a buffer position. This buffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 position is call the relative indent point for the line. Some
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
531 syntactic symbols may not have a relative indent point associated with
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 them.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 After the syntactic context list for a line is generated, vhdl-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 calculates the absolute indentation for the line by looking at each
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 syntactic element in the list. First, it compares the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 element against the SYNTACTIC-SYMBOL's in `vhdl-offsets-alist'. When it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538 finds a match, it adds the OFFSET to the column of the relative indent
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 point. The sum of this calculation for each element in the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
540 list is the absolute offset for line being indented.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
541
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 If the syntactic element does not match any in the `vhdl-offsets-alist',
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
543 an error is generated if `vhdl-strict-syntax-p' is non-nil, otherwise
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544 the element is ignored.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546 Actually, OFFSET can be an integer, a function, a variable, or one of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 the following symbols: `+', `-', `++', or `--'. These latter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 designate positive or negative multiples of `vhdl-basic-offset',
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 respectively: *1, *-1, *2, and *-2. If OFFSET is a function, it is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 called with a single argument containing the cons of the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
551 element symbol and the relative indent point. The function should
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
552 return an integer offset.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554 Here is the current list of valid syntactic element symbols:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
555
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556 string -- inside multi-line string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557 block-open -- statement block open
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 block-close -- statement block close
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559 statement -- a VHDL statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560 statement-cont -- a continuation of a VHDL statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
561 statement-block-intro -- the first line in a new statement block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562 statement-case-intro -- the first line in a case alternative block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563 case-alternative -- a case statement alternative clause
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
564 comment -- a line containing only a comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565 arglist-intro -- the first line in an argument list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 arglist-cont -- subsequent argument list lines when no
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567 arguments follow on the same line as the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 the arglist opening paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569 arglist-cont-nonempty -- subsequent argument list lines when at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
570 least one argument follows on the same
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571 line as the arglist opening paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 arglist-close -- the solo close paren of an argument list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573 entity -- inside an entity declaration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
574 configuration -- inside a configuration declaration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
575 package -- inside a package declaration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 architecture -- inside an architecture body
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577 package-body -- inside a package body
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
579
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 (defvar vhdl-comment-only-line-offset 0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581 "*Extra offset for line which contains only the start of a comment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582 Can contain an integer or a cons cell of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
583
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 Where NON-ANCHORED-OFFSET is the amount of offset given to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587 non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 the amount of offset to give column-zero anchored comment-only lines.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
589 Just an integer as value is equivalent to (<val> . 0)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
590
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 (defvar vhdl-special-indent-hook nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592 "*Hook for user defined special indentation adjustments.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593 This hook gets called after a line is indented by the mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 (defvar vhdl-style-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596 '(("IEEE"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 (vhdl-basic-offset . 4)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 (vhdl-offsets-alist . ())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601 "Styles of Indentation.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 Elements of this alist are of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 (STYLE-STRING (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 where STYLE-STRING is a short descriptive string used to select a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
607 style, VARIABLE is any vhdl-mode variable, and VALUE is the intended
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608 value for that variable when using the selected style.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 There is one special case when VARIABLE is `vhdl-offsets-alist'. In this
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611 case, the VALUE is a list containing elements of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 (SYNTACTIC-SYMBOL . VALUE)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 as described in `vhdl-offsets-alist'. These are passed directly to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616 `vhdl-set-offset' so there is no need to set every syntactic symbol in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617 your style, only those that are different from the default.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
619 ;; dynamically append the default value of most variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620 (or (assoc "Default" vhdl-style-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 (let* ((varlist '(vhdl-inhibit-startup-warnings-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622 vhdl-strict-syntax-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623 vhdl-echo-syntactic-information-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 vhdl-basic-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
625 vhdl-offsets-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 vhdl-comment-only-line-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 (default (cons "Default"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
630 (lambda (var)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631 (cons var (symbol-value var))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
632 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
633 varlist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
634 (setq vhdl-style-alist (cons default vhdl-style-alist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 (defvar vhdl-mode-hook nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 "*Hook called by `vhdl-mode'.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641 ;; Emacs variant handling
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 ;; active regions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
645
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 (defun vhdl-keep-region-active ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 ;; do whatever is necessary to keep the region active in XEmacs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 ;; (formerly Lucid). ignore byte-compiler warnings you might see
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649 (and (boundp 'zmacs-region-stays)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 (setq zmacs-region-stays t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 (defconst vhdl-emacs-features
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 (let ((major (and (boundp 'emacs-major-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 emacs-major-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 (minor (and (boundp 'emacs-minor-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 emacs-minor-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 flavor)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 ;; figure out version numbers if not already discovered
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659 (and (or (not major) (not minor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
661 (setq major (string-to-int (substring emacs-version
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
662 (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
663 (match-end 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
664 minor (string-to-int (substring emacs-version
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
665 (match-beginning 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
666 (match-end 2)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
667 (if (not (and major minor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668 (error "Cannot figure out the major and minor version numbers."))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
669 ;; calculate the major version
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
671 ((= major 18) (setq major 'v18)) ;Emacs 18
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672 ((= major 4) (setq major 'v18)) ;Epoch 4
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 ((= major 19) (setq major 'v19 ;Emacs 19
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674 flavor (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 ((string-match "Win-Emacs" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 'Win-Emacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 ((or (string-match "Lucid" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678 (string-match "XEmacs" emacs-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 'XEmacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 ((= major 20) (setq major 'v20 ;Emacs 20
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 flavor (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
684 ((string-match "Win-Emacs" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
685 'Win-Emacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
686 ((or (string-match "Lucid" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 (string-match "XEmacs" emacs-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688 'XEmacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 ;; I don't know
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 (t (error "Cannot recognize major version number: %s" major)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 ;; lets do some minimal sanity checking.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 (if (and (or
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 ;; Emacs 18 is brain dead
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 (eq major 'v18)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 ;; Lemacs before 19.6 had bugs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 ;; Emacs 19 before 19.21 had bugs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 (and (eq major 'v19) (eq flavor t) (< minor 21)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701 (not vhdl-inhibit-startup-warnings-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 (with-output-to-temp-buffer "*vhdl-mode warnings*"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 (print (format
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 "The version of Emacs that you are running, %s,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705 has known bugs in its syntax.c parsing routines which will affect the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 performance of vhdl-mode. You should strongly consider upgrading to the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 latest available version. vhdl-mode may continue to work, after a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708 fashion, but strange indentation errors could be encountered."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 emacs-version))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 (list major flavor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 "A list of features extant in the Emacs you are using.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712 There are many flavors of Emacs out there, each with different
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713 features supporting those needed by vhdl-mode. Here's the current
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 supported list, along with the values for this variable:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 Emacs 18/Epoch 4: (v18)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717 XEmacs (formerly Lucid) 19: (v19 XEmacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
718 Win-Emacs 1.35: (V19 Win-Emacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
719 Emacs 19: (v19 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
720 Emacs 20: (v20 t).")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724 ;; Bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
725 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
726
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
727 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
728 ;; Key bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
729
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
730 (defvar vhdl-template-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
731 "Keymap for VHDL templates.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
732
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
733 (if vhdl-template-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
734 (setq vhdl-template-map (make-sparse-keymap))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
735 ;; key bindings for VHDL templates
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
736 (define-key vhdl-template-map "\M-A" 'vhdl-alias)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
737 (define-key vhdl-template-map "a" 'vhdl-architecture)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
738 (define-key vhdl-template-map "A" 'vhdl-array)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739 (define-key vhdl-template-map "\M-a" 'vhdl-assert)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
740 (define-key vhdl-template-map "b" 'vhdl-block)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741 (define-key vhdl-template-map "c" 'vhdl-case)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
742 (define-key vhdl-template-map "\M-c" 'vhdl-component)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
743 (define-key vhdl-template-map "I" 'vhdl-component-instance)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
744 (define-key vhdl-template-map "\M-s" 'vhdl-concurrent-signal-assignment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745 (define-key vhdl-template-map "\M-Cb"'vhdl-block-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
746 (define-key vhdl-template-map "\M-Cc"'vhdl-component-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 (define-key vhdl-template-map "\M-Cd"'vhdl-configuration-decl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
748 (define-key vhdl-template-map "\M-Cs"'vhdl-configuration-spec)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
749 (define-key vhdl-template-map "C" 'vhdl-constant)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750 (define-key vhdl-template-map "d" 'vhdl-disconnect)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751 (define-key vhdl-template-map "\M-e" 'vhdl-else)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
752 (define-key vhdl-template-map "E" 'vhdl-elsif)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753 (define-key vhdl-template-map "e" 'vhdl-entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
754 (define-key vhdl-template-map "x" 'vhdl-exit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755 (define-key vhdl-template-map "f" 'vhdl-for)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756 (define-key vhdl-template-map "F" 'vhdl-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
757 (define-key vhdl-template-map "g" 'vhdl-generate)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
758 (define-key vhdl-template-map "G" 'vhdl-generic)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 (define-key vhdl-template-map "h" 'vhdl-header)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760 (define-key vhdl-template-map "i" 'vhdl-if)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761 (define-key vhdl-template-map "L" 'vhdl-library)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762 (define-key vhdl-template-map "l" 'vhdl-loop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
763 (define-key vhdl-template-map "m" 'vhdl-modify)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
764 (define-key vhdl-template-map "M" 'vhdl-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765 (define-key vhdl-template-map "n" 'vhdl-next)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
766 (define-key vhdl-template-map "k" 'vhdl-package)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
767 (define-key vhdl-template-map "(" 'vhdl-paired-parens)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
768 (define-key vhdl-template-map "\M-p" 'vhdl-port)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
769 (define-key vhdl-template-map "p" 'vhdl-procedure)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
770 (define-key vhdl-template-map "P" 'vhdl-process)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
771 (define-key vhdl-template-map "R" 'vhdl-record)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
772 (define-key vhdl-template-map "r" 'vhdl-return-value)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
773 (define-key vhdl-template-map "\M-S" 'vhdl-selected-signal-assignment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
774 (define-key vhdl-template-map "s" 'vhdl-signal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
775 (define-key vhdl-template-map "S" 'vhdl-subtype)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
776 (define-key vhdl-template-map "t" 'vhdl-type)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
777 (define-key vhdl-template-map "u" 'vhdl-use)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
778 (define-key vhdl-template-map "v" 'vhdl-variable)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
779 (define-key vhdl-template-map "W" 'vhdl-wait)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
780 (define-key vhdl-template-map "w" 'vhdl-while-loop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
781 (define-key vhdl-template-map "\M-w" 'vhdl-with)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
782 (define-key vhdl-template-map "\M-W" 'vhdl-clocked-wait)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
783 (define-key vhdl-template-map "Kb" 'vhdl-package-numeric-bit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
784 (define-key vhdl-template-map "Kn" 'vhdl-package-numeric-std)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
785 (define-key vhdl-template-map "Ks" 'vhdl-package-std-logic-1164)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
786 (define-key vhdl-template-map "Kt" 'vhdl-package-textio)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
787 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
788
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
789 (defvar vhdl-mode-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
790 "Keymap for VHDL Mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
791
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
792 (if vhdl-mode-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
793 (setq vhdl-mode-map (make-sparse-keymap))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
794 ;; key bindings for templates
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
795 (define-key vhdl-mode-map
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
796 (concat "\C-c" vhdl-template-key-binding-prefix) vhdl-template-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
797 ;; standard key bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
798 (define-key vhdl-mode-map "\M-a" 'vhdl-beginning-of-statement)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
799 (define-key vhdl-mode-map "\M-e" 'vhdl-end-of-statement)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
800 (define-key vhdl-mode-map "\M-\C-f" 'vhdl-forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
801 (define-key vhdl-mode-map "\M-\C-b" 'vhdl-backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
802 (define-key vhdl-mode-map "\M-\C-u" 'vhdl-backward-up-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
803 ;(define-key vhdl-mode-map "\M-\C-d" 'vhdl-down-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
804 (define-key vhdl-mode-map "\M-\C-a" 'vhdl-beginning-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
805 (define-key vhdl-mode-map "\M-\C-e" 'vhdl-end-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
806 (define-key vhdl-mode-map "\M-\C-h" 'vhdl-mark-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
807 (define-key vhdl-mode-map "\M-\C-q" 'vhdl-indent-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
808 (define-key vhdl-mode-map "\177" 'backward-delete-char-untabify)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
809 (define-key vhdl-mode-map "\r" 'vhdl-return)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
810 (if vhdl-intelligent-tab
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
811 (define-key vhdl-mode-map "\t" 'vhdl-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
812 (define-key vhdl-mode-map "\t" 'vhdl-indent-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
813 (define-key vhdl-mode-map " " 'vhdl-outer-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
814 ;; new key bindings for VHDL Mode, with no counterpart to BOCM
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
815 (define-key vhdl-mode-map "\C-c\C-e" 'vhdl-electric-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
816 (define-key vhdl-mode-map "\C-c\C-s" 'vhdl-stutter-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
817 (define-key vhdl-mode-map "\C-c\C-u" 'vhdl-fix-case-buffer)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
818 (define-key vhdl-mode-map "\C-c\C-f" 'font-lock-fontify-buffer)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
819 (define-key vhdl-mode-map "\C-c\C-x" 'vhdl-show-syntactic-information)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 (define-key vhdl-mode-map "\C-c\C-r" 'vhdl-regress-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821 (define-key vhdl-mode-map "\C-c\C-i" 'vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
822 (define-key vhdl-mode-map "\C-c\C-a" 'vhdl-align-noindent-region)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823 (define-key vhdl-mode-map "\C-c\M-\C-a" 'vhdl-align-comment-region)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
824 (define-key vhdl-mode-map "\C-c\C-c" 'vhdl-comment-uncomment-region)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
825 (define-key vhdl-mode-map "\C-c-" 'vhdl-inline-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
826 (define-key vhdl-mode-map "\C-c\M--" 'vhdl-display-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
827 (define-key vhdl-mode-map "\C-c\C-o" 'vhdl-open-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
828 (define-key vhdl-mode-map "\C-c\C-g" 'goto-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
829 (define-key vhdl-mode-map "\C-c\C-d" 'vhdl-kill-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
830 (define-key vhdl-mode-map "\C-c\C-h" 'vhdl-help)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
831 (define-key vhdl-mode-map "\C-c\C-v" 'vhdl-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832 (define-key vhdl-mode-map "\C-c\C-b" 'vhdl-submit-bug-report)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833 (define-key vhdl-mode-map "\C-c\C-k" 'vhdl-compile)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
834 (define-key vhdl-mode-map "\C-c\M-\C-k" 'vhdl-make)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
835 (define-key vhdl-mode-map "\M-\t" 'tab-to-tab-stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
836 ;; key bindings for stuttering
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
837 (define-key vhdl-mode-map "-" 'vhdl-stutter-mode-dash)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838 (define-key vhdl-mode-map "'" 'vhdl-stutter-mode-quote)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
839 (define-key vhdl-mode-map ";" 'vhdl-stutter-mode-semicolon)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
840 (define-key vhdl-mode-map "[" 'vhdl-stutter-mode-open-bracket)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
841 (define-key vhdl-mode-map "]" 'vhdl-stutter-mode-close-bracket)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
842 (define-key vhdl-mode-map "." 'vhdl-stutter-mode-period)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
843 (define-key vhdl-mode-map "," 'vhdl-stutter-mode-comma)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
844 (let ((c 97))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
845 (while (< c 123) ; for little a-z
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
846 (define-key vhdl-mode-map (char-to-string c) 'vhdl-stutter-mode-caps)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
847 (setq c (1+ c))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
848 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
851 ;; define special minibuffer keymap for enabling word completion in minibuffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
852 ;; (useful in template generator prompts)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
853 (defvar vhdl-minibuffer-local-map (copy-keymap minibuffer-local-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
854 "Keymap for minibuffer used in VHDL Mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
855
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
856 (define-key vhdl-minibuffer-local-map "\t" 'vhdl-minibuffer-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
857
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
858 (defvar vhdl-mode-syntax-table nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
859 "Syntax table used in vhdl-mode buffers.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
860
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
861 (if vhdl-mode-syntax-table ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
862 (setq vhdl-mode-syntax-table (make-syntax-table))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
863 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
864 ;; why not? (is left to the user here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
865 (if vhdl-underscore-is-part-of-word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
866 (modify-syntax-entry ?_ "w" vhdl-mode-syntax-table))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
867 (modify-syntax-entry ?\" "\"" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
868 (modify-syntax-entry ?\$ "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
869 (modify-syntax-entry ?\% "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
870 (modify-syntax-entry ?\& "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
871 (modify-syntax-entry ?\' "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
872 (modify-syntax-entry ?\( "()" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
873 (modify-syntax-entry ?\) ")(" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
874 (modify-syntax-entry ?\* "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
875 (modify-syntax-entry ?\+ "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
876 (modify-syntax-entry ?\. "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
877 (modify-syntax-entry ?\/ "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
878 (modify-syntax-entry ?\: "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
879 (modify-syntax-entry ?\; "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
880 (modify-syntax-entry ?\< "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
881 (modify-syntax-entry ?\= "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
882 (modify-syntax-entry ?\> "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
883 (modify-syntax-entry ?\[ "(]" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
884 (modify-syntax-entry ?\\ "\\" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
885 (modify-syntax-entry ?\] ")[" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
886 (modify-syntax-entry ?\{ "(}" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
887 (modify-syntax-entry ?\| "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
888 (modify-syntax-entry ?\} "){" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
889 ;; add comment syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
890 (modify-syntax-entry ?\- ". 12" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
891 (modify-syntax-entry ?\n ">" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
892 (modify-syntax-entry ?\^M ">" vhdl-mode-syntax-table))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
893
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
894 (defvar vhdl-syntactic-context nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
895 "Buffer local variable containing syntactic analysis list.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
896 (make-variable-buffer-local 'vhdl-syntactic-context)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
897
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
898 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
899 ;; Abbrev hook bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
900
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
901 (defvar vhdl-mode-abbrev-table nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
902 "Abbrev table in use in vhdl-mode buffers.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
903
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
904 (define-abbrev-table 'vhdl-mode-abbrev-table
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
905 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
906 ("--" "" vhdl-display-comment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
907 ("abs" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
908 ("access" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
909 ("after" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
910 ("alias" "" vhdl-alias-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
911 ("all" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
912 ("and" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
913 ("arch" "" vhdl-architecture-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
914 ("architecture" "" vhdl-architecture-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
915 ("array" "" vhdl-array-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
916 ("assert" "" vhdl-assert-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
917 ("attr" "" vhdl-attribute-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
918 ("attribute" "" vhdl-attribute-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
919 ("begin" "" vhdl-default-indent-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
920 ("block" "" vhdl-block-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
921 ("body" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
922 ("buffer" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
923 ("bus" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
924 ("case" "" vhdl-case-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
925 ("comp" "" vhdl-component-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
926 ("component" "" vhdl-component-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 ("conc" "" vhdl-concurrent-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
928 ("concurrent" "" vhdl-concurrent-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
929 ("conf" "" vhdl-configuration-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930 ("configuration" "" vhdl-configuration-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
931 ("cons" "" vhdl-constant-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
932 ("constant" "" vhdl-constant-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
933 ("disconnect" "" vhdl-disconnect-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
934 ("downto" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
935 ("else" "" vhdl-else-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
936 ("elseif" "" vhdl-elsif-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
937 ("elsif" "" vhdl-elsif-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
938 ("end" "" vhdl-default-indent-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939 ("entity" "" vhdl-entity-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
940 ("exit" "" vhdl-exit-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
941 ("file" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
942 ("for" "" vhdl-for-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
943 ("func" "" vhdl-function-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
944 ("function" "" vhdl-function-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
945 ("gen" "" vhdl-generate-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
946 ("generate" "" vhdl-generate-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
947 ("generic" "" vhdl-generic-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
948 ("group" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
949 ("guarded" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
950 ("header" "" vhdl-header-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
951 ("if" "" vhdl-if-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
952 ("impure" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
953 ("in" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
954 ("inertial" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
955 ("inout" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
956 ("inst" "" vhdl-component-instance-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 ("instance" "" vhdl-component-instance-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958 ("is" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 ("label" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
960 ("library" "" vhdl-library-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961 ("linkage" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
962 ("literal" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
963 ("loop" "" vhdl-loop-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
964 ("map" "" vhdl-map-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
965 ("mod" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966 ("modify" "" vhdl-modify-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
967 ("nand" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
968 ("new" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
969 ("next" "" vhdl-next-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
970 ("nor" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
971 ("not" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
972 ("null" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
973 ("of" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
974 ("on" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
975 ("open" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
976 ("or" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
977 ("others" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
978 ("out" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
979 ("pack" "" vhdl-package-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
980 ("package" "" vhdl-package-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
981 ("port" "" vhdl-port-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
982 ("postponed" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
983 ("procedure" "" vhdl-procedure-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
984 ("process" "" vhdl-process-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
985 ("pure" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
986 ("range" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
987 ("record" "" vhdl-record-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
988 ("register" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
989 ("reject" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
990 ("rem" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
991 ("report" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
992 ("ret" "" vhdl-return-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
993 ("return" "" vhdl-return-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
994 ("rol" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
995 ("ror" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
996 ("select" "" vhdl-selected-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
997 ("severity" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
998 ("shared" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
999 ("sig" "" vhdl-signal-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1000 ("signal" "" vhdl-signal-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1001 ("sla" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1002 ("sll" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1003 ("sra" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1004 ("srl" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1005 ("sub" "" vhdl-subtype-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1006 ("subtype" "" vhdl-subtype-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1007 ("then" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1008 ("to" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1009 ("transport" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1010 ("type" "" vhdl-type-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1011 ("unaffected" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1012 ("units" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1013 ("until" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1014 ("use" "" vhdl-use-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1015 ("var" "" vhdl-variable-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1016 ("variable" "" vhdl-variable-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1017 ("wait" "" vhdl-wait-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1018 ("warning" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1019 ("when" "" vhdl-when-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1020 ("while" "" vhdl-while-loop-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1021 ("with" "" vhdl-selected-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1022 ("xnor" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1023 ("xor" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1024 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1025
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1026
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1027 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1028 ;; Menues
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1029 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1030
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1031 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1032 ;; VHDL menu (using `easy-menu.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1033
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1034 ;; `customize-menu-create' is included in `cus-edit.el' version 1.9954,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1035 ;; which is not yet distributed with XEmacs 19.15
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1036 (defun vhdl-customize-menu-create (symbol &optional name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1037 "Return a customize menu for customization group SYMBOL.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1038 If optional NAME is given, use that as the name of the menu.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1039 Otherwise the menu will be named `Customize'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1040 The format is suitable for use with `easy-menu-define'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1041 (unless name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1042 (setq name "Customize"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1043 (if (memq 'XEmacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1044 ;; We can delay it under XEmacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1045 `(,name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1046 :filter (lambda (&rest junk)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1047 (cdr (custom-menu-create ',symbol))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1048 ;; But we must create it now under Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1049 (cons name (cdr (custom-menu-create symbol)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1050
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1051 (defvar vhdl-mode-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1052 (append
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1053 '("VHDL"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1054 ("Mode"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1055 ["Electric" vhdl-electric-mode :style toggle :selected vhdl-electric-mode]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1056 ["Stutter" vhdl-stutter-mode :style toggle :selected vhdl-stutter-mode]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1057 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1058 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1059 ("Compile"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1060 ["Compile Buffer" vhdl-compile t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1061 ["Stop Compilation" kill-compilation t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1062 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1063 ["Make" vhdl-make t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1064 ["Generate Makefile" vhdl-generate-makefile t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1065 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1066 ["Next Error" next-error t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1067 ["Previous Error" previous-error t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1068 ["First Error" first-error t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1069 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1070 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1071 ("Template"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1072 ("VHDL Construct 1"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1073 ["Alias" vhdl-alias t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1074 ["Architecture" vhdl-architecture t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1075 ["Array" vhdl-array t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1076 ["Assert" vhdl-assert t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1077 ["Attribute" vhdl-attribute t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1078 ["Block" vhdl-block t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1079 ["Case" vhdl-case t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1080 ["Component" vhdl-component t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1081 ["Concurrent (Signal Asst)" vhdl-concurrent-signal-assignment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1082 ["Configuration (Block)" vhdl-block-configuration t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1083 ["Configuration (Comp)" vhdl-component-configuration t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1084 ["Configuration (Decl)" vhdl-configuration-decl t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1085 ["Configuration (Spec)" vhdl-configuration-spec t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1086 ["Constant" vhdl-constant t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1087 ["Disconnect" vhdl-disconnect t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1088 ["Else" vhdl-else t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1089 ["Elsif" vhdl-elsif t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1090 ["Entity" vhdl-entity t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1091 ["Exit" vhdl-exit t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1092 ["For (Loop)" vhdl-for t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1093 ["Function" vhdl-function t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1094 ["(For/If) Generate" vhdl-generate t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1095 ["Generic" vhdl-generic t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1096 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1097 ("VHDL Construct 2"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1098 ["If" vhdl-if t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1099 ["Instance" vhdl-component-instance t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1100 ["Library" vhdl-library t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1101 ["Loop" vhdl-loop t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1102 ["Map" vhdl-map t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1103 ["Next" vhdl-next t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1104 ["Package" vhdl-package t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1105 ["Port" vhdl-port t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1106 ["Procedure" vhdl-procedure t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1107 ["Process" vhdl-process t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1108 ["Record" vhdl-record t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1109 ["Return" vhdl-return-value t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1110 ["Select" vhdl-selected-signal-assignment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1111 ["Signal" vhdl-signal t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1112 ["Subtype" vhdl-subtype t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1113 ["Type" vhdl-type t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1114 ["Use" vhdl-use t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1115 ["Variable" vhdl-variable t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1116 ["Wait" vhdl-wait t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1117 ["(Clocked Wait)" vhdl-clocked-wait t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1118 ["When" vhdl-when t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1119 ["While (Loop)" vhdl-while-loop t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1120 ["With" vhdl-with t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1121 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1122 ("Standard Package"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1123 ["numeric_bit" vhdl-package-numeric-bit t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1124 ["numeric_std" vhdl-package-numeric-std t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1125 ["std_logic_1164" vhdl-package-std-logic-1164 t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1126 ["textio" vhdl-package-textio t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1127 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1128 ["Header" vhdl-header t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1129 ["Modify (Date)" vhdl-modify t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1130 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1131 ("Comment"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1132 ["(Un)Comment Out Region" vhdl-comment-uncomment-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1133 ["Insert Inline Comment" vhdl-inline-comment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1134 ["Insert Horizontal Line" vhdl-display-comment-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1135 ["Insert Display Comment" vhdl-display-comment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1136 ["Fill Comment" fill-paragraph t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1137 ["Fill Comment Region" fill-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1138 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1139 ("Indent"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1140 ["Line" vhdl-indent-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1141 ["Region" indent-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1142 ["Buffer" vhdl-indent-buffer t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1143 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1144 ("Align"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1145 ["Region" vhdl-align-noindent-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1146 ["Comment Region" vhdl-align-comment-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1147 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1148 ("Line"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1149 ["Open" vhdl-open-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1150 ["Delete" vhdl-kill-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1151 ["Join" delete-indentation t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1152 ["Goto" goto-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1153 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1154 ("Move"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1155 ["Forward Statement" vhdl-end-of-statement t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1156 ["Backward Statement" vhdl-beginning-of-statement t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1157 ["Forward Expression" vhdl-forward-sexp t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1158 ["Backward Expression" vhdl-backward-sexp t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1159 ["Forward Function" vhdl-end-of-defun t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1160 ["Backward Function" vhdl-beginning-of-defun t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1161 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1162 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1163 ("Fix Case"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1164 ["Buffer" vhdl-fix-case-buffer t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1165 ["Region" vhdl-fix-case-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1166 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1167 ["Fontify Buffer" font-lock-fontify-buffer t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1168 ["Syntactic Info" vhdl-show-syntactic-information t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1169 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1170 ["Help" vhdl-help t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1171 ["Version" vhdl-version t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1172 ["Bug Report" vhdl-submit-bug-report t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1173 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1174 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1175 (list (vhdl-customize-menu-create 'vhdl))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1176 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1177
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1178 (require 'easymenu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1179
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1180 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1181 ;; Index menu (using `imenu.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1182
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1183 (defvar vhdl-imenu-generic-expression
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1184 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1185 ("Entity"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1186 "^\\s-*\\(entity\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1187 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1188 ("Architecture"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1189 "^\\s-*\\(architecture\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\s-+of\\s-+\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1190 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1191 ("Configuration"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1192 "^\\s-*\\(configuration\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\s-+of\\s-+\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1193 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1194 ("Package Body"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1195 "^\\s-*\\(package body\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1196 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1197 ("Package"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1198 "^\\s-*\\(package\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1199 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1200 ("Type"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1201 "^\\s-*\\(sub\\)?type\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1202 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1203 ("Component"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1204 "^\\s-*\\(component\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1205 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1206 ("Function / Procedure"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1207 "^\\s-*\\(procedure\\|function\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1208 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1209 ("Process / Block"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1210 "^\\s-*\\(\\(\\w\\|\\s_\\)+\\)\\s-*:\\(\\s-\\|\n\\)*\\(process\\|block\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1211 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1212 ("Instance"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1213 "^\\s-*\\(\\(\\w\\|\\s_\\)+\\s-*:\\(\\s-\\|\n\\)*\\(\\w\\|\\s_\\)+\\)\\(\\s-\\|\n\\)+\\(generic\\|port\\)\\s-+map\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1214 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1215 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1216 "Imenu generic expression for VHDL Mode. See `imenu-generic-expression'.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1217
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1218 (defun vhdl-add-index-menu ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1219 (make-local-variable 'imenu-generic-expression)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1220 (setq imenu-generic-expression vhdl-imenu-generic-expression)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1221 (imenu-add-to-menubar "Index"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1222
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1223 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1224 ;; Source file menu (using `easy-menu.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1225
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1226 (defvar vhdl-extlist '("[A-Za-z0-9_.]*.vhdl?$"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1227 (defvar vhdl-filelist-menu nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1228
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1229 (defun vhdl-add-source-files-menu ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1230 "Scan directory of current source file for all VHDL source files, and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1231 generate menu."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1232 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1233 (message "Scanning directory for source files ...")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1234 (let (filelist menulist tmpextlist found
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1235 (newmap (current-local-map)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1236 (cd (file-name-directory (buffer-file-name)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1237 ;; find files
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1238 (setq menulist '())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1239 (setq tmpextlist vhdl-extlist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1240 (while tmpextlist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1241 (setq filelist (nreverse (directory-files
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1242 (file-name-directory (buffer-file-name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1243 nil (car tmpextlist) nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1244 ;; Create list for menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1245 (setq found nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1246 (while filelist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1247 (setq found t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1248 (setq menulist (cons (vector (car filelist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1249 (list 'find-file (car filelist)) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1250 menulist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1251 (setq filelist (cdr filelist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1252 (setq menulist (vhdl-menu-split menulist 25))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1253 (if found
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1254 (setq menulist (cons "--" menulist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1255 (setq tmpextlist (cdr tmpextlist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1256 (setq menulist (cons ["*Rescan*" vhdl-add-source-files-menu t] menulist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1257 (setq menulist (cons "Sources" menulist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1258 ;; Create menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1259 (easy-menu-add menulist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1260 (easy-menu-define vhdl-filelist-menu newmap
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1261 "VHDL source files menu" menulist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1262 ; (use-local-map (append (current-local-map) newmap))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1263 ; (use-local-map newmap)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1264 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1265 (message ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1266
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1267 (defun vhdl-menu-split (list n)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1268 "Split menu into several submenues, if number of elements > n."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1269 (if (> (length list) n)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1270 (let ((remain list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1271 (result '())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1272 (sublist '())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1273 (menuno 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1274 (i 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1275 (while remain
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1276 (setq sublist (cons (car remain) sublist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1277 (setq remain (cdr remain))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1278 (setq i (+ i 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1279 (if (= i n)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1280 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1281 (setq result (cons (cons (format "Sources %s" menuno)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1282 (nreverse sublist)) result))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1283 (setq i 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1284 (setq menuno (+ menuno 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1285 (setq sublist '()))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1286 (and sublist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1287 (setq result (cons (cons (format "Sources %s" menuno)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1288 (nreverse sublist)) result)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1289 (nreverse result))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1290 list))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1291
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1292
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1293 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1294 ;; VHDL Mode definition
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1295 ;; ############################################################################
21446
830023d4cec6 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 20665
diff changeset
1296 ;;;###autoload
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1297 (defun vhdl-mode ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1298 "Major mode for editing VHDL code.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1299
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1300 Usage:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1301 ------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1302
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1303 - TEMPLATE INSERTION (electrification) (`\\[vhdl-outer-space]'): After typing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1304 a VHDL keyword and entering `\\[vhdl-outer-space]', you are prompted for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1305 arguments while a template is generated for that VHDL construct. Typing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1306 `\\[vhdl-return]' (or `\\[keyboard-quit]' in yes-no queries) at the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1307 prompt aborts the current template generation. Typing `\\[just-one-space]'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1308 after a keyword inserts a space without calling the template generator.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1309 Automatic calling of the template generators (i.e. electrification) can be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1310 disabled (enabled) by setting the variable `vhdl-electric-mode' to nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1311 (non-nil) or by typing `\\[vhdl-electric-mode]' (toggles electrification
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1312 mode).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1313 Template generators can be called using the VHDL menu, the key bindings, or
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1314 by typing the keyword (first word of menu entry not in parenthesis) and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1315 `\\[vhdl-outer-space]'. The following abbreviations can also be used:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1316 arch, attr, conc, conf, comp, cons, func, inst, pack, ret, sig, sub, var.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1317
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1318 - HEADER INSERTION (`\\[vhdl-header]'): A customized header can be inserted
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1319 including the actual file name, user name, and current date as well as
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1320 prompted title strings. A custom header can be defined in a separate file
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1321 (see custom variable `vhdl-header-file').
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1322
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1323 - STUTTERING (double strike): Double striking of some keys inserts cumbersome
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1324 VHDL syntax elements. Stuttering can be disabled by variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1325 `vhdl-stutter-mode' and be toggled by typing `\\[vhdl-stutter-mode]'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1326 '' --> \" [ --> ( -- --> comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1327 ;; --> \" : \" [[ --> [ --CR --> comment-out code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1328 ;;; --> \" := \" ] --> ) --- --> horizontal line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1329 .. --> \" => \" ]] --> ] ---- --> display comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1330 ,, --> \" <= \" aa --> A - zz --> Z
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1331
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1332 - WORD COMPLETION (`\\[vhdl-tab]'): Typing `\\[vhdl-tab]' after a (not
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1333 completed) word looks for a word in the buffer that starts alike and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1334 inserts it. Re-typing `\\[vhdl-tab]' toggles through alternative word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1335 completions. This also works in the minibuffer (i.e. in template generator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1336 prompts).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1337
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1338 Typing `\\[vhdl-tab]' after a non-word character indents the line if at the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1339 beginning of a line (i.e. no preceding non-blank characters), and inserts a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1340 tabulator stop otherwise. `\\[tab-to-tab-stop]' always inserts a tabulator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1341 stop.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1342
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1343 - COMMENTS (`--', `---', `----', `--CR'):
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1344 `--' puts a single comment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1345 `---' draws a horizontal line for separating code segments.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1346 `----' inserts a display comment, i.e. two horizontal lines with a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1347 comment in between.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1348 `--CR' comments out code on that line. Re-hitting CR comments out
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1349 following lines.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1350 `\\[vhdl-comment-uncomment-region]' comments out a region if not
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1351 commented out, uncomments out a region if already
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1352 commented out.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1353
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1354 You are prompted for comments after object definitions (i.e. signals,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1355 variables, constants, ports) and after subprogram and process specifications
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1356 if variable `vhdl-prompt-for-comments' is non-nil. Comments are
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1357 automatically inserted as additional labels (e.g. after begin statements)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1358 and help comments if `vhdl-self-insert-comments' is non-nil.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1359 Inline comments (i.e. comments after a piece of code on the same line) are
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1360 indented at least to `vhdl-comment-column'. Comments go at maximum to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1361 `vhdl-end-comment-column'. `\\[vhdl-return]' after a space in a comment will
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1362 open a new comment line. Typing beyond `vhdl-end-comment-column' in a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1363 comment automatically opens a new comment line. `\\[fill-paragraph]'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1364 re-fills multi-line comments.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1365
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1366 - INDENTATION: `\\[vhdl-tab]' indents a line if at the beginning of the line.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1367 The amount of indentation is specified by variable `vhdl-basic-offset'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1368 `\\[vhdl-indent-line]' always indents the current line (is bound to `TAB'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1369 if variable `vhdl-intelligent-tab' is nil). Indentation can be done for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1370 an entire region (`\\[indent-region]') or buffer (menu). Argument and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1371 port lists are indented normally (nil) or relative to the opening
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1372 parenthesis (non-nil) according to variable `vhdl-argument-list-indent'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1373 If variable `vhdl-indent-tabs-mode' is nil, spaces are used instead of tabs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1374 `\\[tabify]' and `\\[untabify]' allow to convert spaces to tabs and vice
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1375 versa.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1376
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1377 - ALIGNMENT: `\\[vhdl-align-noindent-region]' aligns port maps, signal and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1378 variable assignments, inline comments, some keywords, etc., on consecutive
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1379 lines relative to each other within a defined region.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1380 `\\[vhdl-align-comment-region]' only aligns inline comments (i.e. comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1381 that are at the end of a line of code). Some templates are automatically
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1382 aligned after generation if custom variable `vhdl-auto-align' is non-nil.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1383
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1384 - KEY BINDINGS: Key bindings (`C-c ...') exist for most commands (see in menu).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1385
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1386 - VHDL MENU: All commands can be called from the VHDL menu.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1387
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1388 - INDEX MENU: For each VHDL source file, an index of the contained entities,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1389 architectures, packages, procedures, processes, etc., is created as a menu.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1390 Selecting a meny entry causes the cursor to jump to the corresponding
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1391 position in the file. Controlled by variable `vhdl-index-menu'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1392
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1393 - SOURCE FILE MENU: A menu containing all VHDL source files in the directory
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1394 of the current file is generated. Selecting a menu entry loads the file.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1395 Controlled by variable `vhdl-source-file-menu'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1396
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1397 - SOURCE FILE COMPILATION: The syntax of the current buffer can be analyzed
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1398 by calling a VHDL compiler (menu, `\\[vhdl-compile]'). The compiler to be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1399 used is defined by variable `vhdl-compiler'. Currently supported are
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1400 `cadence', `ikos', `quickhdl', `synopsys', `vantage', `viewlogic', and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1401 `v-system'. Not all compilers are tested. Please contact me for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1402 incorporating additional VHDL compilers. An entire hierarchy of source
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1403 files can be compiled by the `make' command (menu, `\\[vhdl-make]').
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1404 This only works if an appropriate `Makefile' exists. Compiler options can
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1405 be defined by variable `vhdl-compiler-options'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1406
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1407 - KEYWORD CASE: Lower and upper case for keywords, predefined types, predefined
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1408 attributes, and predefined enumeration values is supported. If the variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1409 `vhdl-upper-case-keywords' is set to non-nil, keywords can be typed in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1410 lower case and are converted into upper case automatically (not for types,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1411 attributes, and enumeration values). The case of keywords, types,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1412 attributes, and enumeration values can be fixed for an entire region (menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1413 or buffer (`\\[vhdl-fix-case-buffer]') according to the variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1414 `vhdl-upper-case-{keywords,types,attributes,enum-values}'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1415
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1416 - HIGHLIGHTING (fontification): Keywords, predefined types, predefined
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1417 attributes, and predefined enumeration values (controlled by variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1418 `vhdl-highlight-keywords'), as well as comments, strings, and template
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1419 prompts are highlighted using different colors. Unit and subprogram names
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1420 as well as labels are highlighted if variable `vhdl-highlight-names' is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1421 non-nil. The default colors from `font-lock.el' are used if variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1422 `vhdl-use-default-colors' is non-nil. Otherwise, an optimized set of colors
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1423 is taken, which uses bright colors for signals and muted colors for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1424 everything else. Variable `vhdl-use-default-faces' does the same on
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1425 monochrome monitors.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1426
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1427 Signal highlighting allows distinction between clock, reset,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1428 status/control, data, and test signals according to some signal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1429 naming convention. Their syntax is defined by variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1430 `vhdl-{clock,reset,control,data,test}-signal-syntax'. Signal coloring
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1431 is controlled by the variable `vhdl-highlight-signals'. The default
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1432 signal naming convention is as follows:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1433
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1434 Signal attributes:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1435 C clock S control and status
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1436 R asynchronous reset D data and address
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1437 I synchronous reset T test
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1438
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1439 Syntax:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1440 signal name ::= \"[A-Z][a-zA-Z0-9]*x[CRISDT][a-zA-Z0-9]*\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1441 signal identifier -^^^^^^^^^^^^^^^^^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1442 delimiter --------------------------^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1443 above signal attributes -------------^^^^^^^^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1444 additional attributes -----------------------^^^^^^^^^^^^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1445
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1446 (`x' is used as delimiter because `_' is reserved by the VITAL standard.)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1447 Examples: ClkxCfast, ResetxRB, ClearxI, SelectDataxS, DataxD, ScanEnablexT.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1448
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1449 If all VHDL words are written in lower case (i.e. variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1450 `vhdl-upper-case-{keywords,types,attributes,enum-values}' are set to nil),
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1451 make highlighting case sensitive by setting variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1452 `vhdl-highlight-case-sensitive' to non-nil. This way, only names fulfilling
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1453 the above signal syntax including case are highlighted.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1454
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1455 - HIDE/SHOW: The code of entire VHDL processes or blocks can be hidden using
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1456 the `Hide/Show' menu or by pressing `S-mouse-2' within the code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1457 (not in XEmacs).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1458
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1459 - PRINTING: Postscript printing with different fonts (`ps-print-color-p' is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1460 nil, default faces from `font-lock.el' used if `vhdl-use-default-faces' is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1461 non-nil) or colors (`ps-print-color-p' is non-nil) is possible using the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1462 standard Emacs postscript printing commands. Variable `vhdl-print-two-column'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1463 defines appropriate default settings for nice landscape two-column printing.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1464 The paper format can be set by variable `ps-paper-type'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1465
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1466 - CUSTOMIZATION: All variables can easily be customized using the `Customize'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1467 menu entry. For some variables, customization only takes effect after
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1468 re-starting Emacs. Customization can also be done globally (i.e. site-wide,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1469 read INSTALL file). Variables of VHDL Mode must NOT be set using the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1470 `vhdl-mode-hook' in the .emacs file anymore (delete them if they still are).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1471
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1472
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1473 Maintenance:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1474 ------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1475
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1476 To submit a bug report, enter `\\[vhdl-submit-bug-report]' within VHDL Mode.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1477 Add a description of the problem and include a reproducible test case.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1478
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1479 Questions and enhancement requests can be sent to <vhdl-mode@geocities.com>.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1480
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1481 The `vhdl-mode-announce' mailing list informs about new VHDL Mode releases.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1482 The `vhdl-mode-victims' mailing list informs about new VHDL Mode beta releases.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1483 You are kindly invited to participate in beta testing. Subscribe to above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1484 mailing lists by sending an email to <vhdl-mode@geocities.com>.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1485
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1486 The archive with the latest version is located at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1487 <http://www.geocities.com/SiliconValley/Peaks/8287>.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1488
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1489
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1490 Bugs and Limitations:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1491 ---------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1492
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1493 - Index menu does not work under XEmacs (limitation of XEmacs ?!).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1494
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1495 - Re-indenting large regions or expressions can be slow.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1496
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1497 - Hideshow does not work under XEmacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1498
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1499 - Parsing compilation error messages for Ikos and Vantage VHDL compilers
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1500 does not work under XEmacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1501
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1502
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1503 Key bindings:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1504 -------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1505
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1506 \\{vhdl-mode-map}"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1507 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1508 (kill-all-local-variables)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1509 (set-syntax-table vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1510 (setq major-mode 'vhdl-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1511 (setq mode-name "VHDL")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1512 (setq local-abbrev-table vhdl-mode-abbrev-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1513 (use-local-map vhdl-mode-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1514 ;; set local variable values
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1515 (set (make-local-variable 'paragraph-start) "\\s-*\\(---\\|[a-zA-Z]\\|$\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1516 (set (make-local-variable 'paragraph-separate) paragraph-start)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1517 (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1518 (set (make-local-variable 'require-final-newline) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1519 (set (make-local-variable 'parse-sexp-ignore-comments) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1520 (set (make-local-variable 'indent-line-function) 'vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1521 (set (make-local-variable 'comment-start) "--")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1522 (set (make-local-variable 'comment-end) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1523 (set (make-local-variable 'comment-column) vhdl-comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1524 (set (make-local-variable 'end-comment-column) vhdl-end-comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1525 (set (make-local-variable 'comment-start-skip) "--+\\s-*")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1526 (set (make-local-variable 'dabbrev-case-fold-search) nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1527 (set (make-local-variable 'indent-tabs-mode) vhdl-indent-tabs-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1528
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1529 ;; setup the comment indent variable in a Emacs version portable way
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1530 ;; ignore any byte compiler warnings you might get here
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1531 (if (boundp 'comment-indent-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1532 (progn (make-local-variable 'comment-indent-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1533 (setq comment-indent-function 'vhdl-comment-indent)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1534
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1535 ;; initialize font locking
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1536 (require 'font-lock)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1537 (vhdl-font-lock-init)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1538 (make-local-variable 'font-lock-defaults)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1539 (setq font-lock-defaults (list 'vhdl-font-lock-keywords nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1540 (not vhdl-highlight-case-sensitive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1541 '((?\_ . "w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1542 (turn-on-font-lock)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1543
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1544 ;; variables for source file compilation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1545 (make-local-variable 'compile-command)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1546 (set (make-local-variable 'compilation-error-regexp-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1547 vhdl-compilation-error-regexp-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1548
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1549 ;; add menus
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1550 (if vhdl-index-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1551 (if (or (not (consp font-lock-maximum-size))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1552 (> font-lock-maximum-size (buffer-size)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1553 (vhdl-add-index-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1554 (message "Scanning buffer for index...buffer too big")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1555 (if vhdl-source-file-menu (vhdl-add-source-files-menu))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1556 (easy-menu-add vhdl-mode-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1557 (easy-menu-define vhdl-mode-easy-menu vhdl-mode-map
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1558 "Menu keymap for VHDL Mode." vhdl-mode-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1559 (run-hooks 'menu-bar-update-hook)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1560
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1561 ;; initialize hideshow and add menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1562 (if vhdl-hideshow-menu (hs-minor-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1563
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1564 ;; initialize postscript printing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1565 (vhdl-ps-init)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1566
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1567 (setq mode-name (if vhdl-electric-mode "Electric VHDL" "VHDL"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1568 (message "Type C-c C-h for VHDL Mode documentation.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1569
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1570 (run-hooks 'vhdl-mode-hook)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1571 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1572
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1573
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1574 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1575 ;; Keywords and predefined words in VHDL'93
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1576 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1577
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1578 ;; `regexp-opt' was not used at this place because it is not yet implemented
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1579 ;; in XEmacs and because it resulted in SLOWER regexps!!
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1580
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1581 (defconst vhdl-93-keywords-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1582 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1583 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1584 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1585 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1586 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1587 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1588 "abs" "access" "after" "alias" "all" "and" "architecture" "array"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1589 "assert" "attribute"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1590 "begin" "block" "body" "buffer" "bus"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1591 "case" "component" "configuration" "constant"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1592 "disconnect" "downto"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1593 "else" "elsif" "end" "entity" "exit"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1594 "file" "for" "function"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1595 "generate" "generic" "group" "guarded"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1596 "if" "impure" "in" "inertial" "inout" "is"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1597 "label" "library" "linkage" "literal" "loop"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1598 "map" "mod"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1599 "nand" "new" "next" "nor" "not" "null"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1600 "of" "on" "open" "or" "others" "out"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1601 "package" "port" "postponed" "procedure" "process" "pure"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1602 "range" "record" "register" "reject" "rem" "report" "return"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1603 "rol" "ror"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1604 "select" "severity" "shared" "signal" "sla" "sll" "sra" "srl" "subtype"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1605 "then" "to" "transport" "type"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1606 "unaffected" "units" "until" "use"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1607 "variable"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1608 "wait" "warning" "when" "while" "with"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1609 "xnor" "xor"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1610 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1611 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1612 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1613 "Regexp for VHDL'93 keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1614
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1615 (defconst vhdl-93-types-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1616 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1617 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1618 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1619 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1620 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1621 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1622 "boolean" "bit" "bit_vector" "character" "severity_level" "integer"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1623 "real" "time" "natural" "positive" "string" "text" "line"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1624 "unsigned" "signed"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1625 "std_logic" "std_logic_vector"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1626 "std_ulogic" "std_ulogic_vector"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1627 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1628 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1629 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1630 "Regexp for VHDL'93 standardized types.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1631
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1632 (defconst vhdl-93-attributes-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1633 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1634 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1635 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1636 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1637 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1638 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1639 "base" "left" "right" "high" "low" "pos" "val" "succ"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1640 "pred" "leftof" "rightof" "range" "reverse_range"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1641 "length" "delayed" "stable" "quiet" "transaction"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1642 "event" "active" "last_event" "last_active" "last_value"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1643 "driving" "driving_value" "ascending" "value" "image"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1644 "simple_name" "instance_name" "path_name"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1645 "foreign"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1646 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1647 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1648 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1649 "Regexp for VHDL'93 standardized attributes.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1650
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1651 (defconst vhdl-93-enum-values-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1652 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1653 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1654 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1655 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1656 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1657 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1658 "true" "false"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1659 "note" "warning" "error" "failure"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1660 "fs" "ps" "ns" "us" "ms" "sec" "min" "hr"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1661 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1662 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1663 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1664 "Regexp for VHDL'93 standardized enumeration values.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1666
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1667 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1668 ;; Syntax analysis and indentation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1669 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1670
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1671 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1672 ;; Syntax analysis
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1673
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1674 ;; constant regular expressions for looking at various constructs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1675
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1676 (defconst vhdl-symbol-key "\\(\\w\\|\\s_\\)+"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1677 "Regexp describing a VHDL symbol.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1678 We cannot use just `word' syntax class since `_' cannot be in word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1679 class. Putting underscore in word class breaks forward word movement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1680 behavior that users are familiar with.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1681
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1682 (defconst vhdl-case-header-key "case[( \t\n][^;=>]+[) \t\n]is"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1683 "Regexp describing a case statement header key.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1684
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1685 (defconst vhdl-label-key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1686 (concat "\\(" vhdl-symbol-key "\\s-*:\\)[^=]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1687 "Regexp describing a VHDL label.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1688
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1689 ;; Macro definitions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1690
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1691 (defmacro vhdl-point (position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1692 ;; Returns the value of point at certain commonly referenced POSITIONs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1693 ;; POSITION can be one of the following symbols:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1694 ;;
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1695 ;; bol -- beginning of line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1696 ;; eol -- end of line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1697 ;; bod -- beginning of defun
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1698 ;; boi -- back to indentation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1699 ;; eoi -- last whitespace on line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1700 ;; ionl -- indentation of next line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1701 ;; iopl -- indentation of previous line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1702 ;; bonl -- beginning of next line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1703 ;; bopl -- beginning of previous line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1704 ;;
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1705 ;; This function does not modify point or mark.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1706 (or (and (eq 'quote (car-safe position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1707 (null (cdr (cdr position))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1708 (error "bad buffer position requested: %s" position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1709 (setq position (nth 1 position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1710 (` (let ((here (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1711 (,@ (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1712 ((eq position 'bol) '((beginning-of-line)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1713 ((eq position 'eol) '((end-of-line)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1714 ((eq position 'bod) '((save-match-data
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1715 (vhdl-beginning-of-defun))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1716 ((eq position 'boi) '((back-to-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1717 ((eq position 'eoi) '((end-of-line)(skip-chars-backward " \t")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1718 ((eq position 'bonl) '((forward-line 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1719 ((eq position 'bopl) '((forward-line -1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1720 ((eq position 'iopl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1721 '((forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1722 (back-to-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1723 ((eq position 'ionl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1724 '((forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1725 (back-to-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1726 (t (error "unknown buffer position requested: %s" position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1727 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1728 (prog1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1729 (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1730 (goto-char here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1731 ;; workaround for an Emacs18 bug -- blech! Well, at least it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1732 ;; doesn't hurt for v19
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1733 (,@ nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1734 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1735
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1736 (defmacro vhdl-safe (&rest body)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1737 ;; safely execute BODY, return nil if an error occurred
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1738 (` (condition-case nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1739 (progn (,@ body))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1740 (error nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1741
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1742 (defmacro vhdl-add-syntax (symbol &optional relpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1743 ;; a simple macro to append the syntax in symbol to the syntax list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1744 ;; try to increase performance by using this macro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1745 (` (setq vhdl-syntactic-context
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1746 (cons (cons (, symbol) (, relpos)) vhdl-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1747
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1748 (defmacro vhdl-has-syntax (symbol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1749 ;; a simple macro to return check the syntax list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1750 ;; try to increase performance by using this macro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1751 (` (assoc (, symbol) vhdl-syntactic-context)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1752
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1753 ;; Syntactic element offset manipulation:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1754
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1755 (defun vhdl-read-offset (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1756 ;; read new offset value for LANGELEM from minibuffer. return a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1757 ;; legal value only
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1758 (let ((oldoff (format "%s" (cdr-safe (assq langelem vhdl-offsets-alist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1759 (errmsg "Offset must be int, func, var, or one of +, -, ++, --: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1760 (prompt "Offset: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1761 offset input interned)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1762 (while (not offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1763 (setq input (read-string prompt oldoff)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1764 offset (cond ((string-equal "+" input) '+)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1765 ((string-equal "-" input) '-)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1766 ((string-equal "++" input) '++)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1767 ((string-equal "--" input) '--)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1768 ((string-match "^-?[0-9]+$" input)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1769 (string-to-int input))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1770 ((fboundp (setq interned (intern input)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1771 interned)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1772 ((boundp interned) interned)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1773 ;; error, but don't signal one, keep trying
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1774 ;; to read an input value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1775 (t (ding)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1776 (setq prompt errmsg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1777 nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1778 offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1779
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1780 (defun vhdl-set-offset (symbol offset &optional add-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1781 "Change the value of a syntactic element symbol in `vhdl-offsets-alist'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1782 SYMBOL is the syntactic element symbol to change and OFFSET is the new
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1783 offset for that syntactic element. Optional ADD says to add SYMBOL to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1784 `vhdl-offsets-alist' if it doesn't already appear there."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1785 (interactive
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1786 (let* ((langelem
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1787 (intern (completing-read
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1788 (concat "Syntactic symbol to change"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1789 (if current-prefix-arg " or add" "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1790 ": ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1791 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1792 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1793 (lambda (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1794 (cons (format "%s" (car langelem)) nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1795 vhdl-offsets-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1796 nil (not current-prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1797 ;; initial contents tries to be the last element
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1798 ;; on the syntactic analysis list for the current
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1799 ;; line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1800 (let* ((syntax (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1801 (len (length syntax))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1802 (ic (format "%s" (car (nth (1- len) syntax)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1803 (if (memq 'v19 vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1804 (cons ic 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1805 ic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1806 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1807 (offset (vhdl-read-offset langelem)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1808 (list langelem offset current-prefix-arg)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1809 ;; sanity check offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1810 (or (eq offset '+)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1811 (eq offset '-)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1812 (eq offset '++)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1813 (eq offset '--)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1814 (integerp offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1815 (fboundp offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1816 (boundp offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1817 (error "Offset must be int, func, var, or one of +, -, ++, --: %s"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1818 offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1819 (let ((entry (assq symbol vhdl-offsets-alist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1820 (if entry
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1821 (setcdr entry offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1822 (if add-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1823 (setq vhdl-offsets-alist (cons (cons symbol offset) vhdl-offsets-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1824 (error "%s is not a valid syntactic symbol." symbol))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1825 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1826
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1827 (defun vhdl-set-style (style &optional local)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1828 "Set vhdl-mode variables to use one of several different indentation styles.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1829 STYLE is a string representing the desired style and optional LOCAL is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1830 a flag which, if non-nil, means to make the style variables being
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1831 changed buffer local, instead of the default, which is to set the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1832 global variables. Interactively, the flag comes from the prefix
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1833 argument. The styles are chosen from the `vhdl-style-alist' variable."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1834 (interactive (list (completing-read "Use which VHDL indentation style? "
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1835 vhdl-style-alist nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1836 current-prefix-arg))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1837 (let ((vars (cdr (assoc style vhdl-style-alist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1838 (or vars
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1839 (error "Invalid VHDL indentation style `%s'" style))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1840 ;; set all the variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1841 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1842 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1843 (lambda (varentry)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1844 (let ((var (car varentry))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1845 (val (cdr varentry)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1846 (and local
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1847 (make-local-variable var))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1848 ;; special case for vhdl-offsets-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1849 (if (not (eq var 'vhdl-offsets-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1850 (set var val)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1851 ;; reset vhdl-offsets-alist to the default value first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1852 (setq vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1853 ;; now set the langelems that are different
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1854 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1855 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1856 (lambda (langentry)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1857 (let ((langelem (car langentry))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1858 (offset (cdr langentry)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1859 (vhdl-set-offset langelem offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1860 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1861 val))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1862 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1863 vars))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1864 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1865
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1866 (defun vhdl-get-offset (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1867 ;; Get offset from LANGELEM which is a cons cell of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1868 ;; (SYMBOL . RELPOS). The symbol is matched against
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1869 ;; vhdl-offsets-alist and the offset found there is either returned,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1870 ;; or added to the indentation at RELPOS. If RELPOS is nil, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1871 ;; the offset is simply returned.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1872 (let* ((symbol (car langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1873 (relpos (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1874 (match (assq symbol vhdl-offsets-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1875 (offset (cdr-safe match)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1876 ;; offset can be a number, a function, a variable, or one of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1877 ;; symbols + or -
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1878 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1879 ((not match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1880 (if vhdl-strict-syntax-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1881 (error "don't know how to indent a %s" symbol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1882 (setq offset 0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1883 relpos 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1884 ((eq offset '+) (setq offset vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1885 ((eq offset '-) (setq offset (- vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1886 ((eq offset '++) (setq offset (* 2 vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1887 ((eq offset '--) (setq offset (* 2 (- vhdl-basic-offset))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1888 ((and (not (numberp offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1889 (fboundp offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1890 (setq offset (funcall offset langelem)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1891 ((not (numberp offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1892 (setq offset (eval offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1893 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1894 (+ (if (and relpos
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1895 (< relpos (vhdl-point 'bol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1896 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1897 (goto-char relpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1898 (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1899 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1900 offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1901
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1902 ;; Syntactic support functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1903
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1904 ;; Returns `comment' if in a comment, `string' if in a string literal,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1905 ;; or nil if not in a literal at all. Optional LIM is used as the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1906 ;; backward limit of the search. If omitted, or nil, (point-min) is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1907 ;; used.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1908
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1909 (defun vhdl-in-literal (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1910 ;; Determine if point is in a VHDL literal.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1911 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1912 (let* ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1913 (state (parse-partial-sexp lim (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1914 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1915 ((nth 3 state) 'string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1916 ((nth 4 state) 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1917 (t nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1918 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1919
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1920 ;; This is the best we can do in Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1921 (defun vhdl-win-il (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1922 ;; Determine if point is in a VHDL literal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1923 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1924 (let* ((here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1925 (state nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1926 (match nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1927 (lim (or lim (vhdl-point 'bod))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1928 (goto-char lim )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1929 (while (< (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1930 (setq match
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1931 (and (re-search-forward "--\\|[\"']"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1932 here 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1933 (buffer-substring (match-beginning 0) (match-end 0))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1934 (setq state
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1935 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1936 ;; no match
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1937 ((null match) nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1938 ;; looking at the opening of a VHDL style comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1939 ((string= "--" match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1940 (if (<= here (progn (end-of-line) (point))) 'comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1941 ;; looking at the opening of a double quote string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1942 ((string= "\"" match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1943 (if (not (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1944 ;; this seems to be necessary since the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1945 ;; re-search-forward will not work without it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1946 (narrow-to-region (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1947 (re-search-forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1948 ;; this regexp matches a double quote
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1949 ;; which is preceded by an even number
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1950 ;; of backslashes, including zero
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1951 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)*\"" here 'move)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1952 'string))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1953 ;; looking at the opening of a single quote string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1954 ((string= "'" match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1955 (if (not (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1956 ;; see comments from above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1957 (narrow-to-region (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1958 (re-search-forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1959 ;; this matches a single quote which is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1960 ;; preceded by zero or two backslashes.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1961 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)?'"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1962 here 'move)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1963 'string))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1964 (t nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1965 ) ; end-while
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1966 state)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1967
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1968 (and (memq 'Win-Emacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1969 (fset 'vhdl-in-literal 'vhdl-win-il))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1970
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1971 ;; Skipping of "syntactic whitespace". Syntactic whitespace is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1972 ;; defined as lexical whitespace or comments. Search no farther back
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1973 ;; or forward than optional LIM. If LIM is omitted, (point-min) is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1974 ;; used for backward skipping, (point-max) is used for forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1975 ;; skipping.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1976
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1977 (defun vhdl-forward-syntactic-ws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1978 ;; Forward skip of syntactic whitespace.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1979 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1980 (let* ((lim (or lim (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1981 (here lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1982 (hugenum (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1983 (narrow-to-region lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1984 (while (/= here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1985 (setq here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1986 (forward-comment hugenum))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1987 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1988
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1989 ;; This is the best we can do in Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1990 (defun vhdl-win-fsws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1991 ;; Forward skip syntactic whitespace for Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1992 (let ((lim (or lim (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1993 stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1994 (while (not stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1995 (skip-chars-forward " \t\n\r\f" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1996 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1997 ;; vhdl comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1998 ((looking-at "--") (end-of-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1999 ;; none of the above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2000 (t (setq stop t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2001 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2002
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2003 (and (memq 'Win-Emacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2004 (fset 'vhdl-forward-syntactic-ws 'vhdl-win-fsws))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2005
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2006 (defun vhdl-backward-syntactic-ws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2007 ;; Backward skip over syntactic whitespace.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2008 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2009 (let* ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2010 (here lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2011 (hugenum (- (point-max))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2012 (if (< lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2013 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2014 (narrow-to-region lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2015 (while (/= here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2016 (setq here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2017 (forward-comment hugenum)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2018 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2019 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2020
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2021 ;; This is the best we can do in Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2022 (defun vhdl-win-bsws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2023 ;; Backward skip syntactic whitespace for Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2024 (let ((lim (or lim (vhdl-point 'bod)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2025 stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2026 (while (not stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2027 (skip-chars-backward " \t\n\r\f" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2028 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2029 ;; vhdl comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2030 ((eq (vhdl-in-literal lim) 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2031 (skip-chars-backward "^-" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2032 (skip-chars-backward "-" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2033 (while (not (or (and (= (following-char) ?-)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2034 (= (char-after (1+ (point))) ?-))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2035 (<= (point) lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2036 (skip-chars-backward "^-" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2037 (skip-chars-backward "-" lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2038 ;; none of the above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2039 (t (setq stop t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2040 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2041
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2042 (and (memq 'Win-Emacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2043 (fset 'vhdl-backward-syntactic-ws 'vhdl-win-bsws))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2044
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2045 ;; Functions to help finding the correct indentation column:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2046
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2047 (defun vhdl-first-word (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2048 "If the keyword at POINT is at boi, then return (current-column) at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2049 that point, else nil."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2050 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2051 (and (goto-char point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2052 (eq (point) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2053 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2054
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2055 (defun vhdl-last-word (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2056 "If the keyword at POINT is at eoi, then return (current-column) at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2057 that point, else nil."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2058 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2059 (and (goto-char point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2060 (save-excursion (or (eq (progn (forward-sexp) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2061 (vhdl-point 'eoi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2062 (looking-at "\\s-*\\(--\\)?")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2063 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2064
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2065 ;; Core syntactic evaluation functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2066
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2067 (defconst vhdl-libunit-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2068 "\\b\\(architecture\\|configuration\\|entity\\|package\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2069
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2070 (defun vhdl-libunit-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2071 (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2072 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2073 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2074 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2075 (not (looking-at "is\\b[^_]")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2076 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2077 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2078 (and (not (looking-at "use\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2079 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2080 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2081 (vhdl-forward-syntactic-ws)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2082 (/= (following-char) ?:))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2083 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2084
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2085 (defconst vhdl-defun-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2086 "\\b\\(architecture\\|block\\|configuration\\|entity\\|package\\|process\\|procedure\\|function\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2087
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2088 (defun vhdl-defun-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2089 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2090 (if (looking-at "block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2091 ;; "block", "process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2092 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2093 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2094 (not (looking-at "end\\s-+\\w")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2095 ;; "architecture", "configuration", "entity",
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2096 ;; "package", "procedure", "function":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2097 t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2098
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2099 (defun vhdl-corresponding-defun ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2100 "If the word at the current position corresponds to a \"defun\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2101 keyword, then return a string that can be used to find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2102 corresponding \"begin\" keyword, else return nil."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2103 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2104 (and (looking-at vhdl-defun-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2105 (vhdl-defun-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2106 (if (looking-at "block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2107 ;; "block", "process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2108 (buffer-substring (match-beginning 0) (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2109 ;; "architecture", "configuration", "entity", "package",
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2110 ;; "procedure", "function":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2111 "is"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2112
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2113 (defconst vhdl-begin-fwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2114 "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|units\\|record\\|for\\)\\b\\([^_]\\|\\'\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2115 "A regular expression for searching forward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2116 \"begin\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2117
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2118 (defconst vhdl-begin-bwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2119 "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|units\\|record\\|for\\)\\b[^_]"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2120 "A regular expression for searching backward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2121 \"begin\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2122
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2123 (defun vhdl-begin-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2124 "Return t if we are looking at a real \"begin\" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2125 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2126 vhdl-begin-fwd-re, and are not inside a literal, and that we are not in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2127 the middle of an identifier that just happens to contain a \"begin\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2128 keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2129 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2130 ;; "[architecture|case|configuration|entity|package|
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2131 ;; procedure|function] ... is":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2132 ((and (looking-at "i")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2133 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2134 ;; Skip backward over first sexp (needed to skip over a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2135 ;; procedure interface list, and is harmless in other
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2136 ;; situations). Note that we need "return" in the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2137 ;; following search list so that we don't run into
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2138 ;; semicolons in the function interface list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2139 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2140 (let (foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2141 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2142 (re-search-backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2143 ";\\|\\b\\(architecture\\|case\\|configuration\\|entity\\|package\\|procedure\\|return\\|is\\|begin\\|process\\|block\\)\\b[^_]"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2144 lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2145 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2146 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2147 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2148 (setq foundp t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2149 (and (/= (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2150 (not (looking-at "is\\|begin\\|process\\|block")))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2151 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2152 ;; "begin", "then":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2153 ((looking-at "be\\|t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2154 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2155 ;; "else":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2156 ((and (looking-at "e")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2157 ;; make sure that the "else" isn't inside a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2158 ;; conditional signal assignment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2159 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2160 (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2161 (or (eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2162 (eq (point) lim))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2163 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2164 ;; "block", "generate", "loop", "process",
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2165 ;; "units", "record":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2166 ((and (looking-at "bl\\|[glpur]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2167 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2168 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2169 (not (looking-at "end\\s-+\\w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2170 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2171 ;; "component":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2172 ((and (looking-at "c")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2173 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2174 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2175 (not (looking-at "end\\s-+\\w")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2176 ;; look out for the dreaded entity class in an attribute
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2177 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2178 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2179 (/= (preceding-char) ?:)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2180 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2181 ;; "for" (inside configuration declaration):
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2182 ((and (looking-at "f")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2183 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2184 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2185 (not (looking-at "end\\s-+\\w")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2186 (vhdl-has-syntax 'configuration))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2187 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2188 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2189
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2190 (defun vhdl-corresponding-mid (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2191 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2192 ((looking-at "is\\|block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2193 "begin")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2194 ((looking-at "then")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2195 "<else>")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2196 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2197 "end")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2198
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2199 (defun vhdl-corresponding-end (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2200 "If the word at the current position corresponds to a \"begin\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2201 keyword, then return a vector containing enough information to find
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2202 the corresponding \"end\" keyword, else return nil. The keyword to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2203 search forward for is aref 0. The column in which the keyword must
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2204 appear is aref 1 or nil if any column is suitable.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2205 Assumes that the caller will make sure that we are not in the middle
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2206 of an identifier that just happens to contain a \"begin\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2207 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2208 (and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2209 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2210 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2211 (vhdl-begin-p lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2212 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2213 ;; "is", "generate", "loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2214 ((looking-at "[igl]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2215 (vector "end"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2216 (and (vhdl-last-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2217 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2218 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2219 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2220 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2221 (vhdl-first-word (point)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2222 ;; "begin", "else", "for":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2223 ((looking-at "be\\|[ef]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2224 (vector "end"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2225 (and (vhdl-last-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2226 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2227 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2228 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2229 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2230 (vhdl-first-word (point)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2231 ;; "component", "units", "record":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2232 ((looking-at "[cur]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2233 ;; The first end found will close the block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2234 (vector "end" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2235 ;; "block", "process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2236 ((looking-at "bl\\|p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2237 (vector "end"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2238 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2239 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2240 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2241 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2242 (vhdl-first-word (point))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2243 ;; "then":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2244 ((looking-at "t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2245 (vector "elsif\\|else\\|end\\s-+if"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2246 (and (vhdl-last-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2247 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2248 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2249 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2250 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2251 (vhdl-first-word (point)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2252 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2253
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2254 (defconst vhdl-end-fwd-re "\\b\\(end\\|else\\|elsif\\)\\b\\([^_]\\|\\'\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2255
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2256 (defconst vhdl-end-bwd-re "\\b\\(end\\|else\\|elsif\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2257
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2258 (defun vhdl-end-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2259 "Return t if we are looking at a real \"end\" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2260 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2261 vhdl-end-fwd-re, and are not inside a literal, and that we are not in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2262 the middle of an identifier that just happens to contain an \"end\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2263 keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2264 (or (not (looking-at "else"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2265 ;; make sure that the "else" isn't inside a conditional signal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2266 ;; assignment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2267 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2268 (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2269 (or (eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2270 (eq (point) lim)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2271
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2272 (defun vhdl-corresponding-begin (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2273 "If the word at the current position corresponds to an \"end\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2274 keyword, then return a vector containing enough information to find
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2275 the corresponding \"begin\" keyword, else return nil. The keyword to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2276 search backward for is aref 0. The column in which the keyword must
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2277 appear is aref 1 or nil if any column is suitable. The supplementary
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2278 keyword to search forward for is aref 2 or nil if this is not
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2279 required. If aref 3 is t, then the \"begin\" keyword may be found in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2280 the middle of a statement.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2281 Assumes that the caller will make sure that we are not in the middle
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2282 of an identifier that just happens to contain an \"end\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2283 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2284 (let (pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2285 (if (and (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2286 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2287 (vhdl-end-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2288 (if (looking-at "el")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2289 ;; "else", "elsif":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2290 (vector "if\\|elsif" (vhdl-first-word (point)) "then" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2291 ;; "end ...":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2292 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2293 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2294 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2295 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2296 ;; "end if":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2297 ((looking-at "if\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2298 (vector "else\\|elsif\\|if"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2299 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2300 "else\\|then" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2301 ;; "end component":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2302 ((looking-at "component\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2303 (vector (buffer-substring (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2304 (match-end 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2305 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2306 nil nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2307 ;; "end units", "end record":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2308 ((looking-at "\\(units\\|record\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2309 (vector (buffer-substring (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2310 (match-end 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2311 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2312 nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2313 ;; "end block", "end process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2314 ((looking-at "\\(block\\|process\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2315 (vector "begin" (vhdl-first-word pos) nil nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2316 ;; "end case":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2317 ((looking-at "case\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2318 (vector "case" (vhdl-first-word pos) "is" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2319 ;; "end generate":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2320 ((looking-at "generate\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2321 (vector "generate\\|for\\|if"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2322 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2323 "generate" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2324 ;; "end loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2325 ((looking-at "loop\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2326 (vector "loop\\|while\\|for"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2327 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2328 "loop" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2329 ;; "end for" (inside configuration declaration):
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2330 ((looking-at "for\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2331 (vector "for" (vhdl-first-word pos) nil nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2332 ;; "end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2333 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2334 (vector "begin\\|architecture\\|configuration\\|entity\\|package\\|procedure\\|function"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2335 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2336 ;; return an alist of (statement . keyword) mappings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2337 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2338 ;; "begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2339 ("begin" . nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2340 ;; "architecture ... is ... begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2341 ("architecture" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2342 ;; "configuration ... is ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2343 ("configuration" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2344 ;; "entity ... is ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2345 ("entity" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2346 ;; "package ... is ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2347 ("package" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2348 ;; "procedure ... is ... begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2349 ("procedure" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2350 ;; "function ... is ... begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2351 ("function" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2352 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2353 nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2354 ))) ; "end ..."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2355 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2356
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2357 (defconst vhdl-leader-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2358 "\\b\\(block\\|component\\|process\\|for\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2359
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2360 (defun vhdl-end-of-leader ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2361 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2362 (cond ((looking-at "block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2363 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2364 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2365 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2366 (= (following-char) ?\())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2367 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2368 (forward-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2369 (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2370 ((looking-at "component")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2371 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2372 (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2373 ((looking-at "for")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2374 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2375 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2376 (while (looking-at "[,:(]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2377 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2378 (skip-chars-forward " \t\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2379 (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2380 (t nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2381 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2382
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2383 (defconst vhdl-trailer-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2384 "\\b\\(is\\|then\\|generate\\|loop\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2385
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2386 (defconst vhdl-statement-fwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2387 "\\b\\(if\\|for\\|while\\)\\b\\([^_]\\|\\'\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2388 "A regular expression for searching forward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2389 \"statement\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2390
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2391 (defconst vhdl-statement-bwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2392 "\\b\\(if\\|for\\|while\\)\\b[^_]"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2393 "A regular expression for searching backward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2394 \"statement\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2395
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2396 (defun vhdl-statement-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2397 "Return t if we are looking at a real \"statement\" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2398 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2399 vhdl-statement-fwd-re, and are not inside a literal, and that we are not in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2400 the middle of an identifier that just happens to contain a \"statement\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2401 keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2402 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2403 ;; "for" ... "generate":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2404 ((and (looking-at "f")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2405 ;; Make sure it's the start of a parameter specification.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2406 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2407 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2408 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2409 (looking-at "in\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2410 ;; Make sure it's not an "end for".
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2411 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2412 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2413 (not (looking-at "end\\s-+\\w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2414 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2415 ;; "if" ... "then", "if" ... "generate", "if" ... "loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2416 ((and (looking-at "i")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2417 ;; Make sure it's not an "end if".
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2418 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2419 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2420 (not (looking-at "end\\s-+\\w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2421 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2422 ;; "while" ... "loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2423 ((looking-at "w")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2424 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2425 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2426
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2427 (defconst vhdl-case-alternative-re "when[( \t\n][^;=>]+=>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2428 "Regexp describing a case statement alternative key.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2429
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2430 (defun vhdl-case-alternative-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2431 "Return t if we are looking at a real case alternative.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2432 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2433 vhdl-case-alternative-re, and are not inside a literal, and that
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2434 we are not in the middle of an identifier that just happens to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2435 contain a \"when\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2436 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2437 (let (foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2438 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2439 (re-search-backward ";\\|<=" lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2440 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2441 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2442 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2443 (setq foundp t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2444 (or (eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2445 (eq (point) lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2446 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2447
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2448 ;; Core syntactic movement functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2449
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2450 (defconst vhdl-b-t-b-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2451 (concat vhdl-begin-bwd-re "\\|" vhdl-end-bwd-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2452
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2453 (defun vhdl-backward-to-block (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2454 "Move backward to the previous \"begin\" or \"end\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2455 (let (foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2456 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2457 (re-search-backward vhdl-b-t-b-re lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2458 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2459 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2460 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2461 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2462 ;; "begin" keyword:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2463 ((and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2464 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2465 (vhdl-begin-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2466 (setq foundp 'begin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2467 ;; "end" keyword:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2468 ((and (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2469 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2470 (vhdl-end-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2471 (setq foundp 'end))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2472 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2473 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2474 foundp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2475 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2476
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2477 (defun vhdl-forward-sexp (&optional count lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2478 "Move forward across one balanced expression (sexp).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2479 With COUNT, do it that many times."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2480 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2481 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2482 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2483 end-vec target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2484 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2485 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2486 ;; skip whitespace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2487 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2488 ;; Check for an unbalanced "end" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2489 (if (and (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2490 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2491 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2492 (vhdl-end-p lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2493 (not (looking-at "else")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2494 (error
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2495 "Containing expression ends prematurely in vhdl-forward-sexp"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2496 ;; If the current keyword is a "begin" keyword, then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2497 ;; corresponding "end" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2498 (if (setq end-vec (vhdl-corresponding-end lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2499 (let (
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2500 ;; end-re is the statement keyword to search for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2501 (end-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2502 (concat "\\b\\(" (aref end-vec 0) "\\)\\b\\([^_]\\|\\'\\)"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2503 ;; column is either the statement keyword target column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2504 ;; or nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2505 (column (aref end-vec 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2506 (eol (vhdl-point 'eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2507 foundp literal placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2508 ;; Look for the statement keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2509 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2510 (re-search-forward end-re nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2511 (setq placeholder (match-end 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2512 (goto-char (match-beginning 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2513 ;; If we are in a literal, or not in the right target
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2514 ;; column and not on the same line as the begin, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2515 ;; try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2516 (if (or (and column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2517 (/= (current-indentation) column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2518 (> (point) eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2519 (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2520 (setq literal (vhdl-in-literal lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2521 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2522 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2523 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2524 ;; An "else" keyword corresponds to both the opening brace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2525 ;; of the following sexp and the closing brace of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2526 ;; previous sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2527 (if (not (looking-at "else"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2528 (goto-char placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2529 (setq foundp t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2530 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2531 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2532 (error "Unbalanced keywords in vhdl-forward-sexp"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2533 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2534 ;; If the current keyword is not a "begin" keyword, then just
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2535 ;; perform the normal forward-sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2536 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2537 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2538 (setq count (1- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2539 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2540 (setq target (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2541 (goto-char target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2542 nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2543
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2544 (defun vhdl-backward-sexp (&optional count lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2545 "Move backward across one balanced expression (sexp).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2546 With COUNT, do it that many times. LIM bounds any required backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2547 searches."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2548 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2549 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2550 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2551 begin-vec target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2552 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2553 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2554 ;; Perform the normal backward-sexp, unless we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2555 ;; "else" - an "else" keyword corresponds to both the opening brace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2556 ;; of the following sexp and the closing brace of the previous sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2557 (if (and (looking-at "else\\b\\([^_]\\|\\'\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2558 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2559 (not (vhdl-in-literal lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2560 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2561 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2562 (if (and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2563 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2564 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2565 (vhdl-begin-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2566 (error "Containing expression ends prematurely in vhdl-backward-sexp")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2567 ;; If the current keyword is an "end" keyword, then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2568 ;; corresponding "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2569 (if (and (setq begin-vec (vhdl-corresponding-begin lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2570 (/= (preceding-char) ?_))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2571 (let (
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2572 ;; begin-re is the statement keyword to search for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2573 (begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2574 (concat "\\b\\(" (aref begin-vec 0) "\\)\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2575 ;; column is either the statement keyword target column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2576 ;; or nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2577 (column (aref begin-vec 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2578 ;; internal-p controls where the statement keyword can
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2579 ;; be found.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2580 (internal-p (aref begin-vec 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2581 (last-backward (point)) last-forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2582 foundp literal keyword)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2583 ;; Look for the statement keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2584 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2585 (re-search-backward begin-re lim t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2586 (setq keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2587 (buffer-substring (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2588 (match-end 1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2589 ;; If we are in a literal or in the wrong column,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2590 ;; then try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2591 (if (or (and column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2592 (and (/= (current-indentation) column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2593 ;; possibly accept current-column as
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2594 ;; well as current-indentation.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2595 (or (not internal-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2596 (/= (current-column) column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2597 (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2598 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2599 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2600 ;; If there is a supplementary keyword, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2601 ;; search forward for it.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2602 (if (and (setq begin-re (aref begin-vec 2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2603 (or (not (listp begin-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2604 ;; If begin-re is an alist, then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2605 ;; element corresponding to the actual
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2606 ;; keyword that we found.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2607 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2608 (setq begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2609 (assoc keyword begin-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2610 (and begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2611 (setq begin-re (cdr begin-re))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2612 (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2613 (setq begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2614 (concat "\\b\\(" begin-re "\\)\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2615 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2616 (setq last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2617 ;; Look for the supplementary keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2618 ;; (bounded by the backward search start
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2619 ;; point).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2620 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2621 (re-search-forward begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2622 last-backward t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2623 (goto-char (match-beginning 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2624 ;; If we are in a literal, then try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2625 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2626 (setq literal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2627 (vhdl-in-literal last-forward)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2628 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2629 (goto-char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2630 (min (vhdl-point 'eol) last-backward))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2631 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2632 ;; We have found the supplementary keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2633 ;; Save the position of the keyword in foundp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2634 (setq foundp (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2635 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2636 foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2637 ;; If the supplementary keyword was found, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2638 ;; move point to the supplementary keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2639 (goto-char foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2640 ;; If there was no supplementary keyword, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2641 ;; point is already at the statement keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2642 (setq foundp t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2643 ) ; end of the search for the statement keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2644 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2645 (error "Unbalanced keywords in vhdl-backward-sexp"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2646 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2647 (setq count (1- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2648 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2649 (setq target (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2650 (goto-char target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2651 nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2652
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2653 (defun vhdl-backward-up-list (&optional count limit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2654 "Move backward out of one level of blocks.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2655 With argument, do this that many times."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2656 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2657 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2658 target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2659 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2660 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2661 (if (looking-at vhdl-defun-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2662 (error "Unbalanced blocks"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2663 (vhdl-backward-to-block limit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2664 (setq count (1- count)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2665 (setq target (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2666 (goto-char target)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2667
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2668 (defun vhdl-end-of-defun (&optional count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2669 "Move forward to the end of a VHDL defun."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2670 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2671 (let ((case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2672 (vhdl-beginning-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2673 (if (not (looking-at "block\\|process"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2674 (re-search-forward "\\bis\\b"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2675 (vhdl-forward-sexp)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2676
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2677 (defun vhdl-mark-defun ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2678 "Put mark at end of this \"defun\", point at beginning."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2679 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2680 (let ((case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2681 (push-mark)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2682 (vhdl-beginning-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2683 (push-mark)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2684 (if (not (looking-at "block\\|process"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2685 (re-search-forward "\\bis\\b"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2686 (vhdl-forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2687 (exchange-point-and-mark)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2688
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2689 (defun vhdl-beginning-of-libunit ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2690 "Move backward to the beginning of a VHDL library unit.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2691 Returns the location of the corresponding begin keyword, unless search
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2692 stops due to beginning or end of buffer."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2693 ;; Note that if point is between the "libunit" keyword and the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2694 ;; corresponding "begin" keyword, then that libunit will not be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2695 ;; recognised, and the search will continue backwards. If point is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2696 ;; at the "begin" keyword, then the defun will be recognised. The
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2697 ;; returned point is at the first character of the "libunit" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2698 (let ((last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2699 (last-backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2700 ;; Just in case we are actually sitting on the "begin"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2701 ;; keyword, allow for the keyword and an extra character,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2702 ;; as this will be used when looking forward for the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2703 ;; "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2704 (save-excursion (forward-word 1) (1+ (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2705 foundp literal placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2706 ;; Find the "libunit" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2707 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2708 (re-search-backward vhdl-libunit-re nil 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2709 ;; If we are in a literal, or not at a real libunit, then try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2710 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2711 (vhdl-in-literal (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2712 (not (vhdl-libunit-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2713 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2714 ;; Find the corresponding "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2715 (setq last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2716 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2717 (re-search-forward "\\bis\\b[^_]" last-backward t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2718 (setq placeholder (match-beginning 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2719 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2720 (setq literal (vhdl-in-literal last-forward)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2721 ;; It wasn't a real keyword, so keep searching.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2722 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2723 (goto-char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2724 (min (vhdl-point 'eol) last-backward))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2725 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2726 ;; We have found the begin keyword, loop will exit.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2727 (setq foundp placeholder)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2728 ;; Go back to the libunit keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2729 (goto-char last-forward)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2730 foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2731
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2732 (defun vhdl-beginning-of-defun (&optional count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2733 "Move backward to the beginning of a VHDL defun.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2734 With argument, do it that many times.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2735 Returns the location of the corresponding begin keyword, unless search
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2736 stops due to beginning or end of buffer."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2737 ;; Note that if point is between the "defun" keyword and the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2738 ;; corresponding "begin" keyword, then that defun will not be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2739 ;; recognised, and the search will continue backwards. If point is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2740 ;; at the "begin" keyword, then the defun will be recognised. The
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2741 ;; returned point is at the first character of the "defun" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2742 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2743 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2744 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2745 (last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2746 foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2747 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2748 (setq foundp nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2749 (goto-char last-forward)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2750 (let ((last-backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2751 ;; Just in case we are actually sitting on the "begin"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2752 ;; keyword, allow for the keyword and an extra character,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2753 ;; as this will be used when looking forward for the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2754 ;; "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2755 (save-excursion (forward-word 1) (1+ (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2756 begin-string literal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2757 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2758 (re-search-backward vhdl-defun-re nil 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2759 ;; If we are in a literal, then try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2760 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2761 (vhdl-in-literal (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2762 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2763 (if (setq begin-string (vhdl-corresponding-defun))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2764 ;; This is a real defun keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2765 ;; Find the corresponding "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2766 ;; Look for the begin keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2767 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2768 ;; Save the search start point.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2769 (setq last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2770 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2771 (search-forward begin-string last-backward t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2772 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2773 (save-match-data
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2774 (setq literal (vhdl-in-literal last-forward))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2775 ;; It wasn't a real keyword, so keep searching.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2776 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2777 (goto-char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2778 (min (vhdl-point 'eol) last-backward))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2779 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2780 ;; We have found the begin keyword, loop will exit.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2781 (setq foundp (match-beginning 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2782 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2783 ;; Go back to the defun keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2784 (goto-char last-forward)) ; end search for begin keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2785 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2786 ) ; end of the search for the defun keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2787 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2788 (setq count (1- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2789 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2790 (vhdl-keep-region-active)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2791 foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2792
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2793 (defun vhdl-beginning-of-statement (&optional count lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2794 "Go to the beginning of the innermost VHDL statement.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2795 With prefix arg, go back N - 1 statements. If already at the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2796 beginning of a statement then go to the beginning of the preceding
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2797 one. If within a string or comment, or next to a comment (only
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2798 whitespace between), move by sentences instead of statements.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2799
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2800 When called from a program, this function takes 2 optional args: the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2801 prefix arg, and a buffer position limit which is the farthest back to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2802 search."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2803 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2804 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2805 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2806 (lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2807 (here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2808 state)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2809 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2810 (goto-char lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2811 (setq state (parse-partial-sexp (point) here nil nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2812 (if (and (interactive-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2813 (or (nth 3 state)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2814 (nth 4 state)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2815 (looking-at (concat "[ \t]*" comment-start-skip))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2816 (forward-sentence (- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2817 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2818 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2819 (setq count (1- count))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2820 ;; its possible we've been left up-buf of lim
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2821 (goto-char (max (point) lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2822 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2823 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2824
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2825 (defconst vhdl-e-o-s-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2826 (concat ";\\|" vhdl-begin-fwd-re "\\|" vhdl-statement-fwd-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2827
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2828 (defun vhdl-end-of-statement ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2829 "Very simple implementation."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2830 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2831 (re-search-forward vhdl-e-o-s-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2832
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2833 (defconst vhdl-b-o-s-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2834 (concat ";\\|\(\\|\)\\|\\bwhen\\b[^_]\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2835 vhdl-begin-bwd-re "\\|" vhdl-statement-bwd-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2836
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2837 (defun vhdl-beginning-of-statement-1 (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2838 ;; move to the start of the current statement, or the previous
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2839 ;; statement if already at the beginning of one.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2840 (let ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2841 (here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2842 (pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2843 donep)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2844 ;; go backwards one balanced expression, but be careful of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2845 ;; unbalanced paren being reached
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2846 (if (not (vhdl-safe (progn (backward-sexp) t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2847 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2848 (backward-up-list 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2849 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2850 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2851 (setq donep t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2852 (while (and (not donep)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2853 (not (bobp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2854 ;; look backwards for a statement boundary
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2855 (re-search-backward vhdl-b-o-s-re lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2856 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2857 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2858 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2859 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2860 ;; If we are looking at an open paren, then stop after it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2861 ((eq (following-char) ?\()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2862 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2863 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2864 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2865 ;; If we are looking at a close paren, then skip it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2866 ((eq (following-char) ?\))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2867 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2868 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2869 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2870 (if (< (point) lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2871 (progn (goto-char pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2872 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2873 (setq donep t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2874 ;; If we are looking at a semicolon, then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2875 ((eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2876 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2877 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2878 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2879 (setq donep t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2880 ;; If we are looking at a "begin", then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2881 ((and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2882 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2883 (vhdl-begin-p nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2884 ;; If it's a leader "begin", then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2885 ;; right place
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2886 (if (looking-at vhdl-leader-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2887 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2888 ;; set a default stop point at the begin
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2889 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2890 ;; is the start point inside the leader area ?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2891 (goto-char (vhdl-end-of-leader))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2892 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2893 (if (< (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2894 ;; start point was not inside leader area
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2895 ;; set stop point at word after leader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2896 (setq pos (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2897 (forward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2898 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2899 (setq pos (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2900 (goto-char pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2901 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2902 ;; If we are looking at a "statement", then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2903 ((and (looking-at vhdl-statement-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2904 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2905 (vhdl-statement-p nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2906 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2907 ;; If we are looking at a case alternative key, then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2908 ((and (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2909 (vhdl-case-alternative-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2910 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2911 ;; set a default stop point at the when
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2912 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2913 ;; is the start point inside the case alternative key ?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2914 (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2915 (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2916 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2917 (if (< (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2918 ;; start point was not inside the case alternative key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2919 ;; set stop point at word after case alternative keyleader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2920 (setq pos (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2921 (goto-char pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2922 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2923 ;; Bogus find, continue
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2924 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2925 (backward-char)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2926 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2927
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2928 ;; Defuns for calculating the current syntactic state:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2929
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2930 (defun vhdl-get-library-unit (bod placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2931 ;; If there is an enclosing library unit at bod, with it's \"begin\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2932 ;; keyword at placeholder, then return the library unit type.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2933 (let ((here (vhdl-point 'bol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2934 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2935 (goto-char placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2936 (vhdl-safe (vhdl-forward-sexp 1 bod))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2937 (<= here (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2938 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2939 (goto-char bod)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2940 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2941 ((looking-at "e") 'entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2942 ((looking-at "a") 'architecture)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2943 ((looking-at "c") 'configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2944 ((looking-at "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2945 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2946 (goto-char bod)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2947 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2948 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2949 (if (looking-at "body\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2950 'package-body 'package))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2951 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2952
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2953 (defun vhdl-get-block-state (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2954 ;; Finds and records all the closest opens.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2955 ;; lim is the furthest back we need to search (it should be the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2956 ;; previous libunit keyword).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2957 (let ((here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2958 (lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2959 keyword sexp-start sexp-mid sexp-end
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2960 preceding-sexp containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2961 containing-begin containing-mid containing-paren)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2962 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2963 ;; Find the containing-paren, and use that as the limit
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2964 (if (setq containing-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2965 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2966 (narrow-to-region lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2967 (vhdl-safe (scan-lists (point) -1 1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2968 (setq lim containing-paren))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2969 ;; Look backwards for "begin" and "end" keywords.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2970 (while (and (> (point) lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2971 (not containing-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2972 (setq keyword (vhdl-backward-to-block lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2973 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2974 ((eq keyword 'begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2975 ;; Found a "begin" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2976 (setq sexp-start (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2977 (setq sexp-mid (vhdl-corresponding-mid lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2978 (setq sexp-end (vhdl-safe
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2979 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2980 (vhdl-forward-sexp 1 lim) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2981 (if (and sexp-end (<= sexp-end here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2982 ;; we want to record this sexp, but we only want to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2983 ;; record the last-most of any of them before here
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2984 (or preceding-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2985 (setq preceding-sexp sexp-start))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2986 ;; we're contained in this sexp so put sexp-start on
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2987 ;; front of list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2988 (setq containing-sexp sexp-start)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2989 (setq containing-mid sexp-mid)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2990 (setq containing-begin t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2991 ((eq keyword 'end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2992 ;; Found an "end" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2993 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2994 (setq sexp-end (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2995 (setq sexp-mid nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2996 (setq sexp-start
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2997 (or (vhdl-safe (vhdl-backward-sexp 1 lim) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2998 (progn (backward-sexp) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2999 ;; we want to record this sexp, but we only want to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3000 ;; record the last-most of any of them before here
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3001 (or preceding-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3002 (setq preceding-sexp sexp-start)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3003 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3004 ;; Check if the containing-paren should be the containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3005 (if (and containing-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3006 (or (null containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3007 (< containing-sexp containing-paren)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3008 (setq containing-sexp containing-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3009 preceding-sexp nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3010 containing-begin nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3011 containing-mid nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3012 (vector containing-sexp preceding-sexp containing-begin containing-mid)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3013 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3014
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3015
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3016 (defconst vhdl-s-c-a-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3017 (concat vhdl-case-alternative-re "\\|" vhdl-case-header-key))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3018
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3019 (defun vhdl-skip-case-alternative (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3020 ;; skip forward over case/when bodies, with optional maximal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3021 ;; limit. if no next case alternative is found, nil is returned and point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3022 ;; is not moved
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3023 (let ((lim (or lim (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3024 (here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3025 donep foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3026 (while (and (< (point) lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3027 (not donep))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3028 (if (and (re-search-forward vhdl-s-c-a-re lim 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3029 (save-match-data
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3030 (not (vhdl-in-literal)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3031 (/= (match-beginning 0) here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3032 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3033 (goto-char (match-beginning 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3034 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3035 ((and (looking-at "case")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3036 (re-search-forward "\\bis[^_]" lim t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3037 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3038 (vhdl-forward-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3039 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3040 (setq donep t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3041 foundp t))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3042 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3043 (goto-char here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3044 foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3045
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3046 (defun vhdl-backward-skip-label (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3047 ;; skip backward over a label, with optional maximal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3048 ;; limit. if label is not found, nil is returned and point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3049 ;; is not moved
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3050 (let ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3051 placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3052 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3053 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3054 (and (eq (preceding-char) ?:)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3055 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3056 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3057 (setq placeholder (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3058 (looking-at vhdl-label-key))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3059 (goto-char placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3060 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3061
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3062 (defun vhdl-forward-skip-label (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3063 ;; skip forward over a label, with optional maximal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3064 ;; limit. if label is not found, nil is returned and point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3065 ;; is not moved
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3066 (let ((lim (or lim (point-max))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3067 (if (looking-at vhdl-label-key)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3068 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3069 (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3070 (vhdl-forward-syntactic-ws lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3071 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3072
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3073 (defun vhdl-get-syntactic-context ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3074 ;; guess the syntactic description of the current line of VHDL code.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3075 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3076 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3077 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3078 (let* ((indent-point (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3079 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3080 vec literal containing-sexp preceding-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3081 containing-begin containing-mid containing-leader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3082 char-before-ip char-after-ip begin-after-ip end-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3083 placeholder lim library-unit
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3084 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3085
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3086 ;; Reset the syntactic context
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3087 (setq vhdl-syntactic-context nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3088
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3089 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3090 ;; Move to the start of the previous library unit, and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3091 ;; record the position of the "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3092 (setq placeholder (vhdl-beginning-of-libunit))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3093 ;; The position of the "libunit" keyword gives us a gross
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3094 ;; limit point.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3095 (setq lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3096 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3097
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3098 ;; If there is a previous library unit, and we are enclosed by
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3099 ;; it, then set the syntax accordingly.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3100 (and placeholder
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3101 (setq library-unit (vhdl-get-library-unit lim placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3102 (vhdl-add-syntax library-unit lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3103
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3104 ;; Find the surrounding state.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3105 (if (setq vec (vhdl-get-block-state lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3106 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3107 (setq containing-sexp (aref vec 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3108 (setq preceding-sexp (aref vec 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3109 (setq containing-begin (aref vec 2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3110 (setq containing-mid (aref vec 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3111 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3112
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3113 ;; set the limit on the farthest back we need to search
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3114 (setq lim (if containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3115 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3116 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3117 ;; set containing-leader if required
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3118 (if (looking-at vhdl-leader-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3119 (setq containing-leader (vhdl-end-of-leader)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3120 (vhdl-point 'bol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3121 (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3122
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3123 ;; cache char before and after indent point, and move point to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3124 ;; the most likely position to perform the majority of tests
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3125 (goto-char indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3126 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3127 (setq literal (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3128 (setq char-after-ip (following-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3129 (setq begin-after-ip (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3130 (not literal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3131 (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3132 (vhdl-begin-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3133 (setq end-after-ip (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3134 (not literal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3135 (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3136 (vhdl-end-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3137 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3138 (setq char-before-ip (preceding-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3139 (goto-char indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3140 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3141
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3142 ;; now figure out syntactic qualities of the current line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3143 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3144 ;; CASE 1: in a string or comment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3145 ((memq literal '(string comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3146 (vhdl-add-syntax literal (vhdl-point 'bopl)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3147 ;; CASE 2: Line is at top level.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3148 ((null containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3149 ;; Find the point to which indentation will be relative
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3150 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3151 (if (null preceding-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3152 ;; CASE 2X.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3153 ;; no preceding-sexp -> use the preceding statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3154 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3155 ;; CASE 2X.2
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3156 ;; if there is a preceding-sexp then indent relative to it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3157 (goto-char preceding-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3158 ;; if not at boi, then the block-opening keyword is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3159 ;; probably following a label, so we need a different
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3160 ;; relpos
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3161 (if (/= (point) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3162 ;; CASE 2X.3
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3163 (vhdl-beginning-of-statement-1 lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3164 ;; v-b-o-s could have left us at point-min
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3165 (and (bobp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3166 ;; CASE 2X.4
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3167 (vhdl-forward-syntactic-ws indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3168 (setq placeholder (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3169 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3170 ;; CASE 2A : we are looking at a block-open
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3171 (begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3172 (vhdl-add-syntax 'block-open placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3173 ;; CASE 2B: we are looking at a block-close
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3174 (end-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3175 (vhdl-add-syntax 'block-close placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3176 ;; CASE 2C: we are looking at a top-level statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3177 ((progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3178 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3179 (or (bobp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3180 (= (preceding-char) ?\;)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3181 (vhdl-add-syntax 'statement placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3182 ;; CASE 2D: we are looking at a top-level statement-cont
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3183 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3184 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3185 ;; v-b-o-s could have left us at point-min
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3186 (and (bobp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3187 ;; CASE 2D.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3188 (vhdl-forward-syntactic-ws indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3189 (vhdl-add-syntax 'statement-cont (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3190 )) ; end CASE 2
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3191 ;; CASE 3: line is inside parentheses. Most likely we are
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3192 ;; either in a subprogram argument (interface) list, or a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3193 ;; continued expression containing parentheses.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3194 ((null containing-begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3195 (vhdl-backward-syntactic-ws containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3196 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3197 ;; CASE 3A: we are looking at the arglist closing paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3198 ((eq char-after-ip ?\))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3199 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3200 (vhdl-add-syntax 'arglist-close (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3201 ;; CASE 3B: we are looking at the first argument in an empty
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3202 ;; argument list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3203 ((eq char-before-ip ?\()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3204 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3205 (vhdl-add-syntax 'arglist-intro (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3206 ;; CASE 3C: we are looking at an arglist continuation line,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3207 ;; but the preceding argument is on the same line as the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3208 ;; opening paren. This case includes multi-line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3209 ;; expression paren groupings.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3210 ((and (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3211 (goto-char (1+ containing-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3212 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3213 (not (eolp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3214 (not (looking-at "--")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3215 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3216 (vhdl-beginning-of-statement-1 containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3217 (skip-chars-backward " \t(")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3218 (<= (point) containing-sexp)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3219 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3220 (vhdl-add-syntax 'arglist-cont-nonempty (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3221 ;; CASE 3D: we are looking at just a normal arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3222 ;; continuation line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3223 (t (vhdl-beginning-of-statement-1 containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3224 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3225 (vhdl-add-syntax 'arglist-cont (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3226 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3227 ;; CASE 4: A block mid open
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3228 ((and begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3229 (looking-at containing-mid))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3230 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3231 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3232 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3233 ;; CASE 4.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3234 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3235 (vhdl-backward-skip-label (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3236 (vhdl-add-syntax 'block-open (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3237 ;; CASE 5: block close brace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3238 (end-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3239 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3240 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3241 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3242 ;; CASE 5.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3243 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3244 (vhdl-backward-skip-label (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3245 (vhdl-add-syntax 'block-close (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3246 ;; CASE 6: A continued statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3247 ((and (/= char-before-ip ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3248 ;; check it's not a trailer begin keyword, or a begin
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3249 ;; keyword immediately following a label.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3250 (not (and begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3251 (or (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3252 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3253 (vhdl-backward-skip-label containing-sexp)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3254 ;; check it's not a statement keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3255 (not (and (looking-at vhdl-statement-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3256 (vhdl-statement-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3257 ;; see if the b-o-s is before the indent point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3258 (> indent-point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3259 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3260 (vhdl-beginning-of-statement-1 containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3261 ;; If we ended up after a leader, then this will
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3262 ;; move us forward to the start of the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3263 ;; statement. Note that a containing sexp here is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3264 ;; always a keyword, not a paren, so this will
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3265 ;; have no effect if we hit the containing-sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3266 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3267 (setq placeholder (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3268 ;; check it's not a block-intro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3269 (/= placeholder containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3270 ;; check it's not a case block-intro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3271 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3272 (goto-char placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3273 (or (not (looking-at vhdl-case-alternative-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3274 (> (match-end 0) indent-point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3275 ;; Make placeholder skip a label, but only if it puts us
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3276 ;; before the indent point at the start of a line.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3277 (let ((new placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3278 (if (and (> indent-point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3279 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3280 (goto-char placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3281 (vhdl-forward-skip-label indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3282 (setq new (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3283 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3284 (goto-char new)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3285 (eq new (progn (back-to-indentation) (point)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3286 (setq placeholder new)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3287 (vhdl-add-syntax 'statement-cont placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3288 (if begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3289 (vhdl-add-syntax 'block-open)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3290 ;; Statement. But what kind?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3291 ;; CASE 7: A case alternative key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3292 ((and (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3293 (vhdl-case-alternative-p containing-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3294 ;; for a case alternative key, we set relpos to the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3295 ;; non-whitespace char on the line containing the "case"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3296 ;; keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3297 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3298 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3299 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3300 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3301 (vhdl-add-syntax 'case-alternative (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3302 ;; CASE 8: statement catchall
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3303 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3304 ;; we know its a statement, but we need to find out if it is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3305 ;; the first statement in a block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3306 (if containing-leader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3307 (goto-char containing-leader)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3308 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3309 ;; Note that a containing sexp here is always a keyword,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3310 ;; not a paren, so skip over the keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3311 (forward-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3312 ;; move to the start of the first statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3313 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3314 (setq placeholder (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3315 ;; we want to ignore case alternatives keys when skipping forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3316 (let (incase-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3317 (while (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3318 (setq incase-p (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3319 ;; we also want to skip over the body of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3320 ;; case/when statement if that doesn't put us at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3321 ;; after the indent-point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3322 (while (vhdl-skip-case-alternative indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3323 ;; set up the match end
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3324 (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3325 (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3326 ;; move to the start of the first case alternative statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3327 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3328 (setq placeholder (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3329 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3330 ;; CASE 8A: we saw a case/when statement so we must be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3331 ;; in a switch statement. find out if we are at the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3332 ;; statement just after a case alternative key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3333 ((and incase-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3334 (= (point) indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3335 ;; relpos is the "when" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3336 (vhdl-add-syntax 'statement-case-intro incase-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3337 ;; CASE 8B: any old statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3338 ((< (point) indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3339 ;; relpos is the first statement of the block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3340 (vhdl-add-syntax 'statement placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3341 (if begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3342 (vhdl-add-syntax 'block-open)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3343 ;; CASE 8C: first statement in a block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3344 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3345 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3346 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3347 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3348 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3349 (vhdl-backward-skip-label (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3350 (vhdl-add-syntax 'statement-block-intro (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3351 (if begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3352 (vhdl-add-syntax 'block-open)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3353 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3354 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3355
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3356 ;; now we need to look at any modifiers
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3357 (goto-char indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3358 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3359 (if (looking-at "--")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3360 (vhdl-add-syntax 'comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3361 ;; return the syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3362 vhdl-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3363
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3364 ;; Standard indentation line-ups:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3365
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3366 (defun vhdl-lineup-arglist (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3367 ;; lineup the current arglist line with the arglist appearing just
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3368 ;; after the containing paren which starts the arglist.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3369 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3370 (let* ((containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3371 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3372 ;; arglist-cont-nonempty gives relpos ==
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3373 ;; to boi of containing-sexp paren. This
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3374 ;; is good when offset is +, but bad
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3375 ;; when it is vhdl-lineup-arglist, so we
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3376 ;; have to special case a kludge here.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3377 (if (memq (car langelem) '(arglist-intro arglist-cont-nonempty))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3378 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3379 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3380 (backward-up-list 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3381 (skip-chars-forward " \t" (vhdl-point 'eol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3382 (goto-char (cdr langelem)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3383 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3384 (cs-curcol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3385 (goto-char (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3386 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3387 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3388 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3389 (looking-at "[ \t]*)"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3390 (progn (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3391 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3392 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3393 (vhdl-forward-syntactic-ws)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3394 (- (current-column) cs-curcol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3395 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3396 (or (eolp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3397 (let ((eol (vhdl-point 'eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3398 (here (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3399 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3400 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3401 (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3402 (vhdl-forward-syntactic-ws)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3403 (if (< (point) eol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3404 (goto-char here))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3405 (- (current-column) cs-curcol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3406 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3407
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3408 (defun vhdl-lineup-arglist-intro (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3409 ;; lineup an arglist-intro line to just after the open paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3410 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3411 (let ((cs-curcol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3412 (goto-char (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3413 (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3414 (ce-curcol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3415 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3416 (backward-up-list 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3417 (skip-chars-forward " \t" (vhdl-point 'eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3418 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3419 (- ce-curcol cs-curcol -1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3420
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3421 (defun vhdl-lineup-comment (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3422 ;; support old behavior for comment indentation. we look at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3423 ;; vhdl-comment-only-line-offset to decide how to indent comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3424 ;; only-lines
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3425 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3426 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3427 ;; at or to the right of comment-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3428 (if (>= (current-column) comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3429 (vhdl-comment-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3430 ;; otherwise, indent as specified by vhdl-comment-only-line-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3431 (if (not (bolp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3432 (or (car-safe vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3433 vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3434 (or (cdr-safe vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3435 (car-safe vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3436 -1000 ;jam it against the left side
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3437 )))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3438
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3439 (defun vhdl-lineup-statement-cont (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3440 ;; line up statement-cont after the assignment operator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3441 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3442 (let* ((relpos (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3443 (assignp (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3444 (goto-char (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3445 (and (re-search-forward "\\(<\\|:\\)="
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3446 (vhdl-point 'eol) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3447 (- (point) (vhdl-point 'boi)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3448 (curcol (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3449 (goto-char relpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3450 (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3451 foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3452 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3453 (< (point) (vhdl-point 'eol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3454 (re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3455 (if (vhdl-in-literal (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3456 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3457 (if (= (preceding-char) ?\()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3458 ;; skip over any parenthesized expressions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3459 (goto-char (min (vhdl-point 'eol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3460 (scan-lists (point) 1 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3461 ;; found an assignment operator (not at eol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3462 (setq foundp (not (looking-at "\\s-*$"))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3463 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3464 ;; there's no assignment operator on the line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3465 vhdl-basic-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3466 ;; calculate indentation column after assign and ws, unless
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3467 ;; our line contains an assignment operator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3468 (if (not assignp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3469 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3470 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3471 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3472 (setq assignp 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3473 (- (current-column) assignp curcol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3474 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3475
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3476 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3477 ;; Indentation commands
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3478
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3479 (defun vhdl-tab (&optional pre-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3480 "If preceeding character is part of a word then dabbrev-expand,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3481 else if right of non whitespace on line then tab-to-tab-stop,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3482 else if last command was a tab or return then dedent one step,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3483 else indent `correctly'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3484 (interactive "*P")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3485 (cond ((= (char-syntax (preceding-char)) ?w)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3486 (let ((case-fold-search nil)) (dabbrev-expand pre-arg)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3487 ((> (current-column) (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3488 (tab-to-tab-stop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3489 ((and (or (eq last-command 'vhdl-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3490 (eq last-command 'vhdl-return))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3491 (/= 0 (current-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3492 (backward-delete-char-untabify vhdl-basic-offset nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3493 ((vhdl-indent-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3494 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3495 (setq this-command 'vhdl-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3496 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3497
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3498 (defun vhdl-untab ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3499 "Delete backwards to previous tab stop."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3500 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3501 (backward-delete-char-untabify vhdl-basic-offset nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3502 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3503
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3504 (defun vhdl-return ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3505 "newline-and-indent or indent-new-comment-line if in comment and preceding
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3506 character is a space."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3507 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3508 (if (and (= (preceding-char) ? ) (vhdl-in-comment-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3509 (indent-new-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3510 (newline-and-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3511 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3512 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3513
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3514 (defun vhdl-indent-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3515 "Indent the current line as VHDL code. Returns the amount of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3516 indentation change."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3517 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3518 (let* ((syntax (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3519 (pos (- (point-max) (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3520 (indent (apply '+ (mapcar 'vhdl-get-offset syntax)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3521 (shift-amt (- (current-indentation) indent)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3522 (and vhdl-echo-syntactic-information-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3523 (message "syntax: %s, indent= %d" syntax indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3524 (if (zerop shift-amt)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3525 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3526 (delete-region (vhdl-point 'bol) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3527 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3528 (indent-to indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3529 (if (< (point) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3530 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3531 ;; If initial point was within line's indentation, position after
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3532 ;; the indentation. Else stay at same point in text.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3533 (if (> (- (point-max) pos) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3534 (goto-char (- (point-max) pos)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3535 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3536 (run-hooks 'vhdl-special-indent-hook)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3537 shift-amt))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3538
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3539 (defun vhdl-indent-buffer ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3540 "Indent whole buffer as VHDL code."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3541 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3542 (indent-region (point-min) (point-max) nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3543 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3544
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3545 (defun vhdl-indent-sexp (&optional endpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3546 "Indent each line of the list starting just after point.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3547 If optional arg ENDPOS is given, indent each line, stopping when
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3548 ENDPOS is encountered."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3549 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3550 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3551 (let ((beg (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3552 (end (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3553 (vhdl-forward-sexp nil endpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3554 (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3555 (indent-region beg end nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3556
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3557 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3558 ;; Miscellaneous commands
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3559
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3560 (defun vhdl-show-syntactic-information ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3561 "Show syntactic information for current line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3562 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3563 (message "syntactic analysis: %s" (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3564 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3565
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3566 ;; Verification and regression functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3567
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3568 (defun vhdl-regress-line (&optional arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3569 "Check syntactic information for current line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3570 (interactive "P")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3571 (let ((expected (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3572 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3573 (if (search-backward " -- ((" (vhdl-point 'bol) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3574 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3575 (forward-char 4)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3576 (read (current-buffer))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3577 (actual (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3578 (expurgated))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3579 ;; remove the library unit symbols
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3580 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3581 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3582 (lambda (elt)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3583 (if (memq (car elt) '(entity configuration package
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3584 package-body architecture))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3585 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3586 (setq expurgated (append expurgated (list elt))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3587 actual)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3588 (if (and (not arg) expected (listp expected))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3589 (if (not (equal expected expurgated))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3590 (error "Should be: %s, is: %s" expected expurgated))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3591 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3592 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3593 (if (not (looking-at "^\\s-*\\(--.*\\)?$"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3594 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3595 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3596 (if (search-backward " -- ((" (vhdl-point 'bol) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3597 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3598 (insert " -- ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3599 (insert (format "%s" expurgated)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3600 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3601
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3602
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3603 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3604 ;; Alignment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3605 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3606
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3607 (defvar vhdl-align-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3608 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3609 ;; after some keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3610 (vhdl-mode "\\<\\(alias\\|constant\\|signal\\|subtype\\|type\\|variable\\)[ \t]"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3611 "\\<\\(alias\\|constant\\|signal\\|subtype\\|type\\|variable\\)\\([ \t]+\\)" 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3612 ;; before ':'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3613 (vhdl-mode ":[^=]" "[^ \t]\\([ \t]*\\):[^=]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3614 ;; after ':'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3615 (vhdl-mode ":[^=]" ":\\([ \t]*\\)[^=]" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3616 ;; after direction specifications
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3617 (vhdl-mode ":[ \t]*\\(in\\|out\\|inout\\|buffer\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3618 ":[ \t]*\\(in\\|out\\|inout\\|buffer\\)\\([ \t]+\\)" 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3619 ;; before "<=", "=>", and ":="
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3620 (vhdl-mode "<=" "[^ \t]\\([ \t]*\\)<=" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3621 (vhdl-mode "=>" "[^ \t]\\([ \t]*\\)=>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3622 (vhdl-mode ":=" "[^ \t]\\([ \t]*\\):=" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3623 ;; after "<=", "=>", and ":="
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3624 (vhdl-mode "<=" "<=\\([ \t]*\\)" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3625 (vhdl-mode "=>" "=>\\([ \t]*\\)" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3626 (vhdl-mode ":=" ":=\\([ \t]*\\)" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3627 ;; before some keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3628 (vhdl-mode "[ \t]after\\>" "[^ \t]\\([ \t]+\\)after\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3629 (vhdl-mode "[ \t]\\(fs\\|ps\\|ns\\|us\\|ms\\|sec\\|min\\|hr\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3630 "[^ \t]\\([ \t]+\\)\\(fs\\|ps\\|ns\\|us\\|ms\\|sec\\|min\\|hr\\)\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3631 (vhdl-mode "[ \t]when\\>" "[^ \t]\\([ \t]+\\)when\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3632 (vhdl-mode "[ \t]else\\>" "[^ \t]\\([ \t]+\\)else\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3633 (vhdl-mode "[ \t]is\\>" "[^ \t]\\([ \t]+\\)is\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3634 (vhdl-mode "[ \t]of\\>" "[^ \t]\\([ \t]+\\)of\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3635 (vhdl-mode "[ \t]use\\>" "[^ \t]\\([ \t]+\\)use\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3636 ;; before comments (two steps required for correct insertion of two spaces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3637 (vhdl-mode "--" "[^ \t]\\([ \t]*\\)--" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3638 (vhdl-mode "--" "[^ \t][ \t]\\([ \t]*\\)--" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3639 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3640 "The format of this alist is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3641 (MODES [or MODE] REGEXP ALIGN-PATTERN SUBEXP).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3642 It is searched in order. If REGEXP is found anywhere in the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3643 line of a region to be aligned, ALIGN-PATTERN will be used for that
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3644 region. ALIGN-PATTERN must include the whitespace to be expanded or
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3645 contracted. It may also provide regexps for the text surrounding the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3646 whitespace. SUBEXP specifies which sub-expression of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3647 ALIGN-PATTERN matches the white space to be expanded/contracted.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3648
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3649 (defvar vhdl-align-try-all-clauses t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3650 "If REGEXP is not found on the first line of the region that clause
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3651 is ignored. If this variable is non-nil, then the clause is tried anyway.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3652
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3653 (defun vhdl-align (begin end spacing &optional alignment-list quick)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3654 "Attempt to align a range of lines based on the content of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3655 lines. The definition of 'alignment-list' determines the matching
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3656 order and the manner in which the lines are aligned. If ALIGNMENT-LIST
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3657 is not specified 'vhdl-align-alist' is used. If QUICK is non-nil, no
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3658 indentation is done before aligning."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3659 (interactive "r\np")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3660 (if (not alignment-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3661 (setq alignment-list vhdl-align-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3662 (if (not spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3663 (setq spacing 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3664 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3665 (let (bol indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3666 (goto-char end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3667 (setq end (point-marker))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3668 (goto-char begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3669 (setq bol
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3670 (setq begin (progn (beginning-of-line) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3671 (untabify bol end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3672 (if quick
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3673 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3674 (indent-region bol end nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3675 (let ((copy (copy-alist alignment-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3676 (while copy
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3677 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3678 (goto-char begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3679 (let (element
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3680 (eol (save-excursion (progn (end-of-line) (point)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3681 (setq element (nth 0 copy))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3682 (if (and (or (and (listp (car element))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3683 (memq major-mode (car element)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3684 (eq major-mode (car element)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3685 (or vhdl-align-try-all-clauses
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3686 (re-search-forward (car (cdr element)) eol t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3687 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3688 (vhdl-align-region begin end (car (cdr (cdr element)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3689 (car (cdr (cdr (cdr element)))) spacing)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3690 (setq copy (cdr copy)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3691
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3692 (defun vhdl-align-region (begin end match &optional substr spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3693 "Align a range of lines from BEGIN to END. The regular expression
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3694 MATCH must match exactly one fields: the whitespace to be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3695 contracted/expanded. The alignment column will equal the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3696 rightmost column of the widest whitespace block. SPACING is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3697 the amount of extra spaces to add to the calculated maximum required.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3698 SPACING defaults to 1 so that at least one space is inserted after
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3699 the token in MATCH."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3700 (if (not spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3701 (setq spacing 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3702 (if (not substr)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3703 (setq substr 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3704 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3705 (let (distance (max 0) (lines 0) bol eol width)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3706 ;; Determine the greatest whitespace distance to the alignment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3707 ;; character
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3708 (goto-char begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3709 (setq eol (progn (end-of-line) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3710 bol (setq begin (progn (beginning-of-line) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3711 (while (< bol end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3712 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3713 (if (re-search-forward match eol t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3714 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3715 (setq distance (- (match-beginning substr) bol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3716 (if (> distance max)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3717 (setq max distance)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3718 (forward-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3719 (setq bol (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3720 eol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3721 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3722 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3723 (setq lines (1+ lines)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3724 ;; Now insert enough maxs to push each assignment operator to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3725 ;; the same column. We need to use 'lines' as a counter, since
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3726 ;; the location of the mark may change
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3727 (goto-char (setq bol begin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3728 (setq eol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3729 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3730 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3731 (while (> lines 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3732 (if (re-search-forward match eol t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3733 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3734 (setq width (- (match-end substr) (match-beginning substr)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3735 (setq distance (- (match-beginning substr) bol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3736 (goto-char (match-beginning substr))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3737 (delete-char width)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3738 (insert-char ? (+ (- max distance) spacing))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3739 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3740 (forward-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3741 (setq bol (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3742 eol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3743 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3744 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3745 (setq lines (1- lines))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3746 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3747
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3748 (defun vhdl-align-comment-region (begin end spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3749 "Aligns inline comments within a region relative to first comment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3750 (interactive "r\nP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3751 (vhdl-align begin end (or spacing 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3752 `((vhdl-mode "--" "[^ \t]\\([ \t]*\\)--" 1)) t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3753
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3754 (defun vhdl-align-noindent-region (begin end spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3755 "Align without indentation."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3756 (interactive "r\nP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3757 (vhdl-align begin end spacing nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3758 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3759
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3760
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3761 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3762 ;; VHDL electrification
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3763 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3764
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3765 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3766 ;; Stuttering
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3767
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3768 (defun vhdl-stutter-mode-caps (count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3769 "Double first letters of a word replaced by a single capital of the letter."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3770 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3771 (if vhdl-stutter-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3772 (if (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3773 (= (preceding-char) last-input-char) ; doubled
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3774 (or (= (point) 2) ; beginning of buffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3775 (/= (char-syntax (char-after (- (point) 2))) ?w) ;not mid-word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3776 (< (char-after (- (point) 2)) ?A))) ;alfa-numeric
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3777 (progn (delete-char -1) (insert-char (- last-input-char 32) count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3778 (self-insert-command count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3779 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3780 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3781
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3782 (defun vhdl-stutter-mode-close-bracket (count) " ']' --> ')', ')]' --> ']'"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3783 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3784 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3785 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3786 (if (= (preceding-char) 41) ; close-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3787 (progn (delete-char -1) (insert-char 93 1)) ; close-bracket
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3788 (insert-char 41 1) ; close-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3789 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3790 (blink-matching-open))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3791 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3792 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3793
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3794 (defun vhdl-stutter-mode-semicolon (count) " ';;' --> ' : ', ': ;' --> ' := '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3795 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3796 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3797 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3798 (cond ((= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3799 (progn (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3800 (if (not (eq (preceding-char) ? )) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3801 (insert ": ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3802 ((and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3803 (eq last-command 'vhdl-stutter-mode-colon) (= (preceding-char) ? ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3804 (progn (delete-char -1) (insert "= ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3805 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3806 (insert-char 59 1)) ; semi-colon
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3807 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3808 (setq this-command 'vhdl-stutter-mode-colon))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3809 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3810 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3811
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3812 (defun vhdl-stutter-mode-open-bracket (count) " '[' --> '(', '([' --> '['"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3813 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3814 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3815 (if (= (preceding-char) 40) ; open-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3816 (progn (delete-char -1) (insert-char 91 1)) ; open-bracket
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3817 (insert-char 40 1)) ; open-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3818 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3819 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3820
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3821 (defun vhdl-stutter-mode-quote (count) " '' --> \""
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3822 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3823 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3824 (if (= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3825 (progn (delete-backward-char 1) (insert-char 34 1)) ; double-quote
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3826 (insert-char 39 1)) ; single-quote
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3827 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3828 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3829
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3830 (defun vhdl-stutter-mode-comma (count) " ',,' --> ' <= '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3831 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3832 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3833 (cond ((= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3834 (progn (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3835 (if (not (eq (preceding-char) ? )) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3836 (insert "<= ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3837 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3838 (insert-char 44 1))) ; comma
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3839 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3840 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3841
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3842 (defun vhdl-stutter-mode-period (count) " '..' --> ' => '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3843 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3844 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3845 (cond ((= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3846 (progn (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3847 (if (not (eq (preceding-char) ? )) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3848 (insert "=> ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3849 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3850 (insert-char 46 1))) ; period
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3851 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3852 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3853
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3854 (defun vhdl-paired-parens ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3855 "Insert a pair of round parentheses, placing point between them."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3856 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3857 (insert "()")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3858 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3859 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3860
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3861 (defun vhdl-stutter-mode-dash (count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3862 "-- starts a comment, --- draws a horizontal line,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3863 ---- starts a display comment"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3864 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3865 (if vhdl-stutter-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3866 (cond ((and abbrev-start-location (= abbrev-start-location (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3867 (setq abbrev-start-location nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3868 (goto-char last-abbrev-location)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3869 (beginning-of-line nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3870 (vhdl-display-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3871 ((/= (preceding-char) ?-) ; standard dash (minus)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3872 (self-insert-command count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3873 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3874 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3875 (message "Enter - for horiz. line, CR for commenting-out code, else 1st char of comment")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3876 (let ((next-input (read-char)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3877 (if (= next-input ?-) ; triple dash
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3878 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3879 (vhdl-display-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3880 (message
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3881 "Enter - for display comment, else continue with coding")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3882 (let ((next-input (read-char)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3883 (if (= next-input ?-) ; four dashes
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3884 (vhdl-display-comment t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3885 (setq unread-command-events ;pushback the char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3886 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3887 (vhdl-character-to-event-hack next-input)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3888 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3889 (setq unread-command-events ;pushback the char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3890 (list (vhdl-character-to-event-hack next-input)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3891 (vhdl-inline-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3892 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3893 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3894 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3895
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3896 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3897 ;; VHDL templates
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3898
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3899 (defun vhdl-alias ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3900 "Insert alias declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3901 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3902 (vhdl-insert-keyword "ALIAS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3903 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3904 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3905 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3906 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3907 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3908 (vhdl-field "name" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3909 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3910 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3911
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3912 (defun vhdl-architecture ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3913 "Insert architecture template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3914 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3915 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3916 (vhdl-architecture-name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3917 (position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3918 (entity-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3919 (string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3920 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3921 (vhdl-insert-keyword "ARCHITECTURE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3922 (if (equal (setq vhdl-architecture-name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3923 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3924 (vhdl-insert-keyword " OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3925 (setq position (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3926 (setq entity-exists
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3927 (re-search-backward "entity \\(\\(\\w\\|\\s_\\)+\\) is" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3928 (setq string (match-string 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3929 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3930 (if (and entity-exists (not (equal string "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3931 (insert string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3932 (vhdl-field "entity name"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3933 (vhdl-insert-keyword " IS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3934 (vhdl-begin-end (cons vhdl-architecture-name margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3935 (vhdl-block-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3936 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3937
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3938
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3939 (defun vhdl-array ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3940 "Insert array type definition."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3941 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3942 (vhdl-insert-keyword "ARRAY (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3943 (if (equal (vhdl-field "range") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3944 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3945 (vhdl-insert-keyword ") OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3946 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3947 (vhdl-insert-keyword ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3948 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3949
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3950 (defun vhdl-assert ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3951 "Inserts a assertion statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3952 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3953 (vhdl-insert-keyword "ASSERT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3954 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3955 (if (equal (vhdl-field "condition (negated)") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3956 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3957 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3958 (vhdl-insert-keyword " REPORT \"")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3959 (vhdl-field "string-expression" "\" ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3960 (vhdl-insert-keyword "SEVERITY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3961 (if (equal (vhdl-field "[note | warning | error | failure]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3962 (delete-char -10))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3963 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3964 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3965
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3966 (defun vhdl-attribute ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3967 "Inserts an attribute declaration or specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3968 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3969 (vhdl-insert-keyword "ATTRIBUTE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3970 (if (y-or-n-p "declaration (or specification)? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3971 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3972 (vhdl-field "name" " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3973 (vhdl-field "type" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3974 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3975 (vhdl-field "name")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3976 (vhdl-insert-keyword " OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3977 (vhdl-field "entity name" " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3978 (vhdl-field "entity class")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3979 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3980 (vhdl-field "expression" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3981 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3982
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3983 (defun vhdl-block ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3984 "Insert a block template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3985 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3986 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3987 (vhdl-insert-keyword " : BLOCK ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3988 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3989 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3990 (name (vhdl-field "label")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3991 (if (equal name "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3992 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3993 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3994 (insert "(")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3995 (if (equal (vhdl-field "[guard expression]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3996 (delete-char -2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3997 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3998 (vhdl-begin-end (cons (concat (vhdl-case-keyword "BLOCK ") name) margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3999 (vhdl-block-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4000 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4001
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4002 (defun vhdl-block-configuration ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4003 "Insert a block configuration statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4004 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4005 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4006 (vhdl-insert-keyword "FOR ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4007 (if (equal (setq name (vhdl-field "block specification")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4008 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4009 (vhdl-insert-keyword "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4010 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4011 (vhdl-insert-keyword "END FOR;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4012 (end-of-line 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4013 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4014 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4015
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4016 (defun vhdl-case ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4017 "Inserts a case statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4018 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4019 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4020 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4021 (vhdl-insert-keyword "CASE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4022 (if (equal (setq name (vhdl-field "expression")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4023 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4024 (vhdl-insert-keyword " IS\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4025 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4026 (vhdl-insert-keyword "END CASE;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4027 ; (if vhdl-self-insert-comments (insert " -- " name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4028 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4029 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4030 (vhdl-insert-keyword "WHEN => ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4031 (backward-char 4)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4032 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4033
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4034 (defun vhdl-component ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4035 "Inserts a component declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4036 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4037 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4038 (vhdl-insert-keyword "COMPONENT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4039 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4040 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4041 (insert "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4042 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4043 (vhdl-insert-keyword "END COMPONENT;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4044 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4045 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4046 (vhdl-insert-keyword "GENERIC (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4047 (vhdl-get-generic t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4048 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4049 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4050 (vhdl-insert-keyword "PORT (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4051 (vhdl-get-port t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4052 (forward-line 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4053 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4054
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4055 (defun vhdl-component-configuration ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4056 "Inserts a component configuration (uses `vhdl-configuration-spec' since
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4057 these are almost equivalent)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4058 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4059 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4060 (vhdl-configuration-spec)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4061 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4062 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4063 (vhdl-insert-keyword "END FOR;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4064 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4065
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4066 (defun vhdl-component-instance ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4067 "Inserts a component instantiation statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4068 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4069 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4070 (if (equal (vhdl-field "instance label") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4071 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4072 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4073 (vhdl-field "component name" "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4074 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4075 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4076 (vhdl-insert-keyword "GENERIC MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4077 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4078 (progn (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4079 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4080 (insert ")\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4081 (indent-to (+ margin vhdl-basic-offset))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4082 (vhdl-insert-keyword "PORT MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4083 (vhdl-field "association list" ");")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4084 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4085
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4086 (defun vhdl-concurrent-signal-assignment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4087 "Inserts a concurrent signal assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4088 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4089 (if (equal (vhdl-field "target signal") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4090 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4091 (insert " <= ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4092 ; (if (not (equal (vhdl-field "[GUARDED] [TRANSPORT]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4093 ; (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4094 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4095 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4096 (vhdl-field "waveform")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4097 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4098 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4099 (while (not (equal (vhdl-field "[condition]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4100 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4101 (vhdl-insert-keyword " ELSE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4102 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4103 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4104 (vhdl-field "waveform")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4105 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4106 (if vhdl-conditions-in-parenthesis (insert "(")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4107 (delete-char -6)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4108 (if vhdl-conditions-in-parenthesis (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4109 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4110 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4111 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4112
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4113 (defun vhdl-configuration ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4114 "Inserts a configuration specification if within an architecture,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4115 a block or component configuration if within a configuration declaration,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4116 a configuration declaration if not within a design unit."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4117 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4118 (cond ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'architecture)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4119 (vhdl-configuration-spec))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4120 ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4121 (if (y-or-n-p "block configuration (or component configuration)? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4122 (vhdl-block-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4123 (vhdl-component-configuration)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4124 (t (vhdl-configuration-decl)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4125 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4126
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4127 (defun vhdl-configuration-spec ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4128 "Inserts a configuration specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4129 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4130 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4131 (vhdl-insert-keyword "FOR ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4132 (if (equal (vhdl-field "(component names | ALL)" " : ") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4133 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4134 (vhdl-field "component type" "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4135 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4136 (vhdl-insert-keyword "USE ENTITY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4137 (vhdl-field "library name" ".")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4138 (vhdl-field "entity name" "(")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4139 (if (equal (vhdl-field "[architecture name]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4140 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4141 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4142 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4143 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4144 (vhdl-insert-keyword "GENERIC MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4145 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4146 (progn (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4147 (indent-to (+ margin vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4148 (insert ")\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4149 (indent-to (+ margin vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4150 (vhdl-insert-keyword "PORT MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4151 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4152 (progn (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4153 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4154 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4155 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4156 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4157
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4158 (defun vhdl-configuration-decl ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4159 "Inserts a configuration declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4160 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4161 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4162 (position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4163 (entity-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4164 (string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4165 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4166 (vhdl-insert-keyword "CONFIGURATION ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4167 (if (equal (setq name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4168 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4169 (vhdl-insert-keyword " OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4170 (setq position (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4171 (setq entity-exists
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4172 (re-search-backward "entity \\(\\(\\w\\|\\s_\\)*\\) is" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4173 (setq string (match-string 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4174 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4175 (if (and entity-exists (not (equal string "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4176 (insert string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4177 (vhdl-field "entity name"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4178 (vhdl-insert-keyword " IS\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4179 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4180 (vhdl-insert-keyword "END ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4181 (insert name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4182 (end-of-line 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4183 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4184 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4185
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4186 (defun vhdl-constant ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4187 "Inserts a constant declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4188 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4189 (vhdl-insert-keyword "CONSTANT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4190 (let ((in-arglist (string-match "arglist"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4191 (format "%s" (car (car (vhdl-get-syntactic-context)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4192 (if (not in-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4193 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4194 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4195 (setq in-arglist (looking-at ".*("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4196 (goto-char opoint)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4197 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4198 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4199 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4200 (if in-arglist (vhdl-insert-keyword "IN "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4201 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4202 (if in-arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4203 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4204 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4205 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4206 (if (equal (vhdl-field "[initialization]" ";") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4207 (progn (goto-char position) (kill-line) (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4208 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4209 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4210
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4211 (defun vhdl-default ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4212 "Insert nothing."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4213 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4214 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4215 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4216 (backward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4217 (vhdl-case-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4218 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4219 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4220
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4221 (defun vhdl-default-indent ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4222 "Insert nothing and indent."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4223 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4224 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4225 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4226 (backward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4227 (vhdl-case-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4228 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4229 (vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4230 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4231
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4232 (defun vhdl-disconnect ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4233 "Insert a disconnect statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4234 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4235 (vhdl-insert-keyword "DISCONNECT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4236 (if (equal (vhdl-field "guarded signal specification") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4237 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4238 (vhdl-insert-keyword " AFTER ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4239 (vhdl-field "time expression" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4240 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4241
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4242 (defun vhdl-else ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4243 "Insert an else statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4244 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4245 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4246 (vhdl-insert-keyword "ELSE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4247 (if (not (equal 'block-close (car (car (vhdl-get-syntactic-context)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4248 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4249 (vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4250 (setq margin (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4251 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4252 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4253 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4254
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4255 (defun vhdl-elsif ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4256 "Insert an elsif statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4257 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4258 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4259 (vhdl-insert-keyword "ELSIF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4260 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4261 (if (equal (vhdl-field "condition") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4262 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4263 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4264 (vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4265 (setq margin (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4266 (vhdl-insert-keyword " THEN\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4267 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4268 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4269
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4270 (defun vhdl-entity ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4271 "Insert an entity template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4272 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4273 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4274 (vhdl-entity-name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4275 (vhdl-insert-keyword "ENTITY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4276 (if (equal (setq vhdl-entity-name (vhdl-field "entity name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4277 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4278 (vhdl-insert-keyword " IS\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4279 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4280 (vhdl-insert-keyword "END ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4281 (insert vhdl-entity-name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4282 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4283 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4284 (vhdl-entity-body)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4285 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4286
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4287 (defun vhdl-entity-body ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4288 "Insert an entity body."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4289 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4290 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4291 (if vhdl-additional-empty-lines (insert "\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4292 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4293 (vhdl-insert-keyword "GENERIC (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4294 (if (vhdl-get-generic t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4295 (if vhdl-additional-empty-lines (insert "\n")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4296 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4297 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4298 (vhdl-insert-keyword "PORT (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4299 (if (vhdl-get-port t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4300 (if vhdl-additional-empty-lines (insert "\n")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4301 (end-of-line 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4302 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4303
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4304 (defun vhdl-exit ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4305 "Insert an exit statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4306 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4307 (vhdl-insert-keyword "EXIT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4308 (if (string-equal (vhdl-field "[loop label]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4309 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4310 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4311 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4312 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4313 (if (equal (vhdl-field "[condition]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4314 (progn (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4315 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4316 (if vhdl-conditions-in-parenthesis (insert ")"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4317 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4318 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4319
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4320 (defun vhdl-for ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4321 "Inserts a block or component configuration if within a configuration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4322 declaration, a for loop otherwise."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4323 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4324 (if (equal (car (car (cdr (vhdl-get-syntactic-context)))) 'configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4325 (if (y-or-n-p "block configuration (or component configuration)? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4326 (vhdl-block-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4327 (vhdl-component-configuration))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4328 (vhdl-for-loop)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4329
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4330 (defun vhdl-for-loop ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4331 "Insert a for loop template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4332 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4333 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4334 (vhdl-insert-keyword " : FOR ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4335 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4336 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4337 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4338 (named (not (string-equal name "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4339 (index))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4340 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4341 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4342 (if (equal (setq index (vhdl-field "loop variable")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4343 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4344 (vhdl-insert-keyword " IN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4345 (vhdl-field "range")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4346 (vhdl-insert-keyword " LOOP\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4347 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4348 (vhdl-insert-keyword "END LOOP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4349 (if named (insert " " name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4350 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4351 (if vhdl-self-insert-comments (insert " -- " index)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4352 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4353 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4354 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4355
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4356 (defun vhdl-function ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4357 "Insert function specification or body template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4358 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4359 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4360 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4361 (vhdl-insert-keyword "FUNCTION ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4362 (if (equal (setq name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4363 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4364 (vhdl-get-arg-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4365 (vhdl-insert-keyword " RETURN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4366 (vhdl-field "type" " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4367 (if (y-or-n-p "insert body? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4368 (progn (vhdl-insert-keyword "IS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4369 (vhdl-begin-end (cons name margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4370 (vhdl-block-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4371 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4372 (insert ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4373 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4374 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4375
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4376 (defun vhdl-generate ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4377 "Insert a generate template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4378 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4379 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4380 (vhdl-insert-keyword " GENERATE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4381 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4382 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4383 (label (vhdl-field "label"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4384 (string))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4385 (if (equal label "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4386 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4387 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4388 (setq string (vhdl-field "(FOR | IF)"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4389 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4390 (if (equal (upcase string) "IF")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4391 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4392 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4393 (vhdl-field "condition")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4394 (if vhdl-conditions-in-parenthesis (insert ")")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4395 (vhdl-field "loop variable")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4396 (vhdl-insert-keyword " IN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4397 (vhdl-field "range"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4398 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4399 (insert "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4400 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4401 (vhdl-insert-keyword "END GENERATE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4402 (insert label ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4403 (end-of-line 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4404 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4405 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4406
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4407 (defun vhdl-generic ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4408 "Insert generic declaration, or generic map in instantiation statements."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4409 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4410 (vhdl-insert-keyword "GENERIC (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4411 (cond ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4412 (vhdl-get-generic nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4413 ((or (equal 'statement-cont (car (car (vhdl-get-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4414 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4415 (and (backward-word 2) (skip-chars-backward " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4416 (eq (preceding-char) ?:))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4417 (delete-char -1) (vhdl-map))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4418 (t (vhdl-get-generic nil t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4419
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4420 (defun vhdl-header ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4421 "Insert a VHDL file header."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4422 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4423 (let (eot)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4424 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4425 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4426 (widen)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4427 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4428 (if vhdl-header-file
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4429 (setq eot (car (cdr (insert-file-contents vhdl-header-file))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4430 ; insert default header
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4431 (insert "\
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4432 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4433 -- Title : <title string>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4434 -- Project : <project string>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4435 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4436 -- File : <filename>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4437 -- Author : <author>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4438 -- Created : <date>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4439 -- Last modified : <date>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4440 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4441 -- Description :
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4442 -- <cursor>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4443 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4444 -- Modification history :
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4445 -- <date> : created
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4446 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4447
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4448 ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4449 (setq eot (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4450 (narrow-to-region (point-min) eot)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4451 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4452 (while (search-forward "<filename>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4453 (replace-match (buffer-name) t t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4454 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4455 (while (search-forward "<author>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4456 (replace-match "" t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4457 (insert (user-full-name) " <" user-mail-address ">"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4458 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4459 ;; Replace <RCS> with $, so that RCS for the source is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4460 ;; not over-enthusiastic with replacements
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4461 (while (search-forward "<RCS>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4462 (replace-match "$" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4463 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4464 (while (search-forward "<date>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4465 (replace-match "" t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4466 (vhdl-insert-date))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4467 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4468 (let (string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4469 (while (re-search-forward "<\\(\\w*\\) string>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4470 (setq string (read-string (concat (match-string 1) ": ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4471 (replace-match string t t)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4472 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4473 (if (search-forward "<cursor>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4474 (replace-match "" t t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4475
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4476 (defun vhdl-if ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4477 "Insert an if statement template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4478 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4479 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4480 (vhdl-insert-keyword "IF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4481 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4482 (if (equal (vhdl-field "condition") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4483 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4484 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4485 (vhdl-insert-keyword " THEN\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4486 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4487 (vhdl-insert-keyword "END IF;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4488 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4489 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4490 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4491
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4492 (defun vhdl-library ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4493 "Insert a library specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4494 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4495 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4496 (lib-name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4497 (vhdl-insert-keyword "LIBRARY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4498 (if (equal (setq lib-name (vhdl-field "library name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4499 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4500 (insert ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4501 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4502 (vhdl-insert-keyword "USE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4503 (insert lib-name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4504 (vhdl-insert-keyword "..ALL;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4505 (backward-char 5)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4506 (if (equal (vhdl-field "package name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4507 (progn (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4508 (end-of-line -0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4509 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4510 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4511
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4512 (defun vhdl-loop ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4513 "Insert a loop template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4514 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4515 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4516 (vhdl-insert-keyword " : LOOP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4517 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4518 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4519 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4520 (named (not (string-equal name ""))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4521 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4522 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4523 (insert "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4524 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4525 (vhdl-insert-keyword "END LOOP")
21466
98b189f8975f (vhdl-loop, vhdl-while-loop): Add backslash.
Karl Heuer <kwzh@gnu.org>
parents: 21446
diff changeset
4526 (insert (if named (concat " " name ";") ?\;))
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4527 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4528 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4529 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4530
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4531 (defun vhdl-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4532 "Insert a map specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4533 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4534 (vhdl-insert-keyword "MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4535 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4536 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4537 (insert ")")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4538 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4539
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4540 (defun vhdl-modify ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4541 "Actualize modification date."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4542 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4543 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4544 (if (search-forward vhdl-modify-date-prefix-string nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4545 (progn (kill-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4546 (vhdl-insert-date))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4547 (message (concat "Modification date prefix string \""
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4548 vhdl-modify-date-prefix-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4549 "\" not found!"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4550 (beep)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4551
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4552 (defun vhdl-next ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4553 "Inserts a next statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4554 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4555 (vhdl-insert-keyword "NEXT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4556 (if (string-equal (vhdl-field "[loop label]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4557 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4558 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4559 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4560 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4561 (if (equal (vhdl-field "[condition]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4562 (progn (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4563 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4564 (if vhdl-conditions-in-parenthesis (insert ")"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4565 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4566 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4567
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4568 (defun vhdl-package ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4569 "Insert a package specification or body."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4570 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4571 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4572 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4573 (vhdl-insert-keyword "PACKAGE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4574 (if (y-or-n-p "body? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4575 (vhdl-insert-keyword "BODY "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4576 (setq name (vhdl-field "name" " is\n\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4577 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4578 (vhdl-insert-keyword "END ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4579 (insert name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4580 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4581 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4582 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4583
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4584 (defun vhdl-port ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4585 "Insert a port declaration, or port map in instantiation statements."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4586 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4587 (vhdl-insert-keyword "PORT (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4588 (cond ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4589 (vhdl-get-port nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4590 ((or (equal 'statement-cont (car (car (vhdl-get-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4591 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4592 (and (backward-word 2) (skip-chars-backward " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4593 (eq (preceding-char) ?:))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4594 (delete-char -1) (vhdl-map))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4595 (t (vhdl-get-port nil t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4596
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4597 (defun vhdl-procedure ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4598 "Insert a procedure specification or body template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4599 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4600 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4601 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4602 (vhdl-insert-keyword "PROCEDURE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4603 (if (equal (setq name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4604 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4605 (vhdl-get-arg-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4606 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4607 (if (y-or-n-p "insert body? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4608 (progn (vhdl-insert-keyword "IS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4609 (vhdl-begin-end (cons name margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4610 (vhdl-block-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4611 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4612 (insert ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4613 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4614 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4615
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4616 (defun vhdl-process ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4617 "Insert a process template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4618 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4619 (let ((clocked))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4620 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4621 (vhdl-insert-keyword "PROCESS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4622 (setq clocked (y-or-n-p "clocked process? "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4623 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4624 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4625 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4626 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4627 (finalline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4628 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4629 (named (not (string-equal name "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4630 (clock) (reset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4631 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4632 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4633 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4634 (insert " (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4635 (if (not clocked)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4636 (if (equal (vhdl-field "[sensitivity list]" ")") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4637 (delete-char -3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4638 (setq clock (vhdl-field "clock name" ", "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4639 (setq reset (vhdl-field "reset name" ")")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4640 (vhdl-begin-end (cons (concat (vhdl-case-keyword "PROCESS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4641 (if named (concat " " name))) margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4642 (if clocked (vhdl-clock-async-reset clock reset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4643 (if vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4644 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4645 (setq finalline (vhdl-current-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4646 (if (and (re-search-backward "\\<begin\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4647 (re-search-backward "\\<process\\>" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4648 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4649 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4650 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4651 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4652 (insert "-- purpose: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4653 (if (equal (vhdl-field "description") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4654 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4655 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4656 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4657 (insert "-- type: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4658 (insert (if clocked "memorizing" "memoryless") "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4659 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4660 (insert "-- inputs: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4661 (if clocked
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4662 (insert clock ", " reset ", "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4663 (if (and (equal (vhdl-field "signal names") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4664 clocked)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4665 (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4666 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4667 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4668 (insert "-- outputs: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4669 (vhdl-field "signal names")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4670 (setq finalline (+ finalline 4)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4671 (goto-line finalline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4672 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4673 )))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4674
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4675 (defun vhdl-record ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4676 "Insert a record type declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4677 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4678 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4679 (start (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4680 (first t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4681 (vhdl-insert-keyword "RECORD\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4682 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4683 (if (equal (vhdl-field "identifiers") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4684 (progn (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4685 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4686 (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4687 (while (or first (not (equal (vhdl-field "[identifiers]") "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4688 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4689 (vhdl-field "type" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4690 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4691 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4692 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4693 (setq first nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4694 (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4695 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4696 (vhdl-insert-keyword "END RECORD;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4697 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4698 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4699
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4700 (defun vhdl-return-value ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4701 "Insert a return statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4702 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4703 (vhdl-insert-keyword "RETURN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4704 (if (equal (vhdl-field "[expression]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4705 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4706 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4707 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4708
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4709 (defun vhdl-selected-signal-assignment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4710 "Insert a selected signal assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4711 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4712 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4713 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4714 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4715 (vhdl-insert-keyword " SELECT")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4716 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4717 (vhdl-insert-keyword "WITH ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4718 (if (equal (vhdl-field "selector expression") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4719 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4720 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4721 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4722 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4723 (vhdl-field "target signal" " <= ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4724 ; (vhdl-field "[GUARDED] [TRANSPORT]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4725 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4726 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4727 (while (not (equal (vhdl-field "[waveform]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4728 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4729 (vhdl-field "choices" ",")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4730 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4731 (indent-to (+ margin vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4732 (if (not (equal (vhdl-field "[alternative waveform]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4733 (vhdl-insert-keyword " WHEN OTHERS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4734 (fixup-whitespace)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4735 (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4736 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4737 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4738 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4739
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4740 (defun vhdl-signal ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4741 "Insert a signal declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4742 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4743 (vhdl-insert-keyword "SIGNAL ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4744 (let ((in-arglist (string-match "arglist"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4745 (format "%s" (car (car (vhdl-get-syntactic-context)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4746 (if (not in-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4747 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4748 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4749 (setq in-arglist (looking-at ".*("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4750 (goto-char opoint)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4751 (if (equal (vhdl-field "names") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4752 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4753 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4754 (if in-arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4755 (progn (vhdl-field "direction")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4756 (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4757 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4758 (if in-arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4759 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4760 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4761 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4762 (if (equal (vhdl-field "[initialization]" ";") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4763 (progn (goto-char position) (kill-line) (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4764 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4765 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4766
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4767 (defun vhdl-subtype ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4768 "Insert a subtype declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4769 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4770 (vhdl-insert-keyword "SUBTYPE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4771 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4772 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4773 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4774 (vhdl-field "type" " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4775 (if (equal (vhdl-field "[RANGE value range | ( index range )]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4776 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4777 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4778 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4779 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4780
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4781 (defun vhdl-type ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4782 "Insert a type declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4783 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4784 (vhdl-insert-keyword "TYPE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4785 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4786 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4787 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4788 (let ((definition (upcase (vhdl-field "(scalar type | ARRAY | RECORD | ACCESS | FILE)"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4789 (cond ((equal definition "ARRAY")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4790 (kill-word -1) (vhdl-array))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4791 ((equal definition "RECORD")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4792 (kill-word -1) (vhdl-record))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4793 ((equal definition "ACCESS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4794 (insert " ") (vhdl-field "type" ";"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4795 ((equal definition "FILE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4796 (vhdl-insert-keyword " OF ") (vhdl-field "type" ";"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4797 (t (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4798 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4799 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4800
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4801 (defun vhdl-use ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4802 "Insert a use clause."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4803 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4804 (vhdl-insert-keyword "USE ..ALL;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4805 (backward-char 6)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4806 (if (equal (vhdl-field "library name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4807 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4808 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4809 (vhdl-field "package name")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4810 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4811 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4812
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4813 (defun vhdl-variable ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4814 "Insert a variable declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4815 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4816 (vhdl-insert-keyword "VARIABLE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4817 (let ((in-arglist (string-match "arglist"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4818 (format "%s" (car (car (vhdl-get-syntactic-context)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4819 (if (not in-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4820 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4821 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4822 (setq in-arglist (looking-at ".*("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4823 (goto-char opoint)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4824 (if (equal (vhdl-field "names") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4825 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4826 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4827 (if in-arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4828 (progn (vhdl-field "direction")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4829 (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4830 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4831 (if in-arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4832 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4833 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4834 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4835 (if (equal (vhdl-field "[initialization]" ";") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4836 (progn (goto-char position) (kill-line) (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4837 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4838 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4839
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4840 (defun vhdl-wait ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4841 "Insert a wait statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4842 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4843 (vhdl-insert-keyword "WAIT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4844 (if (equal (vhdl-field
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4845 "[ON sensitivity list] [UNTIL condition] [FOR time expression]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4846 "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4847 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4848 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4849 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4850
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4851 (defun vhdl-when ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4852 "Indent correctly if within a case statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4853 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4854 (let ((position (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4855 (margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4856 (if (and (re-search-forward "\\<end\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4857 (looking-at "\\s-*\\<case\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4858 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4859 (setq margin (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4860 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4861 (delete-horizontal-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4862 (indent-to (+ margin vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4863 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4864 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4865 (vhdl-insert-keyword "WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4866 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4867
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4868 (defun vhdl-while-loop ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4869 "Insert a while loop template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4870 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4871 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4872 (vhdl-insert-keyword " : WHILE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4873 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4874 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4875 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4876 (named (not (string-equal name ""))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4877 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4878 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4879 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4880 (if (equal (vhdl-field "condition") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4881 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4882 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4883 (vhdl-insert-keyword " LOOP\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4884 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4885 (vhdl-insert-keyword "END LOOP")
21466
98b189f8975f (vhdl-loop, vhdl-while-loop): Add backslash.
Karl Heuer <kwzh@gnu.org>
parents: 21446
diff changeset
4886 (insert (if named (concat " " name ";") ?\;))
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4887 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4888 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4889 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4890
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4891 (defun vhdl-with ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4892 "Insert a with statement (i.e. selected signal assignment)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4893 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4894 (vhdl-selected-signal-assignment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4895 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4896
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4897 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4898 ;; Custom functions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4899
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4900 (defun vhdl-clocked-wait ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4901 "Insert a wait statement for rising clock edge."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4902 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4903 (vhdl-insert-keyword "WAIT UNTIL ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4904 (let* ((clock (vhdl-field "clock name")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4905 (insert "'event")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4906 (vhdl-insert-keyword " AND ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4907 (insert clock)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4908 (insert " = " vhdl-one-string ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4909 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4910
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4911 (defun vhdl-clock-async-reset (clock reset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4912 "Insert a template reacting on asynchronous reset and rising clock edge
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4913 for inside a memorizing processes."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4914 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4915 (let* ( (margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4916 (opoint))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4917 (if vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4918 (insert "-- activities triggered by asynchronous reset (active low)\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4919 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4920 (vhdl-insert-keyword "IF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4921 (insert reset " = " vhdl-zero-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4922 (vhdl-insert-keyword " THEN\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4923 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4924 (setq opoint (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4925 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4926 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4927 (if vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4928 (insert "-- activities triggered by rising edge of clock\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4929 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4930 (vhdl-insert-keyword "ELSIF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4931 (insert clock "'event")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4932 (vhdl-insert-keyword " AND ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4933 (insert clock " = " vhdl-one-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4934 (vhdl-insert-keyword " THEN\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4935 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4936 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4937 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4938 (vhdl-insert-keyword "END IF;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4939 ; (if vhdl-self-insert-comments (insert " -- " clock))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4940 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4941 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4942
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4943 (defun vhdl-standard-package (library package)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4944 "Insert specification of a standard package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4945 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4946 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4947 (vhdl-insert-keyword "LIBRARY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4948 (insert library ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4949 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4950 (vhdl-insert-keyword "USE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4951 (insert library "." package)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4952 (vhdl-insert-keyword ".ALL;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4953 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4954
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4955 (defun vhdl-package-numeric-bit ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4956 "Insert specification of 'numeric_bit' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4957 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4958 (vhdl-standard-package "ieee" "numeric_bit"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4959
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4960 (defun vhdl-package-numeric-std ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4961 "Insert specification of 'numeric_std' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4962 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4963 (vhdl-standard-package "ieee" "numeric_std"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4964
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4965 (defun vhdl-package-std-logic-1164 ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4966 "Insert specification of 'std_logic_1164' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4967 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4968 (vhdl-standard-package "ieee" "std_logic_1164"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4969
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4970 (defun vhdl-package-textio ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4971 "Insert specification of 'textio' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4972 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4973 (vhdl-standard-package "std" "textio"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4974
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4975 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4976 ;; Comment functions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4977
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4978 (defun vhdl-comment-indent ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4979 (let* ((opoint (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4980 (col (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4981 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4982 (if (re-search-forward "--" opoint t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4983 (- (current-column) 2) ;Existing comment at bol stays there.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4984 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4985 (skip-chars-backward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4986 (max comment-column ;else indent to comment column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4987 (1+ (current-column))) ;except leave at least one space.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4988 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4989 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4990 col
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4991 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4992
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4993 (defun vhdl-inline-comment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4994 "Start a comment at the end of the line.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4995 if on line with code, indent at least comment-column.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4996 if starting after end-comment-column, start a new line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4997 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4998 (if (> (current-column) end-comment-column) (newline-and-indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4999 (if (or (looking-at "\\s-*$") ;end of line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5000 (and (not unread-command-events) ; called with key binding or menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5001 (not (end-of-line))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5002 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5003 (while (= (preceding-char) ?-) (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5004 (setq margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5005 (delete-horizontal-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5006 (if (bolp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5007 (progn (indent-to margin) (insert "--"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5008 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5009 (indent-to comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5010 (insert "--"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5011 (if (not unread-command-events) (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5012 ; else code following current point implies commenting out code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5013 (let (next-input code)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5014 (while (= (preceding-char) ?-) (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5015 (while (= (setq next-input (read-char)) 13) ; CR
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5016 (insert "--"); or have a space after it?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5017 (forward-char -2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5018 (forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5019 (message "Enter CR if commenting out a line of code.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5020 (setq code t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5021 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5022 (if (not code) (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5023 ; (indent-to comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5024 (insert "--") ;hardwire to 1 space or use vhdl-basic-offset?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5025 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5026 (setq unread-command-events
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5027 (list (vhdl-character-to-event-hack next-input))) ;pushback the char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5028 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5029
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5030 (defun vhdl-display-comment (&optional line-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5031 "Add 2 comment lines at the current indent, making a display comment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5032 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5033 (if (not line-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5034 (vhdl-display-comment-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5035 (let* ((col (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5036 (len (- end-comment-column col)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5037 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5038 (insert-char ? col)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5039 (insert-char ?- len)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5040 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5041 (insert-char ? col)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5042 (end-of-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5043 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5044 (insert "-- ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5045 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5046
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5047 (defun vhdl-display-comment-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5048 "Displays one line of dashes."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5049 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5050 (while (= (preceding-char) ?-) (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5051 (let* ((col (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5052 (len (- end-comment-column col)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5053 (insert-char ?- len)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5054 (insert-char ?\n 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5055 (insert-char ? col)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5056 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5057
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5058 (defun vhdl-declaration-comment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5059 (if vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5060 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5061 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5062 (indent-to comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5063 (insert "-- ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5064 (if (equal (vhdl-field "comment") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5065 (progn (goto-char position) (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5066 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5067
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5068 (defun vhdl-block-comment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5069 (if vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5070 (let ((finalline (vhdl-current-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5071 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5072 (beginning-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5073 (if (re-search-backward "\\<\\(architecture\\|block\\|function\\|procedure\\|process\\)\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5074 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5075 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5076 (setq margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5077 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5078 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5079 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5080 (insert "-- purpose: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5081 (if (equal (vhdl-field "description") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5082 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5083 (setq finalline (+ finalline 1)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5084 (goto-line finalline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5085 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5086 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5087
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5088 (defun vhdl-comment-uncomment-region (beg end &optional arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5089 "Comment out region if not commented out, uncomment out region if already
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5090 commented out."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5091 (interactive "r\nP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5092 (goto-char beg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5093 (if (looking-at comment-start)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5094 (comment-region beg end -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5095 (comment-region beg end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5096 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5097
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5098 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5099 ;; Help functions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5100
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5101 (defun vhdl-outer-space (count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5102 "Expand abbreviations and self-insert space(s), do indent-new-comment-line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5103 if in comment and past end-comment-column."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5104 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5105 (if (or (and (>= (preceding-char) ?a) (<= (preceding-char) ?z))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5106 (and (>= (preceding-char) ?A) (<= (preceding-char) ?Z)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5107 (expand-abbrev))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5108 (if (not (vhdl-in-comment-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5109 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5110 (if (< (current-column) end-comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5111 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5112 (while (> (current-column) end-comment-column) (forward-word -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5113 (while (> (preceding-char) ? ) (forward-word -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5114 (delete-horizontal-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5115 (indent-new-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5116 (end-of-line nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5117 (insert-char ? count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5118 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5119
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5120 (defun vhdl-field (prompt &optional following-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5121 "Prompt for string and insert it in buffer with optional following-string."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5122 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5123 (insert "<" prompt ">")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5124 (let ((string (read-from-minibuffer (concat prompt ": ") ""
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5125 vhdl-minibuffer-local-map)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5126 (delete-region opoint (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5127 (insert string (or following-string ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5128 (if vhdl-upper-case-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5129 (vhdl-fix-case-region-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5130 opoint (point) t vhdl-93-keywords-regexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5131 string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5132 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5133
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5134 (defun vhdl-in-comment-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5135 "Check if point is to right of beginning comment delimiter."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5136 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5137 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5138 (save-excursion ; finds an unquoted comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5139 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5140 (re-search-forward "^\\([^\"]*\"[^\"]*\"\\)*[^\"]*--" opoint t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5141 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5142
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5143 (defun vhdl-in-string-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5144 "Check if point is in a string."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5145 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5146 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5147 (save-excursion ; preceeded by odd number of string delimiters?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5148 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5149 (equal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5150 opoint
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5151 (re-search-forward "^\\([^\"]*\"[^\"]*\"\\)*[^\"]*\"[^\"]*" opoint t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5152 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5153
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5154 (defun vhdl-begin-end (list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5155 "Insert a begin ... end pair with optional name after the end.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5156 Point is left between them."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5157 (let ((return)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5158 (name (car list))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5159 (margin (cdr list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5160 (if vhdl-additional-empty-lines
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5161 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5162 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5163 (indent-to (+ margin vhdl-basic-offset))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5164 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5165 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5166 (vhdl-insert-keyword "BEGIN")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5167 (if vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5168 (insert (and name (concat " -- " name))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5169 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5170 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5171 (setq return (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5172 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5173 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5174 (vhdl-insert-keyword "END")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5175 (insert (and name (concat " " name)) ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5176 (goto-char return)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5177 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5178
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5179 (defun vhdl-get-arg-list ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5180 "Read from user a procedure or function argument list."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5181 (insert " (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5182 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5183 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5184 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5185 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5186 (setq margin (+ (current-column) vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5187 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5188 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5189 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5190 (let (not-empty interface)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5191 (setq interface (vhdl-field "[CONSTANT] [SIGNAL] [VARIABLE]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5192 (if (not (equal interface ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5193 (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5194 (while (not (string-equal (vhdl-field "[names]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5195 (setq not-empty t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5196 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5197 (if (not (equal (vhdl-field "[direction]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5198 (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5199 (vhdl-field "type" ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5200 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5201 (setq interface (vhdl-field "[CONSTANT] [SIGNAL] [VARIABLE]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5202 (if (not (equal interface ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5203 (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5204 (if not-empty
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5205 (progn (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5206 (delete-char -2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5207 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5208 (progn (insert "\n") (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5209 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5210 (if vhdl-argument-list-indent
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5211 (backward-delete-char 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5212 (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5213 (backward-delete-char 3)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5214 ; (while (string-match "[,;]$" args)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5215 ; (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5216 ; (indent-to margin) (setq args (vhdl-field "next argument")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5217 ; (insert 41) ;close-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5218 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5219
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5220 (defun vhdl-get-port (optional &optional no-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5221 "Read from user a port spec argument list."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5222 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5223 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5224 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5225 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5226 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5227 (setq margin (+ (current-column) vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5228 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5229 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5230 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5231 (let ((vhdl-ports (vhdl-field "[names]")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5232 (if (string-equal vhdl-ports "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5233 (if optional
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5234 (progn (vhdl-kill-entire-line) (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5235 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5236 (progn (vhdl-kill-entire-line) (forward-line -1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5237 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5238 nil )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5239 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5240 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5241 (let ((semicolon-pos))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5242 (while (not (string-equal "" vhdl-ports))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5243 (vhdl-field "direction")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5244 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5245 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5246 (setq semicolon-pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5247 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5248 (if (not no-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5249 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5250 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5251 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5252 (setq vhdl-ports (vhdl-field "[names]" " : ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5253 (goto-char semicolon-pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5254 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5255 (progn (insert "\n") (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5256 (insert ")")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5257 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5258 (if (= (following-char) ? )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5259 (delete-char 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5260 (forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5261 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5262 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5263 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5264 t))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5265
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5266 (defun vhdl-get-generic (optional &optional no-value )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5267 "Read from user a generic spec argument list."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5268 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5269 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5270 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5271 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5272 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5273 (setq margin (+ (current-column) vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5274 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5275 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5276 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5277 (let ((vhdl-generic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5278 (if no-value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5279 (setq vhdl-generic (vhdl-field "[names]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5280 (setq vhdl-generic (vhdl-field "[name]")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5281 (if (string-equal vhdl-generic "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5282 (if optional
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5283 (progn (vhdl-kill-entire-line) (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5284 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5285 (progn (vhdl-kill-entire-line) (end-of-line -0))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5286 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5287 nil )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5288 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5289 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5290 (let ((semicolon-pos))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5291 (while (not(string-equal "" vhdl-generic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5292 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5293 (if no-value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5294 (progn (setq semicolon-pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5295 (insert ";"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5296 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5297 (if (equal (vhdl-field "[value]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5298 (delete-char -4))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5299 (setq semicolon-pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5300 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5301 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5302 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5303 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5304 (if no-value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5305 (setq vhdl-generic (vhdl-field "[names]" " : "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5306 (setq vhdl-generic (vhdl-field "[name]" " : "))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5307 (goto-char semicolon-pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5308 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5309 (progn (insert "\n") (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5310 (insert ")")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5311 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5312 (if (= (following-char) ? )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5313 (delete-char 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5314 (forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5315 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5316 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5317 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5318 t))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5319
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5320 (defun vhdl-insert-date ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5321 "Insert date in appropriate format."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5322 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5323 (insert
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5324 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5325 ((eq vhdl-date-format 'american) (format-time-string "%m/%d/%Y" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5326 ((eq vhdl-date-format 'european) (format-time-string "%d.%m.%Y" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5327 ((eq vhdl-date-format 'scientific) (format-time-string "%Y/%m/%d" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5328 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5329
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5330 (defun vhdl-insert-keyword (keyword)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5331 (insert (if vhdl-upper-case-keywords (upcase keyword) (downcase keyword)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5332 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5333
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5334 (defun vhdl-case-keyword (keyword)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5335 (if vhdl-upper-case-keywords (upcase keyword) (downcase keyword))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5336 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5337
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5338 (defun vhdl-case-word (num)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5339 (if vhdl-upper-case-keywords (upcase-word num) (downcase-word num))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5340 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5341
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5342 (defun vhdl-fix-case-region-1 (beg end upper-case word-regexp &optional count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5343 "Convert all words matching word-regexp in region to lower or upper case,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5344 depending on parameter upper-case."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5345 (let ((case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5346 (case-replace nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5347 (busy-counter 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5348 (modify-syntax-entry ?_ "w" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5349 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5350 (goto-char beg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5351 (while (re-search-forward word-regexp end t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5352 (or (vhdl-in-comment-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5353 (vhdl-in-string-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5354 (if upper-case
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5355 (upcase-word -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5356 (downcase-word -1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5357 (if (and count
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5358 (/= busy-counter (setq busy-counter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5359 (+ (* count 25) (/ (* 25 (- (point) beg)) (- end beg))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5360 (message (format "Fixing case ... (%2d%s)" busy-counter "%%"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5361 (goto-char end))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5362 (if (not vhdl-underscore-is-part-of-word)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5363 (modify-syntax-entry ?_ "_" vhdl-mode-syntax-table))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5364 (message "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5365 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5366
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5367 (defun vhdl-fix-case-region (beg end &optional arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5368 "Convert all VHDL words in region to lower or upper case, depending on
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5369 variables vhdl-upper-case-{keywords,types,attributes,enum-values}."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5370 (interactive "r\nP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5371 (vhdl-fix-case-region-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5372 beg end vhdl-upper-case-keywords vhdl-93-keywords-regexp 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5373 (vhdl-fix-case-region-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5374 beg end vhdl-upper-case-types vhdl-93-types-regexp 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5375 (vhdl-fix-case-region-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5376 beg end vhdl-upper-case-attributes vhdl-93-attributes-regexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5377 (vhdl-fix-case-region-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5378 beg end vhdl-upper-case-enum-values vhdl-93-enum-values-regexp 3)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5379 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5380
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5381 (defun vhdl-fix-case-buffer ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5382 "Convert all VHDL words in buffer to lower or upper case, depending on
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5383 variables vhdl-upper-case-{keywords,types,attributes,enum-values}."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5384 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5385 (vhdl-fix-case-region (point-min) (point-max))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5386 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5387
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5388 (defun vhdl-minibuffer-tab (&optional prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5389 "If preceeding character is part of a word then dabbrev-expand,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5390 else if right of non whitespace on line then tab-to-tab-stop,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5391 else indent line in proper way for current major mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5392 (used for word completion in VHDL minibuffer)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5393 (interactive "P")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5394 (cond ((= (char-syntax (preceding-char)) ?w)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5395 (let ((case-fold-search nil)) (dabbrev-expand prefix-arg)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5396 ((> (current-column) (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5397 (tab-to-tab-stop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5398 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5399 (if (eq indent-line-function 'indent-to-left-margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5400 (insert-tab prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5401 (if prefix-arg
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5402 (funcall indent-line-function prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5403 (funcall indent-line-function))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5404
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5405 (defun vhdl-help ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5406 "Display help information in '*Help*' buffer ."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5407 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5408 (with-output-to-temp-buffer "*Help*"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5409 (princ mode-name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5410 (princ " mode:\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5411 (princ (documentation major-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5412 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5413 (set-buffer standard-output)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5414 (help-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5415 (print-help-return-message)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5416
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5417 (defun vhdl-current-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5418 "Return the line number of the line containing point."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5419 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5420 (widen)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5421 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5422 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5423 (1+ (count-lines 1 (point)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5424 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5425
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5426 (defun vhdl-kill-entire-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5427 "Delete entire line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5428 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5429 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5430 (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5431 (delete-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5432 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5433
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5434 (defun vhdl-open-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5435 "Open a new line and indent."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5436 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5437 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5438 (newline-and-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5439 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5440
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5441 (defun vhdl-kill-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5442 "Kill current line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5443 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5444 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5445 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5446
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5447 (defun vhdl-character-to-event-hack (char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5448 (if (memq 'XEmacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5449 (character-to-event char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5450 char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5451
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5452 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5453 ;; Abbrev hooks
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5454
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5455 (defun vhdl-electric-mode ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5456 "Toggle VHDL Electric mode."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5457 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5458 (setq vhdl-electric-mode (not vhdl-electric-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5459 (setq mode-name (if vhdl-electric-mode "Electric VHDL" "VHDL"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5460 (force-mode-line-update)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5461 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5462
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5463 (defun vhdl-stutter-mode ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5464 "Toggle VHDL Stuttering mode."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5465 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5466 (setq vhdl-stutter-mode (not vhdl-stutter-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5467 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5468
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5469 (defun vhdl-hooked-abbrev (fun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5470 "Do function, if syntax says abbrev is a keyword, invoked by hooked abbrev,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5471 but not if inside a comment or quote)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5472 (if (or (vhdl-in-comment-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5473 (vhdl-in-string-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5474 (save-excursion (forward-word -1) (looking-at "end")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5475 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5476 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5477 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5478 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5479 (if (not vhdl-electric-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5480 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5481 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5482 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5483 (backward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5484 (vhdl-case-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5485 (delete-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5486 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5487 (let ((invoke-char last-command-char) (abbrev-mode -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5488 (funcall fun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5489 (if (= invoke-char ?-) (setq abbrev-start-location (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5490 ;; delete CR which is still in event queue
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5491 (if (memq 'XEmacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5492 (enqueue-eval-event 'delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5493 (setq unread-command-events ; push back a delete char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5494 (list (vhdl-character-to-event-hack ?\177))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5495 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5496
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5497 (defun vhdl-alias-hook () "hooked version of vhdl-alias."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5498 (vhdl-hooked-abbrev 'vhdl-alias))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5499 (defun vhdl-architecture-hook () "hooked version of vhdl-architecture."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5500 (vhdl-hooked-abbrev 'vhdl-architecture))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5501 (defun vhdl-array-hook () "hooked version of vhdl-array."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5502 (vhdl-hooked-abbrev 'vhdl-array))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5503 (defun vhdl-assert-hook () "hooked version of vhdl-assert."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5504 (vhdl-hooked-abbrev 'vhdl-assert))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5505 (defun vhdl-attribute-hook () "hooked version of vhdl-attribute."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5506 (vhdl-hooked-abbrev 'vhdl-attribute))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5507 (defun vhdl-block-hook () "hooked version of vhdl-block."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5508 (vhdl-hooked-abbrev 'vhdl-block))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5509 (defun vhdl-case-hook () "hooked version of vhdl-case."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5510 (vhdl-hooked-abbrev 'vhdl-case))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5511 (defun vhdl-component-hook () "hooked version of vhdl-component."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5512 (vhdl-hooked-abbrev 'vhdl-component))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5513 (defun vhdl-component-instance-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5514 "hooked version of vhdl-component-instance."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5515 (vhdl-hooked-abbrev 'vhdl-component-instance))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5516 (defun vhdl-concurrent-signal-assignment-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5517 "hooked version of vhdl-concurrent-signal-assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5518 (vhdl-hooked-abbrev 'vhdl-concurrent-signal-assignment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5519 (defun vhdl-configuration-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5520 "hooked version of vhdl-configuration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5521 (vhdl-hooked-abbrev 'vhdl-configuration))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5522 (defun vhdl-constant-hook () "hooked version of vhdl-constant."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5523 (vhdl-hooked-abbrev 'vhdl-constant))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5524 (defun vhdl-disconnect-hook () "hooked version of vhdl-disconnect."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5525 (vhdl-hooked-abbrev 'vhdl-disconnect))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5526 (defun vhdl-display-comment-hook () "hooked version of vhdl-display-comment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5527 (vhdl-hooked-abbrev 'vhdl-display-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5528 (defun vhdl-else-hook () "hooked version of vhdl-else."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5529 (vhdl-hooked-abbrev 'vhdl-else))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5530 (defun vhdl-elsif-hook () "hooked version of vhdl-elsif."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5531 (vhdl-hooked-abbrev 'vhdl-elsif))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5532 (defun vhdl-entity-hook () "hooked version of vhdl-entity."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5533 (vhdl-hooked-abbrev 'vhdl-entity))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5534 (defun vhdl-exit-hook () "hooked version of vhdl-exit."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5535 (vhdl-hooked-abbrev 'vhdl-exit))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5536 (defun vhdl-for-hook () "hooked version of vhdl-for."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5537 (vhdl-hooked-abbrev 'vhdl-for))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5538 (defun vhdl-function-hook () "hooked version of vhdl-function."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5539 (vhdl-hooked-abbrev 'vhdl-function))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5540 (defun vhdl-generate-hook () "hooked version of vhdl-generate."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5541 (vhdl-hooked-abbrev 'vhdl-generate))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5542 (defun vhdl-generic-hook () "hooked version of vhdl-generic."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5543 (vhdl-hooked-abbrev 'vhdl-generic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5544 (defun vhdl-library-hook () "hooked version of vhdl-library."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5545 (vhdl-hooked-abbrev 'vhdl-library))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5546 (defun vhdl-header-hook () "hooked version of vhdl-header."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5547 (vhdl-hooked-abbrev 'vhdl-header))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5548 (defun vhdl-if-hook () "hooked version of vhdl-if."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5549 (vhdl-hooked-abbrev 'vhdl-if))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5550 (defun vhdl-loop-hook () "hooked version of vhdl-loop."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5551 (vhdl-hooked-abbrev 'vhdl-loop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5552 (defun vhdl-map-hook () "hooked version of vhdl-map."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5553 (vhdl-hooked-abbrev 'vhdl-map))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5554 (defun vhdl-modify-hook () "hooked version of vhdl-modify."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5555 (vhdl-hooked-abbrev 'vhdl-modify))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5556 (defun vhdl-next-hook () "hooked version of vhdl-next."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5557 (vhdl-hooked-abbrev 'vhdl-next))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5558 (defun vhdl-package-hook () "hooked version of vhdl-package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5559 (vhdl-hooked-abbrev 'vhdl-package))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5560 (defun vhdl-port-hook () "hooked version of vhdl-port."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5561 (vhdl-hooked-abbrev 'vhdl-port))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5562 (defun vhdl-procedure-hook () "hooked version of vhdl-procedure."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5563 (vhdl-hooked-abbrev 'vhdl-procedure))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5564 (defun vhdl-process-hook () "hooked version of vhdl-process."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5565 (vhdl-hooked-abbrev 'vhdl-process))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5566 (defun vhdl-record-hook () "hooked version of vhdl-record."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5567 (vhdl-hooked-abbrev 'vhdl-record))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5568 (defun vhdl-return-hook () "hooked version of vhdl-return-value."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5569 (vhdl-hooked-abbrev 'vhdl-return-value))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5570 (defun vhdl-selected-signal-assignment-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5571 "hooked version of vhdl-selected-signal-assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5572 (vhdl-hooked-abbrev 'vhdl-selected-signal-assignment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5573 (defun vhdl-signal-hook () "hooked version of vhdl-signal."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5574 (vhdl-hooked-abbrev 'vhdl-signal))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5575 (defun vhdl-subtype-hook () "hooked version of vhdl-subtype."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5576 (vhdl-hooked-abbrev 'vhdl-subtype))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5577 (defun vhdl-type-hook () "hooked version of vhdl-type."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5578 (vhdl-hooked-abbrev 'vhdl-type))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5579 (defun vhdl-use-hook () "hooked version of vhdl-use."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5580 (vhdl-hooked-abbrev 'vhdl-use))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5581 (defun vhdl-variable-hook () "hooked version of vhdl-variable."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5582 (vhdl-hooked-abbrev 'vhdl-variable))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5583 (defun vhdl-wait-hook () "hooked version of vhdl-wait."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5584 (vhdl-hooked-abbrev 'vhdl-wait))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5585 (defun vhdl-when-hook () "hooked version of vhdl-when."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5586 (vhdl-hooked-abbrev 'vhdl-when))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5587 (defun vhdl-while-loop-hook () "hooked version of vhdl-while-loop."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5588 (vhdl-hooked-abbrev 'vhdl-while-loop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5589 (defun vhdl-and-hook () "hooked version of vhdl-and."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5590 (vhdl-hooked-abbrev 'vhdl-and))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5591 (defun vhdl-or-hook () "hooked version of vhdl-or."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5592 (vhdl-hooked-abbrev 'vhdl-or))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5593 (defun vhdl-nand-hook () "hooked version of vhdl-nand."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5594 (vhdl-hooked-abbrev 'vhdl-nand))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5595 (defun vhdl-nor-hook () "hooked version of vhdl-nor."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5596 (vhdl-hooked-abbrev 'vhdl-nor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5597 (defun vhdl-xor-hook () "hooked version of vhdl-xor."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5598 (vhdl-hooked-abbrev 'vhdl-xor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5599 (defun vhdl-xnor-hook () "hooked version of vhdl-xnor."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5600 (vhdl-hooked-abbrev 'vhdl-xnor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5601 (defun vhdl-not-hook () "hooked version of vhdl-not."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5602 (vhdl-hooked-abbrev 'vhdl-not))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5603
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5604 (defun vhdl-default-hook () "hooked version of vhdl-default."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5605 (vhdl-hooked-abbrev 'vhdl-default))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5606 (defun vhdl-default-indent-hook () "hooked version of vhdl-default-indent."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5607 (vhdl-hooked-abbrev 'vhdl-default-indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5608
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5609
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5610 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5611 ;; Font locking
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5612 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5613 ;; (using `font-lock.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5614
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5615 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5616 ;; Syntax definitions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5617
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5618 (defvar vhdl-font-lock-keywords nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5619 "Regular expressions to highlight in VHDL Mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5620
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5621 (defconst vhdl-font-lock-keywords-0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5622 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5623 ;; highlight template prompts
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5624 '("\\(^\\|[ (.\t]\\)\\(<[^ =].*[^ =]>\\)\\([ .]\\|$\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5625 2 vhdl-font-lock-prompt-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5626
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5627 ;; highlight character literals
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5628 '("'\\(.\\)'" 1 'font-lock-string-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5629 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5630 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5631 This does highlighting of template prompts and character literals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5632
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5633 (defconst vhdl-font-lock-keywords-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5634 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5635 ;; highlight names of units, subprograms, and components when declared
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5636 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5637 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5638 "^\\s-*\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5639 "architecture\\|configuration\\|entity\\|package\\(\\s-+body\\|\\)\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5640 "function\\|procedure\\|component"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5641 "\\)\\s-+\\(\\w+\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5642 3 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5643
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5644 ;; highlight labels of common constructs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5645 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5646 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5647 "^\\s-*\\(\\w+\\)\\s-*:\\(\\s-\\|\n\\)*\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5648 "assert\\|block\\|case\\|exit\\|for\\|if\\|loop\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5649 "next\\|null\\|process\\| with\\|while\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5650 "\\w+\\(\\s-\\|\n\\)+\\(generic\\|port\\)\\s-+map"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5651 "\\)\\>")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5652 1 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5653
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5654 ;; highlight entity names of architectures and configurations
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5655 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5656 "^\\s-*\\(architecture\\|configuration\\)\\s-+\\w+\\s-+of\\s-+\\(\\w+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5657 2 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5658
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5659 ;; highlight names and labels at end of constructs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5660 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5661 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5662 "^\\s-*end\\s-+\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5663 "\\(block\\|case\\|component\\|for\\|generate\\|if\\|loop\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5664 "process\\|record\\|units\\)\\>\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5665 "\\)\\s-*\\(\\w*\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5666 3 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5667 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5668 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5669 This does highlighting of names and labels.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5670
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5671 (defconst vhdl-font-lock-keywords-2
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5672 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5673 ;; highlight keywords, and types, standardized attributes, enumeration values
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5674 (list (concat "'" vhdl-93-attributes-regexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5675 1 'vhdl-font-lock-attribute-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5676 (list vhdl-93-types-regexp 1 'font-lock-type-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5677 (list vhdl-93-enum-values-regexp 1 'vhdl-font-lock-value-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5678 (list vhdl-93-keywords-regexp 1 'font-lock-keyword-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5679 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5680 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5681 This does highlighting of comments, keywords, and standard types.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5682
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5683 (defconst vhdl-font-lock-keywords-3
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5684 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5685 ;; highlight clock signals.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5686 (cons vhdl-clock-signal-syntax 'vhdl-font-lock-clock-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5687 (cons vhdl-reset-signal-syntax 'vhdl-font-lock-reset-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5688 (cons vhdl-control-signal-syntax 'vhdl-font-lock-control-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5689 (cons vhdl-data-signal-syntax 'vhdl-font-lock-data-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5690 (cons vhdl-test-signal-syntax 'vhdl-font-lock-test-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5691 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5692 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5693 This does highlighting of signal names with specific syntax.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5694
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5695 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5696 ;; Font and color definitions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5697
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5698 (defvar vhdl-font-lock-prompt-face 'vhdl-font-lock-prompt-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5699 "Face name to use for prompts.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5700
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5701 (defvar vhdl-font-lock-attribute-face 'vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5702 "Face name to use for attributes.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5703
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5704 (defvar vhdl-font-lock-value-face 'vhdl-font-lock-value-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5705 "Face name to use for enumeration values.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5706
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5707 (defvar vhdl-font-lock-clock-signal-face 'vhdl-font-lock-clock-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5708 "Face name to use for clock signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5709
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5710 (defvar vhdl-font-lock-reset-signal-face 'vhdl-font-lock-reset-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5711 "Face name to use for reset signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5712
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5713 (defvar vhdl-font-lock-control-signal-face 'vhdl-font-lock-control-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5714 "Face name to use for control signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5715
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5716 (defvar vhdl-font-lock-data-signal-face 'vhdl-font-lock-data-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5717 "Face name to use for data signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5718
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5719 (defvar vhdl-font-lock-test-signal-face 'vhdl-font-lock-test-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5720 "Face name to use for test signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5721
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5722 (defface vhdl-font-lock-prompt-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5723 '((((class color) (background light)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5724 (((class color) (background dark)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5725 (t (:inverse-video t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5726 "Font Lock mode face used to highlight prompts."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5727 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5728
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5729 (defface vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5730 '((((class color) (background light)) (:foreground "CadetBlue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5731 (((class color) (background dark)) (:foreground "CadetBlue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5732 (t (:italic t :bold t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5733 "Font Lock mode face used to highlight attributes."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5734 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5735
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5736 (defface vhdl-font-lock-value-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5737 '((((class color) (background light)) (:foreground "DarkGoldenrod"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5738 (((class color) (background dark)) (:foreground "DarkGoldenrod"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5739 (t (:italic t :bold t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5740 "Font Lock mode face used to highlight enumeration values."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5741 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5742
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5743 (defface vhdl-font-lock-clock-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5744 '((((class color) (background light)) (:foreground "LimeGreen"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5745 (((class color) (background dark)) (:foreground "LimeGreen"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5746 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5747 "Font Lock mode face used to highlight clock signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5748 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5749
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5750 (defface vhdl-font-lock-reset-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5751 '((((class color) (background light)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5752 (((class color) (background dark)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5753 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5754 "Font Lock mode face used to highlight reset signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5755 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5756
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5757 (defface vhdl-font-lock-control-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5758 '((((class color) (background light)) (:foreground "Blue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5759 (((class color) (background dark)) (:foreground "Blue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5760 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5761 "Font Lock mode face used to highlight control signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5762 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5763
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5764 (defface vhdl-font-lock-data-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5765 '((((class color) (background light)) (:foreground "Black"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5766 (((class color) (background dark)) (:foreground "Black"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5767 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5768 "Font Lock mode face used to highlight data signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5769 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5770
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5771 (defface vhdl-font-lock-test-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5772 '((((class color) (background light)) (:foreground "Gold"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5773 (((class color) (background dark)) (:foreground "Gold"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5774 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5775 "Font Lock mode face used to highlight test signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5776 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5777
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5778 ;; Custom color definitions for existing faces
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5779 (defun vhdl-set-face-foreground ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5780 (set-face-foreground 'font-lock-comment-face "IndianRed")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5781 (set-face-foreground 'font-lock-function-name-face "MediumOrchid")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5782 (set-face-foreground 'font-lock-keyword-face "SlateBlue")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5783 (set-face-foreground 'font-lock-string-face "RosyBrown")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5784 (set-face-foreground 'font-lock-type-face "ForestGreen")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5785 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5786
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5787 (defun vhdl-set-face-grayscale ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5788 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5789 (set-face-bold-p 'font-lock-comment-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5790 (set-face-inverse-video-p 'font-lock-comment-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5791 (set-face-italic-p 'font-lock-comment-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5792 (set-face-underline-p 'font-lock-comment-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5793
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5794 (set-face-bold-p 'font-lock-function-name-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5795 (set-face-inverse-video-p 'font-lock-function-name-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5796 (set-face-italic-p 'font-lock-function-name-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5797 (set-face-underline-p 'font-lock-function-name-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5798
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5799 (set-face-bold-p 'font-lock-keyword-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5800 (set-face-inverse-video-p 'font-lock-keyword-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5801 (set-face-italic-p 'font-lock-keyword-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5802 (set-face-underline-p 'font-lock-keyword-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5803
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5804 (set-face-bold-p 'font-lock-string-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5805 (set-face-inverse-video-p 'font-lock-string-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5806 (set-face-italic-p 'font-lock-string-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5807 (set-face-underline-p 'font-lock-string-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5808
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5809 (set-face-bold-p 'font-lock-type-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5810 (set-face-inverse-video-p 'font-lock-type-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5811 (set-face-italic-p 'font-lock-type-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5812 (set-face-underline-p 'font-lock-type-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5813 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5814
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5815 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5816 ;; Font lock initialization
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5817
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5818 (defun vhdl-font-lock-init ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5819 "Initializes fontification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5820 (setq vhdl-font-lock-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5821 (append vhdl-font-lock-keywords-0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5822 (if vhdl-highlight-names vhdl-font-lock-keywords-1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5823 (if vhdl-highlight-keywords vhdl-font-lock-keywords-2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5824 (if (and vhdl-highlight-signals (x-display-color-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5825 vhdl-font-lock-keywords-3)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5826 (if (x-display-color-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5827 (if (not vhdl-use-default-colors) (vhdl-set-face-foreground))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5828 (if (not vhdl-use-default-faces) (vhdl-set-face-grayscale))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5829 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5830
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5831 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5832 ;; Fontification for postscript printing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5833
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5834 (defun vhdl-ps-init ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5835 "Initializes face and page settings for postscript printing."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5836 (require 'ps-print)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5837 (unless (or vhdl-use-default-faces
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5838 ps-print-color-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5839 (set (make-local-variable 'ps-bold-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5840 '(font-lock-keyword-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5841 font-lock-type-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5842 vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5843 vhdl-font-lock-value-face))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5844 (set (make-local-variable 'ps-italic-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5845 '(font-lock-comment-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5846 font-lock-function-name-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5847 font-lock-type-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5848 vhdl-font-lock-prompt-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5849 vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5850 vhdl-font-lock-value-face))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5851 (set (make-local-variable 'ps-underlined-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5852 '(font-lock-string-face))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5853 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5854 ;; define page settings, so that a line containing 79 characters (default)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5855 ;; fits into one column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5856 (if vhdl-print-two-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5857 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5858 (set (make-local-variable 'ps-landscape-mode) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5859 (set (make-local-variable 'ps-number-of-columns) 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5860 (set (make-local-variable 'ps-font-size) 7.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5861 (set (make-local-variable 'ps-header-title-font-size) 10.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5862 (set (make-local-variable 'ps-header-font-size) 9.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5863 (set (make-local-variable 'ps-header-offset) 12.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5864 (if (eq ps-paper-type 'letter)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5865 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5866 (set (make-local-variable 'ps-inter-column) 40.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5867 (set (make-local-variable 'ps-left-margin) 40.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5868 (set (make-local-variable 'ps-right-margin) 40.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5869 )))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5870
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5871
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5872 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5873 ;; Hideshow
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5874 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5875 ;; (using `hideshow.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5876
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5877 (defun vhdl-forward-sexp-function (&optional count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5878 "Find begin and end of VHDL process or block (for hideshow)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5879 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5880 (let (name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5881 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5882 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5883 (if (< count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5884 (re-search-backward "\\s-*\\(\\w\\|\\s_\\)+\\s-*:\\s-*\\(process\\|block\\)\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5885 (re-search-forward "\\s-*\\<end\\s-+\\(process\\|block\\)\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5886 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5887
21653
e95a88dc6110 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21651
diff changeset
5888 ;; Not needed `hs-special-modes-alist' is autoloaded.
e95a88dc6110 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21651
diff changeset
5889 ;(require 'hideshow)
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5890
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5891 (unless (assq 'vhdl-mode hs-special-modes-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5892 (setq hs-special-modes-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5893 (cons
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5894 '(vhdl-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5895 "\\s-*\\(\\w\\|\\s_\\)+\\s-*:\\s-*\\(process\\|PROCESS\\|block\\|BLOCK\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5896 "\\s-*\\<\\(end\\|END\\)\\s-+\\(process\\|PROCESS\\|block\\|BLOCK\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5897 "-- "
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5898 vhdl-forward-sexp-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5899 hs-special-modes-alist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5900
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5901
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5902 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5903 ;; Compilation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5904 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5905 ;; (using `compile.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5906
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5907 (defvar vhdl-compile-commands
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5908 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5909 (cadence "cv -file" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5910 (ikos "analyze" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5911 (quickhdl "qvhcom" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5912 (synopsys "vhdlan" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5913 (vantage "analyze -libfile vsslib.ini -src" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5914 (viewlogic "analyze -libfile vsslib.ini -src" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5915 (v-system "vcom" "vmake > Makefile")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5916 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5917 "Commands to be called in the shell for compilation (syntax analysis) of a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5918 single buffer and `Makefile' generation for different tools. First item is tool
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5919 identifier, second item is shell command for compilation, and third item is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5920 shell command for `Makefile' generation. A tool is specified by assigning a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5921 tool identifier to variable `vhdl-compiler'.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5922
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5923 (defvar vhdl-compilation-error-regexp-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5924 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5925 ;; Cadence Design Systems: cv -file test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5926 ;; duluth: *E,430 (test.vhd,13): identifier (POSITIV) is not declared
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5927 '("duluth: \\*E,[0-9]+ (\\(.+\\),\\([0-9]+\\)):" 1 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5928
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5929 ;; Ikos Voyager: analyze test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5930 ;; E L4/C5: this library unit is inaccessible
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5931 ; Xemacs does not support error messages without included file name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5932 (if (not (memq 'XEmacs vhdl-emacs-features))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5933 '("E L\\([0-9]+\\)/C[0-9]+:" nil 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5934 '("E L\\([0-9]+\\)/C[0-9]+:" 2 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5935 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5936
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5937 ;; QuickHDL, Mentor Graphics: qvhcom test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5938 ;; ERROR: test.vhd(24): near "dnd": expecting: END
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5939 '("ERROR: \\(.+\\)(\\([0-9]+\\)):" 1 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5940
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5941 ;; Synopsys, VHDL Analyzer: vhdlan test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5942 ;; **Error: vhdlan,703 test.vhd(22): OTHERS is not legal in this context.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5943 '("\\*\\*Error: vhdlan,[0-9]+ \\(.+\\)(\\([0-9]+\\)):" 1 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5944
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5945 ;; Vantage Analysis Systems: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5946 ;; **Error: LINE 499 *** No aggregate value is valid in this context.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5947 ; Xemacs does not support error messages without included file name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5948 (if (not (memq 'XEmacs vhdl-emacs-features))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5949 '("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" nil 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5950 '("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" 2 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5951 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5952
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5953 ;; Viewlogic: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5954 ;; **Error: LINE 499 *** No aggregate value is valid in this context.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5955 ;; same regexp as for Vantage
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5956
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5957 ;; V-System, Model Technology: vcom test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5958 ;; ERROR: test.vhd(14): Unknown identifier: positiv
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5959 ;; same regexp as for QuickHDL
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5960
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5961 ) "Alist that specifies how to match errors in VHDL compiler output.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5962
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5963 (defvar compilation-file-regexp-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5964 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5965 ;; Ikos Voyager: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5966 ;; analyze sdrctl.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5967 ("^analyze +\\(.+ +\\)*\\(.+\\)$" 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5968
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5969 ;; Vantage Analysis Systems: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5970 ;; Compiling "pcu.vhd" line 1...
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5971 (" *Compiling \"\\(.+\\)\" " 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5972
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5973 ;; Viewlogic: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5974 ;; Compiling "pcu.vhd" line 1...
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5975 ;; same regexp as for Vantage
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5976
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5977 ) "Alist specifying how to match lines that indicate a new current file.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5978 Used for compilers with no file name in the error messages.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5979
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5980 (defun vhdl-compile ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5981 "Compile current buffer using the VHDL compiler specified in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5982 `vhdl-compiler'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5983 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5984 (let ((command-list vhdl-compile-commands)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5985 command)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5986 (while command-list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5987 (if (eq vhdl-compiler (car (car command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5988 (setq command (car (cdr (car command-list)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5989 (setq command-list (cdr command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5990 (if command
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5991 (compile (concat command " " vhdl-compiler-options
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5992 (if (not (string-equal vhdl-compiler-options "")) " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5993 (file-name-nondirectory (buffer-file-name)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5994
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5995 (defun vhdl-make ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5996 "Call make command for compilation of all updated source files
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5997 (requires `Makefile')."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5998 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5999 (compile "make"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6000
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6001 (defun vhdl-generate-makefile ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6002 "Generate new `Makefile'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6003 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6004 (let ((command-list vhdl-compile-commands)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6005 command)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6006 (while command-list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6007 (if (eq vhdl-compiler (car (car command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6008 (setq command (car (cdr (cdr (car command-list))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6009 (setq command-list (cdr command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6010 (if command
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6011 (compile command )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6012 (message (format "Not implemented for `%s'!" vhdl-compiler))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6013 (beep))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6014
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6015
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6016 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6017 ;; Bug reports
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6018 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6019 ;; (using `reporter.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6020
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6021 (defconst vhdl-version "3.19"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6022 "VHDL Mode version number.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6023
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6024 (defconst vhdl-mode-help-address "vhdl-mode@geocities.com"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6025 "Address for VHDL Mode bug reports.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6026
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6027 (defun vhdl-version ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6028 "Echo the current version of VHDL Mode in the minibuffer."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6029 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6030 (message "Using VHDL Mode version %s" vhdl-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6031 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6032
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6033 ;; get reporter-submit-bug-report when byte-compiling
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6034 (and (fboundp 'eval-when-compile)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6035 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6036 (require 'reporter)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6037
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6038 (defun vhdl-submit-bug-report ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6039 "Submit via mail a bug report on VHDL Mode."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6040 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6041 ;; load in reporter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6042 (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6043 (y-or-n-p "Do you want to submit a report on VHDL Mode? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6044 (require 'reporter)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6045 (reporter-submit-bug-report
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6046 vhdl-mode-help-address
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6047 (concat "VHDL Mode " vhdl-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6048 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6049 ;; report all important variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6050 'vhdl-basic-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6051 'vhdl-offsets-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6052 'vhdl-comment-only-line-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6053 'tab-width
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6054 'vhdl-electric-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6055 'vhdl-stutter-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6056 'vhdl-indent-tabs-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6057 'vhdl-compiler
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6058 'vhdl-compiler-options
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6059 'vhdl-upper-case-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6060 'vhdl-upper-case-types
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6061 'vhdl-upper-case-attributes
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6062 'vhdl-upper-case-enum-values
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6063 'vhdl-auto-align
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6064 'vhdl-additional-empty-lines
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6065 'vhdl-argument-list-indent
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6066 'vhdl-conditions-in-parenthesis
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6067 'vhdl-date-format
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6068 'vhdl-header-file
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6069 'vhdl-modify-date-prefix-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6070 'vhdl-zero-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6071 'vhdl-one-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6072 'vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6073 'vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6074 'vhdl-comment-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6075 'vhdl-end-comment-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6076 'vhdl-highlight-names
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6077 'vhdl-highlight-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6078 'vhdl-highlight-signals
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6079 'vhdl-highlight-case-sensitive
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6080 'vhdl-use-default-colors
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6081 'vhdl-use-default-faces
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6082 'vhdl-clock-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6083 'vhdl-reset-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6084 'vhdl-control-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6085 'vhdl-data-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6086 'vhdl-test-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6087 'vhdl-source-file-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6088 'vhdl-index-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6089 'vhdl-hideshow-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6090 'vhdl-print-two-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6091 'vhdl-intelligent-tab
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6092 'vhdl-template-key-binding-prefix
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6093 'vhdl-word-completion-in-minibuffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6094 'vhdl-underscore-is-part-of-word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6095 'vhdl-mode-hook
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6096 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6097 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6098 (lambda ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6099 (insert
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6100 (if vhdl-special-indent-hook
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6101 (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6102 "vhdl-special-indent-hook is set to '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6103 (format "%s" vhdl-special-indent-hook)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6104 ".\nPerhaps this is your problem?\n"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6105 "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6106 "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6107 (format "vhdl-emacs-features: %s\n" vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6108 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6109 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6110 "Dear VHDL Mode maintainers,"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6111 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6112
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6113
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6114 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6115
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6116 (provide 'vhdl-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6117
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6118 ;;; vhdl-mode.el ends here