]> code.delx.au - gnu-emacs/blob - doc/misc/vhdl-mode.texi
b8b3850c55a7327604e404e1d0a0bf0ebc0d431b
[gnu-emacs] / doc / misc / vhdl-mode.texi
1 \input texinfo @c -*- texinfo -*-
2
3 @setfilename ../../info/vhdl-mode.info
4 @settitle VHDL Mode, an Emacs mode for editing VHDL code
5 @include docstyle.texi
6
7 @c Adapted from the VHDL Mode texinfo manual version 2 by Rodney J. Whitby.
8 @c Adapted from the CC Mode texinfo manual by Barry A. Warsaw.
9
10 @copying
11 This file documents VHDL Mode, an Emacs mode for editing VHDL code.
12
13 Copyright @copyright{} 1995--2008, 2010, 2012, 2015 Free Software
14 Foundation, Inc.
15
16 @quotation
17 Permission is granted to copy, distribute and/or modify this document
18 under the terms of the GNU Free Documentation License, Version 1.3 or
19 any later version published by the Free Software Foundation; with no
20 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
21 and with the Back-Cover Texts as in (a) below. A copy of the license
22 is included in the section entitled ``GNU Free Documentation License.''
23
24 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
25 modify this GNU manual.''
26 @end quotation
27 @end copying
28
29 @dircategory Emacs editing modes
30 @direntry
31 * VHDL Mode: (vhdl-mode). Emacs mode for editing VHDL code.
32 @end direntry
33
34 @finalout
35
36 @titlepage
37 @title VHDL Mode
38 @sp 2
39 @subtitle A GNU Emacs mode for editing VHDL code.
40 @sp 2
41 @author Reto Zimmermann
42 @author @email{reto@@gnu.org}
43 @author Rod Whitby
44 @author @email{software.vhdl-mode@@rwhitby.net}
45
46 @page
47 @vskip 0pt plus 1filll
48 @insertcopying
49 @end titlepage
50
51 @contents
52
53 @ifnottex
54 @node Top
55 @top VHDL Mode, an Emacs mode for editing VHDL code
56
57 @insertcopying
58 @end ifnottex
59
60 @menu
61 * Introduction::
62 * Getting Connected::
63 * New Indentation Engine::
64 * Customizing Indentation::
65 * Syntactic Symbols::
66 * Frequently Asked Questions::
67 * Getting the latest VHDL Mode release::
68 * Sample .emacs File::
69 * Limitations and Known Bugs::
70 * Mailing Lists and Submitting Bug Reports::
71 * GNU Free Documentation License:: The license for this documentation.
72 * Concept Index::
73 * Command Index:: Command Index
74 * Key Index:: Key Index
75 * Variable Index:: Variable Index
76 @end menu
77
78 @node Introduction
79 @chapter Introduction
80 @cindex Introduction
81
82 Welcome to VHDL Mode. This is a GNU Emacs mode for editing files
83 containing VHDL code.
84
85 This manual will describe the following:
86
87 @itemize @bullet
88 @item
89 How to get started using VHDL Mode.
90
91 @item
92 How the indentation engine works.
93
94 @item
95 How to customize the indentation engine.
96
97 @end itemize
98
99 @findex vhdl-version
100 The major version number was incremented to 3 with the addition of
101 many new features for editing VHDL code to the new indentation engine,
102 which was introduced in major version 2. To find the minor revision
103 number of this release, use @kbd{M-x vhdl-version RET}.
104
105 A special word of thanks goes to Rod Whitby, who wrote the
106 VHDL Mode indentation engine, and to Barry Warsaw, who wrote
107 the CC Mode indentation engine that formed the basis
108 thereof. Their manuals were also the basis for this manual.
109
110 This manual is not very up-to-date. It basically contains the
111 indentation machine documentation by Rod Whitby with only minor
112 adaptions. A short documentation of the entire VHDL Mode is available
113 within the mode itself by typing @kbd{C-c C-h}. Also, all commands and
114 customization of most variables are available through the menu, which
115 makes everything highly self-explaining.
116
117 @node Getting Connected
118 @chapter Getting Connected
119 @cindex Getting Connected
120
121 To get started, simply visit a @file{.vhd} file in Emacs; or type
122 @kbd{M-x vhdl-mode RET}.
123
124 @node New Indentation Engine
125 @chapter New Indentation Engine
126 @cindex New Indentation Engine
127
128 VHDL Mode has a new indentation engine, providing a simplified, yet
129 flexible and general mechanism for customizing indentation. It breaks
130 indentation calculation into two steps. First for the line of code being
131 indented, VHDL Mode analyzes what kind of language construct it's
132 looking at, then it applies user defined offsets to the current line
133 based on this analysis.
134
135 This section will briefly cover how indentation is calculated in
136 VHDL Mode. It is important to understand the indentation model
137 being used so that you will know how to customize VHDL Mode for
138 your personal coding style.
139
140 @menu
141 * Syntactic Analysis:: Step 1 -- Syntactic Analysis
142 * Indentation Calculation:: Step 2 -- Indentation Calculation
143 @end menu
144
145 @node Syntactic Analysis
146 @section Syntactic Analysis
147 @cindex Syntactic Analysis
148
149 @vindex vhdl-offsets-alist
150 @vindex offsets-alist (vhdl-)
151 @cindex relative buffer position
152 @cindex syntactic symbol
153 @cindex syntactic component
154 @cindex syntactic component list
155 @cindex relative buffer position
156 The first thing VHDL Mode does when indenting a line of code, is
157 to analyze the line, determining the @dfn{syntactic component list} of
158 the construct on that line. A @dfn{syntactic component} consists of a
159 pair of information (in lisp parlance, a @emph{cons cell}), where the
160 first part is a @dfn{syntactic symbol}, and the second part is a
161 @dfn{relative buffer position}. Syntactic symbols describe elements of
162 VHDL code, e.g., @code{statement}, @code{comment}, @code{block-open},
163 @code{block-close}, etc. @xref{Syntactic Symbols}, for a complete list
164 of currently recognized syntactic symbols and their semantics. Also,
165 the variable @code{vhdl-offsets-alist} contains the list of currently
166 supported syntactic symbols.
167
168 Conceptually, a line of VHDL code is always indented relative to the
169 indentation of some line higher up in the buffer. This is represented
170 by the relative buffer position in the syntactic component.
171
172 It might help to see an example. Suppose we had the following code as
173 the only thing in a VHDL Mode buffer @footnote{The line numbers
174 in this and future examples don't actually appear in the buffer.}:
175 @example
176 @group
177
178 1: inverter : process
179 2: begin
180 3: q <= not d;
181 4: wait on d;
182 5: end inverter;
183
184 @end group
185 @end example
186
187 @kindex C-c C-x
188 @findex vhdl-show-syntactic-information
189 @findex show-syntactic-information (vhdl-)
190 We can use the command @kbd{C-c C-x}
191 (@code{vhdl-show-syntactic-information}) to simply report what the
192 syntactic analysis is for the current line. Running this command on
193 line 4 of example 1, we'd see in the echo area:
194 @example
195
196 ((statement . 28))
197
198 @end example
199
200 This tells us that the line is a statement and it is indented relative
201 to buffer position 28, which happens to be the @samp{q} on line 3. If
202 you were to move point to line 3 and hit @kbd{C-c C-x}, you would see:
203 @example
204
205 ((statement-block-intro . 20))
206
207 @end example
208
209 This indicates that line 3 is the first statement in a block, and is
210 indented relative to buffer position 20, which is the @samp{b} in the
211 @code{begin} keyword on line 2.
212
213 @cindex comment only line
214 Syntactic component lists can contain more than one component, and
215 individual syntactic components need not have relative buffer positions.
216 The most common example of this is a line that contains a @dfn{comment
217 only line}.
218 @example
219 @group
220
221 %%% TBD %%%
222
223 @end group
224 @end example
225
226 @noindent
227 Hitting @kbd{C-c C-x} on line 3 of the example gives us:
228 @example
229
230 ((comment-intro) (block-intro . 46))
231
232 @end example
233
234 @noindent
235 so you can see that the syntactic component list contains two syntactic
236 components. Also notice that the first component,
237 @samp{(comment-intro)} has no relative buffer position.
238
239 @node Indentation Calculation
240 @section Indentation Calculation
241 @cindex Indentation Calculation
242
243 @vindex vhdl-offsets-alist
244 @vindex offsets-alist (vhdl-)
245 Indentation for the current line is calculated using the syntactic
246 component list derived in step 1 above (see @ref{Syntactic
247 Analysis}). Each component contributes to the final total indentation
248 of the line in two ways.
249
250 First, the syntactic symbols are looked up in the @code{vhdl-offsets-alist}
251 variable, which is an association list of syntactic symbols and the
252 offsets to apply for those symbols. These offsets are added to the
253 running total.
254
255 Second, if the component has a relative buffer position, VHDL Mode
256 adds the column number of that position to the running total. By adding
257 up the offsets and columns for every syntactic component on the list,
258 the final total indentation for the current line is computed.
259
260 Let's use our code example above to see how this works. Here is our
261 example again.
262 @example
263 @group
264
265 1: inverter : process
266 2: begin
267 3: q <= not d;
268 4: wait on d;
269 5: end inverter;
270
271 @end group
272 @end example
273
274 @kindex TAB
275 Let's say point is on line 3 and we hit the @key{TAB} key to re-indent
276 the line. Remember that the syntactic component list for that
277 line is:
278 @example
279
280 ((statement-block-intro . 20))
281
282 @end example
283
284 @noindent
285 VHDL Mode looks up @code{statement-block-intro} in the
286 @code{vhdl-offsets-alist} variable. Let's say it finds the value @samp{2};
287 it adds this to the running total (initialized to zero), yielding a
288 running total indentation of 2 spaces.
289
290 Next VHDL Mode goes to buffer position 20 and asks for the
291 current column. Since the @code{begin} keyword at buffer position 20 is
292 in column zero, it adds @samp{0} to the running total. Since there is
293 only one syntactic component on the list for this line, indentation
294 calculation is complete, and the total indentation for the line is 2
295 spaces.
296 Simple, huh?
297
298 Actually, the mode usually just does The Right Thing without you having
299 to think about it in this much detail. But when customizing
300 indentation, it's helpful to understand the general indentation model
301 being used.
302
303 @vindex vhdl-echo-syntactic-information-p
304 @vindex echo-syntactic-information-p (vhdl-)
305 @cindex TAB
306 To help you configure VHDL Mode, you can set the variable
307 @code{vhdl-echo-syntactic-information-p} to non-@code{nil} so that the
308 syntactic component list and calculated offset will always be echoed in
309 the minibuffer when you hit @kbd{TAB}.
310
311
312 @ignore
313 @node Indentation Commands
314 @chapter Indentation Commands
315 @cindex Indentation Commands
316
317 @strong{<TBD>}
318 @end ignore
319
320
321 @node Customizing Indentation
322 @chapter Customizing Indentation
323 @cindex Customizing Indentation
324
325 @cindex vhdl-set-offset
326 @cindex set-offset (vhdl-)
327 The @code{vhdl-offsets-alist} variable is where you customize all your
328 indentations. You simply need to decide what additional offset you want
329 to add for every syntactic symbol. You can use the command @kbd{C-c
330 O} (@code{vhdl-set-offset}) as the way to set offsets, both
331 interactively and from your mode hook. Also, you can set up
332 @emph{styles} of indentation. Most likely, you'll find one of the
333 pre-defined styles will suit your needs, but if not, this section will
334 describe how to set up basic editing configurations. @xref{Styles}, for
335 an explanation of how to set up named styles.
336
337 @cindex vhdl-basic-offset
338 @cindex basic-offset (vhdl-)
339 As mentioned previously, the variable @code{vhdl-offsets-alist} is an
340 association list between syntactic symbols and the offsets to be applied
341 for those symbols. In fact, these offset values can be an integer, a
342 function or variable name, or one of the following symbols: @code{+},
343 @code{-}, @code{++}, @code{--}, @code{*}, or @code{/}. The symbol
344 values have the following meanings:
345
346 @itemize @bullet
347
348 @item
349 @code{+} -- 1 x @code{vhdl-basic-offset}
350 @item
351 @code{-} -- -1 x @code{vhdl-basic-offset}
352 @item
353 @code{++} -- 2 x @code{vhdl-basic-offset}
354 @item
355 @code{--} -- -2 x @code{vhdl-basic-offset}
356 @item
357 @code{*} -- 0.5 x @code{vhdl-basic-offset}
358 @item
359 @code{/} -- -0.5 x @code{vhdl-basic-offset}
360
361 @end itemize
362
363 @noindent
364 So, for example, because most of the default offsets are defined in
365 terms of @code{+}, @code{-}, and @code{0}, if you like the general
366 indentation style, but you use 2 spaces instead of 4 spaces per level,
367 you can probably achieve your style just by changing
368 @code{vhdl-basic-offset} like so (in your @file{.emacs} file):
369 @example
370
371 (setq vhdl-basic-offset 2)
372
373 @end example
374
375 To change indentation styles more radically, you will want to change the
376 value associated with the syntactic symbols in the
377 @code{vhdl-offsets-alist} variable. First, I'll show you how to do that
378 interactively, then I'll describe how to make changes to your
379 @file{.emacs} file so that your changes are more permanent.
380
381 @menu
382 * Interactive Customization::
383 * Permanent Customization::
384 * Styles::
385 * Advanced Customizations::
386 @end menu
387
388 @node Interactive Customization
389 @section Interactive Customization
390 @cindex Interactive Customization
391
392 As an example of how to customize indentation, let's change the
393 style of the example above from:
394 @example
395 @group
396
397 1: inverter : process
398 2: begin
399 3: q <= not d;
400 4: wait on d;
401 5: end inverter;
402
403 @end group
404 @end example
405 @noindent
406 to:
407 @example
408 @group
409
410 1: inverter : process
411 2: begin
412 3: q <= not d;
413 4: wait on d;
414 5: end inverter;
415
416 @end group
417 @end example
418
419 In other words, we want to change the indentation of the statements
420 inside the inverter process. Notice that the construct we want to
421 change starts on line 3. To change the indentation of a line, we need
422 to see which syntactic component affect the offset calculations for that
423 line. Hitting @kbd{C-c C-x} on line 3 yields:
424 @example
425
426 ((statement-block-intro . 20))
427
428 @end example
429
430 @findex vhdl-set-offset
431 @findex set-offset (vhdl-)
432 @kindex C-c O
433 @noindent
434 So we know that to change the offset of the first signal assignment, we need to
435 change the indentation for the @code{statement-block-intro} syntactic
436 symbol. To do this interactively, just hit @kbd{C-c O}
437 (@code{vhdl-set-offset}). This prompts you for the syntactic symbol to
438 change, providing a reasonable default. In this case, the default is
439 @code{statement-block-intro}, which is just the syntactic symbol we want to
440 change!
441
442 After you hit return, VHDL Mode will then prompt you for the new
443 offset value, with the old value as the default. The default in this
444 case is @samp{+}, so hit backspace to delete the @samp{+}, then hit
445 @samp{++} and @kbd{RET}. This will associate an offset of twice the
446 basic indent with the syntactic symbol @code{statement-block-intro} in
447 the @code{vhdl-offsets-alist} variable.
448
449 @findex vhdl-indent-defun
450 @findex indent-defun (vhdl-)
451 To check your changes quickly, just enter @kbd{M-x vhdl-indent-defun} to
452 reindent the entire function. The example should now look like:
453 @example
454 @group
455
456 1: inverter : process
457 2: begin
458 3: q <= not d;
459 4: wait on d;
460 5: end inverter;
461
462 @end group
463 @end example
464
465 Notice how just changing the offset on line 3 is all we needed to do.
466 Since the other affected lines are indented relative to line 3, they are
467 automatically indented the way you'd expect. For more complicated
468 examples, this may not always work. The general approach to take is to
469 always start adjusting offsets for lines higher up in the file, then
470 re-indent and see if any following lines need further adjustments.
471
472 @node Permanent Customization
473 @section Permanent Indentation
474 @cindex Permanent Indentation
475
476 @vindex vhdl-mode-hook
477 @cindex hooks
478 To make this change permanent, you need to add some lisp code to your
479 @file{.emacs} file. VHDL Mode provides a @code{vhdl-mode-hook}
480 that you can use to customize your language editing styles. This hook
481 gets run as the last thing when you enter VHDL Mode.
482
483 Here's a simplified example of what you can add to your @file{.emacs}
484 file to make the changes described in the previous section
485 (@ref{Interactive Customization}) more permanent. See the Emacs
486 manuals for more information on customizing Emacs via hooks.
487 @xref{Sample .emacs File}, for a more complete sample @file{.emacs} file.
488
489 @example
490 @group
491
492 (defun my-vhdl-mode-hook ()
493 ;; my customizations for all of vhdl-mode
494 (vhdl-set-offset 'statement-block-intro '++)
495 ;; other customizations can go here
496 )
497 (add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
498
499 @end group
500 @end example
501
502 For complex customizations, you will probably want to set up a
503 @emph{style} that groups all your customizations under a single
504 name. @xref{Styles}.
505
506 The offset value can also be a function, and this is how power users
507 gain enormous flexibility in customizing indentation. @xref{Advanced
508 Customizations}.
509
510 @node Styles
511 @section Styles
512 @cindex Styles
513
514 Most people only need to edit code formatted in just a few well-defined
515 and consistent styles. For example, their organization might impose a
516 ``blessed'' style that all its programmers must conform to. Similarly,
517 people who work on GNU software will have to use the GNU coding style on
518 C code. Some shops are more lenient, allowing some variety of coding
519 styles, and as programmers come and go, there could be a number of
520 styles in use. For this reason, VHDL Mode makes it convenient for
521 you to set up logical groupings of customizations called @dfn{styles},
522 associate a single name for any particular style, and pretty easily
523 start editing new or existing code using these styles. This chapter
524 describes how to set up styles and how to edit your C code using styles.
525
526 @menu
527 * Built-in Styles::
528 * Adding Styles::
529 * File Styles::
530 @end menu
531
532
533 @node Built-in Styles
534 @subsection Built-in Styles
535 @cindex Built-in Styles
536
537 If you're lucky, one of VHDL Mode's built-in styles might be just
538 what you're looking for. Some of the most common VHDL styles are
539 already built-in. These include:
540
541 @itemize @bullet
542 @item
543 @cindex IEEE style
544 @code{GNU} -- the coding style in the IEEE Language Reference Manual.
545
546 @end itemize
547
548 @findex vhdl-set-style
549 @findex set-style (vhdl-)
550 If you'd like to experiment with these built-in styles you can simply
551 type @kbd{M-x vhdl-set-style RET} in a VHDL Mode buffer.
552
553 You will be prompted for one of the above styles (with completion).
554 Enter one of the styles and hit @kbd{RET}. Note however that setting a
555 style in this way does @emph{not} automatically re-indent your file.
556 @ignore
557 For commands that you can use to view the effect of your changes, see
558 @ref{Indentation Commands}.
559 @end ignore
560
561 Once you find a built-in style you like, you can make the change
562 permanent by adding a call to your @file{.emacs} file. Let's say for
563 example that you want to use the @code{IEEE} style in all your
564 files. You would add this:
565 @example
566 @group
567
568 (defun my-vhdl-mode-hook ()
569 ;; use IEEE style for all VHDL code
570 (vhdl-set-style "IEEE")
571 ;; other customizations can go here
572 )
573 (add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
574
575 @end group
576 @end example
577
578 @noindent
579 @xref{Permanent Customization}.
580
581 @node Adding Styles
582 @subsection Adding Styles
583 @cindex Adding Styles
584
585 @vindex vhdl-style-alist
586 @vindex style-alist (vhdl-)
587 @findex vhdl-add-style
588 @findex add-style (vhdl-)
589 If none of the built-in styles is appropriate, you'll probably want to
590 add a new style definition. Styles are kept in the @code{vhdl-style-alist}
591 variable, but you probably won't want to modify this variable directly.
592 VHDL Mode provides a function, called @code{vhdl-add-style}, that you
593 can use to easily add new styles or update existing styles. This
594 function takes two arguments, a @var{stylename} string, and an
595 association list @var{description} of style customizations. If
596 @var{stylename} is not already in @code{vhdl-style-alist}, the new style is
597 added, otherwise the style already associated with @var{stylename} is
598 changed to the new @var{description}. This function also takes an
599 optional third argument, which if non-@code{nil}, automatically
600 institutes the new style in the current buffer.
601
602 The sample @file{.emacs} file provides a concrete example of how a new
603 style can be added and automatically set. @xref{Sample .emacs File}.
604
605 @node File Styles
606 @subsection File Styles
607 @cindex File Styles
608
609 @cindex local variables
610 The Emacs manual describes how you can customize certain variables on a
611 per-file basis by including a @dfn{Local Variable} block at the end of
612 the file. So far, you've only seen a functional interface to
613 VHDL Mode, which is highly inconvenient for use in a Local Variable
614 block. VHDL Mode provides two variables that make it easier for
615 you to customize your style on a per-file basis.
616
617 @vindex vhdl-file-style
618 @vindex file-style (vhdl-)
619 @vindex vhdl-file-offsets
620 @vindex file-offsets (vhdl-)
621
622 The variable @code{vhdl-file-style} can be set to a style name string as
623 described in @ref{Built-in Styles}. When the file is visited,
624 VHDL Mode will automatically set the file's style to this style
625 using @code{vhdl-set-style}.
626
627 @vindex vhdl-offsets-alist
628 @vindex offsets-alist (vhdl-)
629 @findex vhdl-set-offset
630 @findex set-offset (vhdl-)
631 Another variable, @code{vhdl-file-offsets}, takes an association list
632 similar to what is allowed in @code{vhdl-offsets-alist}. When the file is
633 visited, VHDL Mode will automatically institute these offsets using
634 @code{vhdl-set-offset}. @xref{Customizing Indentation}.
635
636 Note that file style settings (i.e., @code{vhdl-file-style}) are applied
637 before file offset settings (i.e., @code{vhdl-file-offsets}).
638
639
640 @node Advanced Customizations
641 @section Advanced Customizations
642 @cindex Advanced Customizations
643
644 @vindex vhdl-style-alist
645 @vindex style-alist (vhdl-)
646 @vindex vhdl-basic-offset
647 @vindex basic-offset (vhdl-)
648 For most users, VHDL Mode will support their coding styles with
649 very little need for customizations. Usually, one of the standard
650 styles defined in @code{vhdl-style-alist} will do the trick. Sometimes,
651 one of the syntactic symbol offsets will need to be tweaked slightly, or
652 perhaps @code{vhdl-basic-offset} will need to be changed. However, some
653 styles require a more advanced ability for customization, and one of the
654 real strengths of VHDL Mode is that the syntactic analysis model
655 provides a very flexible framework for customizing indentation. This
656 allows you to perform special indentation calculations for situations
657 not handled by the mode directly.
658
659 @menu
660 * Custom Indentation Functions::
661 * Other Special Indentations::
662 @end menu
663
664 @node Custom Indentation Functions
665 @subsection Custom Indentation Functions
666 @cindex Custom Indentation Functions
667
668 @cindex custom indentation functions
669 One of the most common ways to customize VHDL Mode is by writing
670 @dfn{custom indentation functions} and associating them with specific
671 syntactic symbols (see @ref{Syntactic Symbols}). VHDL Mode itself
672 uses custom indentation functions to provide more sophisticated
673 indentation, for example when lining up selected signal assignments:
674 @example
675 @group
676
677 %%% TBD %%%
678
679 @end group
680 @end example
681
682 In this example, the @code{statement-cont} syntactic symbol has an
683 offset of @code{+}, and @code{vhdl-basic-offset} is 2, so lines 4
684 through 6 are simply indented two spaces to the right of line 3. But
685 perhaps we'd like VHDL Mode to be a little more intelligent so
686 that it offsets the waveform descriptions relative to the signal
687 assignment operator in line 3. To do this, we have to write a custom
688 indentation function which finds the column of signal assignment
689 operator on the first line of the statement. Here is the lisp code
690 (from the @file{vhdl-mode.el} source file) that implements this:
691 @example
692 @group
693
694 (defun vhdl-lineup-statement-cont (langelem)
695 ;; line up statement-cont after the assignment operator
696 (save-excursion
697 (let* ((relpos (cdr langelem))
698 (assignp (save-excursion
699 (goto-char (vhdl-point 'boi))
700 (and (re-search-forward "\\(<\\|:\\)="
701 (vhdl-point 'eol) t)
702 (- (point) (vhdl-point 'boi)))))
703 (curcol (progn
704 (goto-char relpos)
705 (current-column)))
706 foundp)
707 (while (and (not foundp)
708 (< (point) (vhdl-point 'eol)))
709 (re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
710 (if (vhdl-in-literal (cdr langelem))
711 (forward-char)
712 (if (= (preceding-char) ?\()
713 ;; skip over any parenthesized expressions
714 (goto-char (min (vhdl-point 'eol)
715 (scan-lists (point) 1 1)))
716 ;; found an assignment operator (not at eol)
717 (setq foundp (not (looking-at "\\s-*$"))))))
718 (if (not foundp)
719 ;; there's no assignment operator on the line
720 vhdl-basic-offset
721 ;; calculate indentation column after assign and ws, unless
722 ;; our line contains an assignment operator
723 (if (not assignp)
724 (progn
725 (forward-char)
726 (skip-chars-forward " \t")
727 (setq assignp 0)))
728 (- (current-column) assignp curcol))
729 )))
730
731 @end group
732 @end example
733 @noindent
734 Custom indent functions take a single argument, which is a syntactic
735 component cons cell (see @ref{Syntactic Analysis}). The
736 function returns an integer offset value that will be added to the
737 running total indentation for the lne. Note that what actually gets
738 returned is the difference between the column that the signal assignment
739 operator is on, and the column of the buffer relative position passed in
740 the function's argument. Remember that VHDL Mode automatically
741 adds in the column of the component's relative buffer position and we
742 don't want that value added into the final total twice.
743
744 @cindex statement-cont syntactic symbol
745 @findex vhdl-lineup-statement-cont
746 @findex lineup-statement-cont (vhdl-)
747 Now, to associate the function @code{vhdl-lineup-statement-cont} with the
748 @code{statement-cont} syntactic symbol, we can add something like the
749 following to our @code{vhdl-mode-hook}:
750 @example
751
752 (vhdl-set-offset 'statement-cont 'vhdl-lineup-statement-cont)
753
754 @end example
755
756 @findex vhdl-indent-defun
757 Now the function looks like this after re-indenting (using @kbd{M-x
758 vhdl-indent-defun}):
759 @example
760 @group
761
762 %%% TBD %%%
763
764 @end group
765 @end example
766
767 @vindex vhdl-offsets-alist
768 @vindex offsets-alist (vhdl-)
769 Custom indentation functions can be as simple or as complex as you like,
770 and any syntactic symbol that appears in @code{vhdl-offsets-alist} can have
771 a custom indentation function associated with it. Note however that
772 using many custom indentation functions may have a performance impact on
773 VHDL Mode.
774
775 @node Other Special Indentations
776 @subsection Other Special Indentations
777 @cindex Other Special Indentations
778
779 @vindex vhdl-special-indent-hook
780 @vindex special-indent-hook (vhdl-)
781 One other variable is available for you to customize VHDL Mode:
782 @code{vhdl-special-indent-hook}. This is a standard hook variable that
783 is called after every line is indented by VHDL Mode. You can use
784 it to do any special indentation or line adjustments your style
785 dictates, such as adding extra indentation to the port map clause in a
786 component instantiation, etc. Note however, that you should not change
787 @code{point} or @code{mark} inside your @code{vhdl-special-indent-hook}
788 functions.
789
790
791 @node Syntactic Symbols
792 @chapter Syntactic Symbols
793 @cindex Syntactic Symbols
794
795 @vindex vhdl-offsets-alist
796 The complete list of recognized syntactic symbols is described in the
797 @code{vhdl-offsets-alist} variable. This chapter will provide some
798 examples to help clarify these symbols.
799
800 @cindex -open syntactic symbols
801 @cindex -close syntactic symbols
802 Most syntactic symbol names follow a general naming convention. When a
803 line begins with a @code{begin} or @code{end} keyword, the syntactic
804 symbol will contain the suffix @code{-open} or @code{-close}
805 respectively.
806
807 @cindex -intro syntactic symbols
808 @cindex -cont syntactic symbols
809 @cindex -block-intro syntactic symbols
810 Usually, a distinction is made between the first line that introduces a
811 construct and lines that continue a construct, and the syntactic symbols
812 that represent these lines will contain the suffix @code{-intro} or
813 @code{-cont} respectively. As a sub-classification of this scheme, a
814 line which is the first of a particular block construct will contain the
815 suffix @code{-block-intro}.
816
817 @strong{<TBD> include the name and a brief example of every syntactic
818 symbol currently recognized}
819
820 @node Frequently Asked Questions
821 @chapter Frequently Asked Questions
822 @cindex Frequently Asked Questions
823
824 @kindex C-x h
825 @kindex ESC C-\
826 @kindex ESC C-q
827 @kindex ESC C-u
828 @kindex RET
829 @kindex LFD
830 @findex newline-and-indent
831 @quotation
832
833 @strong{Q.} @emph{How do I re-indent the whole file?}
834
835 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole
836 buffer. Then hit @kbd{@key{ESC} C-\} to re-indent the entire region
837 which you've just marked. Or just enter @kbd{M-x vhdl-indent-buffer}.
838 @sp 2
839
840 @strong{Q.} @emph{How do I re-indent the entire function?}
841
842 @strong{A.} Hit @kbd{@key{ESC} C-h} to mark the entire function. Then
843 hit @kbd{@key{ESC} C-\} to re-indent the entire region which you've just
844 marked.
845 @sp 2
846
847 @strong{Q.} @emph{How do I re-indent the current block?}
848
849 @strong{A.} First move to the brace which opens the block with
850 @kbd{@key{ESC} C-u}, then re-indent that expression with
851 @kbd{@key{ESC} C-q}.
852 @sp 2
853
854 @strong{Q.} @emph{How do I re-indent the current statement?}
855
856 @strong{A.} First move to the beginning of the statement with
857 @kbd{@key{ESC} a}, then re-indent that expression with @kbd{@key{ESC}
858 C-q}.
859 @sp 2
860
861 @strong{Q.} @emph{I put @code{(vhdl-set-offset 'statement-cont 0)}
862 in my @file{.emacs} file but I get an error saying that
863 @code{vhdl-set-offset}'s function definition is void.}
864
865 @strong{A.} This means that VHDL Mode wasn't loaded into your
866 Emacs session by the time the @code{vhdl-set-offset} call was reached,
867 mostly likely because VHDL Mode is being autoloaded. Instead
868 of putting the @code{vhdl-set-offset} line in your top-level
869 @file{.emacs} file, put it in your @code{vhdl-mode-hook}, or
870 simply add the following to the top of your @file{.emacs} file:
871 @example
872
873 (require 'vhdl-mode)
874
875 @end example
876
877 See the sample @file{.emacs} file @ref{Sample .emacs File} for
878 details.
879
880 @end quotation
881
882
883 @node Getting the latest VHDL Mode release
884 @chapter Getting the latest VHDL Mode release
885 @cindex Getting the latest VHDL Mode release
886
887 The best way to be sure you always have the latest VHDL Mode release
888 is to join the @code{vhdl-mode-announce} mailing list. If you are a
889 brave soul, and wish to participate in beta testing of new releases of
890 VHDL Mode, you may also join the @code{vhdl-mode-victims} mailing
891 list. Send email to the maintainer @email{reto@@gnu.org} to join
892 either of these lists.
893
894 The official Emacs VHDL Mode Home Page can be found at
895 @uref{http://www.iis.ee.ethz.ch/~zimmi/emacs/vhdl-mode.html}.
896
897 @node Sample .emacs File
898 @chapter Sample @file{.emacs} file
899 @cindex Sample @file{.emacs} file
900
901 Most customizations can be done using the ``Customize'' entry in the
902 VHDL Mode menu, which requires no editing of the .emacs file.
903 If you want to customize indentation, here you go:
904
905 @example
906 ;; Here's a sample .emacs file that might help you along the way. Just
907 ;; copy this region and paste it into your .emacs file. You may want to
908 ;; change some of the actual values.
909
910 (defconst my-vhdl-style
911 '((vhdl-tab-always-indent . t)
912 (vhdl-comment-only-line-offset . 4)
913 (vhdl-offsets-alist . ((arglist-close . vhdl-lineup-arglist)
914 (statement-cont . 0)
915 (case-alternative . 4)
916 (block-open . 0)))
917 (vhdl-echo-syntactic-information-p . t)
918 )
919 "My VHDL Programming Style")
920
921 ;; Customizations for vhdl-mode
922 (defun my-vhdl-mode-hook ()
923 ;; add my personal style and set it for the current buffer
924 (vhdl-add-style "PERSONAL" my-vhdl-style t)
925 ;; offset customizations not in my-vhdl-style
926 (vhdl-set-offset 'statement-case-intro '++)
927 ;; other customizations
928 (setq tab-width 8
929 ;; this will make sure spaces are used instead of tabs
930 indent-tabs-mode nil)
931 ;; keybindings for VHDL are put in vhdl-mode-map
932 (define-key vhdl-mode-map "\C-m" 'newline-and-indent)
933 )
934
935 (add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
936 @end example
937
938 @node Limitations and Known Bugs
939 @chapter Limitations and Known Bugs
940 @cindex Limitations and Known Bugs
941
942 @itemize @bullet
943 @item
944 Re-indenting large regions or expressions can be slow.
945
946 @ignore
947 @item
948 The index menu does not work on my XEmacs installation (don't know why).
949 @end ignore
950
951 @end itemize
952
953 @node Mailing Lists and Submitting Bug Reports
954 @chapter Mailing Lists and Submitting Bug Reports
955 @cindex Mailing Lists and Submitting Bug Reports
956
957 @kindex C-c C-b
958 @findex vhdl-submit-bug-report
959 @findex submit-bug-report (vhdl-)
960 @cindex beta testers mailing list
961 @cindex announcement mailing list
962 To report bugs, use the @kbd{C-c C-b} (@code{vhdl-submit-bug-report})
963 command. This provides vital information I need to reproduce your
964 problem. Make sure you include a concise, but complete code example.
965 Please try to boil your example down to just the essential code needed
966 to reproduce the problem, and include an exact recipe of steps needed to
967 expose the bug. Be especially sure to include any code that appears
968 @emph{before} your bug example.
969
970 For other help or suggestions, send a message to @email{reto@@gnu.org}.
971
972 Send an add message to @email{reto@@gnu.org} to get on the
973 @code{vhdl-mode-victims} beta testers list where beta releases of
974 VHDL Mode are posted. Note that you shouldn't expect beta
975 releases to be as stable as public releases.
976
977 There is also an announce only list where the latest public releases
978 of VHDL Mode are posted. Send an add message to
979 @email{reto@@gnu.org} to be added to this list.
980
981
982 @node GNU Free Documentation License
983 @appendix GNU Free Documentation License
984 @include doclicense.texi
985
986
987 @node Concept Index
988 @unnumbered Concept Index
989
990 @printindex cp
991
992
993 @node Command Index
994 @unnumbered Command Index
995
996 Since all VHDL Mode commands are prepended with the string
997 @samp{vhdl-}, each appears under its @code{vhdl-<thing>} name and its
998 @code{<thing> (vhdl-)} name.
999 @iftex
1000 @sp 2
1001 @end iftex
1002 @printindex fn
1003
1004
1005 @node Key Index
1006 @unnumbered Key Index
1007
1008 @printindex ky
1009
1010
1011 @node Variable Index
1012 @unnumbered Variable Index
1013
1014 Since all VHDL Mode variables are prepended with the string
1015 @samp{vhdl-}, each appears under its @code{vhdl-<thing>} name and its
1016 @code{<thing> (vhdl-)} name.
1017 @iftex
1018 @sp 2
1019 @end iftex
1020 @printindex vr
1021
1022 @bye