annotate lisp/progmodes/vhdl-mode.el @ 22853:62d2fb895f5f

(concat): Fix previous change.
author Kenichi Handa <handa@m17n.org>
date Thu, 30 Jul 1998 01:35:40 +0000
parents e03f87c938ca
children 7e4879a1cb2d
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
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
51 ;; - Works under Emacs and XEmacs
20665
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
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
336 (defcustom vhdl-customize-colors nil
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
337 "*If non-nil, colors are customized to go with the additional signal colors.
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
338 NOTE: this alters the behavior of Emacs for *all* modes,
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
339 so it is not enabled by default."
20665
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
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
343 (defcustom vhdl-customize-faces t
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
344 "*If non-nil, faces are customized to work better with VHDL Mode.
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
345 This variable comes only into effect if no colors are used
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
346 for highlighting or printing (i.e. variable `ps-print-color-p' is nil).
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
347
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
348 NOTE: this alters the behavior of Emacs for *all* modes,
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
349 so it is not enabled by default."
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 (defgroup vhdl-signal-syntax nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 "Customizations of signal syntax for highlighting."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 :group 'vhdl-highlight)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 (defcustom vhdl-signal-syntax-doc-string "
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 Must be of the form \"\\ \<\\\(...\\\)\\\>\", where ... specifies the actual syntax.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
360 (delete this space ^ , it's only a workaround to get this doc string.)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 The basic regexp elements are:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 [A-Z] any upper case letter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 [A-Za-z] any letter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 [0-9] any digit
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 \\w any letter or digit (corresponds to [A-Za-z0-9])
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 [XY] letter \"X\" or \"Y\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 [^XY] neither letter \"X\" nor \"Y\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 x letter \"x\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 * postfix operator for matching previous regexp element any times
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 + postfix operator for matching previous regexp element at least once
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 ? postfix operator for matching previous regexp element at most once"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 "Common document string used for the custom variables below. Must be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 defined as custom variable due to a bug in XEmacs.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 (defcustom vhdl-clock-signal-syntax "\\<\\([A-Z]\\w*xC\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 "*Regular expression (regexp) for syntax of clock signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 (defcustom vhdl-reset-signal-syntax "\\<\\([A-Z]\\w*xR\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384 "*Regular expression (regexp) for syntax of (asynchronous) reset signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 (defcustom vhdl-control-signal-syntax "\\<\\([A-Z]\\w*x[IS]\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 "*Regular expression (regexp) for syntax of status/control signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 (defcustom vhdl-data-signal-syntax "\\<\\([A-Z]\\w*xD\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 "*Regular expression (regexp) for syntax of data signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 (defcustom vhdl-test-signal-syntax "\\<\\([A-Z]\\w*xT\\w*\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
405 "*Regular expression (regexp) for syntax of test signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 vhdl-signal-syntax-doc-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407 :type 'regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408 :group 'vhdl-signal-syntax)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411 (defgroup vhdl-menu nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
412 "Customizations for menues."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 (defcustom vhdl-source-file-menu t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 "*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
417 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 :group 'vhdl-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 (defcustom vhdl-index-menu t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 "*If non-nil, an index menu for the current source file is created."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423 :group 'vhdl-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 (defcustom vhdl-hideshow-menu (not (string-match "XEmacs" emacs-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 "*If non-nil, hideshow menu and functionality is added.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 Hideshow allows hiding code of VHDL processes and blocks.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
428 (Does not work under XEmacs.)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 :group 'vhdl-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
431
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
432
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
433 (defgroup vhdl-print nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434 "Customizations for printing."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 (defcustom vhdl-print-two-column t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438 "*If non-nil, code is printed in two columns and landscape format."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
440 :group 'vhdl-print)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 (defgroup vhdl-misc nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444 "Miscellaneous customizations."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
445 :group 'vhdl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 (defcustom vhdl-intelligent-tab t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 "*If non-nil, `TAB' does indentation, word completion, and tab insertion.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449 That is, if preceeding character is part of a word then complete word,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 else if not at beginning of line then insert tab,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
451 else if last command was a `TAB' or `RET' then dedent one step,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
452 else indent current line (i.e. `TAB' is bound to `vhdl-tab').
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
453 If nil, TAB always indents current line (i.e. `TAB' is bound to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 `vhdl-indent-line')."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
457
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
458 (defcustom vhdl-template-key-binding-prefix "\C-t"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 "*`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
460 Default key binding prefix for templates is `C-c C-t' (example: architecture
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 `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
462 template key binding prefix to `C-c' (example: architecture `C-c a') by
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 assigning the empty character (\"\") to this variable. The syntax to enter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
464 control keys is \"\\C-t\"."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465 :type 'sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 (defcustom vhdl-word-completion-in-minibuffer t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 "*If non-nil, word completion works in minibuffer (for template prompts)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 (defcustom vhdl-underscore-is-part-of-word nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474 "*If non-nil, the underscore character `_' is considered as part of word.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 An identifier containing underscores is then treated as a single word in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 select and move operations. All parts of an identifier separated by underscore
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 are treated as single words otherwise."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 :type 'boolean
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 :group 'vhdl-misc)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 ;; Other variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484 (defvar vhdl-inhibit-startup-warnings-p nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485 "*If non-nil, inhibits start up compatibility warnings.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
487 (defvar vhdl-strict-syntax-p nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488 "*If non-nil, all syntactic symbols must be found in `vhdl-offsets-alist'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 If the syntactic symbol for a particular line does not match a symbol
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490 in the offsets alist, an error is generated, otherwise no error is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491 reported and the syntactic symbol is ignored.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
493 (defvar vhdl-echo-syntactic-information-p nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
494 "*If non-nil, syntactic info is echoed when the line is indented.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
495
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 (defconst vhdl-offsets-alist-default
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
497 '((string . -1000)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
498 (block-open . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499 (block-close . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 (statement . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 (statement-cont . vhdl-lineup-statement-cont)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502 (statement-block-intro . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 (statement-case-intro . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 (case-alternative . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505 (comment . vhdl-lineup-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
506 (arglist-intro . +)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
507 (arglist-cont . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
508 (arglist-cont-nonempty . vhdl-lineup-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
509 (arglist-close . vhdl-lineup-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510 (entity . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 (configuration . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 (package . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 (architecture . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 (package-body . 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 "Default settings for offsets of syntactic elements.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 Do not change this constant! See the variable `vhdl-offsets-alist' for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518 more information.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 (defvar vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521 "*Association list of syntactic element symbols and indentation offsets.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 As described below, each cons cell in this list has the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524 (SYNTACTIC-SYMBOL . OFFSET)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 When a line is indented, vhdl-mode first determines the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
527 context of the line by generating a list of symbols called syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 elements. This list can contain more than one syntactic element and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 the global variable `vhdl-syntactic-context' contains the context list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 for the line being indented. Each element in this list is actually a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
531 cons cell of the syntactic symbol and a buffer position. This buffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 position is call the relative indent point for the line. Some
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533 syntactic symbols may not have a relative indent point associated with
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 them.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 After the syntactic context list for a line is generated, vhdl-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 calculates the absolute indentation for the line by looking at each
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538 syntactic element in the list. First, it compares the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 element against the SYNTACTIC-SYMBOL's in `vhdl-offsets-alist'. When it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
540 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
541 point. The sum of this calculation for each element in the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 list is the absolute offset for line being indented.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
543
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544 If the syntactic element does not match any in the `vhdl-offsets-alist',
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545 an error is generated if `vhdl-strict-syntax-p' is non-nil, otherwise
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546 the element is ignored.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 Actually, OFFSET can be an integer, a function, a variable, or one of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 the following symbols: `+', `-', `++', or `--'. These latter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 designate positive or negative multiples of `vhdl-basic-offset',
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
551 respectively: *1, *-1, *2, and *-2. If OFFSET is a function, it is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
552 called with a single argument containing the cons of the syntactic
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553 element symbol and the relative indent point. The function should
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554 return an integer offset.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
555
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556 Here is the current list of valid syntactic element symbols:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 string -- inside multi-line string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559 block-open -- statement block open
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560 block-close -- statement block close
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
561 statement -- a VHDL statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562 statement-cont -- a continuation of a VHDL statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563 statement-block-intro -- the first line in a new statement block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
564 statement-case-intro -- the first line in a case alternative block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565 case-alternative -- a case statement alternative clause
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 comment -- a line containing only a comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567 arglist-intro -- the first line in an argument list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 arglist-cont -- subsequent argument list lines when no
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569 arguments follow on the same line as the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
570 the arglist opening paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571 arglist-cont-nonempty -- subsequent argument list lines when at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 least one argument follows on the same
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573 line as the arglist opening paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
574 arglist-close -- the solo close paren of an argument list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
575 entity -- inside an entity declaration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 configuration -- inside a configuration declaration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577 package -- inside a package declaration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 architecture -- inside an architecture body
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
579 package-body -- inside a package body
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582 (defvar vhdl-comment-only-line-offset 0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
583 "*Extra offset for line which contains only the start of a comment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 Can contain an integer or a cons cell of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 Where NON-ANCHORED-OFFSET is the amount of offset given to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
589 non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
590 the amount of offset to give column-zero anchored comment-only lines.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 Just an integer as value is equivalent to (<val> . 0)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593 (defvar vhdl-special-indent-hook nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594 "*Hook for user defined special indentation adjustments.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 This hook gets called after a line is indented by the mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 (defvar vhdl-style-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 '(("IEEE"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 (vhdl-basic-offset . 4)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600 (vhdl-offsets-alist . ())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603 "Styles of Indentation.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 Elements of this alist are of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 (STYLE-STRING (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
607
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608 where STYLE-STRING is a short descriptive string used to select a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609 style, VARIABLE is any vhdl-mode variable, and VALUE is the intended
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 value for that variable when using the selected style.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 There is one special case when VARIABLE is `vhdl-offsets-alist'. In this
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 case, the VALUE is a list containing elements of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 (SYNTACTIC-SYMBOL . VALUE)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617 as described in `vhdl-offsets-alist'. These are passed directly to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 `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
619 your style, only those that are different from the default.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 ;; dynamically append the default value of most variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622 (or (assoc "Default" vhdl-style-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623 (let* ((varlist '(vhdl-inhibit-startup-warnings-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 vhdl-strict-syntax-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
625 vhdl-echo-syntactic-information-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 vhdl-basic-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 vhdl-offsets-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628 vhdl-comment-only-line-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 (default (cons "Default"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
630 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
632 (lambda (var)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
633 (cons var (symbol-value var))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
634 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635 varlist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 (setq vhdl-style-alist (cons default vhdl-style-alist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638 (defvar vhdl-mode-hook nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639 "*Hook called by `vhdl-mode'.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643 ;; Emacs variant handling
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
645
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 ;; active regions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 (defun vhdl-keep-region-active ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649 ;; do whatever is necessary to keep the region active in XEmacs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 ;; (formerly Lucid). ignore byte-compiler warnings you might see
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651 (and (boundp 'zmacs-region-stays)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 (setq zmacs-region-stays t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 (defconst vhdl-emacs-features
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 (let ((major (and (boundp 'emacs-major-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 emacs-major-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 (minor (and (boundp 'emacs-minor-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 emacs-minor-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659 flavor)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 ;; figure out version numbers if not already discovered
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
661 (and (or (not major) (not minor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
662 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
663 (setq major (string-to-int (substring emacs-version
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
664 (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
665 (match-end 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
666 minor (string-to-int (substring emacs-version
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
667 (match-beginning 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668 (match-end 2)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
669 (if (not (and major minor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670 (error "Cannot figure out the major and minor version numbers."))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
671 ;; calculate the major version
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 ((= major 18) (setq major 'v18)) ;Emacs 18
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674 ((= major 4) (setq major 'v18)) ;Epoch 4
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 ((= major 19) (setq major 'v19 ;Emacs 19
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676 flavor (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 ((string-match "Win-Emacs" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678 'Win-Emacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 ((or (string-match "Lucid" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
680 (string-match "XEmacs" emacs-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 'XEmacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
684 ((= major 20) (setq major 'v20 ;Emacs 20
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
685 flavor (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
686 ((string-match "Win-Emacs" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 'Win-Emacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688 ((or (string-match "Lucid" emacs-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 (string-match "XEmacs" emacs-version))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 'XEmacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 ;; I don't know
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 (t (error "Cannot recognize major version number: %s" major)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 ;; lets do some minimal sanity checking.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 (if (and (or
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 ;; Emacs 18 is brain dead
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 (eq major 'v18)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 ;; Lemacs before 19.6 had bugs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701 ;; Emacs 19 before 19.21 had bugs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 (and (eq major 'v19) (eq flavor t) (< minor 21)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 (not vhdl-inhibit-startup-warnings-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
704 (with-output-to-temp-buffer "*vhdl-mode warnings*"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
705 (print (format
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 "The version of Emacs that you are running, %s,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 has known bugs in its syntax.c parsing routines which will affect the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708 performance of vhdl-mode. You should strongly consider upgrading to the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 latest available version. vhdl-mode may continue to work, after a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 fashion, but strange indentation errors could be encountered."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 emacs-version))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712 (list major flavor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713 "A list of features extant in the Emacs you are using.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 There are many flavors of Emacs out there, each with different
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715 features supporting those needed by vhdl-mode. Here's the current
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 supported list, along with the values for this variable:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
718 Emacs 18/Epoch 4: (v18)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
719 XEmacs (formerly Lucid) 19: (v19 XEmacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
720 Win-Emacs 1.35: (V19 Win-Emacs)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721 Emacs 19: (v19 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722 Emacs 20: (v20 t).")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
725 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
726 ;; Bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
727 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
728
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
729 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
730 ;; Key bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
731
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
732 (defvar vhdl-template-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
733 "Keymap for VHDL templates.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
734
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
735 (if vhdl-template-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
736 (setq vhdl-template-map (make-sparse-keymap))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
737 ;; key bindings for VHDL templates
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
738 (define-key vhdl-template-map "\M-A" 'vhdl-alias)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739 (define-key vhdl-template-map "a" 'vhdl-architecture)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
740 (define-key vhdl-template-map "A" 'vhdl-array)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741 (define-key vhdl-template-map "\M-a" 'vhdl-assert)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
742 (define-key vhdl-template-map "b" 'vhdl-block)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
743 (define-key vhdl-template-map "c" 'vhdl-case)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
744 (define-key vhdl-template-map "\M-c" 'vhdl-component)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745 (define-key vhdl-template-map "I" 'vhdl-component-instance)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
746 (define-key vhdl-template-map "\M-s" 'vhdl-concurrent-signal-assignment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 (define-key vhdl-template-map "\M-Cb"'vhdl-block-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
748 (define-key vhdl-template-map "\M-Cc"'vhdl-component-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
749 (define-key vhdl-template-map "\M-Cd"'vhdl-configuration-decl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750 (define-key vhdl-template-map "\M-Cs"'vhdl-configuration-spec)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751 (define-key vhdl-template-map "C" 'vhdl-constant)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
752 (define-key vhdl-template-map "d" 'vhdl-disconnect)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753 (define-key vhdl-template-map "\M-e" 'vhdl-else)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
754 (define-key vhdl-template-map "E" 'vhdl-elsif)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755 (define-key vhdl-template-map "e" 'vhdl-entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756 (define-key vhdl-template-map "x" 'vhdl-exit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
757 (define-key vhdl-template-map "f" 'vhdl-for)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
758 (define-key vhdl-template-map "F" 'vhdl-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 (define-key vhdl-template-map "g" 'vhdl-generate)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760 (define-key vhdl-template-map "G" 'vhdl-generic)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761 (define-key vhdl-template-map "h" 'vhdl-header)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762 (define-key vhdl-template-map "i" 'vhdl-if)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
763 (define-key vhdl-template-map "L" 'vhdl-library)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
764 (define-key vhdl-template-map "l" 'vhdl-loop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765 (define-key vhdl-template-map "m" 'vhdl-modify)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
766 (define-key vhdl-template-map "M" 'vhdl-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
767 (define-key vhdl-template-map "n" 'vhdl-next)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
768 (define-key vhdl-template-map "k" 'vhdl-package)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
769 (define-key vhdl-template-map "(" 'vhdl-paired-parens)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
770 (define-key vhdl-template-map "\M-p" 'vhdl-port)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
771 (define-key vhdl-template-map "p" 'vhdl-procedure)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
772 (define-key vhdl-template-map "P" 'vhdl-process)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
773 (define-key vhdl-template-map "R" 'vhdl-record)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
774 (define-key vhdl-template-map "r" 'vhdl-return-value)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
775 (define-key vhdl-template-map "\M-S" 'vhdl-selected-signal-assignment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
776 (define-key vhdl-template-map "s" 'vhdl-signal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
777 (define-key vhdl-template-map "S" 'vhdl-subtype)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
778 (define-key vhdl-template-map "t" 'vhdl-type)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
779 (define-key vhdl-template-map "u" 'vhdl-use)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
780 (define-key vhdl-template-map "v" 'vhdl-variable)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
781 (define-key vhdl-template-map "W" 'vhdl-wait)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
782 (define-key vhdl-template-map "w" 'vhdl-while-loop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
783 (define-key vhdl-template-map "\M-w" 'vhdl-with)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
784 (define-key vhdl-template-map "\M-W" 'vhdl-clocked-wait)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
785 (define-key vhdl-template-map "Kb" 'vhdl-package-numeric-bit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
786 (define-key vhdl-template-map "Kn" 'vhdl-package-numeric-std)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
787 (define-key vhdl-template-map "Ks" 'vhdl-package-std-logic-1164)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
788 (define-key vhdl-template-map "Kt" 'vhdl-package-textio)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
789 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
790
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
791 (defvar vhdl-mode-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
792 "Keymap for VHDL Mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
793
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
794 (if vhdl-mode-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
795 (setq vhdl-mode-map (make-sparse-keymap))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
796 ;; key bindings for templates
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
797 (define-key vhdl-mode-map
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
798 (concat "\C-c" vhdl-template-key-binding-prefix) vhdl-template-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
799 ;; standard key bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
800 (define-key vhdl-mode-map "\M-a" 'vhdl-beginning-of-statement)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
801 (define-key vhdl-mode-map "\M-e" 'vhdl-end-of-statement)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
802 (define-key vhdl-mode-map "\M-\C-f" 'vhdl-forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
803 (define-key vhdl-mode-map "\M-\C-b" 'vhdl-backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
804 (define-key vhdl-mode-map "\M-\C-u" 'vhdl-backward-up-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
805 ;(define-key vhdl-mode-map "\M-\C-d" 'vhdl-down-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
806 (define-key vhdl-mode-map "\M-\C-a" 'vhdl-beginning-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
807 (define-key vhdl-mode-map "\M-\C-e" 'vhdl-end-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
808 (define-key vhdl-mode-map "\M-\C-h" 'vhdl-mark-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
809 (define-key vhdl-mode-map "\M-\C-q" 'vhdl-indent-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
810 (define-key vhdl-mode-map "\177" 'backward-delete-char-untabify)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
811 (define-key vhdl-mode-map "\r" 'vhdl-return)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
812 (if vhdl-intelligent-tab
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
813 (define-key vhdl-mode-map "\t" 'vhdl-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
814 (define-key vhdl-mode-map "\t" 'vhdl-indent-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
815 (define-key vhdl-mode-map " " 'vhdl-outer-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
816 ;; new key bindings for VHDL Mode, with no counterpart to BOCM
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
817 (define-key vhdl-mode-map "\C-c\C-e" 'vhdl-electric-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
818 (define-key vhdl-mode-map "\C-c\C-s" 'vhdl-stutter-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
819 (define-key vhdl-mode-map "\C-c\C-u" 'vhdl-fix-case-buffer)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 (define-key vhdl-mode-map "\C-c\C-f" 'font-lock-fontify-buffer)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821 (define-key vhdl-mode-map "\C-c\C-x" 'vhdl-show-syntactic-information)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
822 (define-key vhdl-mode-map "\C-c\C-r" 'vhdl-regress-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823 (define-key vhdl-mode-map "\C-c\C-i" 'vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
824 (define-key vhdl-mode-map "\C-c\C-a" 'vhdl-align-noindent-region)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
825 (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
826 (define-key vhdl-mode-map "\C-c\C-c" 'vhdl-comment-uncomment-region)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
827 (define-key vhdl-mode-map "\C-c-" 'vhdl-inline-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
828 (define-key vhdl-mode-map "\C-c\M--" 'vhdl-display-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
829 (define-key vhdl-mode-map "\C-c\C-o" 'vhdl-open-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
830 (define-key vhdl-mode-map "\C-c\C-g" 'goto-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
831 (define-key vhdl-mode-map "\C-c\C-d" 'vhdl-kill-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832 (define-key vhdl-mode-map "\C-c\C-h" 'vhdl-help)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833 (define-key vhdl-mode-map "\C-c\C-v" 'vhdl-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
834 (define-key vhdl-mode-map "\C-c\C-b" 'vhdl-submit-bug-report)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
835 (define-key vhdl-mode-map "\C-c\C-k" 'vhdl-compile)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
836 (define-key vhdl-mode-map "\C-c\M-\C-k" 'vhdl-make)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
837 (define-key vhdl-mode-map "\M-\t" 'tab-to-tab-stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838 ;; key bindings for stuttering
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
839 (define-key vhdl-mode-map "-" 'vhdl-stutter-mode-dash)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
840 (define-key vhdl-mode-map "'" 'vhdl-stutter-mode-quote)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
841 (define-key vhdl-mode-map ";" 'vhdl-stutter-mode-semicolon)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
842 (define-key vhdl-mode-map "[" 'vhdl-stutter-mode-open-bracket)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
843 (define-key vhdl-mode-map "]" 'vhdl-stutter-mode-close-bracket)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
844 (define-key vhdl-mode-map "." 'vhdl-stutter-mode-period)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
845 (define-key vhdl-mode-map "," 'vhdl-stutter-mode-comma)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
846 (let ((c 97))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
847 (while (< c 123) ; for little a-z
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
848 (define-key vhdl-mode-map (char-to-string c) 'vhdl-stutter-mode-caps)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849 (setq c (1+ c))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
851 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
852
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
853 ;; define special minibuffer keymap for enabling word completion in minibuffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
854 ;; (useful in template generator prompts)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
855 (defvar vhdl-minibuffer-local-map (copy-keymap minibuffer-local-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
856 "Keymap for minibuffer used in VHDL Mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
857
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
858 (define-key vhdl-minibuffer-local-map "\t" 'vhdl-minibuffer-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
859
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
860 (defvar vhdl-mode-syntax-table nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
861 "Syntax table used in vhdl-mode buffers.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
862
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
863 (if vhdl-mode-syntax-table ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
864 (setq vhdl-mode-syntax-table (make-syntax-table))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
865 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
866 ;; why not? (is left to the user here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
867 (if vhdl-underscore-is-part-of-word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
868 (modify-syntax-entry ?_ "w" 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 (modify-syntax-entry ?\| "." vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
890 (modify-syntax-entry ?\} "){" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
891 ;; add comment syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
892 (modify-syntax-entry ?\- ". 12" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
893 (modify-syntax-entry ?\n ">" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
894 (modify-syntax-entry ?\^M ">" vhdl-mode-syntax-table))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
895
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
896 (defvar vhdl-syntactic-context nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
897 "Buffer local variable containing syntactic analysis list.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
898 (make-variable-buffer-local 'vhdl-syntactic-context)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
899
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
900 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
901 ;; Abbrev hook bindings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
902
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
903 (defvar vhdl-mode-abbrev-table nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
904 "Abbrev table in use in vhdl-mode buffers.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
905
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
906 (define-abbrev-table 'vhdl-mode-abbrev-table
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
907 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
908 ("--" "" vhdl-display-comment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
909 ("abs" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
910 ("access" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
911 ("after" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
912 ("alias" "" vhdl-alias-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
913 ("all" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
914 ("and" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
915 ("arch" "" vhdl-architecture-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
916 ("architecture" "" vhdl-architecture-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
917 ("array" "" vhdl-array-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
918 ("assert" "" vhdl-assert-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
919 ("attr" "" vhdl-attribute-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
920 ("attribute" "" vhdl-attribute-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
921 ("begin" "" vhdl-default-indent-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
922 ("block" "" vhdl-block-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
923 ("body" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
924 ("buffer" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
925 ("bus" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
926 ("case" "" vhdl-case-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 ("comp" "" vhdl-component-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
928 ("component" "" vhdl-component-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
929 ("conc" "" vhdl-concurrent-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930 ("concurrent" "" vhdl-concurrent-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
931 ("conf" "" vhdl-configuration-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
932 ("configuration" "" vhdl-configuration-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
933 ("cons" "" vhdl-constant-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
934 ("constant" "" vhdl-constant-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
935 ("disconnect" "" vhdl-disconnect-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
936 ("downto" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
937 ("else" "" vhdl-else-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
938 ("elseif" "" vhdl-elsif-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939 ("elsif" "" vhdl-elsif-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
940 ("end" "" vhdl-default-indent-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
941 ("entity" "" vhdl-entity-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
942 ("exit" "" vhdl-exit-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
943 ("file" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
944 ("for" "" vhdl-for-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
945 ("func" "" vhdl-function-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
946 ("function" "" vhdl-function-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
947 ("gen" "" vhdl-generate-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
948 ("generate" "" vhdl-generate-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
949 ("generic" "" vhdl-generic-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
950 ("group" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
951 ("guarded" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
952 ("header" "" vhdl-header-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
953 ("if" "" vhdl-if-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
954 ("impure" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
955 ("in" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
956 ("inertial" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 ("inout" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958 ("inst" "" vhdl-component-instance-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 ("instance" "" vhdl-component-instance-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
960 ("is" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961 ("label" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
962 ("library" "" vhdl-library-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
963 ("linkage" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
964 ("literal" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
965 ("loop" "" vhdl-loop-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966 ("map" "" vhdl-map-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
967 ("mod" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
968 ("modify" "" vhdl-modify-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
969 ("nand" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
970 ("new" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
971 ("next" "" vhdl-next-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
972 ("nor" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
973 ("not" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
974 ("null" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
975 ("of" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
976 ("on" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
977 ("open" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
978 ("or" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
979 ("others" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
980 ("out" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
981 ("pack" "" vhdl-package-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
982 ("package" "" vhdl-package-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
983 ("port" "" vhdl-port-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
984 ("postponed" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
985 ("procedure" "" vhdl-procedure-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
986 ("process" "" vhdl-process-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
987 ("pure" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
988 ("range" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
989 ("record" "" vhdl-record-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
990 ("register" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
991 ("reject" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
992 ("rem" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
993 ("report" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
994 ("ret" "" vhdl-return-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
995 ("return" "" vhdl-return-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
996 ("rol" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
997 ("ror" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
998 ("select" "" vhdl-selected-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
999 ("severity" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1000 ("shared" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1001 ("sig" "" vhdl-signal-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1002 ("signal" "" vhdl-signal-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1003 ("sla" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1004 ("sll" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1005 ("sra" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1006 ("srl" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1007 ("sub" "" vhdl-subtype-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1008 ("subtype" "" vhdl-subtype-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1009 ("then" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1010 ("to" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1011 ("transport" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1012 ("type" "" vhdl-type-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1013 ("unaffected" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1014 ("units" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1015 ("until" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1016 ("use" "" vhdl-use-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1017 ("var" "" vhdl-variable-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1018 ("variable" "" vhdl-variable-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1019 ("wait" "" vhdl-wait-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1020 ("warning" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1021 ("when" "" vhdl-when-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1022 ("while" "" vhdl-while-loop-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1023 ("with" "" vhdl-selected-signal-assignment-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1024 ("xnor" "" vhdl-default-hook 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1025 ("xor" "" vhdl-default-hook 0)
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
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1029 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1030 ;; Menues
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1031 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1032
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1033 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1034 ;; VHDL menu (using `easy-menu.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1035
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1036 ;; `customize-menu-create' is included in `cus-edit.el' version 1.9954,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1037 ;; which is not yet distributed with XEmacs 19.15
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1038 (defun vhdl-customize-menu-create (symbol &optional name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1039 "Return a customize menu for customization group SYMBOL.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1040 If optional NAME is given, use that as the name of the menu.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1041 Otherwise the menu will be named `Customize'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1042 The format is suitable for use with `easy-menu-define'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1043 (unless name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1044 (setq name "Customize"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1045 (if (memq 'XEmacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1046 ;; We can delay it under XEmacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1047 `(,name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1048 :filter (lambda (&rest junk)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1049 (cdr (custom-menu-create ',symbol))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1050 ;; But we must create it now under Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1051 (cons name (cdr (custom-menu-create symbol)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1052
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1053 (defvar vhdl-mode-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1054 (append
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1055 '("VHDL"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1056 ("Mode"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1057 ["Electric" vhdl-electric-mode :style toggle :selected vhdl-electric-mode]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1058 ["Stutter" vhdl-stutter-mode :style toggle :selected vhdl-stutter-mode]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1059 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1060 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1061 ("Compile"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1062 ["Compile Buffer" vhdl-compile t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1063 ["Stop Compilation" kill-compilation t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1064 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1065 ["Make" vhdl-make t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1066 ["Generate Makefile" vhdl-generate-makefile t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1067 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1068 ["Next Error" next-error t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1069 ["Previous Error" previous-error t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1070 ["First Error" first-error t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1071 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1072 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1073 ("Template"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1074 ("VHDL Construct 1"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1075 ["Alias" vhdl-alias t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1076 ["Architecture" vhdl-architecture t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1077 ["Array" vhdl-array t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1078 ["Assert" vhdl-assert t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1079 ["Attribute" vhdl-attribute t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1080 ["Block" vhdl-block t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1081 ["Case" vhdl-case t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1082 ["Component" vhdl-component t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1083 ["Concurrent (Signal Asst)" vhdl-concurrent-signal-assignment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1084 ["Configuration (Block)" vhdl-block-configuration t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1085 ["Configuration (Comp)" vhdl-component-configuration t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1086 ["Configuration (Decl)" vhdl-configuration-decl t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1087 ["Configuration (Spec)" vhdl-configuration-spec t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1088 ["Constant" vhdl-constant t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1089 ["Disconnect" vhdl-disconnect t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1090 ["Else" vhdl-else t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1091 ["Elsif" vhdl-elsif t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1092 ["Entity" vhdl-entity t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1093 ["Exit" vhdl-exit t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1094 ["For (Loop)" vhdl-for t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1095 ["Function" vhdl-function t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1096 ["(For/If) Generate" vhdl-generate t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1097 ["Generic" vhdl-generic t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1098 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1099 ("VHDL Construct 2"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1100 ["If" vhdl-if t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1101 ["Instance" vhdl-component-instance t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1102 ["Library" vhdl-library t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1103 ["Loop" vhdl-loop t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1104 ["Map" vhdl-map t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1105 ["Next" vhdl-next t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1106 ["Package" vhdl-package t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1107 ["Port" vhdl-port t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1108 ["Procedure" vhdl-procedure t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1109 ["Process" vhdl-process t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1110 ["Record" vhdl-record t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1111 ["Return" vhdl-return-value t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1112 ["Select" vhdl-selected-signal-assignment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1113 ["Signal" vhdl-signal t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1114 ["Subtype" vhdl-subtype t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1115 ["Type" vhdl-type t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1116 ["Use" vhdl-use t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1117 ["Variable" vhdl-variable t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1118 ["Wait" vhdl-wait t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1119 ["(Clocked Wait)" vhdl-clocked-wait t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1120 ["When" vhdl-when t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1121 ["While (Loop)" vhdl-while-loop t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1122 ["With" vhdl-with t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1123 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1124 ("Standard Package"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1125 ["numeric_bit" vhdl-package-numeric-bit t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1126 ["numeric_std" vhdl-package-numeric-std t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1127 ["std_logic_1164" vhdl-package-std-logic-1164 t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1128 ["textio" vhdl-package-textio t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1129 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1130 ["Header" vhdl-header t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1131 ["Modify (Date)" vhdl-modify t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1132 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1133 ("Comment"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1134 ["(Un)Comment Out Region" vhdl-comment-uncomment-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1135 ["Insert Inline Comment" vhdl-inline-comment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1136 ["Insert Horizontal Line" vhdl-display-comment-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1137 ["Insert Display Comment" vhdl-display-comment t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1138 ["Fill Comment" fill-paragraph t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1139 ["Fill Comment Region" fill-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1140 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1141 ("Indent"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1142 ["Line" vhdl-indent-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1143 ["Region" indent-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1144 ["Buffer" vhdl-indent-buffer t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1145 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1146 ("Align"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1147 ["Region" vhdl-align-noindent-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1148 ["Comment Region" vhdl-align-comment-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1149 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1150 ("Line"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1151 ["Open" vhdl-open-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1152 ["Delete" vhdl-kill-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1153 ["Join" delete-indentation t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1154 ["Goto" goto-line t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1155 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1156 ("Move"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1157 ["Forward Statement" vhdl-end-of-statement t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1158 ["Backward Statement" vhdl-beginning-of-statement t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1159 ["Forward Expression" vhdl-forward-sexp t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1160 ["Backward Expression" vhdl-backward-sexp t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1161 ["Forward Function" vhdl-end-of-defun t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1162 ["Backward Function" vhdl-beginning-of-defun t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1163 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1164 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1165 ("Fix Case"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1166 ["Buffer" vhdl-fix-case-buffer t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1167 ["Region" vhdl-fix-case-region (mark)]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1168 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1169 ["Fontify Buffer" font-lock-fontify-buffer t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1170 ["Syntactic Info" vhdl-show-syntactic-information t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1171 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1172 ["Help" vhdl-help t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1173 ["Version" vhdl-version t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1174 ["Bug Report" vhdl-submit-bug-report t]
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1175 "--"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1176 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1177 (list (vhdl-customize-menu-create 'vhdl))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1178 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1179
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1180 (require 'easymenu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1181
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1182 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1183 ;; Index menu (using `imenu.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1184
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1185 (defvar vhdl-imenu-generic-expression
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1186 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1187 ("Entity"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1188 "^\\s-*\\(entity\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1189 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1190 ("Architecture"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1191 "^\\s-*\\(architecture\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\s-+of\\s-+\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1192 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1193 ("Configuration"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1194 "^\\s-*\\(configuration\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\s-+of\\s-+\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1195 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1196 ("Package Body"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1197 "^\\s-*\\(package body\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1198 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1199 ("Package"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1200 "^\\s-*\\(package\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1201 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1202 ("Type"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1203 "^\\s-*\\(sub\\)?type\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1204 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1205 ("Component"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1206 "^\\s-*\\(component\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1207 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1208 ("Function / Procedure"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1209 "^\\s-*\\(procedure\\|function\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1210 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1211 ("Process / Block"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1212 "^\\s-*\\(\\(\\w\\|\\s_\\)+\\)\\s-*:\\(\\s-\\|\n\\)*\\(process\\|block\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1213 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1214 ("Instance"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1215 "^\\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
1216 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1217 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1218 "Imenu generic expression for VHDL Mode. See `imenu-generic-expression'.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1219
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1220 (defun vhdl-add-index-menu ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1221 (make-local-variable 'imenu-generic-expression)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1222 (setq imenu-generic-expression vhdl-imenu-generic-expression)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1223 (imenu-add-to-menubar "Index"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1224
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1225 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1226 ;; Source file menu (using `easy-menu.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1227
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1228 (defvar vhdl-extlist '("[A-Za-z0-9_.]*.vhdl?$"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1229 (defvar vhdl-filelist-menu nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1230
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1231 (defun vhdl-add-source-files-menu ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1232 "Scan directory of current source file for all VHDL source files, and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1233 generate menu."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1234 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1235 (message "Scanning directory for source files ...")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1236 (let (filelist menulist tmpextlist found
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1237 (newmap (current-local-map)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1238 (cd (file-name-directory (buffer-file-name)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1239 ;; find files
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1240 (setq menulist '())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1241 (setq tmpextlist vhdl-extlist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1242 (while tmpextlist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1243 (setq filelist (nreverse (directory-files
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1244 (file-name-directory (buffer-file-name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1245 nil (car tmpextlist) nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1246 ;; Create list for menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1247 (setq found nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1248 (while filelist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1249 (setq found t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1250 (setq menulist (cons (vector (car filelist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1251 (list 'find-file (car filelist)) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1252 menulist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1253 (setq filelist (cdr filelist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1254 (setq menulist (vhdl-menu-split menulist 25))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1255 (if found
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1256 (setq menulist (cons "--" menulist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1257 (setq tmpextlist (cdr tmpextlist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1258 (setq menulist (cons ["*Rescan*" vhdl-add-source-files-menu t] menulist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1259 (setq menulist (cons "Sources" menulist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1260 ;; Create menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1261 (easy-menu-add menulist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1262 (easy-menu-define vhdl-filelist-menu newmap
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1263 "VHDL source files menu" menulist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1264 ; (use-local-map (append (current-local-map) newmap))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1265 ; (use-local-map newmap)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1266 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1267 (message ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1268
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1269 (defun vhdl-menu-split (list n)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1270 "Split menu into several submenues, if number of elements > n."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1271 (if (> (length list) n)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1272 (let ((remain list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1273 (result '())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1274 (sublist '())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1275 (menuno 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1276 (i 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1277 (while remain
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1278 (setq sublist (cons (car remain) sublist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1279 (setq remain (cdr remain))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1280 (setq i (+ i 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1281 (if (= i n)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1282 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1283 (setq result (cons (cons (format "Sources %s" menuno)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1284 (nreverse sublist)) result))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1285 (setq i 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1286 (setq menuno (+ menuno 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1287 (setq sublist '()))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1288 (and sublist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1289 (setq result (cons (cons (format "Sources %s" menuno)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1290 (nreverse sublist)) result)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1291 (nreverse result))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1292 list))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1293
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1294
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1295 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1296 ;; VHDL Mode definition
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1297 ;; ############################################################################
21446
830023d4cec6 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 20665
diff changeset
1298 ;;;###autoload
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1299 (defun vhdl-mode ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1300 "Major mode for editing VHDL code.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1301
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1302 Usage:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1303 ------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1304
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1305 - TEMPLATE INSERTION (electrification) (`\\[vhdl-outer-space]'): After typing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1306 a VHDL keyword and entering `\\[vhdl-outer-space]', you are prompted for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1307 arguments while a template is generated for that VHDL construct. Typing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1308 `\\[vhdl-return]' (or `\\[keyboard-quit]' in yes-no queries) at the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1309 prompt aborts the current template generation. Typing `\\[just-one-space]'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1310 after a keyword inserts a space without calling the template generator.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1311 Automatic calling of the template generators (i.e. electrification) can be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1312 disabled (enabled) by setting the variable `vhdl-electric-mode' to nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1313 (non-nil) or by typing `\\[vhdl-electric-mode]' (toggles electrification
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1314 mode).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1315 Template generators can be called using the VHDL menu, the key bindings, or
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1316 by typing the keyword (first word of menu entry not in parenthesis) and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1317 `\\[vhdl-outer-space]'. The following abbreviations can also be used:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1318 arch, attr, conc, conf, comp, cons, func, inst, pack, ret, sig, sub, var.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1319
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1320 - HEADER INSERTION (`\\[vhdl-header]'): A customized header can be inserted
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1321 including the actual file name, user name, and current date as well as
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1322 prompted title strings. A custom header can be defined in a separate file
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1323 (see custom variable `vhdl-header-file').
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1324
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1325 - STUTTERING (double strike): Double striking of some keys inserts cumbersome
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1326 VHDL syntax elements. Stuttering can be disabled by variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1327 `vhdl-stutter-mode' and be toggled by typing `\\[vhdl-stutter-mode]'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1328 '' --> \" [ --> ( -- --> comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1329 ;; --> \" : \" [[ --> [ --CR --> comment-out code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1330 ;;; --> \" := \" ] --> ) --- --> horizontal line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1331 .. --> \" => \" ]] --> ] ---- --> display comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1332 ,, --> \" <= \" aa --> A - zz --> Z
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1333
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1334 - WORD COMPLETION (`\\[vhdl-tab]'): Typing `\\[vhdl-tab]' after a (not
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1335 completed) word looks for a word in the buffer that starts alike and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1336 inserts it. Re-typing `\\[vhdl-tab]' toggles through alternative word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1337 completions. This also works in the minibuffer (i.e. in template generator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1338 prompts).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1339
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1340 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
1341 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
1342 tabulator stop otherwise. `\\[tab-to-tab-stop]' always inserts a tabulator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1343 stop.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1344
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1345 - COMMENTS (`--', `---', `----', `--CR'):
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1346 `--' puts a single comment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1347 `---' draws a horizontal line for separating code segments.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1348 `----' inserts a display comment, i.e. two horizontal lines with a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1349 comment in between.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1350 `--CR' comments out code on that line. Re-hitting CR comments out
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1351 following lines.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1352 `\\[vhdl-comment-uncomment-region]' comments out a region if not
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1353 commented out, uncomments out a region if already
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1354 commented out.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1355
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1356 You are prompted for comments after object definitions (i.e. signals,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1357 variables, constants, ports) and after subprogram and process specifications
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1358 if variable `vhdl-prompt-for-comments' is non-nil. Comments are
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1359 automatically inserted as additional labels (e.g. after begin statements)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1360 and help comments if `vhdl-self-insert-comments' is non-nil.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1361 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
1362 indented at least to `vhdl-comment-column'. Comments go at maximum to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1363 `vhdl-end-comment-column'. `\\[vhdl-return]' after a space in a comment will
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1364 open a new comment line. Typing beyond `vhdl-end-comment-column' in a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1365 comment automatically opens a new comment line. `\\[fill-paragraph]'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1366 re-fills multi-line comments.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1367
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1368 - INDENTATION: `\\[vhdl-tab]' indents a line if at the beginning of the line.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1369 The amount of indentation is specified by variable `vhdl-basic-offset'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1370 `\\[vhdl-indent-line]' always indents the current line (is bound to `TAB'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1371 if variable `vhdl-intelligent-tab' is nil). Indentation can be done for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1372 an entire region (`\\[indent-region]') or buffer (menu). Argument and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1373 port lists are indented normally (nil) or relative to the opening
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1374 parenthesis (non-nil) according to variable `vhdl-argument-list-indent'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1375 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
1376 `\\[tabify]' and `\\[untabify]' allow to convert spaces to tabs and vice
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1377 versa.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1378
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1379 - ALIGNMENT: `\\[vhdl-align-noindent-region]' aligns port maps, signal and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1380 variable assignments, inline comments, some keywords, etc., on consecutive
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1381 lines relative to each other within a defined region.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1382 `\\[vhdl-align-comment-region]' only aligns inline comments (i.e. comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1383 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
1384 aligned after generation if custom variable `vhdl-auto-align' is non-nil.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1385
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1386 - KEY BINDINGS: Key bindings (`C-c ...') exist for most commands (see in 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 - VHDL MENU: All commands can be called from the VHDL menu.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1389
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1390 - INDEX MENU: For each VHDL source file, an index of the contained entities,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1391 architectures, packages, procedures, processes, etc., is created as a menu.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1392 Selecting a meny entry causes the cursor to jump to the corresponding
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1393 position in the file. Controlled by variable `vhdl-index-menu'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1394
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1395 - SOURCE FILE MENU: A menu containing all VHDL source files in the directory
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1396 of the current file is generated. Selecting a menu entry loads the file.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1397 Controlled by variable `vhdl-source-file-menu'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1398
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1399 - SOURCE FILE COMPILATION: The syntax of the current buffer can be analyzed
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1400 by calling a VHDL compiler (menu, `\\[vhdl-compile]'). The compiler to be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1401 used is defined by variable `vhdl-compiler'. Currently supported are
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1402 `cadence', `ikos', `quickhdl', `synopsys', `vantage', `viewlogic', and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1403 `v-system'. Not all compilers are tested. Please contact me for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1404 incorporating additional VHDL compilers. An entire hierarchy of source
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1405 files can be compiled by the `make' command (menu, `\\[vhdl-make]').
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1406 This only works if an appropriate `Makefile' exists. Compiler options can
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1407 be defined by variable `vhdl-compiler-options'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1408
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1409 - KEYWORD CASE: Lower and upper case for keywords, predefined types, predefined
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1410 attributes, and predefined enumeration values is supported. If the variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1411 `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
1412 lower case and are converted into upper case automatically (not for types,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1413 attributes, and enumeration values). The case of keywords, types,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1414 attributes, and enumeration values can be fixed for an entire region (menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1415 or buffer (`\\[vhdl-fix-case-buffer]') according to the variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1416 `vhdl-upper-case-{keywords,types,attributes,enum-values}'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1417
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1418 - HIGHLIGHTING (fontification): Keywords, predefined types, predefined
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1419 attributes, and predefined enumeration values (controlled by variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1420 `vhdl-highlight-keywords'), as well as comments, strings, and template
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1421 prompts are highlighted using different colors. Unit and subprogram names
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1422 as well as labels are highlighted if variable `vhdl-highlight-names' is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1423 non-nil. The default colors from `font-lock.el' are used if variable
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
1424 `vhdl-customize-colors' is nil. Otherwise, an optimized set of colors
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1425 is taken, which uses bright colors for signals and muted colors for
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
1426 everything else. Variable `vhdl-customize-faces' does the same on
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1427 monochrome monitors.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1428
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1429 Signal highlighting allows distinction between clock, reset,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1430 status/control, data, and test signals according to some signal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1431 naming convention. Their syntax is defined by variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1432 `vhdl-{clock,reset,control,data,test}-signal-syntax'. Signal coloring
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1433 is controlled by the variable `vhdl-highlight-signals'. The default
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1434 signal naming convention is as follows:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1435
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1436 Signal attributes:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1437 C clock S control and status
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1438 R asynchronous reset D data and address
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1439 I synchronous reset T test
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1440
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1441 Syntax:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1442 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
1443 signal identifier -^^^^^^^^^^^^^^^^^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1444 delimiter --------------------------^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1445 above signal attributes -------------^^^^^^^^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1446 additional attributes -----------------------^^^^^^^^^^^^
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1447
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1448 (`x' is used as delimiter because `_' is reserved by the VITAL standard.)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1449 Examples: ClkxCfast, ResetxRB, ClearxI, SelectDataxS, DataxD, ScanEnablexT.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1450
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1451 If all VHDL words are written in lower case (i.e. variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1452 `vhdl-upper-case-{keywords,types,attributes,enum-values}' are set to nil),
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1453 make highlighting case sensitive by setting variable
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1454 `vhdl-highlight-case-sensitive' to non-nil. This way, only names fulfilling
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1455 the above signal syntax including case are highlighted.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1456
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1457 - 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
1458 the `Hide/Show' menu or by pressing `S-mouse-2' within the code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1459 (not in XEmacs).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1460
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1461 - PRINTING: Postscript printing with different fonts (`ps-print-color-p' is
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
1462 nil, default faces from `font-lock.el' used if `vhdl-customize-faces' is
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
1463 nil) or colors (`ps-print-color-p' is non-nil) is possible using the
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1464 standard Emacs postscript printing commands. Variable `vhdl-print-two-column'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1465 defines appropriate default settings for nice landscape two-column printing.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1466 The paper format can be set by variable `ps-paper-type'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1467
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1468 - CUSTOMIZATION: All variables can easily be customized using the `Customize'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1469 menu entry. For some variables, customization only takes effect after
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1470 re-starting Emacs. Customization can also be done globally (i.e. site-wide,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1471 read INSTALL file). Variables of VHDL Mode must NOT be set using the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1472 `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
1473
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1474
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1475 Maintenance:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1476 ------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1477
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1478 To submit a bug report, enter `\\[vhdl-submit-bug-report]' within VHDL Mode.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1479 Add a description of the problem and include a reproducible test case.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1480
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1481 Questions and enhancement requests can be sent to <vhdl-mode@geocities.com>.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1482
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1483 The `vhdl-mode-announce' mailing list informs about new VHDL Mode releases.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1484 The `vhdl-mode-victims' mailing list informs about new VHDL Mode beta releases.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1485 You are kindly invited to participate in beta testing. Subscribe to above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1486 mailing lists by sending an email to <vhdl-mode@geocities.com>.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1487
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1488 The archive with the latest version is located at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1489 <http://www.geocities.com/SiliconValley/Peaks/8287>.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1490
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1491
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1492 Bugs and Limitations:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1493 ---------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1494
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1495 - Index menu does not work under XEmacs (limitation of XEmacs ?!).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1496
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1497 - Re-indenting large regions or expressions can be slow.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1498
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1499 - Hideshow does not work under XEmacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1500
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1501 - Parsing compilation error messages for Ikos and Vantage VHDL compilers
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1502 does not work under XEmacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1503
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1504
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1505 Key bindings:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1506 -------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1507
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1508 \\{vhdl-mode-map}"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1509 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1510 (kill-all-local-variables)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1511 (set-syntax-table vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1512 (setq major-mode 'vhdl-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1513 (setq mode-name "VHDL")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1514 (setq local-abbrev-table vhdl-mode-abbrev-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1515 (use-local-map vhdl-mode-map)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1516 ;; set local variable values
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1517 (set (make-local-variable 'paragraph-start) "\\s-*\\(---\\|[a-zA-Z]\\|$\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1518 (set (make-local-variable 'paragraph-separate) paragraph-start)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1519 (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1520 (set (make-local-variable 'require-final-newline) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1521 (set (make-local-variable 'parse-sexp-ignore-comments) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1522 (set (make-local-variable 'indent-line-function) 'vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1523 (set (make-local-variable 'comment-start) "--")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1524 (set (make-local-variable 'comment-end) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1525 (set (make-local-variable 'comment-column) vhdl-comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1526 (set (make-local-variable 'end-comment-column) vhdl-end-comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1527 (set (make-local-variable 'comment-start-skip) "--+\\s-*")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1528 (set (make-local-variable 'dabbrev-case-fold-search) nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1529 (set (make-local-variable 'indent-tabs-mode) vhdl-indent-tabs-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1530
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1531 ;; setup the comment indent variable in a Emacs version portable way
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1532 ;; ignore any byte compiler warnings you might get here
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1533 (if (boundp 'comment-indent-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1534 (progn (make-local-variable 'comment-indent-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1535 (setq comment-indent-function 'vhdl-comment-indent)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1536
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1537 ;; initialize font locking
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1538 (require 'font-lock)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1539 (vhdl-font-lock-init)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1540 (make-local-variable 'font-lock-defaults)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1541 (setq font-lock-defaults (list 'vhdl-font-lock-keywords nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1542 (not vhdl-highlight-case-sensitive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1543 '((?\_ . "w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1544 (turn-on-font-lock)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1545
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1546 ;; variables for source file compilation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1547 (make-local-variable 'compile-command)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1548 (set (make-local-variable 'compilation-error-regexp-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1549 vhdl-compilation-error-regexp-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1550
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1551 ;; add menus
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1552 (if vhdl-index-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1553 (if (or (not (consp font-lock-maximum-size))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1554 (> font-lock-maximum-size (buffer-size)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1555 (vhdl-add-index-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1556 (message "Scanning buffer for index...buffer too big")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1557 (if vhdl-source-file-menu (vhdl-add-source-files-menu))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1558 (easy-menu-add vhdl-mode-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1559 (easy-menu-define vhdl-mode-easy-menu vhdl-mode-map
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1560 "Menu keymap for VHDL Mode." vhdl-mode-menu)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1561 (run-hooks 'menu-bar-update-hook)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1562
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1563 ;; initialize hideshow and add menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1564 (if vhdl-hideshow-menu (hs-minor-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1565
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1566 ;; initialize postscript printing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1567 (vhdl-ps-init)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1568
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1569 (setq mode-name (if vhdl-electric-mode "Electric VHDL" "VHDL"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1570 (message "Type C-c C-h for VHDL Mode documentation.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1571
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1572 (run-hooks 'vhdl-mode-hook)
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
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1576 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1577 ;; Keywords and predefined words in VHDL'93
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1578 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1579
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1580 ;; `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
1581 ;; in XEmacs and because it resulted in SLOWER regexps!!
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1582
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1583 (defconst vhdl-93-keywords-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1584 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1585 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1586 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1587 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1588 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1589 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1590 "abs" "access" "after" "alias" "all" "and" "architecture" "array"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1591 "assert" "attribute"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1592 "begin" "block" "body" "buffer" "bus"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1593 "case" "component" "configuration" "constant"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1594 "disconnect" "downto"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1595 "else" "elsif" "end" "entity" "exit"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1596 "file" "for" "function"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1597 "generate" "generic" "group" "guarded"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1598 "if" "impure" "in" "inertial" "inout" "is"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1599 "label" "library" "linkage" "literal" "loop"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1600 "map" "mod"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1601 "nand" "new" "next" "nor" "not" "null"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1602 "of" "on" "open" "or" "others" "out"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1603 "package" "port" "postponed" "procedure" "process" "pure"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1604 "range" "record" "register" "reject" "rem" "report" "return"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1605 "rol" "ror"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1606 "select" "severity" "shared" "signal" "sla" "sll" "sra" "srl" "subtype"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1607 "then" "to" "transport" "type"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1608 "unaffected" "units" "until" "use"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1609 "variable"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1610 "wait" "warning" "when" "while" "with"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1611 "xnor" "xor"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1612 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1613 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1614 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1615 "Regexp for VHDL'93 keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1616
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1617 (defconst vhdl-93-types-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1618 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1619 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1620 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1621 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1622 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1623 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1624 "boolean" "bit" "bit_vector" "character" "severity_level" "integer"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1625 "real" "time" "natural" "positive" "string" "text" "line"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1626 "unsigned" "signed"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1627 "std_logic" "std_logic_vector"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1628 "std_ulogic" "std_ulogic_vector"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1629 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1630 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1631 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1632 "Regexp for VHDL'93 standardized types.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1633
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1634 (defconst vhdl-93-attributes-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1635 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1636 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1637 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1638 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1639 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1640 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1641 "base" "left" "right" "high" "low" "pos" "val" "succ"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1642 "pred" "leftof" "rightof" "range" "reverse_range"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1643 "length" "delayed" "stable" "quiet" "transaction"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1644 "event" "active" "last_event" "last_active" "last_value"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1645 "driving" "driving_value" "ascending" "value" "image"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1646 "simple_name" "instance_name" "path_name"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1647 "foreign"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1648 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1649 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1650 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1651 "Regexp for VHDL'93 standardized attributes.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1652
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1653 (defconst vhdl-93-enum-values-regexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1654 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1655 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1656 "\\<\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1657 (mapconcat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1658 'identity
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1659 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1660 "true" "false"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1661 "note" "warning" "error" "failure"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1662 "fs" "ps" "ns" "us" "ms" "sec" "min" "hr"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1663 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1664 "\\|")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1665 "\\)\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1666 "Regexp for VHDL'93 standardized enumeration values.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1667
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1668
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1669 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1670 ;; Syntax analysis and indentation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1671 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1672
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1673 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1674 ;; Syntax analysis
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1675
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1676 ;; constant regular expressions for looking at various constructs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1677
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1678 (defconst vhdl-symbol-key "\\(\\w\\|\\s_\\)+"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1679 "Regexp describing a VHDL symbol.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1680 We cannot use just `word' syntax class since `_' cannot be in word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1681 class. Putting underscore in word class breaks forward word movement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1682 behavior that users are familiar with.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1683
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1684 (defconst vhdl-case-header-key "case[( \t\n][^;=>]+[) \t\n]is"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1685 "Regexp describing a case statement header key.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1686
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1687 (defconst vhdl-label-key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1688 (concat "\\(" vhdl-symbol-key "\\s-*:\\)[^=]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1689 "Regexp describing a VHDL label.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1690
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1691 ;; Macro definitions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1692
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1693 (defmacro vhdl-point (position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1694 ;; Returns the value of point at certain commonly referenced POSITIONs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1695 ;; POSITION can be one of the following symbols:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1696 ;;
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1697 ;; bol -- beginning of line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1698 ;; eol -- end of line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1699 ;; bod -- beginning of defun
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1700 ;; boi -- back to indentation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1701 ;; eoi -- last whitespace on line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1702 ;; ionl -- indentation of next line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1703 ;; iopl -- indentation of previous line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1704 ;; bonl -- beginning of next line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1705 ;; bopl -- beginning of previous line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1706 ;;
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1707 ;; This function does not modify point or mark.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1708 (or (and (eq 'quote (car-safe position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1709 (null (cdr (cdr position))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1710 (error "bad buffer position requested: %s" position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1711 (setq position (nth 1 position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1712 (` (let ((here (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1713 (,@ (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1714 ((eq position 'bol) '((beginning-of-line)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1715 ((eq position 'eol) '((end-of-line)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1716 ((eq position 'bod) '((save-match-data
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1717 (vhdl-beginning-of-defun))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1718 ((eq position 'boi) '((back-to-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1719 ((eq position 'eoi) '((end-of-line)(skip-chars-backward " \t")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1720 ((eq position 'bonl) '((forward-line 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1721 ((eq position 'bopl) '((forward-line -1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1722 ((eq position 'iopl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1723 '((forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1724 (back-to-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1725 ((eq position 'ionl)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1726 '((forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1727 (back-to-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1728 (t (error "unknown buffer position requested: %s" position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1729 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1730 (prog1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1731 (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1732 (goto-char here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1733 ;; workaround for an Emacs18 bug -- blech! Well, at least it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1734 ;; doesn't hurt for v19
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1735 (,@ nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1736 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1737
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1738 (defmacro vhdl-safe (&rest body)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1739 ;; safely execute BODY, return nil if an error occurred
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1740 (` (condition-case nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1741 (progn (,@ body))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1742 (error nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1743
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1744 (defmacro vhdl-add-syntax (symbol &optional relpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1745 ;; a simple macro to append the syntax in symbol to the syntax list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1746 ;; try to increase performance by using this macro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1747 (` (setq vhdl-syntactic-context
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1748 (cons (cons (, symbol) (, relpos)) vhdl-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1749
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1750 (defmacro vhdl-has-syntax (symbol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1751 ;; a simple macro to return check the syntax list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1752 ;; try to increase performance by using this macro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1753 (` (assoc (, symbol) vhdl-syntactic-context)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1754
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1755 ;; Syntactic element offset manipulation:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1756
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1757 (defun vhdl-read-offset (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1758 ;; read new offset value for LANGELEM from minibuffer. return a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1759 ;; legal value only
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1760 (let ((oldoff (format "%s" (cdr-safe (assq langelem vhdl-offsets-alist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1761 (errmsg "Offset must be int, func, var, or one of +, -, ++, --: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1762 (prompt "Offset: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1763 offset input interned)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1764 (while (not offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1765 (setq input (read-string prompt oldoff)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1766 offset (cond ((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-equal "++" input) '++)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1769 ((string-equal "--" input) '--)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1770 ((string-match "^-?[0-9]+$" input)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1771 (string-to-int input))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1772 ((fboundp (setq interned (intern input)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1773 interned)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1774 ((boundp interned) interned)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1775 ;; error, but don't signal one, keep trying
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1776 ;; to read an input value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1777 (t (ding)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1778 (setq prompt errmsg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1779 nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1780 offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1781
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1782 (defun vhdl-set-offset (symbol offset &optional add-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1783 "Change the value of a syntactic element symbol in `vhdl-offsets-alist'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1784 SYMBOL is the syntactic element symbol to change and OFFSET is the new
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1785 offset for that syntactic element. Optional ADD says to add SYMBOL to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1786 `vhdl-offsets-alist' if it doesn't already appear there."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1787 (interactive
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1788 (let* ((langelem
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1789 (intern (completing-read
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1790 (concat "Syntactic symbol to change"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1791 (if current-prefix-arg " or add" "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1792 ": ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1793 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1794 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1795 (lambda (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1796 (cons (format "%s" (car langelem)) nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1797 vhdl-offsets-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1798 nil (not current-prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1799 ;; initial contents tries to be the last element
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1800 ;; on the syntactic analysis list for the current
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1801 ;; line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1802 (let* ((syntax (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1803 (len (length syntax))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1804 (ic (format "%s" (car (nth (1- len) syntax)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1805 (if (memq 'v19 vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1806 (cons ic 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1807 ic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1808 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1809 (offset (vhdl-read-offset langelem)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1810 (list langelem offset current-prefix-arg)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1811 ;; sanity check offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1812 (or (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 (eq offset '++)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1815 (eq offset '--)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1816 (integerp offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1817 (fboundp offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1818 (boundp offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1819 (error "Offset must be int, func, var, or one of +, -, ++, --: %s"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1820 offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1821 (let ((entry (assq symbol vhdl-offsets-alist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1822 (if entry
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1823 (setcdr entry offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1824 (if add-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1825 (setq vhdl-offsets-alist (cons (cons symbol offset) vhdl-offsets-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1826 (error "%s is not a valid syntactic symbol." symbol))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1827 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1828
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1829 (defun vhdl-set-style (style &optional local)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1830 "Set vhdl-mode variables to use one of several different indentation styles.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1831 STYLE is a string representing the desired style and optional LOCAL is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1832 a flag which, if non-nil, means to make the style variables being
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1833 changed buffer local, instead of the default, which is to set the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1834 global variables. Interactively, the flag comes from the prefix
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1835 argument. The styles are chosen from the `vhdl-style-alist' variable."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1836 (interactive (list (completing-read "Use which VHDL indentation style? "
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1837 vhdl-style-alist nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1838 current-prefix-arg))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1839 (let ((vars (cdr (assoc style vhdl-style-alist))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1840 (or vars
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1841 (error "Invalid VHDL indentation style `%s'" style))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1842 ;; set all the variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1843 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1844 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1845 (lambda (varentry)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1846 (let ((var (car varentry))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1847 (val (cdr varentry)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1848 (and local
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1849 (make-local-variable var))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1850 ;; special case for vhdl-offsets-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1851 (if (not (eq var 'vhdl-offsets-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1852 (set var val)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1853 ;; reset vhdl-offsets-alist to the default value first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1854 (setq vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1855 ;; now set the langelems that are different
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1856 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1857 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1858 (lambda (langentry)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1859 (let ((langelem (car langentry))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1860 (offset (cdr langentry)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1861 (vhdl-set-offset langelem offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1862 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1863 val))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1864 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1865 vars))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1866 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1867
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1868 (defun vhdl-get-offset (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1869 ;; Get offset from LANGELEM which is a cons cell of the form:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1870 ;; (SYMBOL . RELPOS). The symbol is matched against
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1871 ;; vhdl-offsets-alist and the offset found there is either returned,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1872 ;; or added to the indentation at RELPOS. If RELPOS is nil, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1873 ;; the offset is simply returned.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1874 (let* ((symbol (car langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1875 (relpos (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1876 (match (assq symbol vhdl-offsets-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1877 (offset (cdr-safe match)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1878 ;; offset can be a number, a function, a variable, or one of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1879 ;; symbols + or -
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1880 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1881 ((not match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1882 (if vhdl-strict-syntax-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1883 (error "don't know how to indent a %s" symbol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1884 (setq offset 0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1885 relpos 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1886 ((eq offset '+) (setq offset vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1887 ((eq offset '-) (setq offset (- vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1888 ((eq offset '++) (setq offset (* 2 vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1889 ((eq offset '--) (setq offset (* 2 (- vhdl-basic-offset))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1890 ((and (not (numberp offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1891 (fboundp offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1892 (setq offset (funcall offset langelem)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1893 ((not (numberp offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1894 (setq offset (eval offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1895 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1896 (+ (if (and relpos
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1897 (< relpos (vhdl-point 'bol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1898 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1899 (goto-char relpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1900 (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1901 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1902 offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1903
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1904 ;; Syntactic support functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1905
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1906 ;; Returns `comment' if in a comment, `string' if in a string literal,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1907 ;; 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
1908 ;; backward limit of the search. If omitted, or nil, (point-min) is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1909 ;; used.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1910
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1911 (defun vhdl-in-literal (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1912 ;; Determine if point is in a VHDL literal.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1913 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1914 (let* ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1915 (state (parse-partial-sexp lim (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1916 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1917 ((nth 3 state) 'string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1918 ((nth 4 state) 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1919 (t nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1920 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1921
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1922 ;; This is the best we can do in Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1923 (defun vhdl-win-il (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1924 ;; Determine if point is in a VHDL literal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1925 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1926 (let* ((here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1927 (state nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1928 (match nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1929 (lim (or lim (vhdl-point 'bod))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1930 (goto-char lim )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1931 (while (< (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1932 (setq match
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1933 (and (re-search-forward "--\\|[\"']"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1934 here 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1935 (buffer-substring (match-beginning 0) (match-end 0))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1936 (setq state
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1937 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1938 ;; no match
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1939 ((null match) nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1940 ;; looking at the opening of a VHDL style comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1941 ((string= "--" match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1942 (if (<= here (progn (end-of-line) (point))) 'comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1943 ;; looking at the opening of a double quote string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1944 ((string= "\"" match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1945 (if (not (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1946 ;; this seems to be necessary since the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1947 ;; re-search-forward will not work without it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1948 (narrow-to-region (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1949 (re-search-forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1950 ;; this regexp matches a double quote
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1951 ;; which is preceded by an even number
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1952 ;; of backslashes, including zero
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1953 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)*\"" here 'move)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1954 'string))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1955 ;; looking at the opening of a single quote string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1956 ((string= "'" match)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1957 (if (not (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1958 ;; see comments from above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1959 (narrow-to-region (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1960 (re-search-forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1961 ;; this matches a single quote which is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1962 ;; preceded by zero or two backslashes.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1963 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)?'"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1964 here 'move)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1965 'string))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1966 (t nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1967 ) ; end-while
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1968 state)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1969
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1970 (and (memq 'Win-Emacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1971 (fset 'vhdl-in-literal 'vhdl-win-il))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1972
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1973 ;; Skipping of "syntactic whitespace". Syntactic whitespace is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1974 ;; defined as lexical whitespace or comments. Search no farther back
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1975 ;; or forward than optional LIM. If LIM is omitted, (point-min) is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1976 ;; used for backward skipping, (point-max) is used for forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1977 ;; skipping.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1978
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1979 (defun vhdl-forward-syntactic-ws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1980 ;; Forward skip of syntactic whitespace.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1981 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1982 (let* ((lim (or lim (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1983 (here lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1984 (hugenum (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1985 (narrow-to-region lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1986 (while (/= here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1987 (setq here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1988 (forward-comment hugenum))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1989 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1990
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1991 ;; This is the best we can do in Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1992 (defun vhdl-win-fsws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1993 ;; Forward skip syntactic whitespace for Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1994 (let ((lim (or lim (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1995 stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1996 (while (not stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1997 (skip-chars-forward " \t\n\r\f" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1998 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1999 ;; vhdl comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2000 ((looking-at "--") (end-of-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2001 ;; none of the above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2002 (t (setq stop t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2003 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2004
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2005 (and (memq 'Win-Emacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2006 (fset 'vhdl-forward-syntactic-ws 'vhdl-win-fsws))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2007
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2008 (defun vhdl-backward-syntactic-ws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2009 ;; Backward skip over syntactic whitespace.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2010 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2011 (let* ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2012 (here lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2013 (hugenum (- (point-max))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2014 (if (< lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2015 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2016 (narrow-to-region lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2017 (while (/= here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2018 (setq here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2019 (forward-comment hugenum)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2020 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2021 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2022
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2023 ;; This is the best we can do in Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2024 (defun vhdl-win-bsws (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2025 ;; Backward skip syntactic whitespace for Win-Emacs.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2026 (let ((lim (or lim (vhdl-point 'bod)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2027 stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2028 (while (not stop)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2029 (skip-chars-backward " \t\n\r\f" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2030 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2031 ;; vhdl comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2032 ((eq (vhdl-in-literal lim) 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2033 (skip-chars-backward "^-" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2034 (skip-chars-backward "-" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2035 (while (not (or (and (= (following-char) ?-)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2036 (= (char-after (1+ (point))) ?-))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2037 (<= (point) lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2038 (skip-chars-backward "^-" lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2039 (skip-chars-backward "-" lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2040 ;; none of the above
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2041 (t (setq stop t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2042 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2043
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2044 (and (memq 'Win-Emacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2045 (fset 'vhdl-backward-syntactic-ws 'vhdl-win-bsws))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2046
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2047 ;; Functions to help finding the correct indentation column:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2048
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2049 (defun vhdl-first-word (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2050 "If the keyword at POINT is at boi, then return (current-column) at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2051 that point, else nil."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2052 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2053 (and (goto-char point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2054 (eq (point) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2055 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2056
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2057 (defun vhdl-last-word (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2058 "If the keyword at POINT is at eoi, then return (current-column) at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2059 that point, else nil."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2060 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2061 (and (goto-char point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2062 (save-excursion (or (eq (progn (forward-sexp) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2063 (vhdl-point 'eoi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2064 (looking-at "\\s-*\\(--\\)?")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2065 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2066
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2067 ;; Core syntactic evaluation functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2068
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2069 (defconst vhdl-libunit-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2070 "\\b\\(architecture\\|configuration\\|entity\\|package\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2071
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2072 (defun vhdl-libunit-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2073 (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2074 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2075 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2076 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2077 (not (looking-at "is\\b[^_]")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2078 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2079 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2080 (and (not (looking-at "use\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2081 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2082 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2083 (vhdl-forward-syntactic-ws)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2084 (/= (following-char) ?:))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2085 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2086
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2087 (defconst vhdl-defun-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2088 "\\b\\(architecture\\|block\\|configuration\\|entity\\|package\\|process\\|procedure\\|function\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2089
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2090 (defun vhdl-defun-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2091 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2092 (if (looking-at "block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2093 ;; "block", "process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2094 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2095 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2096 (not (looking-at "end\\s-+\\w")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2097 ;; "architecture", "configuration", "entity",
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2098 ;; "package", "procedure", "function":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2099 t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2100
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2101 (defun vhdl-corresponding-defun ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2102 "If the word at the current position corresponds to a \"defun\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2103 keyword, then return a string that can be used to find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2104 corresponding \"begin\" keyword, else return nil."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2105 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2106 (and (looking-at vhdl-defun-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2107 (vhdl-defun-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2108 (if (looking-at "block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2109 ;; "block", "process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2110 (buffer-substring (match-beginning 0) (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2111 ;; "architecture", "configuration", "entity", "package",
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2112 ;; "procedure", "function":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2113 "is"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2114
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2115 (defconst vhdl-begin-fwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2116 "\\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
2117 "A regular expression for searching forward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2118 \"begin\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2119
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2120 (defconst vhdl-begin-bwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2121 "\\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
2122 "A regular expression for searching backward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2123 \"begin\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2124
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2125 (defun vhdl-begin-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2126 "Return t if we are looking at a real \"begin\" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2127 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2128 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
2129 the middle of an identifier that just happens to contain a \"begin\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2130 keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2131 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2132 ;; "[architecture|case|configuration|entity|package|
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2133 ;; procedure|function] ... is":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2134 ((and (looking-at "i")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2135 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2136 ;; Skip backward over first sexp (needed to skip over a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2137 ;; procedure interface list, and is harmless in other
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2138 ;; situations). Note that we need "return" in the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2139 ;; following search list so that we don't run into
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2140 ;; semicolons in the function interface list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2141 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2142 (let (foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2143 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2144 (re-search-backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2145 ";\\|\\b\\(architecture\\|case\\|configuration\\|entity\\|package\\|procedure\\|return\\|is\\|begin\\|process\\|block\\)\\b[^_]"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2146 lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2147 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2148 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2149 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2150 (setq foundp t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2151 (and (/= (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2152 (not (looking-at "is\\|begin\\|process\\|block")))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2153 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2154 ;; "begin", "then":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2155 ((looking-at "be\\|t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2156 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2157 ;; "else":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2158 ((and (looking-at "e")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2159 ;; make sure that the "else" isn't inside a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2160 ;; conditional signal assignment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2161 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2162 (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2163 (or (eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2164 (eq (point) lim))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2165 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2166 ;; "block", "generate", "loop", "process",
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2167 ;; "units", "record":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2168 ((and (looking-at "bl\\|[glpur]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2169 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2170 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2171 (not (looking-at "end\\s-+\\w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2172 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2173 ;; "component":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2174 ((and (looking-at "c")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2175 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2176 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2177 (not (looking-at "end\\s-+\\w")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2178 ;; look out for the dreaded entity class in an attribute
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2179 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2180 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2181 (/= (preceding-char) ?:)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2182 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2183 ;; "for" (inside configuration declaration):
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2184 ((and (looking-at "f")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2185 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2186 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2187 (not (looking-at "end\\s-+\\w")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2188 (vhdl-has-syntax 'configuration))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2189 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2190 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2191
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2192 (defun vhdl-corresponding-mid (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2193 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2194 ((looking-at "is\\|block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2195 "begin")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2196 ((looking-at "then")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2197 "<else>")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2198 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2199 "end")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2200
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2201 (defun vhdl-corresponding-end (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2202 "If the word at the current position corresponds to a \"begin\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2203 keyword, then return a vector containing enough information to find
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2204 the corresponding \"end\" keyword, else return nil. The keyword to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2205 search forward for is aref 0. The column in which the keyword must
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2206 appear is aref 1 or nil if any column is suitable.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2207 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
2208 of an identifier that just happens to contain a \"begin\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2209 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2210 (and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2211 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2212 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2213 (vhdl-begin-p lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2214 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2215 ;; "is", "generate", "loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2216 ((looking-at "[igl]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2217 (vector "end"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2218 (and (vhdl-last-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2219 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2220 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2221 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2222 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2223 (vhdl-first-word (point)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2224 ;; "begin", "else", "for":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2225 ((looking-at "be\\|[ef]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2226 (vector "end"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2227 (and (vhdl-last-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2228 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2229 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2230 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2231 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2232 (vhdl-first-word (point)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2233 ;; "component", "units", "record":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2234 ((looking-at "[cur]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2235 ;; The first end found will close the block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2236 (vector "end" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2237 ;; "block", "process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2238 ((looking-at "bl\\|p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2239 (vector "end"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2240 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2241 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2242 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2243 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2244 (vhdl-first-word (point))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2245 ;; "then":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2246 ((looking-at "t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2247 (vector "elsif\\|else\\|end\\s-+if"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2248 (and (vhdl-last-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2249 (or (vhdl-first-word (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2250 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2251 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2252 (vhdl-backward-skip-label lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2253 (vhdl-first-word (point)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2254 ))))
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-fwd-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 (defconst vhdl-end-bwd-re "\\b\\(end\\|else\\|elsif\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2259
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2260 (defun vhdl-end-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2261 "Return t if we are looking at a real \"end\" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2262 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2263 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
2264 the middle of an identifier that just happens to contain an \"end\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2265 keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2266 (or (not (looking-at "else"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2267 ;; make sure that the "else" isn't inside a conditional signal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2268 ;; assignment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2269 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2270 (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2271 (or (eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2272 (eq (point) lim)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2273
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2274 (defun vhdl-corresponding-begin (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2275 "If the word at the current position corresponds to an \"end\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2276 keyword, then return a vector containing enough information to find
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2277 the corresponding \"begin\" keyword, else return nil. The keyword to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2278 search backward for is aref 0. The column in which the keyword must
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2279 appear is aref 1 or nil if any column is suitable. The supplementary
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2280 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
2281 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
2282 the middle of a statement.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2283 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
2284 of an identifier that just happens to contain an \"end\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2285 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2286 (let (pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2287 (if (and (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2288 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2289 (vhdl-end-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2290 (if (looking-at "el")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2291 ;; "else", "elsif":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2292 (vector "if\\|elsif" (vhdl-first-word (point)) "then" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2293 ;; "end ...":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2294 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2295 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2296 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2297 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2298 ;; "end if":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2299 ((looking-at "if\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2300 (vector "else\\|elsif\\|if"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2301 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2302 "else\\|then" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2303 ;; "end component":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2304 ((looking-at "component\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2305 (vector (buffer-substring (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2306 (match-end 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2307 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2308 nil nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2309 ;; "end units", "end record":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2310 ((looking-at "\\(units\\|record\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2311 (vector (buffer-substring (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2312 (match-end 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2313 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2314 nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2315 ;; "end block", "end process":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2316 ((looking-at "\\(block\\|process\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2317 (vector "begin" (vhdl-first-word pos) nil nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2318 ;; "end case":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2319 ((looking-at "case\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2320 (vector "case" (vhdl-first-word pos) "is" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2321 ;; "end generate":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2322 ((looking-at "generate\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2323 (vector "generate\\|for\\|if"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2324 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2325 "generate" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2326 ;; "end loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2327 ((looking-at "loop\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2328 (vector "loop\\|while\\|for"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2329 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2330 "loop" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2331 ;; "end for" (inside configuration declaration):
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2332 ((looking-at "for\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2333 (vector "for" (vhdl-first-word pos) nil nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2334 ;; "end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2335 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2336 (vector "begin\\|architecture\\|configuration\\|entity\\|package\\|procedure\\|function"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2337 (vhdl-first-word pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2338 ;; return an alist of (statement . keyword) mappings
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2339 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2340 ;; "begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2341 ("begin" . nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2342 ;; "architecture ... is ... begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2343 ("architecture" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2344 ;; "configuration ... is ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2345 ("configuration" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2346 ;; "entity ... is ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2347 ("entity" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2348 ;; "package ... is ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2349 ("package" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2350 ;; "procedure ... is ... begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2351 ("procedure" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2352 ;; "function ... is ... begin ... end [id]":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2353 ("function" . "is")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2354 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2355 nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2356 ))) ; "end ..."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2357 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2358
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2359 (defconst vhdl-leader-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2360 "\\b\\(block\\|component\\|process\\|for\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2361
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2362 (defun vhdl-end-of-leader ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2363 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2364 (cond ((looking-at "block\\|process")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2365 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2366 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2367 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2368 (= (following-char) ?\())
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2369 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2370 (forward-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2371 (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2372 ((looking-at "component")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2373 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2374 (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2375 ((looking-at "for")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2376 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2377 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2378 (while (looking-at "[,:(]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2379 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2380 (skip-chars-forward " \t\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2381 (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2382 (t nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2383 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2384
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2385 (defconst vhdl-trailer-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2386 "\\b\\(is\\|then\\|generate\\|loop\\)\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2387
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2388 (defconst vhdl-statement-fwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2389 "\\b\\(if\\|for\\|while\\)\\b\\([^_]\\|\\'\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2390 "A regular expression for searching forward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2391 \"statement\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2392
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2393 (defconst vhdl-statement-bwd-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2394 "\\b\\(if\\|for\\|while\\)\\b[^_]"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2395 "A regular expression for searching backward that matches all known
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2396 \"statement\" keywords.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2397
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2398 (defun vhdl-statement-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2399 "Return t if we are looking at a real \"statement\" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2400 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2401 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
2402 the middle of an identifier that just happens to contain a \"statement\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2403 keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2404 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2405 ;; "for" ... "generate":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2406 ((and (looking-at "f")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2407 ;; Make sure it's the start of a parameter specification.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2408 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2409 (forward-sexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2410 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2411 (looking-at "in\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2412 ;; Make sure it's not an "end for".
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2413 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2414 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2415 (not (looking-at "end\\s-+\\w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2416 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2417 ;; "if" ... "then", "if" ... "generate", "if" ... "loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2418 ((and (looking-at "i")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2419 ;; Make sure it's not an "end if".
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2420 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2421 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2422 (not (looking-at "end\\s-+\\w"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2423 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2424 ;; "while" ... "loop":
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2425 ((looking-at "w")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2426 t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2427 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2428
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2429 (defconst vhdl-case-alternative-re "when[( \t\n][^;=>]+=>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2430 "Regexp describing a case statement alternative key.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2431
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2432 (defun vhdl-case-alternative-p (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2433 "Return t if we are looking at a real case alternative.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2434 Assumes that the caller will make sure that we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2435 vhdl-case-alternative-re, and are not inside a literal, and that
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2436 we are not in the middle of an identifier that just happens to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2437 contain a \"when\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2438 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2439 (let (foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2440 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2441 (re-search-backward ";\\|<=" lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2442 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2443 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2444 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2445 (setq foundp t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2446 (or (eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2447 (eq (point) lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2448 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2449
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2450 ;; Core syntactic movement functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2451
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2452 (defconst vhdl-b-t-b-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2453 (concat vhdl-begin-bwd-re "\\|" vhdl-end-bwd-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2454
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2455 (defun vhdl-backward-to-block (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2456 "Move backward to the previous \"begin\" or \"end\" keyword."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2457 (let (foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2458 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2459 (re-search-backward vhdl-b-t-b-re lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2460 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2461 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2462 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2463 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2464 ;; "begin" keyword:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2465 ((and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2466 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2467 (vhdl-begin-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2468 (setq foundp 'begin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2469 ;; "end" keyword:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2470 ((and (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2471 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2472 (vhdl-end-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2473 (setq foundp 'end))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2474 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2475 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2476 foundp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2477 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2478
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2479 (defun vhdl-forward-sexp (&optional count lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2480 "Move forward across one balanced expression (sexp).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2481 With COUNT, do it that many times."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2482 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2483 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2484 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2485 end-vec target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2486 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2487 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2488 ;; skip whitespace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2489 (skip-chars-forward " \t\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2490 ;; Check for an unbalanced "end" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2491 (if (and (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2492 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2493 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2494 (vhdl-end-p lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2495 (not (looking-at "else")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2496 (error
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2497 "Containing expression ends prematurely in vhdl-forward-sexp"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2498 ;; If the current keyword is a "begin" keyword, then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2499 ;; corresponding "end" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2500 (if (setq end-vec (vhdl-corresponding-end lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2501 (let (
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2502 ;; end-re is the statement keyword to search for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2503 (end-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2504 (concat "\\b\\(" (aref end-vec 0) "\\)\\b\\([^_]\\|\\'\\)"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2505 ;; column is either the statement keyword target column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2506 ;; or nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2507 (column (aref end-vec 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2508 (eol (vhdl-point 'eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2509 foundp literal placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2510 ;; Look for the statement keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2511 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2512 (re-search-forward end-re nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2513 (setq placeholder (match-end 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2514 (goto-char (match-beginning 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2515 ;; If we are in a literal, or not in the right target
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2516 ;; column and not on the same line as the begin, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2517 ;; try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2518 (if (or (and column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2519 (/= (current-indentation) column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2520 (> (point) eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2521 (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2522 (setq literal (vhdl-in-literal lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2523 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2524 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2525 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2526 ;; An "else" keyword corresponds to both the opening brace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2527 ;; of the following sexp and the closing brace of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2528 ;; previous sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2529 (if (not (looking-at "else"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2530 (goto-char placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2531 (setq foundp t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2532 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2533 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2534 (error "Unbalanced keywords in vhdl-forward-sexp"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2535 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2536 ;; If the current keyword is not a "begin" keyword, then just
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2537 ;; perform the normal forward-sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2538 (forward-sexp)
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 count (1- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2541 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2542 (setq target (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2543 (goto-char target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2544 nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2545
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2546 (defun vhdl-backward-sexp (&optional count lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2547 "Move backward across one balanced expression (sexp).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2548 With COUNT, do it that many times. LIM bounds any required backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2549 searches."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2550 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2551 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2552 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2553 begin-vec target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2554 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2555 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2556 ;; Perform the normal backward-sexp, unless we are looking at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2557 ;; "else" - an "else" keyword corresponds to both the opening brace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2558 ;; of the following sexp and the closing brace of the previous sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2559 (if (and (looking-at "else\\b\\([^_]\\|\\'\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2560 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2561 (not (vhdl-in-literal lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2562 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2563 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2564 (if (and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2565 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2566 (not (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2567 (vhdl-begin-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2568 (error "Containing expression ends prematurely in vhdl-backward-sexp")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2569 ;; If the current keyword is an "end" keyword, then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2570 ;; corresponding "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2571 (if (and (setq begin-vec (vhdl-corresponding-begin lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2572 (/= (preceding-char) ?_))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2573 (let (
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2574 ;; begin-re is the statement keyword to search for
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2575 (begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2576 (concat "\\b\\(" (aref begin-vec 0) "\\)\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2577 ;; column is either the statement keyword target column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2578 ;; or nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2579 (column (aref begin-vec 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2580 ;; internal-p controls where the statement keyword can
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2581 ;; be found.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2582 (internal-p (aref begin-vec 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2583 (last-backward (point)) last-forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2584 foundp literal keyword)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2585 ;; Look for the statement keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2586 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2587 (re-search-backward begin-re lim t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2588 (setq keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2589 (buffer-substring (match-beginning 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2590 (match-end 1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2591 ;; If we are in a literal or in the wrong column,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2592 ;; then try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2593 (if (or (and column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2594 (and (/= (current-indentation) column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2595 ;; possibly accept current-column as
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2596 ;; well as current-indentation.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2597 (or (not internal-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2598 (/= (current-column) column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2599 (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2600 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2601 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2602 ;; If there is a supplementary keyword, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2603 ;; search forward for it.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2604 (if (and (setq begin-re (aref begin-vec 2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2605 (or (not (listp begin-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2606 ;; If begin-re is an alist, then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2607 ;; element corresponding to the actual
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2608 ;; keyword that we found.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2609 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2610 (setq begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2611 (assoc keyword begin-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2612 (and begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2613 (setq begin-re (cdr begin-re))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2614 (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2615 (setq begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2616 (concat "\\b\\(" begin-re "\\)\\b[^_]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2617 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2618 (setq last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2619 ;; Look for the supplementary keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2620 ;; (bounded by the backward search start
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2621 ;; point).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2622 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2623 (re-search-forward begin-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2624 last-backward t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2625 (goto-char (match-beginning 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2626 ;; If we are in a literal, then try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2627 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2628 (setq literal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2629 (vhdl-in-literal last-forward)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2630 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2631 (goto-char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2632 (min (vhdl-point 'eol) last-backward))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2633 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2634 ;; We have found the supplementary keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2635 ;; Save the position of the keyword in foundp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2636 (setq foundp (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2637 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2638 foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2639 ;; If the supplementary keyword was found, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2640 ;; move point to the supplementary keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2641 (goto-char foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2642 ;; If there was no supplementary keyword, then
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2643 ;; point is already at the statement keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2644 (setq foundp t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2645 ) ; end of the search for the statement keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2646 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2647 (error "Unbalanced keywords in vhdl-backward-sexp"))
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 count (1- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2650 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2651 (setq target (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2652 (goto-char target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2653 nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2654
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2655 (defun vhdl-backward-up-list (&optional count limit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2656 "Move backward out of one level of blocks.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2657 With argument, do this that many times."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2658 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2659 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2660 target)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2661 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2662 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2663 (if (looking-at vhdl-defun-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2664 (error "Unbalanced blocks"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2665 (vhdl-backward-to-block limit)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2666 (setq count (1- count)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2667 (setq target (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2668 (goto-char target)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2669
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2670 (defun vhdl-end-of-defun (&optional count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2671 "Move forward to the end of a VHDL defun."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2672 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2673 (let ((case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2674 (vhdl-beginning-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2675 (if (not (looking-at "block\\|process"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2676 (re-search-forward "\\bis\\b"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2677 (vhdl-forward-sexp)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2678
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2679 (defun vhdl-mark-defun ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2680 "Put mark at end of this \"defun\", point at beginning."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2681 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2682 (let ((case-fold-search t))
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 (vhdl-beginning-of-defun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2685 (push-mark)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2686 (if (not (looking-at "block\\|process"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2687 (re-search-forward "\\bis\\b"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2688 (vhdl-forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2689 (exchange-point-and-mark)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2690
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2691 (defun vhdl-beginning-of-libunit ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2692 "Move backward to the beginning of a VHDL library unit.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2693 Returns the location of the corresponding begin keyword, unless search
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2694 stops due to beginning or end of buffer."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2695 ;; Note that if point is between the "libunit" keyword and the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2696 ;; corresponding "begin" keyword, then that libunit will not be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2697 ;; recognised, and the search will continue backwards. If point is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2698 ;; at the "begin" keyword, then the defun will be recognised. The
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2699 ;; returned point is at the first character of the "libunit" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2700 (let ((last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2701 (last-backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2702 ;; Just in case we are actually sitting on the "begin"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2703 ;; keyword, allow for the keyword and an extra character,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2704 ;; as this will be used when looking forward for the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2705 ;; "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2706 (save-excursion (forward-word 1) (1+ (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2707 foundp literal placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2708 ;; Find the "libunit" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2709 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2710 (re-search-backward vhdl-libunit-re nil 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2711 ;; 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
2712 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2713 (vhdl-in-literal (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2714 (not (vhdl-libunit-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2715 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2716 ;; Find the corresponding "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2717 (setq last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2718 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2719 (re-search-forward "\\bis\\b[^_]" last-backward t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2720 (setq placeholder (match-beginning 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2721 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2722 (setq literal (vhdl-in-literal last-forward)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2723 ;; It wasn't a real keyword, so keep searching.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2724 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2725 (goto-char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2726 (min (vhdl-point 'eol) last-backward))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2727 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2728 ;; We have found the begin keyword, loop will exit.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2729 (setq foundp placeholder)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2730 ;; Go back to the libunit keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2731 (goto-char last-forward)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2732 foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2733
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2734 (defun vhdl-beginning-of-defun (&optional count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2735 "Move backward to the beginning of a VHDL defun.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2736 With argument, do it that many times.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2737 Returns the location of the corresponding begin keyword, unless search
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2738 stops due to beginning or end of buffer."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2739 ;; Note that if point is between the "defun" keyword and the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2740 ;; corresponding "begin" keyword, then that defun will not be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2741 ;; recognised, and the search will continue backwards. If point is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2742 ;; at the "begin" keyword, then the defun will be recognised. The
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2743 ;; returned point is at the first character of the "defun" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2744 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2745 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2746 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2747 (last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2748 foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2749 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2750 (setq foundp nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2751 (goto-char last-forward)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2752 (let ((last-backward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2753 ;; Just in case we are actually sitting on the "begin"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2754 ;; keyword, allow for the keyword and an extra character,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2755 ;; as this will be used when looking forward for the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2756 ;; "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2757 (save-excursion (forward-word 1) (1+ (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2758 begin-string literal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2759 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2760 (re-search-backward vhdl-defun-re nil 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2761 ;; If we are in a literal, then try again.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2762 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2763 (vhdl-in-literal (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2764 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2765 (if (setq begin-string (vhdl-corresponding-defun))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2766 ;; This is a real defun keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2767 ;; Find the corresponding "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2768 ;; Look for the begin keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2769 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2770 ;; Save the search start point.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2771 (setq last-forward (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2772 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2773 (search-forward begin-string last-backward t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2774 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2775 (save-match-data
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2776 (setq literal (vhdl-in-literal last-forward))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2777 ;; It wasn't a real keyword, so keep searching.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2778 (if (eq literal 'comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2779 (goto-char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2780 (min (vhdl-point 'eol) last-backward))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2781 (forward-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2782 ;; We have found the begin keyword, loop will exit.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2783 (setq foundp (match-beginning 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2784 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2785 ;; Go back to the defun keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2786 (goto-char last-forward)) ; end search for begin 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 ) ; end of the search for the defun keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2789 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2790 (setq count (1- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2791 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2792 (vhdl-keep-region-active)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2793 foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2794
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2795 (defun vhdl-beginning-of-statement (&optional count lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2796 "Go to the beginning of the innermost VHDL statement.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2797 With prefix arg, go back N - 1 statements. If already at the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2798 beginning of a statement then go to the beginning of the preceding
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2799 one. If within a string or comment, or next to a comment (only
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2800 whitespace between), move by sentences instead of statements.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2801
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2802 When called from a program, this function takes 2 optional args: the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2803 prefix arg, and a buffer position limit which is the farthest back to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2804 search."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2805 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2806 (let ((count (or count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2807 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2808 (lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2809 (here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2810 state)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2811 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2812 (goto-char lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2813 (setq state (parse-partial-sexp (point) here nil nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2814 (if (and (interactive-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2815 (or (nth 3 state)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2816 (nth 4 state)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2817 (looking-at (concat "[ \t]*" comment-start-skip))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2818 (forward-sentence (- count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2819 (while (> count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2820 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2821 (setq count (1- count))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2822 ;; its possible we've been left up-buf of lim
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2823 (goto-char (max (point) lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2824 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2825 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2826
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2827 (defconst vhdl-e-o-s-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2828 (concat ";\\|" vhdl-begin-fwd-re "\\|" vhdl-statement-fwd-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2829
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2830 (defun vhdl-end-of-statement ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2831 "Very simple implementation."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2832 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2833 (re-search-forward vhdl-e-o-s-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2834
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2835 (defconst vhdl-b-o-s-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2836 (concat ";\\|\(\\|\)\\|\\bwhen\\b[^_]\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2837 vhdl-begin-bwd-re "\\|" vhdl-statement-bwd-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2838
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2839 (defun vhdl-beginning-of-statement-1 (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2840 ;; move to the start of the current statement, or the previous
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2841 ;; statement if already at the beginning of one.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2842 (let ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2843 (here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2844 (pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2845 donep)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2846 ;; go backwards one balanced expression, but be careful of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2847 ;; unbalanced paren being reached
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2848 (if (not (vhdl-safe (progn (backward-sexp) t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2849 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2850 (backward-up-list 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2851 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2852 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2853 (setq donep t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2854 (while (and (not donep)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2855 (not (bobp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2856 ;; look backwards for a statement boundary
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2857 (re-search-backward vhdl-b-o-s-re lim 'move))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2858 (if (or (= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2859 (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2860 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2861 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2862 ;; If we are looking at an open paren, then stop after it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2863 ((eq (following-char) ?\()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2864 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2865 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2866 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2867 ;; If we are looking at a close paren, then skip it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2868 ((eq (following-char) ?\))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2869 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2870 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2871 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2872 (if (< (point) lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2873 (progn (goto-char pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2874 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2875 (setq donep t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2876 ;; If we are looking at a semicolon, then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2877 ((eq (following-char) ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2878 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2879 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2880 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2881 (setq donep t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2882 ;; If we are looking at a "begin", then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2883 ((and (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2884 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2885 (vhdl-begin-p nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2886 ;; If it's a leader "begin", then find the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2887 ;; right place
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2888 (if (looking-at vhdl-leader-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2889 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2890 ;; set a default stop point at the begin
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2891 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2892 ;; is the start point inside the leader area ?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2893 (goto-char (vhdl-end-of-leader))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2894 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2895 (if (< (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2896 ;; start point was not inside leader area
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2897 ;; set stop point at word after leader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2898 (setq pos (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2899 (forward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2900 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2901 (setq pos (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2902 (goto-char pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2903 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2904 ;; If we are looking at a "statement", then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2905 ((and (looking-at vhdl-statement-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2906 (/= (preceding-char) ?_)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2907 (vhdl-statement-p nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2908 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2909 ;; If we are looking at a case alternative key, then stop
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2910 ((and (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2911 (vhdl-case-alternative-p lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2912 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2913 ;; set a default stop point at the when
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2914 (setq pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2915 ;; is the start point inside the case alternative key ?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2916 (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2917 (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2918 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2919 (if (< (point) here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2920 ;; start point was not inside the case alternative key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2921 ;; set stop point at word after case alternative keyleader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2922 (setq pos (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2923 (goto-char pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2924 (setq donep t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2925 ;; Bogus find, continue
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2926 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2927 (backward-char)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2928 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2929
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2930 ;; Defuns for calculating the current syntactic state:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2931
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2932 (defun vhdl-get-library-unit (bod placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2933 ;; If there is an enclosing library unit at bod, with it's \"begin\"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2934 ;; keyword at placeholder, then return the library unit type.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2935 (let ((here (vhdl-point 'bol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2936 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2937 (goto-char placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2938 (vhdl-safe (vhdl-forward-sexp 1 bod))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2939 (<= here (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2940 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2941 (goto-char bod)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2942 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2943 ((looking-at "e") 'entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2944 ((looking-at "a") 'architecture)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2945 ((looking-at "c") 'configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2946 ((looking-at "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2947 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2948 (goto-char bod)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2949 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2950 (vhdl-forward-syntactic-ws here)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2951 (if (looking-at "body\\b[^_]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2952 'package-body 'package))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2953 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2954
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2955 (defun vhdl-get-block-state (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2956 ;; Finds and records all the closest opens.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2957 ;; lim is the furthest back we need to search (it should be the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2958 ;; previous libunit keyword).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2959 (let ((here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2960 (lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2961 keyword sexp-start sexp-mid sexp-end
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2962 preceding-sexp containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2963 containing-begin containing-mid containing-paren)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2964 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2965 ;; Find the containing-paren, and use that as the limit
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2966 (if (setq containing-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2967 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2968 (narrow-to-region lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2969 (vhdl-safe (scan-lists (point) -1 1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2970 (setq lim containing-paren))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2971 ;; Look backwards for "begin" and "end" keywords.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2972 (while (and (> (point) lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2973 (not containing-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2974 (setq keyword (vhdl-backward-to-block lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2975 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2976 ((eq keyword 'begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2977 ;; Found a "begin" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2978 (setq sexp-start (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2979 (setq sexp-mid (vhdl-corresponding-mid lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2980 (setq sexp-end (vhdl-safe
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2981 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2982 (vhdl-forward-sexp 1 lim) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2983 (if (and sexp-end (<= sexp-end here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2984 ;; we want to record this sexp, but we only want to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2985 ;; record the last-most of any of them before here
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2986 (or preceding-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2987 (setq preceding-sexp sexp-start))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2988 ;; we're contained in this sexp so put sexp-start on
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2989 ;; front of list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2990 (setq containing-sexp sexp-start)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2991 (setq containing-mid sexp-mid)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2992 (setq containing-begin t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2993 ((eq keyword 'end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2994 ;; Found an "end" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2995 (forward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2996 (setq sexp-end (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2997 (setq sexp-mid nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2998 (setq sexp-start
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2999 (or (vhdl-safe (vhdl-backward-sexp 1 lim) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3000 (progn (backward-sexp) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3001 ;; we want to record this sexp, but we only want to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3002 ;; record the last-most of any of them before here
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3003 (or preceding-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3004 (setq preceding-sexp sexp-start)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3005 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3006 ;; Check if the containing-paren should be the containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3007 (if (and containing-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3008 (or (null containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3009 (< containing-sexp containing-paren)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3010 (setq containing-sexp containing-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3011 preceding-sexp nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3012 containing-begin nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3013 containing-mid nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3014 (vector containing-sexp preceding-sexp containing-begin containing-mid)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3015 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3016
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3017
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3018 (defconst vhdl-s-c-a-re
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3019 (concat vhdl-case-alternative-re "\\|" vhdl-case-header-key))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3020
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3021 (defun vhdl-skip-case-alternative (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3022 ;; skip forward over case/when bodies, with optional maximal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3023 ;; limit. if no next case alternative is found, nil is returned and point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3024 ;; is not moved
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3025 (let ((lim (or lim (point-max)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3026 (here (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3027 donep foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3028 (while (and (< (point) lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3029 (not donep))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3030 (if (and (re-search-forward vhdl-s-c-a-re lim 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3031 (save-match-data
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3032 (not (vhdl-in-literal)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3033 (/= (match-beginning 0) here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3034 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3035 (goto-char (match-beginning 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3036 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3037 ((and (looking-at "case")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3038 (re-search-forward "\\bis[^_]" lim t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3039 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3040 (vhdl-forward-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3041 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3042 (setq donep t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3043 foundp t))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3044 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3045 (goto-char here))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3046 foundp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3047
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3048 (defun vhdl-backward-skip-label (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3049 ;; skip backward over a label, with optional maximal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3050 ;; limit. if label is not found, nil is returned and point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3051 ;; is not moved
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3052 (let ((lim (or lim (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3053 placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3054 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3055 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3056 (and (eq (preceding-char) ?:)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3057 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3058 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3059 (setq placeholder (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3060 (looking-at vhdl-label-key))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3061 (goto-char placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3062 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3063
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3064 (defun vhdl-forward-skip-label (&optional lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3065 ;; skip forward over a label, with optional maximal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3066 ;; limit. if label is not found, nil is returned and point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3067 ;; is not moved
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3068 (let ((lim (or lim (point-max))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3069 (if (looking-at vhdl-label-key)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3070 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3071 (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3072 (vhdl-forward-syntactic-ws lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3073 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3074
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3075 (defun vhdl-get-syntactic-context ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3076 ;; guess the syntactic description of the current line of VHDL code.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3077 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3078 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3079 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3080 (let* ((indent-point (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3081 (case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3082 vec literal containing-sexp preceding-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3083 containing-begin containing-mid containing-leader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3084 char-before-ip char-after-ip begin-after-ip end-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3085 placeholder lim library-unit
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3086 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3087
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3088 ;; Reset the syntactic context
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3089 (setq vhdl-syntactic-context nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3090
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3091 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3092 ;; Move to the start of the previous library unit, and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3093 ;; record the position of the "begin" keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3094 (setq placeholder (vhdl-beginning-of-libunit))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3095 ;; The position of the "libunit" keyword gives us a gross
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3096 ;; limit point.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3097 (setq lim (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3098 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3099
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3100 ;; If there is a previous library unit, and we are enclosed by
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3101 ;; it, then set the syntax accordingly.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3102 (and placeholder
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3103 (setq library-unit (vhdl-get-library-unit lim placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3104 (vhdl-add-syntax library-unit lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3105
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3106 ;; Find the surrounding state.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3107 (if (setq vec (vhdl-get-block-state lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3108 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3109 (setq containing-sexp (aref vec 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3110 (setq preceding-sexp (aref vec 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3111 (setq containing-begin (aref vec 2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3112 (setq containing-mid (aref vec 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3113 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3114
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3115 ;; set the limit on the farthest back we need to search
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3116 (setq lim (if containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3117 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3118 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3119 ;; set containing-leader if required
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3120 (if (looking-at vhdl-leader-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3121 (setq containing-leader (vhdl-end-of-leader)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3122 (vhdl-point 'bol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3123 (point-min)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3124
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3125 ;; cache char before and after indent point, and move point to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3126 ;; the most likely position to perform the majority of tests
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3127 (goto-char indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3128 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3129 (setq literal (vhdl-in-literal lim))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3130 (setq char-after-ip (following-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3131 (setq begin-after-ip (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3132 (not literal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3133 (looking-at vhdl-begin-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3134 (vhdl-begin-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3135 (setq end-after-ip (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3136 (not literal)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3137 (looking-at vhdl-end-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3138 (vhdl-end-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3139 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3140 (setq char-before-ip (preceding-char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3141 (goto-char indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3142 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3143
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3144 ;; now figure out syntactic qualities of the current line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3145 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3146 ;; CASE 1: in a string or comment.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3147 ((memq literal '(string comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3148 (vhdl-add-syntax literal (vhdl-point 'bopl)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3149 ;; CASE 2: Line is at top level.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3150 ((null containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3151 ;; Find the point to which indentation will be relative
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3152 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3153 (if (null preceding-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3154 ;; CASE 2X.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3155 ;; no preceding-sexp -> use the preceding statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3156 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3157 ;; CASE 2X.2
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3158 ;; if there is a preceding-sexp then indent relative to it
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3159 (goto-char preceding-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3160 ;; if not at boi, then the block-opening keyword is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3161 ;; probably following a label, so we need a different
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3162 ;; relpos
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3163 (if (/= (point) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3164 ;; CASE 2X.3
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3165 (vhdl-beginning-of-statement-1 lim)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3166 ;; v-b-o-s could have left us at point-min
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3167 (and (bobp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3168 ;; CASE 2X.4
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3169 (vhdl-forward-syntactic-ws indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3170 (setq placeholder (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3171 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3172 ;; CASE 2A : we are looking at a block-open
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3173 (begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3174 (vhdl-add-syntax 'block-open placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3175 ;; CASE 2B: we are looking at a block-close
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3176 (end-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3177 (vhdl-add-syntax 'block-close placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3178 ;; CASE 2C: we are looking at a top-level statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3179 ((progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3180 (vhdl-backward-syntactic-ws lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3181 (or (bobp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3182 (= (preceding-char) ?\;)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3183 (vhdl-add-syntax 'statement placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3184 ;; CASE 2D: we are looking at a top-level statement-cont
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3185 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3186 (vhdl-beginning-of-statement-1 lim)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3187 ;; v-b-o-s could have left us at point-min
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3188 (and (bobp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3189 ;; CASE 2D.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3190 (vhdl-forward-syntactic-ws indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3191 (vhdl-add-syntax 'statement-cont (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3192 )) ; end CASE 2
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3193 ;; CASE 3: line is inside parentheses. Most likely we are
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3194 ;; either in a subprogram argument (interface) list, or a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3195 ;; continued expression containing parentheses.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3196 ((null containing-begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3197 (vhdl-backward-syntactic-ws containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3198 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3199 ;; CASE 3A: we are looking at the arglist closing paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3200 ((eq char-after-ip ?\))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3201 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3202 (vhdl-add-syntax 'arglist-close (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3203 ;; CASE 3B: we are looking at the first argument in an empty
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3204 ;; argument list.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3205 ((eq char-before-ip ?\()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3206 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3207 (vhdl-add-syntax 'arglist-intro (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3208 ;; CASE 3C: we are looking at an arglist continuation line,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3209 ;; but the preceding argument is on the same line as the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3210 ;; opening paren. This case includes multi-line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3211 ;; expression paren groupings.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3212 ((and (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3213 (goto-char (1+ containing-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3214 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3215 (not (eolp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3216 (not (looking-at "--")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3217 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3218 (vhdl-beginning-of-statement-1 containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3219 (skip-chars-backward " \t(")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3220 (<= (point) containing-sexp)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3221 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3222 (vhdl-add-syntax 'arglist-cont-nonempty (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3223 ;; CASE 3D: we are looking at just a normal arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3224 ;; continuation line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3225 (t (vhdl-beginning-of-statement-1 containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3226 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3227 (vhdl-add-syntax 'arglist-cont (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3228 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3229 ;; CASE 4: A block mid open
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3230 ((and begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3231 (looking-at containing-mid))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3232 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3233 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3234 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3235 ;; CASE 4.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3236 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3237 (vhdl-backward-skip-label (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3238 (vhdl-add-syntax 'block-open (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3239 ;; CASE 5: block close brace
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3240 (end-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3241 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3242 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3243 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3244 ;; CASE 5.1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3245 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3246 (vhdl-backward-skip-label (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3247 (vhdl-add-syntax 'block-close (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3248 ;; CASE 6: A continued statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3249 ((and (/= char-before-ip ?\;)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3250 ;; check it's not a trailer begin keyword, or a begin
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3251 ;; keyword immediately following a label.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3252 (not (and begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3253 (or (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3254 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3255 (vhdl-backward-skip-label containing-sexp)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3256 ;; check it's not a statement keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3257 (not (and (looking-at vhdl-statement-fwd-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3258 (vhdl-statement-p)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3259 ;; see if the b-o-s is before the indent point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3260 (> indent-point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3261 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3262 (vhdl-beginning-of-statement-1 containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3263 ;; If we ended up after a leader, then this will
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3264 ;; move us forward to the start of the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3265 ;; statement. Note that a containing sexp here is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3266 ;; always a keyword, not a paren, so this will
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3267 ;; have no effect if we hit the containing-sexp.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3268 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3269 (setq placeholder (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3270 ;; check it's not a block-intro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3271 (/= placeholder containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3272 ;; check it's not a case block-intro
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3273 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3274 (goto-char placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3275 (or (not (looking-at vhdl-case-alternative-re))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3276 (> (match-end 0) indent-point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3277 ;; Make placeholder skip a label, but only if it puts us
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3278 ;; before the indent point at the start of a line.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3279 (let ((new placeholder))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3280 (if (and (> indent-point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3281 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3282 (goto-char placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3283 (vhdl-forward-skip-label indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3284 (setq new (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3285 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3286 (goto-char new)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3287 (eq new (progn (back-to-indentation) (point)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3288 (setq placeholder new)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3289 (vhdl-add-syntax 'statement-cont placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3290 (if begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3291 (vhdl-add-syntax 'block-open)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3292 ;; Statement. But what kind?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3293 ;; CASE 7: A case alternative key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3294 ((and (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3295 (vhdl-case-alternative-p containing-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3296 ;; for a case alternative key, we set relpos to the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3297 ;; non-whitespace char on the line containing the "case"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3298 ;; keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3299 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3300 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3301 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3302 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3303 (vhdl-add-syntax 'case-alternative (vhdl-point 'boi)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3304 ;; CASE 8: statement catchall
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3305 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3306 ;; 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
3307 ;; the first statement in a block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3308 (if containing-leader
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3309 (goto-char containing-leader)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3310 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3311 ;; Note that a containing sexp here is always a keyword,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3312 ;; not a paren, so skip over the keyword.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3313 (forward-sexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3314 ;; move to the start of the first statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3315 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3316 (setq placeholder (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3317 ;; we want to ignore case alternatives keys when skipping forward
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3318 (let (incase-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3319 (while (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3320 (setq incase-p (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3321 ;; we also want to skip over the body of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3322 ;; case/when statement if that doesn't put us at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3323 ;; after the indent-point
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3324 (while (vhdl-skip-case-alternative indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3325 ;; set up the match end
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3326 (looking-at vhdl-case-alternative-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3327 (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3328 ;; move to the start of the first case alternative statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3329 (vhdl-forward-syntactic-ws indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3330 (setq placeholder (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3331 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3332 ;; CASE 8A: we saw a case/when statement so we must be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3333 ;; in a switch statement. find out if we are at the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3334 ;; statement just after a case alternative key
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3335 ((and incase-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3336 (= (point) indent-point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3337 ;; relpos is the "when" keyword
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3338 (vhdl-add-syntax 'statement-case-intro incase-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3339 ;; CASE 8B: any old statement
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3340 ((< (point) indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3341 ;; relpos is the first statement of the block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3342 (vhdl-add-syntax 'statement placeholder)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3343 (if begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3344 (vhdl-add-syntax 'block-open)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3345 ;; CASE 8C: first statement in a block
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3346 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3347 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3348 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3349 (if (looking-at vhdl-trailer-re)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3350 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3351 (vhdl-backward-skip-label (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3352 (vhdl-add-syntax 'statement-block-intro (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3353 (if begin-after-ip
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3354 (vhdl-add-syntax 'block-open)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3355 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3356 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3357
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3358 ;; now we need to look at any modifiers
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3359 (goto-char indent-point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3360 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3361 (if (looking-at "--")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3362 (vhdl-add-syntax 'comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3363 ;; return the syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3364 vhdl-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3365
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3366 ;; Standard indentation line-ups:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3367
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3368 (defun vhdl-lineup-arglist (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3369 ;; lineup the current arglist line with the arglist appearing just
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3370 ;; after the containing paren which starts the arglist.
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 (let* ((containing-sexp
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3373 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3374 ;; arglist-cont-nonempty gives relpos ==
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3375 ;; to boi of containing-sexp paren. This
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3376 ;; is good when offset is +, but bad
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3377 ;; when it is vhdl-lineup-arglist, so we
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3378 ;; have to special case a kludge here.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3379 (if (memq (car langelem) '(arglist-intro arglist-cont-nonempty))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3380 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3381 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3382 (backward-up-list 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3383 (skip-chars-forward " \t" (vhdl-point 'eol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3384 (goto-char (cdr langelem)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3385 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3386 (cs-curcol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3387 (goto-char (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3388 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3389 (if (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3390 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3391 (looking-at "[ \t]*)"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3392 (progn (goto-char (match-end 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3393 (backward-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3394 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3395 (vhdl-forward-syntactic-ws)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3396 (- (current-column) cs-curcol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3397 (goto-char containing-sexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3398 (or (eolp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3399 (let ((eol (vhdl-point 'eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3400 (here (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3401 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3402 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3403 (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3404 (vhdl-forward-syntactic-ws)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3405 (if (< (point) eol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3406 (goto-char here))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3407 (- (current-column) cs-curcol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3408 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3409
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3410 (defun vhdl-lineup-arglist-intro (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3411 ;; lineup an arglist-intro line to just after the open paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3412 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3413 (let ((cs-curcol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3414 (goto-char (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3415 (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3416 (ce-curcol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3417 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3418 (backward-up-list 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3419 (skip-chars-forward " \t" (vhdl-point 'eol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3420 (current-column))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3421 (- ce-curcol cs-curcol -1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3422
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3423 (defun vhdl-lineup-comment (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3424 ;; support old behavior for comment indentation. we look at
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3425 ;; vhdl-comment-only-line-offset to decide how to indent comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3426 ;; only-lines
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3427 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3428 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3429 ;; at or to the right of comment-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3430 (if (>= (current-column) comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3431 (vhdl-comment-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3432 ;; otherwise, indent as specified by vhdl-comment-only-line-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3433 (if (not (bolp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3434 (or (car-safe vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3435 vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3436 (or (cdr-safe vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3437 (car-safe vhdl-comment-only-line-offset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3438 -1000 ;jam it against the left side
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3439 )))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3440
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3441 (defun vhdl-lineup-statement-cont (langelem)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3442 ;; line up statement-cont after the assignment operator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3443 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3444 (let* ((relpos (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3445 (assignp (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3446 (goto-char (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3447 (and (re-search-forward "\\(<\\|:\\)="
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3448 (vhdl-point 'eol) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3449 (- (point) (vhdl-point 'boi)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3450 (curcol (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3451 (goto-char relpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3452 (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3453 foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3454 (while (and (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3455 (< (point) (vhdl-point 'eol)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3456 (re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3457 (if (vhdl-in-literal (cdr langelem))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3458 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3459 (if (= (preceding-char) ?\()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3460 ;; skip over any parenthesized expressions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3461 (goto-char (min (vhdl-point 'eol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3462 (scan-lists (point) 1 1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3463 ;; found an assignment operator (not at eol)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3464 (setq foundp (not (looking-at "\\s-*$"))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3465 (if (not foundp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3466 ;; there's no assignment operator on the line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3467 vhdl-basic-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3468 ;; calculate indentation column after assign and ws, unless
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3469 ;; our line contains an assignment operator
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3470 (if (not assignp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3471 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3472 (forward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3473 (skip-chars-forward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3474 (setq assignp 0)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3475 (- (current-column) assignp curcol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3476 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3477
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3478 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3479 ;; Indentation commands
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3480
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3481 (defun vhdl-tab (&optional pre-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3482 "If preceeding character is part of a word then dabbrev-expand,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3483 else if right of non whitespace on line then tab-to-tab-stop,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3484 else if last command was a tab or return then dedent one step,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3485 else indent `correctly'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3486 (interactive "*P")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3487 (cond ((= (char-syntax (preceding-char)) ?w)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3488 (let ((case-fold-search nil)) (dabbrev-expand pre-arg)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3489 ((> (current-column) (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3490 (tab-to-tab-stop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3491 ((and (or (eq last-command 'vhdl-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3492 (eq last-command 'vhdl-return))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3493 (/= 0 (current-indentation)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3494 (backward-delete-char-untabify vhdl-basic-offset nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3495 ((vhdl-indent-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3496 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3497 (setq this-command 'vhdl-tab)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3498 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3499
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3500 (defun vhdl-untab ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3501 "Delete backwards to previous tab stop."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3502 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3503 (backward-delete-char-untabify vhdl-basic-offset nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3504 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3505
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3506 (defun vhdl-return ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3507 "newline-and-indent or indent-new-comment-line if in comment and preceding
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3508 character is a space."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3509 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3510 (if (and (= (preceding-char) ? ) (vhdl-in-comment-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3511 (indent-new-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3512 (newline-and-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3513 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3514 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3515
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3516 (defun vhdl-indent-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3517 "Indent the current line as VHDL code. Returns the amount of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3518 indentation change."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3519 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3520 (let* ((syntax (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3521 (pos (- (point-max) (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3522 (indent (apply '+ (mapcar 'vhdl-get-offset syntax)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3523 (shift-amt (- (current-indentation) indent)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3524 (and vhdl-echo-syntactic-information-p
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3525 (message "syntax: %s, indent= %d" syntax indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3526 (if (zerop shift-amt)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3527 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3528 (delete-region (vhdl-point 'bol) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3529 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3530 (indent-to indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3531 (if (< (point) (vhdl-point 'boi))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3532 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3533 ;; If initial point was within line's indentation, position after
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3534 ;; the indentation. Else stay at same point in text.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3535 (if (> (- (point-max) pos) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3536 (goto-char (- (point-max) pos)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3537 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3538 (run-hooks 'vhdl-special-indent-hook)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3539 shift-amt))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3540
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3541 (defun vhdl-indent-buffer ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3542 "Indent whole buffer as VHDL code."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3543 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3544 (indent-region (point-min) (point-max) nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3545 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3546
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3547 (defun vhdl-indent-sexp (&optional endpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3548 "Indent each line of the list starting just after point.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3549 If optional arg ENDPOS is given, indent each line, stopping when
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3550 ENDPOS is encountered."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3551 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3552 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3553 (let ((beg (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3554 (end (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3555 (vhdl-forward-sexp nil endpos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3556 (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3557 (indent-region beg end nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3558
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3559 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3560 ;; Miscellaneous commands
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3561
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3562 (defun vhdl-show-syntactic-information ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3563 "Show syntactic information for current line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3564 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3565 (message "syntactic analysis: %s" (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3566 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3567
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3568 ;; Verification and regression functions:
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3569
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3570 (defun vhdl-regress-line (&optional arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3571 "Check syntactic information for current line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3572 (interactive "P")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3573 (let ((expected (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3574 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3575 (if (search-backward " -- ((" (vhdl-point 'bol) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3576 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3577 (forward-char 4)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3578 (read (current-buffer))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3579 (actual (vhdl-get-syntactic-context))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3580 (expurgated))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3581 ;; remove the library unit symbols
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3582 (mapcar
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3583 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3584 (lambda (elt)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3585 (if (memq (car elt) '(entity configuration package
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3586 package-body architecture))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3587 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3588 (setq expurgated (append expurgated (list elt))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3589 actual)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3590 (if (and (not arg) expected (listp expected))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3591 (if (not (equal expected expurgated))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3592 (error "Should be: %s, is: %s" expected expurgated))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3593 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3594 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3595 (if (not (looking-at "^\\s-*\\(--.*\\)?$"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3596 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3597 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3598 (if (search-backward " -- ((" (vhdl-point 'bol) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3599 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3600 (insert " -- ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3601 (insert (format "%s" expurgated)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3602 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3603
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3604
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3605 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3606 ;; Alignment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3607 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3608
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3609 (defvar vhdl-align-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3610 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3611 ;; after some keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3612 (vhdl-mode "\\<\\(alias\\|constant\\|signal\\|subtype\\|type\\|variable\\)[ \t]"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3613 "\\<\\(alias\\|constant\\|signal\\|subtype\\|type\\|variable\\)\\([ \t]+\\)" 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3614 ;; before ':'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3615 (vhdl-mode ":[^=]" "[^ \t]\\([ \t]*\\):[^=]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3616 ;; after ':'
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3617 (vhdl-mode ":[^=]" ":\\([ \t]*\\)[^=]" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3618 ;; after direction specifications
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3619 (vhdl-mode ":[ \t]*\\(in\\|out\\|inout\\|buffer\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3620 ":[ \t]*\\(in\\|out\\|inout\\|buffer\\)\\([ \t]+\\)" 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3621 ;; before "<=", "=>", and ":="
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 (vhdl-mode "=>" "[^ \t]\\([ \t]*\\)=>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3624 (vhdl-mode ":=" "[^ \t]\\([ \t]*\\):=" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3625 ;; after "<=", "=>", and ":="
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 (vhdl-mode "=>" "=>\\([ \t]*\\)" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3628 (vhdl-mode ":=" ":=\\([ \t]*\\)" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3629 ;; before some keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3630 (vhdl-mode "[ \t]after\\>" "[^ \t]\\([ \t]+\\)after\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3631 (vhdl-mode "[ \t]\\(fs\\|ps\\|ns\\|us\\|ms\\|sec\\|min\\|hr\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3632 "[^ \t]\\([ \t]+\\)\\(fs\\|ps\\|ns\\|us\\|ms\\|sec\\|min\\|hr\\)\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3633 (vhdl-mode "[ \t]when\\>" "[^ \t]\\([ \t]+\\)when\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3634 (vhdl-mode "[ \t]else\\>" "[^ \t]\\([ \t]+\\)else\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3635 (vhdl-mode "[ \t]is\\>" "[^ \t]\\([ \t]+\\)is\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3636 (vhdl-mode "[ \t]of\\>" "[^ \t]\\([ \t]+\\)of\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3637 (vhdl-mode "[ \t]use\\>" "[^ \t]\\([ \t]+\\)use\\>" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3638 ;; before comments (two steps required for correct insertion of two spaces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3639 (vhdl-mode "--" "[^ \t]\\([ \t]*\\)--" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3640 (vhdl-mode "--" "[^ \t][ \t]\\([ \t]*\\)--" 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3641 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3642 "The format of this alist is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3643 (MODES [or MODE] REGEXP ALIGN-PATTERN SUBEXP).
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3644 It is searched in order. If REGEXP is found anywhere in the first
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3645 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
3646 region. ALIGN-PATTERN must include the whitespace to be expanded or
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3647 contracted. It may also provide regexps for the text surrounding the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3648 whitespace. SUBEXP specifies which sub-expression of
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3649 ALIGN-PATTERN matches the white space to be expanded/contracted.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3650
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3651 (defvar vhdl-align-try-all-clauses t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3652 "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
3653 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
3654
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3655 (defun vhdl-align (begin end spacing &optional alignment-list quick)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3656 "Attempt to align a range of lines based on the content of the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3657 lines. The definition of 'alignment-list' determines the matching
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3658 order and the manner in which the lines are aligned. If ALIGNMENT-LIST
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3659 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
3660 indentation is done before aligning."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3661 (interactive "r\np")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3662 (if (not alignment-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3663 (setq alignment-list vhdl-align-alist))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3664 (if (not spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3665 (setq spacing 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3666 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3667 (let (bol indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3668 (goto-char end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3669 (setq end (point-marker))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3670 (goto-char begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3671 (setq bol
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3672 (setq begin (progn (beginning-of-line) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3673 (untabify bol end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3674 (if quick
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3675 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3676 (indent-region bol end nil))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3677 (let ((copy (copy-alist alignment-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3678 (while copy
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3679 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3680 (goto-char begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3681 (let (element
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3682 (eol (save-excursion (progn (end-of-line) (point)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3683 (setq element (nth 0 copy))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3684 (if (and (or (and (listp (car element))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3685 (memq major-mode (car element)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3686 (eq major-mode (car element)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3687 (or vhdl-align-try-all-clauses
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3688 (re-search-forward (car (cdr element)) eol t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3689 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3690 (vhdl-align-region begin end (car (cdr (cdr element)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3691 (car (cdr (cdr (cdr element)))) spacing)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3692 (setq copy (cdr copy)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3693
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3694 (defun vhdl-align-region (begin end match &optional substr spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3695 "Align a range of lines from BEGIN to END. The regular expression
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3696 MATCH must match exactly one fields: the whitespace to be
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3697 contracted/expanded. The alignment column will equal the
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3698 rightmost column of the widest whitespace block. SPACING is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3699 the amount of extra spaces to add to the calculated maximum required.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3700 SPACING defaults to 1 so that at least one space is inserted after
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3701 the token in MATCH."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3702 (if (not spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3703 (setq spacing 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3704 (if (not substr)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3705 (setq substr 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3706 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3707 (let (distance (max 0) (lines 0) bol eol width)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3708 ;; Determine the greatest whitespace distance to the alignment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3709 ;; character
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3710 (goto-char begin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3711 (setq eol (progn (end-of-line) (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3712 bol (setq begin (progn (beginning-of-line) (point))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3713 (while (< bol end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3714 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3715 (if (re-search-forward match eol t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3716 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3717 (setq distance (- (match-beginning substr) bol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3718 (if (> distance max)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3719 (setq max distance)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3720 (forward-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3721 (setq bol (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3722 eol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3723 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3724 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3725 (setq lines (1+ lines)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3726 ;; Now insert enough maxs to push each assignment operator to
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3727 ;; the same column. We need to use 'lines' as a counter, since
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3728 ;; the location of the mark may change
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3729 (goto-char (setq bol begin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3730 (setq eol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3731 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3732 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3733 (while (> lines 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3734 (if (re-search-forward match eol t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3735 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3736 (setq width (- (match-end substr) (match-beginning substr)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3737 (setq distance (- (match-beginning substr) bol))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3738 (goto-char (match-beginning substr))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3739 (delete-char width)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3740 (insert-char ? (+ (- max distance) spacing))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3741 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3742 (forward-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3743 (setq bol (point)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3744 eol (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3745 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3746 (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3747 (setq lines (1- lines))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3748 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3749
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3750 (defun vhdl-align-comment-region (begin end spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3751 "Aligns inline comments within a region relative to first comment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3752 (interactive "r\nP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3753 (vhdl-align begin end (or spacing 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3754 `((vhdl-mode "--" "[^ \t]\\([ \t]*\\)--" 1)) t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3755
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3756 (defun vhdl-align-noindent-region (begin end spacing)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3757 "Align without indentation."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3758 (interactive "r\nP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3759 (vhdl-align begin end spacing nil t)
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
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3763 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3764 ;; VHDL electrification
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3765 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3766
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3767 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3768 ;; Stuttering
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3769
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3770 (defun vhdl-stutter-mode-caps (count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3771 "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
3772 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3773 (if vhdl-stutter-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3774 (if (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3775 (= (preceding-char) last-input-char) ; doubled
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3776 (or (= (point) 2) ; beginning of buffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3777 (/= (char-syntax (char-after (- (point) 2))) ?w) ;not mid-word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3778 (< (char-after (- (point) 2)) ?A))) ;alfa-numeric
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3779 (progn (delete-char -1) (insert-char (- last-input-char 32) count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3780 (self-insert-command count))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3781 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3782 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3783
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3784 (defun vhdl-stutter-mode-close-bracket (count) " ']' --> ')', ')]' --> ']'"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3785 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3786 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3787 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3788 (if (= (preceding-char) 41) ; close-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3789 (progn (delete-char -1) (insert-char 93 1)) ; close-bracket
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3790 (insert-char 41 1) ; close-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3791 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3792 (blink-matching-open))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3793 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3794 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3795
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3796 (defun vhdl-stutter-mode-semicolon (count) " ';;' --> ' : ', ': ;' --> ' := '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3797 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3798 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3799 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3800 (cond ((= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3801 (progn (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3802 (if (not (eq (preceding-char) ? )) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3803 (insert ": ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3804 ((and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3805 (eq last-command 'vhdl-stutter-mode-colon) (= (preceding-char) ? ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3806 (progn (delete-char -1) (insert "= ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3807 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3808 (insert-char 59 1)) ; semi-colon
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3809 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3810 (setq this-command 'vhdl-stutter-mode-colon))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3811 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3812 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3813
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3814 (defun vhdl-stutter-mode-open-bracket (count) " '[' --> '(', '([' --> '['"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3815 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3816 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3817 (if (= (preceding-char) 40) ; open-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3818 (progn (delete-char -1) (insert-char 91 1)) ; open-bracket
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3819 (insert-char 40 1)) ; open-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3820 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3821 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3822
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3823 (defun vhdl-stutter-mode-quote (count) " '' --> \""
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3824 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3825 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3826 (if (= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3827 (progn (delete-backward-char 1) (insert-char 34 1)) ; double-quote
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3828 (insert-char 39 1)) ; single-quote
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3829 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3830 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3831
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3832 (defun vhdl-stutter-mode-comma (count) " ',,' --> ' <= '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3833 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3834 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3835 (cond ((= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3836 (progn (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3837 (if (not (eq (preceding-char) ? )) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3838 (insert "<= ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3839 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3840 (insert-char 44 1))) ; comma
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3841 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3842 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3843
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3844 (defun vhdl-stutter-mode-period (count) " '..' --> ' => '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3845 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3846 (if (and vhdl-stutter-mode (= count 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3847 (cond ((= (preceding-char) last-input-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3848 (progn (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3849 (if (not (eq (preceding-char) ? )) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3850 (insert "=> ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3851 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3852 (insert-char 46 1))) ; period
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3853 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3854 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3855
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3856 (defun vhdl-paired-parens ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3857 "Insert a pair of round parentheses, placing point between them."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3858 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3859 (insert "()")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3860 (backward-char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3861 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3862
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3863 (defun vhdl-stutter-mode-dash (count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3864 "-- starts a comment, --- draws a horizontal line,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3865 ---- starts a display comment"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3866 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3867 (if vhdl-stutter-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3868 (cond ((and abbrev-start-location (= abbrev-start-location (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3869 (setq abbrev-start-location nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3870 (goto-char last-abbrev-location)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3871 (beginning-of-line nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3872 (vhdl-display-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3873 ((/= (preceding-char) ?-) ; standard dash (minus)
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 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3876 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3877 (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
3878 (let ((next-input (read-char)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3879 (if (= next-input ?-) ; triple dash
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3880 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3881 (vhdl-display-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3882 (message
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3883 "Enter - for display comment, else continue with coding")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3884 (let ((next-input (read-char)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3885 (if (= next-input ?-) ; four dashes
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3886 (vhdl-display-comment t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3887 (setq unread-command-events ;pushback the char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3888 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3889 (vhdl-character-to-event-hack next-input)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3890 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3891 (setq unread-command-events ;pushback the char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3892 (list (vhdl-character-to-event-hack next-input)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3893 (vhdl-inline-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3894 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3895 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3896 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3897
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3898 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3899 ;; VHDL templates
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3900
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3901 (defun vhdl-alias ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3902 "Insert alias declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3903 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3904 (vhdl-insert-keyword "ALIAS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3905 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3906 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3907 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3908 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3909 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3910 (vhdl-field "name" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3911 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3912 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3913
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3914 (defun vhdl-architecture ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3915 "Insert architecture template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3916 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3917 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3918 (vhdl-architecture-name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3919 (position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3920 (entity-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3921 (string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3922 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3923 (vhdl-insert-keyword "ARCHITECTURE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3924 (if (equal (setq vhdl-architecture-name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3925 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3926 (vhdl-insert-keyword " OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3927 (setq position (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3928 (setq entity-exists
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3929 (re-search-backward "entity \\(\\(\\w\\|\\s_\\)+\\) is" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3930 (setq string (match-string 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3931 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3932 (if (and entity-exists (not (equal string "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3933 (insert string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3934 (vhdl-field "entity name"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3935 (vhdl-insert-keyword " IS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3936 (vhdl-begin-end (cons vhdl-architecture-name margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3937 (vhdl-block-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3938 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3939
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3940
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3941 (defun vhdl-array ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3942 "Insert array type definition."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3943 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3944 (vhdl-insert-keyword "ARRAY (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3945 (if (equal (vhdl-field "range") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3946 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3947 (vhdl-insert-keyword ") OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3948 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3949 (vhdl-insert-keyword ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3950 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3951
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3952 (defun vhdl-assert ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3953 "Inserts a assertion statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3954 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3955 (vhdl-insert-keyword "ASSERT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3956 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3957 (if (equal (vhdl-field "condition (negated)") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3958 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3959 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3960 (vhdl-insert-keyword " REPORT \"")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3961 (vhdl-field "string-expression" "\" ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3962 (vhdl-insert-keyword "SEVERITY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3963 (if (equal (vhdl-field "[note | warning | error | failure]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3964 (delete-char -10))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3965 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3966 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3967
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3968 (defun vhdl-attribute ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3969 "Inserts an attribute declaration or specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3970 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3971 (vhdl-insert-keyword "ATTRIBUTE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3972 (if (y-or-n-p "declaration (or specification)? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3973 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3974 (vhdl-field "name" " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3975 (vhdl-field "type" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3976 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3977 (vhdl-field "name")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3978 (vhdl-insert-keyword " OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3979 (vhdl-field "entity name" " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3980 (vhdl-field "entity class")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3981 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3982 (vhdl-field "expression" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3983 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3984
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3985 (defun vhdl-block ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3986 "Insert a block template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3987 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3988 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3989 (vhdl-insert-keyword " : BLOCK ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3990 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3991 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3992 (name (vhdl-field "label")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3993 (if (equal name "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3994 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3995 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3996 (insert "(")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3997 (if (equal (vhdl-field "[guard expression]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3998 (delete-char -2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3999 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4000 (vhdl-begin-end (cons (concat (vhdl-case-keyword "BLOCK ") name) margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4001 (vhdl-block-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4002 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4003
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4004 (defun vhdl-block-configuration ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4005 "Insert a block configuration statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4006 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4007 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4008 (vhdl-insert-keyword "FOR ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4009 (if (equal (setq name (vhdl-field "block specification")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4010 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4011 (vhdl-insert-keyword "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4012 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4013 (vhdl-insert-keyword "END FOR;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4014 (end-of-line 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4015 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4016 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4017
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4018 (defun vhdl-case ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4019 "Inserts a case statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4020 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4021 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4022 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4023 (vhdl-insert-keyword "CASE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4024 (if (equal (setq name (vhdl-field "expression")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4025 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4026 (vhdl-insert-keyword " IS\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4027 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4028 (vhdl-insert-keyword "END CASE;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4029 ; (if vhdl-self-insert-comments (insert " -- " name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4030 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4031 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4032 (vhdl-insert-keyword "WHEN => ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4033 (backward-char 4)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4034 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4035
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4036 (defun vhdl-component ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4037 "Inserts a component declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4038 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4039 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4040 (vhdl-insert-keyword "COMPONENT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4041 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4042 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4043 (insert "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4044 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4045 (vhdl-insert-keyword "END COMPONENT;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4046 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4047 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4048 (vhdl-insert-keyword "GENERIC (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4049 (vhdl-get-generic t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4050 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4051 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4052 (vhdl-insert-keyword "PORT (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4053 (vhdl-get-port t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4054 (forward-line 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4055 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4056
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4057 (defun vhdl-component-configuration ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4058 "Inserts a component configuration (uses `vhdl-configuration-spec' since
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4059 these are almost equivalent)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4060 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4061 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4062 (vhdl-configuration-spec)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4063 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4064 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4065 (vhdl-insert-keyword "END FOR;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4066 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4067
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4068 (defun vhdl-component-instance ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4069 "Inserts a component instantiation statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4070 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4071 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4072 (if (equal (vhdl-field "instance label") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4073 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4074 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4075 (vhdl-field "component name" "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4076 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4077 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4078 (vhdl-insert-keyword "GENERIC MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4079 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4080 (progn (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4081 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4082 (insert ")\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4083 (indent-to (+ margin vhdl-basic-offset))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4084 (vhdl-insert-keyword "PORT MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4085 (vhdl-field "association list" ");")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4086 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4087
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4088 (defun vhdl-concurrent-signal-assignment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4089 "Inserts a concurrent signal assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4090 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4091 (if (equal (vhdl-field "target signal") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4092 nil
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 ; (if (not (equal (vhdl-field "[GUARDED] [TRANSPORT]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4095 ; (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4096 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4097 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4098 (vhdl-field "waveform")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4099 (vhdl-insert-keyword " WHEN ")
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 (while (not (equal (vhdl-field "[condition]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4102 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4103 (vhdl-insert-keyword " ELSE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4104 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4105 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4106 (vhdl-field "waveform")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4107 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4108 (if vhdl-conditions-in-parenthesis (insert "(")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4109 (delete-char -6)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4110 (if vhdl-conditions-in-parenthesis (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4111 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4112 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4113 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4114
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4115 (defun vhdl-configuration ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4116 "Inserts a configuration specification if within an architecture,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4117 a block or component configuration if within a configuration declaration,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4118 a configuration declaration if not within a design unit."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4119 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4120 (cond ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'architecture)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4121 (vhdl-configuration-spec))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4122 ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4123 (if (y-or-n-p "block configuration (or component configuration)? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4124 (vhdl-block-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4125 (vhdl-component-configuration)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4126 (t (vhdl-configuration-decl)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4127 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4128
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4129 (defun vhdl-configuration-spec ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4130 "Inserts a configuration specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4131 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4132 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4133 (vhdl-insert-keyword "FOR ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4134 (if (equal (vhdl-field "(component names | ALL)" " : ") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4135 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4136 (vhdl-field "component type" "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4137 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4138 (vhdl-insert-keyword "USE ENTITY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4139 (vhdl-field "library name" ".")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4140 (vhdl-field "entity name" "(")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4141 (if (equal (vhdl-field "[architecture name]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4142 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4143 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4144 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4145 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4146 (vhdl-insert-keyword "GENERIC MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4147 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4148 (progn (kill-line -0)
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 (insert ")\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4151 (indent-to (+ margin vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4152 (vhdl-insert-keyword "PORT MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4153 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4154 (progn (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4155 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4156 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4157 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4158 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4159
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4160 (defun vhdl-configuration-decl ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4161 "Inserts a configuration declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4162 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4163 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4164 (position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4165 (entity-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4166 (string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4167 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4168 (vhdl-insert-keyword "CONFIGURATION ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4169 (if (equal (setq name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4170 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4171 (vhdl-insert-keyword " OF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4172 (setq position (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4173 (setq entity-exists
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4174 (re-search-backward "entity \\(\\(\\w\\|\\s_\\)*\\) is" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4175 (setq string (match-string 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4176 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4177 (if (and entity-exists (not (equal string "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4178 (insert string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4179 (vhdl-field "entity name"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4180 (vhdl-insert-keyword " IS\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4181 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4182 (vhdl-insert-keyword "END ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4183 (insert name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4184 (end-of-line 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4185 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4186 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4187
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4188 (defun vhdl-constant ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4189 "Inserts a constant declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4190 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4191 (vhdl-insert-keyword "CONSTANT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4192 (let ((in-arglist (string-match "arglist"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4193 (format "%s" (car (car (vhdl-get-syntactic-context)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4194 (if (not in-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4195 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4196 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4197 (setq in-arglist (looking-at ".*("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4198 (goto-char opoint)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4199 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4200 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4201 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4202 (if in-arglist (vhdl-insert-keyword "IN "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4203 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4204 (if in-arglist
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 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4207 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4208 (if (equal (vhdl-field "[initialization]" ";") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4209 (progn (goto-char position) (kill-line) (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4210 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4211 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4212
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4213 (defun vhdl-default ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4214 "Insert nothing."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4215 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4216 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4217 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4218 (backward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4219 (vhdl-case-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4220 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4221 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4222
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4223 (defun vhdl-default-indent ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4224 "Insert nothing and indent."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4225 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4226 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4227 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4228 (backward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4229 (vhdl-case-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4230 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4231 (vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4232 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4233
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4234 (defun vhdl-disconnect ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4235 "Insert a disconnect statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4236 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4237 (vhdl-insert-keyword "DISCONNECT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4238 (if (equal (vhdl-field "guarded signal specification") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4239 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4240 (vhdl-insert-keyword " AFTER ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4241 (vhdl-field "time expression" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4242 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4243
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4244 (defun vhdl-else ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4245 "Insert an else statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4246 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4247 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4248 (vhdl-insert-keyword "ELSE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4249 (if (not (equal 'block-close (car (car (vhdl-get-syntactic-context)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4250 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4251 (vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4252 (setq margin (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4253 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4254 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4255 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4256
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4257 (defun vhdl-elsif ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4258 "Insert an elsif statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4259 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4260 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4261 (vhdl-insert-keyword "ELSIF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4262 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4263 (if (equal (vhdl-field "condition") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4264 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4265 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4266 (vhdl-indent-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4267 (setq margin (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4268 (vhdl-insert-keyword " THEN\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4269 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4270 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4271
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4272 (defun vhdl-entity ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4273 "Insert an entity template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4274 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4275 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4276 (vhdl-entity-name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4277 (vhdl-insert-keyword "ENTITY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4278 (if (equal (setq vhdl-entity-name (vhdl-field "entity name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4279 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4280 (vhdl-insert-keyword " IS\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4281 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4282 (vhdl-insert-keyword "END ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4283 (insert vhdl-entity-name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4284 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4285 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4286 (vhdl-entity-body)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4287 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4288
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4289 (defun vhdl-entity-body ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4290 "Insert an entity body."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4291 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4292 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4293 (if vhdl-additional-empty-lines (insert "\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4294 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4295 (vhdl-insert-keyword "GENERIC (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4296 (if (vhdl-get-generic t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4297 (if vhdl-additional-empty-lines (insert "\n")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4298 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4299 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4300 (vhdl-insert-keyword "PORT (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4301 (if (vhdl-get-port t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4302 (if vhdl-additional-empty-lines (insert "\n")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4303 (end-of-line 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4304 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4305
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4306 (defun vhdl-exit ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4307 "Insert an exit statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4308 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4309 (vhdl-insert-keyword "EXIT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4310 (if (string-equal (vhdl-field "[loop label]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4311 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4312 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4313 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4314 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4315 (if (equal (vhdl-field "[condition]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4316 (progn (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4317 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4318 (if vhdl-conditions-in-parenthesis (insert ")"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4319 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4320 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4321
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4322 (defun vhdl-for ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4323 "Inserts a block or component configuration if within a configuration
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4324 declaration, a for loop otherwise."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4325 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4326 (if (equal (car (car (cdr (vhdl-get-syntactic-context)))) 'configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4327 (if (y-or-n-p "block configuration (or component configuration)? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4328 (vhdl-block-configuration)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4329 (vhdl-component-configuration))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4330 (vhdl-for-loop)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4331
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4332 (defun vhdl-for-loop ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4333 "Insert a for loop template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4334 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4335 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4336 (vhdl-insert-keyword " : FOR ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4337 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4338 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4339 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4340 (named (not (string-equal name "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4341 (index))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4342 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4343 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4344 (if (equal (setq index (vhdl-field "loop variable")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4345 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4346 (vhdl-insert-keyword " IN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4347 (vhdl-field "range")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4348 (vhdl-insert-keyword " LOOP\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4349 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4350 (vhdl-insert-keyword "END LOOP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4351 (if named (insert " " name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4352 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4353 (if vhdl-self-insert-comments (insert " -- " index)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4354 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4355 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4356 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4357
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4358 (defun vhdl-function ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4359 "Insert function specification or body template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4360 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4361 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4362 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4363 (vhdl-insert-keyword "FUNCTION ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4364 (if (equal (setq name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4365 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4366 (vhdl-get-arg-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4367 (vhdl-insert-keyword " RETURN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4368 (vhdl-field "type" " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4369 (if (y-or-n-p "insert body? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4370 (progn (vhdl-insert-keyword "IS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4371 (vhdl-begin-end (cons name margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4372 (vhdl-block-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4373 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4374 (insert ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4375 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4376 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4377
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4378 (defun vhdl-generate ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4379 "Insert a generate template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4380 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4381 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4382 (vhdl-insert-keyword " GENERATE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4383 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4384 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4385 (label (vhdl-field "label"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4386 (string))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4387 (if (equal label "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4388 (progn (undo 0) (insert " "))
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 (setq string (vhdl-field "(FOR | IF)"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4391 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4392 (if (equal (upcase string) "IF")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4393 (progn
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 "condition")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4396 (if vhdl-conditions-in-parenthesis (insert ")")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4397 (vhdl-field "loop variable")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4398 (vhdl-insert-keyword " IN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4399 (vhdl-field "range"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4400 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4401 (insert "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4402 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4403 (vhdl-insert-keyword "END GENERATE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4404 (insert label ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4405 (end-of-line 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4406 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4407 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4408
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4409 (defun vhdl-generic ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4410 "Insert generic declaration, or generic map in instantiation statements."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4411 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4412 (vhdl-insert-keyword "GENERIC (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4413 (cond ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4414 (vhdl-get-generic nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4415 ((or (equal 'statement-cont (car (car (vhdl-get-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4416 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4417 (and (backward-word 2) (skip-chars-backward " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4418 (eq (preceding-char) ?:))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4419 (delete-char -1) (vhdl-map))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4420 (t (vhdl-get-generic nil t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4421
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4422 (defun vhdl-header ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4423 "Insert a VHDL file header."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4424 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4425 (let (eot)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4426 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4427 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4428 (widen)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4429 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4430 (if vhdl-header-file
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4431 (setq eot (car (cdr (insert-file-contents vhdl-header-file))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4432 ; insert default header
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4433 (insert "\
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4434 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4435 -- Title : <title string>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4436 -- Project : <project string>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4437 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4438 -- File : <filename>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4439 -- Author : <author>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4440 -- Created : <date>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4441 -- Last modified : <date>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4442 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4443 -- Description :
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4444 -- <cursor>
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4445 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4446 -- Modification history :
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4447 -- <date> : created
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4448 -------------------------------------------------------------------------------
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4449
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4450 ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4451 (setq eot (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4452 (narrow-to-region (point-min) eot)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4453 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4454 (while (search-forward "<filename>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4455 (replace-match (buffer-name) t t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4456 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4457 (while (search-forward "<author>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4458 (replace-match "" t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4459 (insert (user-full-name) " <" user-mail-address ">"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4460 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4461 ;; Replace <RCS> with $, so that RCS for the source is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4462 ;; not over-enthusiastic with replacements
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4463 (while (search-forward "<RCS>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4464 (replace-match "$" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4465 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4466 (while (search-forward "<date>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4467 (replace-match "" t t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4468 (vhdl-insert-date))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4469 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4470 (let (string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4471 (while (re-search-forward "<\\(\\w*\\) string>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4472 (setq string (read-string (concat (match-string 1) ": ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4473 (replace-match string t t)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4474 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4475 (if (search-forward "<cursor>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4476 (replace-match "" t t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4477
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4478 (defun vhdl-if ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4479 "Insert an if statement template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4480 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4481 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4482 (vhdl-insert-keyword "IF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4483 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4484 (if (equal (vhdl-field "condition") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4485 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4486 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4487 (vhdl-insert-keyword " THEN\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4488 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4489 (vhdl-insert-keyword "END IF;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4490 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4491 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4492 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4493
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4494 (defun vhdl-library ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4495 "Insert a library specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4496 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4497 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4498 (lib-name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4499 (vhdl-insert-keyword "LIBRARY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4500 (if (equal (setq lib-name (vhdl-field "library name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4501 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4502 (insert ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4503 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4504 (vhdl-insert-keyword "USE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4505 (insert lib-name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4506 (vhdl-insert-keyword "..ALL;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4507 (backward-char 5)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4508 (if (equal (vhdl-field "package name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4509 (progn (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4510 (end-of-line -0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4511 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4512 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4513
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4514 (defun vhdl-loop ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4515 "Insert a loop template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4516 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4517 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4518 (vhdl-insert-keyword " : LOOP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4519 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4520 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4521 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4522 (named (not (string-equal name ""))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4523 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4524 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4525 (insert "\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4526 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4527 (vhdl-insert-keyword "END LOOP")
21466
98b189f8975f (vhdl-loop, vhdl-while-loop): Add backslash.
Karl Heuer <kwzh@gnu.org>
parents: 21446
diff changeset
4528 (insert (if named (concat " " name ";") ?\;))
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4529 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4530 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4531 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4532
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4533 (defun vhdl-map ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4534 "Insert a map specification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4535 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4536 (vhdl-insert-keyword "MAP (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4537 (if (equal (vhdl-field "[association list]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4538 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4539 (insert ")")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4540 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4541
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4542 (defun vhdl-modify ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4543 "Actualize modification date."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4544 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4545 (goto-char (point-min))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4546 (if (search-forward vhdl-modify-date-prefix-string nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4547 (progn (kill-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4548 (vhdl-insert-date))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4549 (message (concat "Modification date prefix string \""
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4550 vhdl-modify-date-prefix-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4551 "\" not found!"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4552 (beep)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4553
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4554 (defun vhdl-next ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4555 "Inserts a next statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4556 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4557 (vhdl-insert-keyword "NEXT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4558 (if (string-equal (vhdl-field "[loop label]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4559 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4560 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4561 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4562 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4563 (if (equal (vhdl-field "[condition]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4564 (progn (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4565 (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4566 (if vhdl-conditions-in-parenthesis (insert ")"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4567 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4568 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4569
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4570 (defun vhdl-package ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4571 "Insert a package specification or body."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4572 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4573 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4574 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4575 (vhdl-insert-keyword "PACKAGE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4576 (if (y-or-n-p "body? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4577 (vhdl-insert-keyword "BODY "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4578 (setq name (vhdl-field "name" " is\n\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4579 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4580 (vhdl-insert-keyword "END ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4581 (insert name ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4582 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4583 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4584 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4585
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4586 (defun vhdl-port ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4587 "Insert a port declaration, or port map in instantiation statements."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4588 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4589 (vhdl-insert-keyword "PORT (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4590 (cond ((equal (car (car (cdr (vhdl-get-syntactic-context)))) 'entity)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4591 (vhdl-get-port nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4592 ((or (equal 'statement-cont (car (car (vhdl-get-syntactic-context))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4593 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4594 (and (backward-word 2) (skip-chars-backward " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4595 (eq (preceding-char) ?:))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4596 (delete-char -1) (vhdl-map))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4597 (t (vhdl-get-port nil t))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4598
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4599 (defun vhdl-procedure ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4600 "Insert a procedure specification or body template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4601 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4602 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4603 (name))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4604 (vhdl-insert-keyword "PROCEDURE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4605 (if (equal (setq name (vhdl-field "name")) "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4606 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4607 (vhdl-get-arg-list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4608 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4609 (if (y-or-n-p "insert body? ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4610 (progn (vhdl-insert-keyword "IS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4611 (vhdl-begin-end (cons name margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4612 (vhdl-block-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4613 (delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4614 (insert ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4615 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4616 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4617
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4618 (defun vhdl-process ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4619 "Insert a process template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4620 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4621 (let ((clocked))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4622 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4623 (vhdl-insert-keyword "PROCESS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4624 (setq clocked (y-or-n-p "clocked process? "))
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 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4627 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4628 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4629 (finalline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4630 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4631 (named (not (string-equal name "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4632 (clock) (reset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4633 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4634 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4635 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4636 (insert " (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4637 (if (not clocked)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4638 (if (equal (vhdl-field "[sensitivity list]" ")") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4639 (delete-char -3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4640 (setq clock (vhdl-field "clock name" ", "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4641 (setq reset (vhdl-field "reset name" ")")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4642 (vhdl-begin-end (cons (concat (vhdl-case-keyword "PROCESS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4643 (if named (concat " " name))) margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4644 (if clocked (vhdl-clock-async-reset clock reset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4645 (if vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4646 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4647 (setq finalline (vhdl-current-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4648 (if (and (re-search-backward "\\<begin\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4649 (re-search-backward "\\<process\\>" nil t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4650 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4651 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4652 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4653 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4654 (insert "-- purpose: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4655 (if (equal (vhdl-field "description") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4656 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4657 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4658 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4659 (insert "-- type: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4660 (insert (if clocked "memorizing" "memoryless") "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4661 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4662 (insert "-- inputs: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4663 (if clocked
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4664 (insert clock ", " reset ", "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4665 (if (and (equal (vhdl-field "signal names") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4666 clocked)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4667 (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4668 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4669 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4670 (insert "-- outputs: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4671 (vhdl-field "signal names")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4672 (setq finalline (+ finalline 4)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4673 (goto-line finalline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4674 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4675 )))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4676
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4677 (defun vhdl-record ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4678 "Insert a record type declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4679 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4680 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4681 (start (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4682 (first t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4683 (vhdl-insert-keyword "RECORD\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4684 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4685 (if (equal (vhdl-field "identifiers") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4686 (progn (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4687 (delete-char -1)
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 (while (or first (not (equal (vhdl-field "[identifiers]") "")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4690 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4691 (vhdl-field "type" ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4692 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4693 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4694 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4695 (setq first nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4696 (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4697 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4698 (vhdl-insert-keyword "END RECORD;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4699 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4700 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4701
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4702 (defun vhdl-return-value ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4703 "Insert a return statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4704 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4705 (vhdl-insert-keyword "RETURN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4706 (if (equal (vhdl-field "[expression]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4707 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4708 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4709 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4710
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4711 (defun vhdl-selected-signal-assignment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4712 "Insert a selected signal assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4713 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4714 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4715 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4716 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4717 (vhdl-insert-keyword " SELECT")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4718 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4719 (vhdl-insert-keyword "WITH ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4720 (if (equal (vhdl-field "selector expression") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4721 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4722 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4723 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4724 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4725 (vhdl-field "target signal" " <= ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4726 ; (vhdl-field "[GUARDED] [TRANSPORT]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4727 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4728 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4729 (while (not (equal (vhdl-field "[waveform]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4730 (vhdl-insert-keyword " WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4731 (vhdl-field "choices" ",")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4732 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4733 (indent-to (+ margin vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4734 (if (not (equal (vhdl-field "[alternative waveform]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4735 (vhdl-insert-keyword " WHEN OTHERS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4736 (fixup-whitespace)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4737 (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4738 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4739 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4740 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4741
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4742 (defun vhdl-signal ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4743 "Insert a signal declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4744 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4745 (vhdl-insert-keyword "SIGNAL ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4746 (let ((in-arglist (string-match "arglist"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4747 (format "%s" (car (car (vhdl-get-syntactic-context)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4748 (if (not in-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4749 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4750 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4751 (setq in-arglist (looking-at ".*("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4752 (goto-char opoint)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4753 (if (equal (vhdl-field "names") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4754 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4755 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4756 (if in-arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4757 (progn (vhdl-field "direction")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4758 (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4759 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4760 (if in-arglist
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 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4763 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4764 (if (equal (vhdl-field "[initialization]" ";") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4765 (progn (goto-char position) (kill-line) (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4766 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4767 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4768
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4769 (defun vhdl-subtype ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4770 "Insert a subtype declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4771 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4772 (vhdl-insert-keyword "SUBTYPE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4773 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4774 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4775 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4776 (vhdl-field "type" " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4777 (if (equal (vhdl-field "[RANGE value range | ( index range )]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4778 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4779 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4780 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4781 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4782
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4783 (defun vhdl-type ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4784 "Insert a type declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4785 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4786 (vhdl-insert-keyword "TYPE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4787 (if (equal (vhdl-field "name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4788 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4789 (vhdl-insert-keyword " IS ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4790 (let ((definition (upcase (vhdl-field "(scalar type | ARRAY | RECORD | ACCESS | FILE)"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4791 (cond ((equal definition "ARRAY")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4792 (kill-word -1) (vhdl-array))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4793 ((equal definition "RECORD")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4794 (kill-word -1) (vhdl-record))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4795 ((equal definition "ACCESS")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4796 (insert " ") (vhdl-field "type" ";"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4797 ((equal definition "FILE")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4798 (vhdl-insert-keyword " OF ") (vhdl-field "type" ";"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4799 (t (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4800 (vhdl-declaration-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4801 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4802
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4803 (defun vhdl-use ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4804 "Insert a use clause."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4805 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4806 (vhdl-insert-keyword "USE ..ALL;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4807 (backward-char 6)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4808 (if (equal (vhdl-field "library name") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4809 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4810 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4811 (vhdl-field "package name")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4812 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4813 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4814
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4815 (defun vhdl-variable ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4816 "Insert a variable declaration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4817 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4818 (vhdl-insert-keyword "VARIABLE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4819 (let ((in-arglist (string-match "arglist"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4820 (format "%s" (car (car (vhdl-get-syntactic-context)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4821 (if (not in-arglist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4822 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4823 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4824 (setq in-arglist (looking-at ".*("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4825 (goto-char opoint)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4826 (if (equal (vhdl-field "names") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4827 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4828 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4829 (if in-arglist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4830 (progn (vhdl-field "direction")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4831 (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4832 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4833 (if in-arglist
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 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4836 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4837 (if (equal (vhdl-field "[initialization]" ";") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4838 (progn (goto-char position) (kill-line) (insert ";")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4839 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4840 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4841
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4842 (defun vhdl-wait ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4843 "Insert a wait statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4844 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4845 (vhdl-insert-keyword "WAIT ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4846 (if (equal (vhdl-field
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4847 "[ON sensitivity list] [UNTIL condition] [FOR time expression]")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4848 "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4849 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4850 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4851 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4852
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4853 (defun vhdl-when ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4854 "Indent correctly if within a case statement."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4855 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4856 (let ((position (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4857 (margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4858 (if (and (re-search-forward "\\<end\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4859 (looking-at "\\s-*\\<case\\>"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4860 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4861 (setq margin (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4862 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4863 (delete-horizontal-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4864 (indent-to (+ margin vhdl-basic-offset)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4865 (goto-char position)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4866 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4867 (vhdl-insert-keyword "WHEN ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4868 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4869
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4870 (defun vhdl-while-loop ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4871 "Insert a while loop template."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4872 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4873 (let ((position (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4874 (vhdl-insert-keyword " : WHILE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4875 (goto-char position))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4876 (let* ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4877 (name (vhdl-field "[label]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4878 (named (not (string-equal name ""))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4879 (if (not named) (delete-char 3))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4880 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4881 (if vhdl-conditions-in-parenthesis (insert "("))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4882 (if (equal (vhdl-field "condition") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4883 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4884 (if vhdl-conditions-in-parenthesis (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4885 (vhdl-insert-keyword " LOOP\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4886 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4887 (vhdl-insert-keyword "END LOOP")
21466
98b189f8975f (vhdl-loop, vhdl-while-loop): Add backslash.
Karl Heuer <kwzh@gnu.org>
parents: 21446
diff changeset
4888 (insert (if named (concat " " name ";") ?\;))
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4889 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4890 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4891 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4892
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4893 (defun vhdl-with ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4894 "Insert a with statement (i.e. selected signal assignment)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4895 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4896 (vhdl-selected-signal-assignment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4897 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4898
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4899 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4900 ;; Custom functions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4901
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4902 (defun vhdl-clocked-wait ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4903 "Insert a wait statement for rising clock edge."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4904 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4905 (vhdl-insert-keyword "WAIT UNTIL ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4906 (let* ((clock (vhdl-field "clock name")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4907 (insert "'event")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4908 (vhdl-insert-keyword " AND ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4909 (insert clock)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4910 (insert " = " vhdl-one-string ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4911 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4912
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4913 (defun vhdl-clock-async-reset (clock reset)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4914 "Insert a template reacting on asynchronous reset and rising clock edge
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4915 for inside a memorizing processes."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4916 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4917 (let* ( (margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4918 (opoint))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4919 (if vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4920 (insert "-- activities triggered by asynchronous reset (active low)\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4921 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4922 (vhdl-insert-keyword "IF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4923 (insert reset " = " vhdl-zero-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4924 (vhdl-insert-keyword " THEN\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4925 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4926 (setq opoint (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4927 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4928 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4929 (if vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4930 (insert "-- activities triggered by rising edge of clock\n"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4931 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4932 (vhdl-insert-keyword "ELSIF ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4933 (insert clock "'event")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4934 (vhdl-insert-keyword " AND ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4935 (insert clock " = " vhdl-one-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4936 (vhdl-insert-keyword " THEN\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4937 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4938 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4939 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4940 (vhdl-insert-keyword "END IF;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4941 ; (if vhdl-self-insert-comments (insert " -- " clock))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4942 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4943 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4944
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4945 (defun vhdl-standard-package (library package)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4946 "Insert specification of a standard package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4947 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4948 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4949 (vhdl-insert-keyword "LIBRARY ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4950 (insert library ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4951 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4952 (vhdl-insert-keyword "USE ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4953 (insert library "." package)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4954 (vhdl-insert-keyword ".ALL;")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4955 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4956
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4957 (defun vhdl-package-numeric-bit ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4958 "Insert specification of 'numeric_bit' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4959 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4960 (vhdl-standard-package "ieee" "numeric_bit"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4961
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4962 (defun vhdl-package-numeric-std ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4963 "Insert specification of 'numeric_std' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4964 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4965 (vhdl-standard-package "ieee" "numeric_std"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4966
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4967 (defun vhdl-package-std-logic-1164 ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4968 "Insert specification of 'std_logic_1164' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4969 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4970 (vhdl-standard-package "ieee" "std_logic_1164"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4971
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4972 (defun vhdl-package-textio ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4973 "Insert specification of 'textio' package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4974 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4975 (vhdl-standard-package "std" "textio"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4976
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4977 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4978 ;; Comment functions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4979
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4980 (defun vhdl-comment-indent ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4981 (let* ((opoint (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4982 (col (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4983 (forward-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4984 (if (re-search-forward "--" opoint t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4985 (- (current-column) 2) ;Existing comment at bol stays there.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4986 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4987 (skip-chars-backward " \t")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4988 (max comment-column ;else indent to comment column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4989 (1+ (current-column))) ;except leave at least one space.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4990 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4991 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4992 col
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4993 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4994
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4995 (defun vhdl-inline-comment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4996 "Start a comment at the end of the line.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4997 if on line with code, indent at least comment-column.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4998 if starting after end-comment-column, start a new line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4999 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5000 (if (> (current-column) end-comment-column) (newline-and-indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5001 (if (or (looking-at "\\s-*$") ;end of line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5002 (and (not unread-command-events) ; called with key binding or menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5003 (not (end-of-line))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5004 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5005 (while (= (preceding-char) ?-) (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5006 (setq margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5007 (delete-horizontal-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5008 (if (bolp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5009 (progn (indent-to margin) (insert "--"))
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 (indent-to comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5012 (insert "--"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5013 (if (not unread-command-events) (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5014 ; else code following current point implies commenting out code
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5015 (let (next-input code)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5016 (while (= (preceding-char) ?-) (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5017 (while (= (setq next-input (read-char)) 13) ; CR
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5018 (insert "--"); or have a space after it?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5019 (forward-char -2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5020 (forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5021 (message "Enter CR if commenting out a line of code.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5022 (setq code t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5023 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5024 (if (not code) (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5025 ; (indent-to comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5026 (insert "--") ;hardwire to 1 space or use vhdl-basic-offset?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5027 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5028 (setq unread-command-events
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5029 (list (vhdl-character-to-event-hack next-input))) ;pushback the char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5030 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5031
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5032 (defun vhdl-display-comment (&optional line-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5033 "Add 2 comment lines at the current indent, making a display comment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5034 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5035 (if (not line-exists)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5036 (vhdl-display-comment-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5037 (let* ((col (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5038 (len (- end-comment-column col)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5039 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5040 (insert-char ? col)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5041 (insert-char ?- len)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5042 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5043 (insert-char ? col)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5044 (end-of-line -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5045 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5046 (insert "-- ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5047 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5048
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5049 (defun vhdl-display-comment-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5050 "Displays one line of dashes."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5051 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5052 (while (= (preceding-char) ?-) (delete-char -2))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5053 (let* ((col (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5054 (len (- end-comment-column col)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5055 (insert-char ?- len)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5056 (insert-char ?\n 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5057 (insert-char ? col)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5058 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5059
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5060 (defun vhdl-declaration-comment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5061 (if vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5062 (let ((position (point)))
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 (indent-to comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5065 (insert "-- ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5066 (if (equal (vhdl-field "comment") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5067 (progn (goto-char position) (kill-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5068 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5069
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5070 (defun vhdl-block-comment ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5071 (if vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5072 (let ((finalline (vhdl-current-line))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5073 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5074 (beginning-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5075 (if (re-search-backward "\\<\\(architecture\\|block\\|function\\|procedure\\|process\\)\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5076 (let ((margin))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5077 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5078 (setq margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5079 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5080 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5081 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5082 (insert "-- purpose: ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5083 (if (equal (vhdl-field "description") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5084 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5085 (setq finalline (+ finalline 1)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5086 (goto-line finalline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5087 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5088 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5089
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5090 (defun vhdl-comment-uncomment-region (beg end &optional arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5091 "Comment out region if not commented out, uncomment out region if already
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5092 commented out."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5093 (interactive "r\nP")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5094 (goto-char beg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5095 (if (looking-at comment-start)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5096 (comment-region beg end -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5097 (comment-region beg end)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5098 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5099
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5100 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5101 ;; Help functions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5102
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5103 (defun vhdl-outer-space (count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5104 "Expand abbreviations and self-insert space(s), do indent-new-comment-line
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5105 if in comment and past end-comment-column."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5106 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5107 (if (or (and (>= (preceding-char) ?a) (<= (preceding-char) ?z))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5108 (and (>= (preceding-char) ?A) (<= (preceding-char) ?Z)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5109 (expand-abbrev))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5110 (if (not (vhdl-in-comment-p))
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 (if (< (current-column) end-comment-column)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5113 (self-insert-command count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5114 (while (> (current-column) end-comment-column) (forward-word -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5115 (while (> (preceding-char) ? ) (forward-word -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5116 (delete-horizontal-space)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5117 (indent-new-comment-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5118 (end-of-line nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5119 (insert-char ? count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5120 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5121
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5122 (defun vhdl-field (prompt &optional following-string)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5123 "Prompt for string and insert it in buffer with optional following-string."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5124 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5125 (insert "<" prompt ">")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5126 (let ((string (read-from-minibuffer (concat prompt ": ") ""
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5127 vhdl-minibuffer-local-map)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5128 (delete-region opoint (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5129 (insert string (or following-string ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5130 (if vhdl-upper-case-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5131 (vhdl-fix-case-region-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5132 opoint (point) t vhdl-93-keywords-regexp))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5133 string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5134 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5135
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5136 (defun vhdl-in-comment-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5137 "Check if point is to right of beginning comment delimiter."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5138 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5139 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5140 (save-excursion ; finds an unquoted comment
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5141 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5142 (re-search-forward "^\\([^\"]*\"[^\"]*\"\\)*[^\"]*--" opoint t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5143 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5144
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5145 (defun vhdl-in-string-p ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5146 "Check if point is in a string."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5147 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5148 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5149 (save-excursion ; preceeded by odd number of string delimiters?
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5150 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5151 (equal
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5152 opoint
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5153 (re-search-forward "^\\([^\"]*\"[^\"]*\"\\)*[^\"]*\"[^\"]*" opoint t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5154 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5155
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5156 (defun vhdl-begin-end (list)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5157 "Insert a begin ... end pair with optional name after the end.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5158 Point is left between them."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5159 (let ((return)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5160 (name (car list))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5161 (margin (cdr list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5162 (if vhdl-additional-empty-lines
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5163 (progn
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 vhdl-basic-offset))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5166 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5167 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5168 (vhdl-insert-keyword "BEGIN")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5169 (if vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5170 (insert (and name (concat " -- " name))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5171 (insert "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5172 (indent-to (+ margin vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5173 (setq return (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5174 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5175 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5176 (vhdl-insert-keyword "END")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5177 (insert (and name (concat " " name)) ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5178 (goto-char return)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5179 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5180
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5181 (defun vhdl-get-arg-list ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5182 "Read from user a procedure or function argument list."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5183 (insert " (")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5184 (let ((margin (current-column)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5185 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5186 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5187 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5188 (setq margin (+ (current-column) vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5189 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5190 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5191 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5192 (let (not-empty interface)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5193 (setq interface (vhdl-field "[CONSTANT] [SIGNAL] [VARIABLE]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5194 (if (not (equal interface ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5195 (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5196 (while (not (string-equal (vhdl-field "[names]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5197 (setq not-empty t)
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 (if (not (equal (vhdl-field "[direction]") ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5200 (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5201 (vhdl-field "type" ";\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5202 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5203 (setq interface (vhdl-field "[CONSTANT] [SIGNAL] [VARIABLE]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5204 (if (not (equal interface ""))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5205 (insert " ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5206 (if not-empty
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5207 (progn (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5208 (delete-char -2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5209 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5210 (progn (insert "\n") (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5211 (insert ")"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5212 (if vhdl-argument-list-indent
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5213 (backward-delete-char 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5214 (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5215 (backward-delete-char 3)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5216 ; (while (string-match "[,;]$" args)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5217 ; (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5218 ; (indent-to margin) (setq args (vhdl-field "next argument")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5219 ; (insert 41) ;close-paren
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5220 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5221
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5222 (defun vhdl-get-port (optional &optional no-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5223 "Read from user a port spec argument list."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5224 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5225 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5226 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5227 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5228 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5229 (setq margin (+ (current-column) vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5230 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5231 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5232 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5233 (let ((vhdl-ports (vhdl-field "[names]")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5234 (if (string-equal vhdl-ports "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5235 (if optional
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 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5238 (progn (vhdl-kill-entire-line) (forward-line -1))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5239 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5240 nil )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5241 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5242 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5243 (let ((semicolon-pos))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5244 (while (not (string-equal "" vhdl-ports))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5245 (vhdl-field "direction")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5246 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5247 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5248 (setq semicolon-pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5249 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5250 (if (not no-comment)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5251 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5252 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5253 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5254 (setq vhdl-ports (vhdl-field "[names]" " : ")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5255 (goto-char semicolon-pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5256 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5257 (progn (insert "\n") (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5258 (insert ")")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5259 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5260 (if (= (following-char) ? )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5261 (delete-char 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5262 (forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5263 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5264 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5265 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5266 t))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5267
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5268 (defun vhdl-get-generic (optional &optional no-value )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5269 "Read from user a generic spec argument list."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5270 (let ((margin (current-column))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5271 (start (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5272 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5273 (let ((opoint (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5274 (back-to-indentation)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5275 (setq margin (+ (current-column) vhdl-basic-offset))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5276 (goto-char opoint)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5277 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5278 (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5279 (let ((vhdl-generic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5280 (if no-value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5281 (setq vhdl-generic (vhdl-field "[names]"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5282 (setq vhdl-generic (vhdl-field "[name]")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5283 (if (string-equal vhdl-generic "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5284 (if optional
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 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5287 (progn (vhdl-kill-entire-line) (end-of-line -0))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5288 (progn (undo 0) (insert " "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5289 nil )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5290 (insert " : ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5291 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5292 (let ((semicolon-pos))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5293 (while (not(string-equal "" vhdl-generic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5294 (vhdl-field "type")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5295 (if no-value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5296 (progn (setq semicolon-pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5297 (insert ";"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5298 (insert " := ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5299 (if (equal (vhdl-field "[value]") "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5300 (delete-char -4))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5301 (setq semicolon-pos (point))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5302 (insert ";")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5303 (vhdl-declaration-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5304 (newline)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5305 (indent-to margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5306 (if no-value
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5307 (setq vhdl-generic (vhdl-field "[names]" " : "))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5308 (setq vhdl-generic (vhdl-field "[name]" " : "))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5309 (goto-char semicolon-pos)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5310 (if (not vhdl-argument-list-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5311 (progn (insert "\n") (indent-to margin)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5312 (insert ")")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5313 (forward-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5314 (if (= (following-char) ? )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5315 (delete-char 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5316 (forward-line 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5317 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5318 (end-of-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5319 (if vhdl-auto-align (vhdl-align start (point) 1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5320 t))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5321
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5322 (defun vhdl-insert-date ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5323 "Insert date in appropriate format."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5324 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5325 (insert
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5326 (cond
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5327 ((eq vhdl-date-format 'american) (format-time-string "%m/%d/%Y" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5328 ((eq vhdl-date-format 'european) (format-time-string "%d.%m.%Y" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5329 ((eq vhdl-date-format 'scientific) (format-time-string "%Y/%m/%d" nil))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5330 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5331
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5332 (defun vhdl-insert-keyword (keyword)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5333 (insert (if vhdl-upper-case-keywords (upcase keyword) (downcase keyword)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5334 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5335
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5336 (defun vhdl-case-keyword (keyword)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5337 (if vhdl-upper-case-keywords (upcase keyword) (downcase keyword))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5338 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5339
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5340 (defun vhdl-case-word (num)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5341 (if vhdl-upper-case-keywords (upcase-word num) (downcase-word num))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5342 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5343
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5344 (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
5345 "Convert all words matching word-regexp in region to lower or upper case,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5346 depending on parameter upper-case."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5347 (let ((case-fold-search t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5348 (case-replace nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5349 (busy-counter 0))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5350 (modify-syntax-entry ?_ "w" vhdl-mode-syntax-table)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5351 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5352 (goto-char beg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5353 (while (re-search-forward word-regexp end t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5354 (or (vhdl-in-comment-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5355 (vhdl-in-string-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5356 (if upper-case
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5357 (upcase-word -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5358 (downcase-word -1)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5359 (if (and count
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5360 (/= busy-counter (setq busy-counter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5361 (+ (* count 25) (/ (* 25 (- (point) beg)) (- end beg))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5362 (message (format "Fixing case ... (%2d%s)" busy-counter "%%"))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5363 (goto-char end))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5364 (if (not vhdl-underscore-is-part-of-word)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5365 (modify-syntax-entry ?_ "_" vhdl-mode-syntax-table))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5366 (message "")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5367 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5368
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5369 (defun vhdl-fix-case-region (beg end &optional arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5370 "Convert all VHDL words in region to lower or upper case, depending on
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5371 variables vhdl-upper-case-{keywords,types,attributes,enum-values}."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5372 (interactive "r\nP")
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-keywords vhdl-93-keywords-regexp 0)
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-types vhdl-93-types-regexp 1)
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-attributes vhdl-93-attributes-regexp 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5379 (vhdl-fix-case-region-1
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5380 beg end vhdl-upper-case-enum-values vhdl-93-enum-values-regexp 3)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5381 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5382
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5383 (defun vhdl-fix-case-buffer ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5384 "Convert all VHDL words in buffer to lower or upper case, depending on
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5385 variables vhdl-upper-case-{keywords,types,attributes,enum-values}."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5386 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5387 (vhdl-fix-case-region (point-min) (point-max))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5388 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5389
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5390 (defun vhdl-minibuffer-tab (&optional prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5391 "If preceeding character is part of a word then dabbrev-expand,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5392 else if right of non whitespace on line then tab-to-tab-stop,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5393 else indent line in proper way for current major mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5394 (used for word completion in VHDL minibuffer)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5395 (interactive "P")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5396 (cond ((= (char-syntax (preceding-char)) ?w)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5397 (let ((case-fold-search nil)) (dabbrev-expand prefix-arg)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5398 ((> (current-column) (current-indentation))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5399 (tab-to-tab-stop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5400 (t
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5401 (if (eq indent-line-function 'indent-to-left-margin)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5402 (insert-tab prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5403 (if prefix-arg
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5404 (funcall indent-line-function prefix-arg)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5405 (funcall indent-line-function))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5406
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5407 (defun vhdl-help ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5408 "Display help information in '*Help*' buffer ."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5409 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5410 (with-output-to-temp-buffer "*Help*"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5411 (princ mode-name)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5412 (princ " mode:\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5413 (princ (documentation major-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5414 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5415 (set-buffer standard-output)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5416 (help-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5417 (print-help-return-message)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5418
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5419 (defun vhdl-current-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5420 "Return the line number of the line containing point."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5421 (save-restriction
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5422 (widen)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5423 (save-excursion
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5424 (beginning-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5425 (1+ (count-lines 1 (point)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5426 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5427
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5428 (defun vhdl-kill-entire-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5429 "Delete entire line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5430 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5431 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5432 (kill-line -0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5433 (delete-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5434 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5435
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5436 (defun vhdl-open-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5437 "Open a new line and indent."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5438 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5439 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5440 (newline-and-indent)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5441 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5442
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5443 (defun vhdl-kill-line ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5444 "Kill current line."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5445 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5446 (vhdl-kill-entire-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5447 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5448
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5449 (defun vhdl-character-to-event-hack (char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5450 (if (memq 'XEmacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5451 (character-to-event char)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5452 char))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5453
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5454 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5455 ;; Abbrev hooks
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5456
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5457 (defun vhdl-electric-mode ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5458 "Toggle VHDL Electric mode."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5459 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5460 (setq vhdl-electric-mode (not vhdl-electric-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5461 (setq mode-name (if vhdl-electric-mode "Electric VHDL" "VHDL"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5462 (force-mode-line-update)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5463 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5464
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5465 (defun vhdl-stutter-mode ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5466 "Toggle VHDL Stuttering mode."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5467 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5468 (setq vhdl-stutter-mode (not vhdl-stutter-mode))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5469 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5470
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5471 (defun vhdl-hooked-abbrev (fun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5472 "Do function, if syntax says abbrev is a keyword, invoked by hooked abbrev,
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5473 but not if inside a comment or quote)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5474 (if (or (vhdl-in-comment-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5475 (vhdl-in-string-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5476 (save-excursion (forward-word -1) (looking-at "end")))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5477 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5478 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5479 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5480 (delete-char -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5481 (if (not vhdl-electric-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5482 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5483 (insert " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5484 (unexpand-abbrev)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5485 (backward-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5486 (vhdl-case-word 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5487 (delete-char 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5488 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5489 (let ((invoke-char last-command-char) (abbrev-mode -1))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5490 (funcall fun)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5491 (if (= invoke-char ?-) (setq abbrev-start-location (point)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5492 ;; delete CR which is still in event queue
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5493 (if (memq 'XEmacs vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5494 (enqueue-eval-event 'delete-char -1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5495 (setq unread-command-events ; push back a delete char
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5496 (list (vhdl-character-to-event-hack ?\177))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5497 ))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5498
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5499 (defun vhdl-alias-hook () "hooked version of vhdl-alias."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5500 (vhdl-hooked-abbrev 'vhdl-alias))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5501 (defun vhdl-architecture-hook () "hooked version of vhdl-architecture."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5502 (vhdl-hooked-abbrev 'vhdl-architecture))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5503 (defun vhdl-array-hook () "hooked version of vhdl-array."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5504 (vhdl-hooked-abbrev 'vhdl-array))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5505 (defun vhdl-assert-hook () "hooked version of vhdl-assert."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5506 (vhdl-hooked-abbrev 'vhdl-assert))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5507 (defun vhdl-attribute-hook () "hooked version of vhdl-attribute."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5508 (vhdl-hooked-abbrev 'vhdl-attribute))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5509 (defun vhdl-block-hook () "hooked version of vhdl-block."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5510 (vhdl-hooked-abbrev 'vhdl-block))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5511 (defun vhdl-case-hook () "hooked version of vhdl-case."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5512 (vhdl-hooked-abbrev 'vhdl-case))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5513 (defun vhdl-component-hook () "hooked version of vhdl-component."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5514 (vhdl-hooked-abbrev 'vhdl-component))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5515 (defun vhdl-component-instance-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5516 "hooked version of vhdl-component-instance."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5517 (vhdl-hooked-abbrev 'vhdl-component-instance))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5518 (defun vhdl-concurrent-signal-assignment-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5519 "hooked version of vhdl-concurrent-signal-assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5520 (vhdl-hooked-abbrev 'vhdl-concurrent-signal-assignment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5521 (defun vhdl-configuration-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5522 "hooked version of vhdl-configuration."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5523 (vhdl-hooked-abbrev 'vhdl-configuration))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5524 (defun vhdl-constant-hook () "hooked version of vhdl-constant."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5525 (vhdl-hooked-abbrev 'vhdl-constant))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5526 (defun vhdl-disconnect-hook () "hooked version of vhdl-disconnect."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5527 (vhdl-hooked-abbrev 'vhdl-disconnect))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5528 (defun vhdl-display-comment-hook () "hooked version of vhdl-display-comment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5529 (vhdl-hooked-abbrev 'vhdl-display-comment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5530 (defun vhdl-else-hook () "hooked version of vhdl-else."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5531 (vhdl-hooked-abbrev 'vhdl-else))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5532 (defun vhdl-elsif-hook () "hooked version of vhdl-elsif."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5533 (vhdl-hooked-abbrev 'vhdl-elsif))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5534 (defun vhdl-entity-hook () "hooked version of vhdl-entity."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5535 (vhdl-hooked-abbrev 'vhdl-entity))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5536 (defun vhdl-exit-hook () "hooked version of vhdl-exit."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5537 (vhdl-hooked-abbrev 'vhdl-exit))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5538 (defun vhdl-for-hook () "hooked version of vhdl-for."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5539 (vhdl-hooked-abbrev 'vhdl-for))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5540 (defun vhdl-function-hook () "hooked version of vhdl-function."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5541 (vhdl-hooked-abbrev 'vhdl-function))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5542 (defun vhdl-generate-hook () "hooked version of vhdl-generate."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5543 (vhdl-hooked-abbrev 'vhdl-generate))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5544 (defun vhdl-generic-hook () "hooked version of vhdl-generic."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5545 (vhdl-hooked-abbrev 'vhdl-generic))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5546 (defun vhdl-library-hook () "hooked version of vhdl-library."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5547 (vhdl-hooked-abbrev 'vhdl-library))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5548 (defun vhdl-header-hook () "hooked version of vhdl-header."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5549 (vhdl-hooked-abbrev 'vhdl-header))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5550 (defun vhdl-if-hook () "hooked version of vhdl-if."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5551 (vhdl-hooked-abbrev 'vhdl-if))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5552 (defun vhdl-loop-hook () "hooked version of vhdl-loop."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5553 (vhdl-hooked-abbrev 'vhdl-loop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5554 (defun vhdl-map-hook () "hooked version of vhdl-map."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5555 (vhdl-hooked-abbrev 'vhdl-map))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5556 (defun vhdl-modify-hook () "hooked version of vhdl-modify."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5557 (vhdl-hooked-abbrev 'vhdl-modify))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5558 (defun vhdl-next-hook () "hooked version of vhdl-next."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5559 (vhdl-hooked-abbrev 'vhdl-next))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5560 (defun vhdl-package-hook () "hooked version of vhdl-package."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5561 (vhdl-hooked-abbrev 'vhdl-package))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5562 (defun vhdl-port-hook () "hooked version of vhdl-port."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5563 (vhdl-hooked-abbrev 'vhdl-port))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5564 (defun vhdl-procedure-hook () "hooked version of vhdl-procedure."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5565 (vhdl-hooked-abbrev 'vhdl-procedure))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5566 (defun vhdl-process-hook () "hooked version of vhdl-process."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5567 (vhdl-hooked-abbrev 'vhdl-process))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5568 (defun vhdl-record-hook () "hooked version of vhdl-record."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5569 (vhdl-hooked-abbrev 'vhdl-record))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5570 (defun vhdl-return-hook () "hooked version of vhdl-return-value."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5571 (vhdl-hooked-abbrev 'vhdl-return-value))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5572 (defun vhdl-selected-signal-assignment-hook ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5573 "hooked version of vhdl-selected-signal-assignment."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5574 (vhdl-hooked-abbrev 'vhdl-selected-signal-assignment))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5575 (defun vhdl-signal-hook () "hooked version of vhdl-signal."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5576 (vhdl-hooked-abbrev 'vhdl-signal))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5577 (defun vhdl-subtype-hook () "hooked version of vhdl-subtype."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5578 (vhdl-hooked-abbrev 'vhdl-subtype))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5579 (defun vhdl-type-hook () "hooked version of vhdl-type."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5580 (vhdl-hooked-abbrev 'vhdl-type))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5581 (defun vhdl-use-hook () "hooked version of vhdl-use."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5582 (vhdl-hooked-abbrev 'vhdl-use))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5583 (defun vhdl-variable-hook () "hooked version of vhdl-variable."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5584 (vhdl-hooked-abbrev 'vhdl-variable))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5585 (defun vhdl-wait-hook () "hooked version of vhdl-wait."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5586 (vhdl-hooked-abbrev 'vhdl-wait))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5587 (defun vhdl-when-hook () "hooked version of vhdl-when."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5588 (vhdl-hooked-abbrev 'vhdl-when))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5589 (defun vhdl-while-loop-hook () "hooked version of vhdl-while-loop."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5590 (vhdl-hooked-abbrev 'vhdl-while-loop))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5591 (defun vhdl-and-hook () "hooked version of vhdl-and."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5592 (vhdl-hooked-abbrev 'vhdl-and))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5593 (defun vhdl-or-hook () "hooked version of vhdl-or."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5594 (vhdl-hooked-abbrev 'vhdl-or))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5595 (defun vhdl-nand-hook () "hooked version of vhdl-nand."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5596 (vhdl-hooked-abbrev 'vhdl-nand))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5597 (defun vhdl-nor-hook () "hooked version of vhdl-nor."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5598 (vhdl-hooked-abbrev 'vhdl-nor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5599 (defun vhdl-xor-hook () "hooked version of vhdl-xor."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5600 (vhdl-hooked-abbrev 'vhdl-xor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5601 (defun vhdl-xnor-hook () "hooked version of vhdl-xnor."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5602 (vhdl-hooked-abbrev 'vhdl-xnor))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5603 (defun vhdl-not-hook () "hooked version of vhdl-not."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5604 (vhdl-hooked-abbrev 'vhdl-not))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5605
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5606 (defun vhdl-default-hook () "hooked version of vhdl-default."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5607 (vhdl-hooked-abbrev 'vhdl-default))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5608 (defun vhdl-default-indent-hook () "hooked version of vhdl-default-indent."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5609 (vhdl-hooked-abbrev 'vhdl-default-indent))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5610
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5611
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5612 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5613 ;; Font locking
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5614 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5615 ;; (using `font-lock.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5616
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5617 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5618 ;; Syntax definitions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5619
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5620 (defvar vhdl-font-lock-keywords nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5621 "Regular expressions to highlight in VHDL Mode.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5622
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5623 (defconst vhdl-font-lock-keywords-0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5624 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5625 ;; highlight template prompts
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5626 '("\\(^\\|[ (.\t]\\)\\(<[^ =].*[^ =]>\\)\\([ .]\\|$\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5627 2 vhdl-font-lock-prompt-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5628
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5629 ;; highlight character literals
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5630 '("'\\(.\\)'" 1 'font-lock-string-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5631 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5632 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5633 This does highlighting of template prompts and character literals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5634
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5635 (defconst vhdl-font-lock-keywords-1
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 ;; highlight names of units, subprograms, and components when declared
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5638 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5639 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5640 "^\\s-*\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5641 "architecture\\|configuration\\|entity\\|package\\(\\s-+body\\|\\)\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5642 "function\\|procedure\\|component"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5643 "\\)\\s-+\\(\\w+\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5644 3 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5645
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5646 ;; highlight labels of common constructs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5647 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5648 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5649 "^\\s-*\\(\\w+\\)\\s-*:\\(\\s-\\|\n\\)*\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5650 "assert\\|block\\|case\\|exit\\|for\\|if\\|loop\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5651 "next\\|null\\|process\\| with\\|while\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5652 "\\w+\\(\\s-\\|\n\\)+\\(generic\\|port\\)\\s-+map"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5653 "\\)\\>")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5654 1 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5655
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5656 ;; highlight entity names of architectures and configurations
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5657 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5658 "^\\s-*\\(architecture\\|configuration\\)\\s-+\\w+\\s-+of\\s-+\\(\\w+\\)"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5659 2 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5660
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5661 ;; highlight names and labels at end of constructs
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5662 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5663 (concat
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5664 "^\\s-*end\\s-+\\("
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5665 "\\(block\\|case\\|component\\|for\\|generate\\|if\\|loop\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5666 "process\\|record\\|units\\)\\>\\|"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5667 "\\)\\s-*\\(\\w*\\)")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5668 3 'font-lock-function-name-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5669 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5670 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5671 This does highlighting of names and labels.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5672
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5673 (defconst vhdl-font-lock-keywords-2
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5674 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5675 ;; highlight keywords, and types, standardized attributes, enumeration values
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5676 (list (concat "'" vhdl-93-attributes-regexp)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5677 1 'vhdl-font-lock-attribute-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5678 (list vhdl-93-types-regexp 1 'font-lock-type-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5679 (list vhdl-93-enum-values-regexp 1 'vhdl-font-lock-value-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5680 (list vhdl-93-keywords-regexp 1 'font-lock-keyword-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5681 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5682 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5683 This does highlighting of comments, keywords, and standard types.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5684
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5685 (defconst vhdl-font-lock-keywords-3
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5686 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5687 ;; highlight clock signals.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5688 (cons vhdl-clock-signal-syntax 'vhdl-font-lock-clock-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5689 (cons vhdl-reset-signal-syntax 'vhdl-font-lock-reset-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5690 (cons vhdl-control-signal-syntax 'vhdl-font-lock-control-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5691 (cons vhdl-data-signal-syntax 'vhdl-font-lock-data-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5692 (cons vhdl-test-signal-syntax 'vhdl-font-lock-test-signal-face)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5693 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5694 "For consideration as a value of `vhdl-font-lock-keywords'.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5695 This does highlighting of signal names with specific syntax.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5696
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5697 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5698 ;; Font and color definitions
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5699
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5700 (defvar vhdl-font-lock-prompt-face 'vhdl-font-lock-prompt-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5701 "Face name to use for prompts.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5702
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5703 (defvar vhdl-font-lock-attribute-face 'vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5704 "Face name to use for attributes.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5705
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5706 (defvar vhdl-font-lock-value-face 'vhdl-font-lock-value-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5707 "Face name to use for enumeration values.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5708
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5709 (defvar vhdl-font-lock-clock-signal-face 'vhdl-font-lock-clock-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5710 "Face name to use for clock signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5711
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5712 (defvar vhdl-font-lock-reset-signal-face 'vhdl-font-lock-reset-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5713 "Face name to use for reset signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5714
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5715 (defvar vhdl-font-lock-control-signal-face 'vhdl-font-lock-control-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5716 "Face name to use for control signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5717
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5718 (defvar vhdl-font-lock-data-signal-face 'vhdl-font-lock-data-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5719 "Face name to use for data signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5720
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5721 (defvar vhdl-font-lock-test-signal-face 'vhdl-font-lock-test-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5722 "Face name to use for test signals.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5723
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5724 (defface vhdl-font-lock-prompt-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5725 '((((class color) (background light)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5726 (((class color) (background dark)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5727 (t (:inverse-video t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5728 "Font Lock mode face used to highlight prompts."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5729 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5730
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5731 (defface vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5732 '((((class color) (background light)) (:foreground "CadetBlue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5733 (((class color) (background dark)) (:foreground "CadetBlue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5734 (t (:italic t :bold t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5735 "Font Lock mode face used to highlight attributes."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5736 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5737
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5738 (defface vhdl-font-lock-value-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5739 '((((class color) (background light)) (:foreground "DarkGoldenrod"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5740 (((class color) (background dark)) (:foreground "DarkGoldenrod"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5741 (t (:italic t :bold t)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5742 "Font Lock mode face used to highlight enumeration values."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5743 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5744
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5745 (defface vhdl-font-lock-clock-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5746 '((((class color) (background light)) (:foreground "LimeGreen"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5747 (((class color) (background dark)) (:foreground "LimeGreen"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5748 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5749 "Font Lock mode face used to highlight clock signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5750 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5751
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5752 (defface vhdl-font-lock-reset-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5753 '((((class color) (background light)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5754 (((class color) (background dark)) (:foreground "Red"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5755 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5756 "Font Lock mode face used to highlight reset signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5757 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5758
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5759 (defface vhdl-font-lock-control-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5760 '((((class color) (background light)) (:foreground "Blue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5761 (((class color) (background dark)) (:foreground "Blue"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5762 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5763 "Font Lock mode face used to highlight control signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5764 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5765
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5766 (defface vhdl-font-lock-data-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5767 '((((class color) (background light)) (:foreground "Black"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5768 (((class color) (background dark)) (:foreground "Black"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5769 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5770 "Font Lock mode face used to highlight data signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5771 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5772
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5773 (defface vhdl-font-lock-test-signal-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5774 '((((class color) (background light)) (:foreground "Gold"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5775 (((class color) (background dark)) (:foreground "Gold"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5776 (t ()))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5777 "Font Lock mode face used to highlight test signals."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5778 :group 'font-lock-highlighting-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5779
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5780 ;; Custom color definitions for existing faces
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5781 (defun vhdl-set-face-foreground ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5782 (set-face-foreground 'font-lock-comment-face "IndianRed")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5783 (set-face-foreground 'font-lock-function-name-face "MediumOrchid")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5784 (set-face-foreground 'font-lock-keyword-face "SlateBlue")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5785 (set-face-foreground 'font-lock-string-face "RosyBrown")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5786 (set-face-foreground 'font-lock-type-face "ForestGreen")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5787 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5788
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5789 (defun vhdl-set-face-grayscale ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5790 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5791 (set-face-bold-p 'font-lock-comment-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5792 (set-face-inverse-video-p 'font-lock-comment-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5793 (set-face-italic-p 'font-lock-comment-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5794 (set-face-underline-p 'font-lock-comment-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5795
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5796 (set-face-bold-p 'font-lock-function-name-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5797 (set-face-inverse-video-p 'font-lock-function-name-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5798 (set-face-italic-p 'font-lock-function-name-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5799 (set-face-underline-p 'font-lock-function-name-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5800
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5801 (set-face-bold-p 'font-lock-keyword-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5802 (set-face-inverse-video-p 'font-lock-keyword-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5803 (set-face-italic-p 'font-lock-keyword-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5804 (set-face-underline-p 'font-lock-keyword-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5805
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5806 (set-face-bold-p 'font-lock-string-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5807 (set-face-inverse-video-p 'font-lock-string-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5808 (set-face-italic-p 'font-lock-string-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5809 (set-face-underline-p 'font-lock-string-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5810
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5811 (set-face-bold-p 'font-lock-type-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5812 (set-face-inverse-video-p 'font-lock-type-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5813 (set-face-italic-p 'font-lock-type-face t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5814 (set-face-underline-p 'font-lock-type-face nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5815 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5816
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5817 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5818 ;; Font lock initialization
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5819
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5820 (defun vhdl-font-lock-init ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5821 "Initializes fontification."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5822 (setq vhdl-font-lock-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5823 (append vhdl-font-lock-keywords-0
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5824 (if vhdl-highlight-names vhdl-font-lock-keywords-1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5825 (if vhdl-highlight-keywords vhdl-font-lock-keywords-2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5826 (if (and vhdl-highlight-signals (x-display-color-p))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5827 vhdl-font-lock-keywords-3)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5828 (if (x-display-color-p)
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
5829 (if vhdl-customize-colors (vhdl-set-face-foreground))
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
5830 (if vhdl-customize-faces (vhdl-set-face-grayscale))
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5831 ))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5832
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5833 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5834 ;; Fontification for postscript printing
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5835
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5836 (defun vhdl-ps-init ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5837 "Initializes face and page settings for postscript printing."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5838 (require 'ps-print)
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
5839 (unless (or (not vhdl-customize-faces)
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5840 ps-print-color-p)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5841 (set (make-local-variable 'ps-bold-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5842 '(font-lock-keyword-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5843 font-lock-type-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5844 vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5845 vhdl-font-lock-value-face))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5846 (set (make-local-variable 'ps-italic-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5847 '(font-lock-comment-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5848 font-lock-function-name-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5849 font-lock-type-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5850 vhdl-font-lock-prompt-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5851 vhdl-font-lock-attribute-face
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5852 vhdl-font-lock-value-face))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5853 (set (make-local-variable 'ps-underlined-faces)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5854 '(font-lock-string-face))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5855 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5856 ;; define page settings, so that a line containing 79 characters (default)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5857 ;; fits into one column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5858 (if vhdl-print-two-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5859 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5860 (set (make-local-variable 'ps-landscape-mode) t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5861 (set (make-local-variable 'ps-number-of-columns) 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5862 (set (make-local-variable 'ps-font-size) 7.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5863 (set (make-local-variable 'ps-header-title-font-size) 10.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5864 (set (make-local-variable 'ps-header-font-size) 9.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5865 (set (make-local-variable 'ps-header-offset) 12.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5866 (if (eq ps-paper-type 'letter)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5867 (progn
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5868 (set (make-local-variable 'ps-inter-column) 40.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5869 (set (make-local-variable 'ps-left-margin) 40.0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5870 (set (make-local-variable 'ps-right-margin) 40.0)
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
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5874 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5875 ;; Hideshow
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5876 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5877 ;; (using `hideshow.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5878
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5879 (defun vhdl-forward-sexp-function (&optional count)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5880 "Find begin and end of VHDL process or block (for hideshow)."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5881 (interactive "p")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5882 (let (name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5883 (case-fold-search t))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5884 (end-of-line)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5885 (if (< count 0)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5886 (re-search-backward "\\s-*\\(\\w\\|\\s_\\)+\\s-*:\\s-*\\(process\\|block\\)\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5887 (re-search-forward "\\s-*\\<end\\s-+\\(process\\|block\\)\\>" nil t)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5888 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5889
21653
e95a88dc6110 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21651
diff changeset
5890 ;; Not needed `hs-special-modes-alist' is autoloaded.
e95a88dc6110 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21651
diff changeset
5891 ;(require 'hideshow)
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5892
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5893 (unless (assq 'vhdl-mode hs-special-modes-alist)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5894 (setq hs-special-modes-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5895 (cons
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5896 '(vhdl-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5897 "\\s-*\\(\\w\\|\\s_\\)+\\s-*:\\s-*\\(process\\|PROCESS\\|block\\|BLOCK\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5898 "\\s-*\\<\\(end\\|END\\)\\s-+\\(process\\|PROCESS\\|block\\|BLOCK\\)\\>"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5899 "-- "
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5900 vhdl-forward-sexp-function)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5901 hs-special-modes-alist)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5902
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5903
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5904 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5905 ;; Compilation
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5906 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5907 ;; (using `compile.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5908
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5909 (defvar vhdl-compile-commands
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5910 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5911 (cadence "cv -file" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5912 (ikos "analyze" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5913 (quickhdl "qvhcom" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5914 (synopsys "vhdlan" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5915 (vantage "analyze -libfile vsslib.ini -src" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5916 (viewlogic "analyze -libfile vsslib.ini -src" nil)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5917 (v-system "vcom" "vmake > Makefile")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5918 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5919 "Commands to be called in the shell for compilation (syntax analysis) of a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5920 single buffer and `Makefile' generation for different tools. First item is tool
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5921 identifier, second item is shell command for compilation, and third item is
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5922 shell command for `Makefile' generation. A tool is specified by assigning a
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5923 tool identifier to variable `vhdl-compiler'.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5924
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5925 (defvar vhdl-compilation-error-regexp-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5926 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5927 ;; Cadence Design Systems: cv -file test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5928 ;; duluth: *E,430 (test.vhd,13): identifier (POSITIV) is not declared
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5929 '("duluth: \\*E,[0-9]+ (\\(.+\\),\\([0-9]+\\)):" 1 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5930
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5931 ;; Ikos Voyager: analyze test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5932 ;; E L4/C5: this library unit is inaccessible
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5933 ; Xemacs does not support error messages without included file name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5934 (if (not (memq 'XEmacs vhdl-emacs-features))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5935 '("E L\\([0-9]+\\)/C[0-9]+:" nil 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5936 '("E L\\([0-9]+\\)/C[0-9]+:" 2 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5937 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5938
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5939 ;; QuickHDL, Mentor Graphics: qvhcom test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5940 ;; ERROR: test.vhd(24): near "dnd": expecting: END
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5941 '("ERROR: \\(.+\\)(\\([0-9]+\\)):" 1 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5942
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5943 ;; Synopsys, VHDL Analyzer: vhdlan test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5944 ;; **Error: vhdlan,703 test.vhd(22): OTHERS is not legal in this context.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5945 '("\\*\\*Error: vhdlan,[0-9]+ \\(.+\\)(\\([0-9]+\\)):" 1 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5946
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5947 ;; Vantage Analysis Systems: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5948 ;; **Error: LINE 499 *** No aggregate value is valid in this context.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5949 ; Xemacs does not support error messages without included file name
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5950 (if (not (memq 'XEmacs vhdl-emacs-features))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5951 '("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" nil 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5952 '("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" 2 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5953 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5954
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5955 ;; Viewlogic: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5956 ;; **Error: LINE 499 *** No aggregate value is valid in this context.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5957 ;; same regexp as for Vantage
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5958
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5959 ;; V-System, Model Technology: vcom test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5960 ;; ERROR: test.vhd(14): Unknown identifier: positiv
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5961 ;; same regexp as for QuickHDL
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5962
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5963 ) "Alist that specifies how to match errors in VHDL compiler output.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5964
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5965 (defvar compilation-file-regexp-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5966 '(
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5967 ;; Ikos Voyager: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5968 ;; analyze sdrctl.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5969 ("^analyze +\\(.+ +\\)*\\(.+\\)$" 2)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5970
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5971 ;; Vantage Analysis Systems: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5972 ;; Compiling "pcu.vhd" line 1...
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5973 (" *Compiling \"\\(.+\\)\" " 1)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5974
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5975 ;; Viewlogic: analyze -libfile vsslib.ini -src test.vhd
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5976 ;; Compiling "pcu.vhd" line 1...
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5977 ;; same regexp as for Vantage
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5978
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5979 ) "Alist specifying how to match lines that indicate a new current file.
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5980 Used for compilers with no file name in the error messages.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5981
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5982 (defun vhdl-compile ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5983 "Compile current buffer using the VHDL compiler specified in
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5984 `vhdl-compiler'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5985 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5986 (let ((command-list vhdl-compile-commands)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5987 command)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5988 (while command-list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5989 (if (eq vhdl-compiler (car (car command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5990 (setq command (car (cdr (car command-list)))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5991 (setq command-list (cdr command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5992 (if command
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5993 (compile (concat command " " vhdl-compiler-options
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5994 (if (not (string-equal vhdl-compiler-options "")) " ")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5995 (file-name-nondirectory (buffer-file-name)))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5996
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5997 (defun vhdl-make ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5998 "Call make command for compilation of all updated source files
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5999 (requires `Makefile')."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6000 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6001 (compile "make"))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6002
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6003 (defun vhdl-generate-makefile ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6004 "Generate new `Makefile'."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6005 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6006 (let ((command-list vhdl-compile-commands)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6007 command)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6008 (while command-list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6009 (if (eq vhdl-compiler (car (car command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6010 (setq command (car (cdr (cdr (car command-list))))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6011 (setq command-list (cdr command-list)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6012 (if command
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6013 (compile command )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6014 (message (format "Not implemented for `%s'!" vhdl-compiler))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6015 (beep))))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6016
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6017
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6018 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6019 ;; Bug reports
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6020 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6021 ;; (using `reporter.el')
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6022
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6023 (defconst vhdl-version "3.19"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6024 "VHDL Mode version number.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6025
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6026 (defconst vhdl-mode-help-address "vhdl-mode@geocities.com"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6027 "Address for VHDL Mode bug reports.")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6028
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6029 (defun vhdl-version ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6030 "Echo the current version of VHDL Mode in the minibuffer."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6031 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6032 (message "Using VHDL Mode version %s" vhdl-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6033 (vhdl-keep-region-active))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6034
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6035 ;; get reporter-submit-bug-report when byte-compiling
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6036 (and (fboundp 'eval-when-compile)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6037 (eval-when-compile
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6038 (require 'reporter)))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6039
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6040 (defun vhdl-submit-bug-report ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6041 "Submit via mail a bug report on VHDL Mode."
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6042 (interactive)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6043 ;; load in reporter
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6044 (and
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6045 (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
6046 (require 'reporter)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6047 (reporter-submit-bug-report
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6048 vhdl-mode-help-address
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6049 (concat "VHDL Mode " vhdl-version)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6050 (list
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6051 ;; report all important variables
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6052 'vhdl-basic-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6053 'vhdl-offsets-alist
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6054 'vhdl-comment-only-line-offset
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6055 'tab-width
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6056 'vhdl-electric-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6057 'vhdl-stutter-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6058 'vhdl-indent-tabs-mode
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6059 'vhdl-compiler
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6060 'vhdl-compiler-options
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6061 'vhdl-upper-case-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6062 'vhdl-upper-case-types
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6063 'vhdl-upper-case-attributes
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6064 'vhdl-upper-case-enum-values
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6065 'vhdl-auto-align
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6066 'vhdl-additional-empty-lines
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6067 'vhdl-argument-list-indent
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6068 'vhdl-conditions-in-parenthesis
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6069 'vhdl-date-format
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6070 'vhdl-header-file
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6071 'vhdl-modify-date-prefix-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6072 'vhdl-zero-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6073 'vhdl-one-string
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6074 'vhdl-self-insert-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6075 'vhdl-prompt-for-comments
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6076 'vhdl-comment-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6077 'vhdl-end-comment-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6078 'vhdl-highlight-names
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6079 'vhdl-highlight-keywords
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6080 'vhdl-highlight-signals
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6081 'vhdl-highlight-case-sensitive
22197
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
6082 'vhdl-customize-colors
e03f87c938ca (vhdl-customize-colors):
Richard M. Stallman <rms@gnu.org>
parents: 21653
diff changeset
6083 'vhdl-customize-faces
20665
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6084 'vhdl-clock-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6085 'vhdl-reset-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6086 'vhdl-control-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6087 'vhdl-data-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6088 'vhdl-test-signal-syntax
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6089 'vhdl-source-file-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6090 'vhdl-index-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6091 'vhdl-hideshow-menu
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6092 'vhdl-print-two-column
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6093 'vhdl-intelligent-tab
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6094 'vhdl-template-key-binding-prefix
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6095 'vhdl-word-completion-in-minibuffer
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6096 'vhdl-underscore-is-part-of-word
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6097 'vhdl-mode-hook
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6098 )
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6099 (function
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6100 (lambda ()
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6101 (insert
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6102 (if vhdl-special-indent-hook
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6103 (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6104 "vhdl-special-indent-hook is set to '"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6105 (format "%s" vhdl-special-indent-hook)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6106 ".\nPerhaps this is your problem?\n"
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6107 "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6108 "\n")
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6109 (format "vhdl-emacs-features: %s\n" vhdl-emacs-features)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6110 )))
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6111 nil
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6112 "Dear VHDL Mode maintainers,"
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 ;; ############################################################################
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6117
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6118 (provide 'vhdl-mode)
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6119
5d82beffb498 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6120 ;;; vhdl-mode.el ends here