1 ;;; document-vars.el --- Default settings for the document package.
3 ;;; Copyright (C) 2000, 2001 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; X-RCS: $Id: document-vars.el,v 1.4 2005/09/30 20:18:39 zappo Exp $
9 ;; This file is not part of GNU Emacs.
11 ;; Semantic is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This software is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; Default settings for the document comment generation package.
32 (provide 'document-vars)
41 (defvar document-comment-start nil
42 "Comment start string.")
44 (defvar document-comment-line-prefix nil
45 "Comment prefix string. Used at the beginning of each line.")
47 (defvar document-comment-end nil
48 "Comment end string.")
50 (defcustom document-copyright-notice-file nil
51 "*A file name containing a copyright notice.
52 It will be reformatted in the header to have the correct prefix character.
53 See the %N token in `document-file-comment'"
57 (defcustom document-change-number nil
58 "*The current change number being worked on.
59 Large projects may use change numbers, bug numbers, or other tag."
63 (defcustom document-extra-line-after-short-parameters t
64 "*Non-nil to add an extra line when there is < 1 arguments."
68 (defvar document-comment-left-edge-character nil
69 "*Language/preference specific characters to use in comments.")
71 (defcustom document-file-comment "%s %B
73 %m Copyright (C) %Y %O
87 "Comment block for the beginning of a new file.
88 The format tokens available are:
89 %B - Brief description of the file (Auto-comment by file name)
90 %D - Made up documentation
91 %N - Copyright notice for your organization
92 %O - Owner (full name of copyright holder held in `document-copyright-holder'
94 %T - cproto header id token. Always is form 'token file.h' where
95 token is defined in cpr-header-token, and file.h is the
96 relational file name of the header. If you wish to use cproto's
97 features, you must have this somewhere in the header.
100 %b - Comment start string
101 %m - Comment line prefix (not the start)
102 %e - Comment end string"
106 (defcustom document-header-comment "%b
107 %m Copyright (c) %Y %O
115 "Comment block for the beginning of a new header/dependency file.
116 The format tokens available are the same as for `document-file-comment'"
120 (defcustom document-file-brief-comment "%F - %C"
121 "Format of the brief comment with tokens.
122 Available tokens are:
128 (defcustom document-function-comment "
\f
140 "Comment block for the beginning of a new function/variable definition.
141 There are several format tokens represent the following:
143 %D - Made up documentation
144 %f - Place, where everything before the point is the distance to set
145 in the fill prefix. Allows a first line in paragraph indent
146 %p - Where to place point after insertion of a new header
149 %H - History insertion point
151 The parts %f and %p can be confusing, so here is an example:
155 Will set fill prefix to ` * `, and put the point AFTER the
156 description. The `Moose:` will not be in the prefix. The default
157 value shows the equivalent of a hanging indent.
160 %b - Comment start string
161 %m - Comment line prefix (not the start)
162 %e - Comment end string"
166 (defcustom document-param-element "%P - %D"
167 "The format of a parameter element in the list of parameters.
169 %P - Parameter name spaced to length of max param
170 %p - Parameter name with no padding
172 %D - Description of parameter as known by document."
176 (defcustom document-history-element "%-7U %-10D %C"
177 "Format for history element.
179 %U - Username, initials, what have you.
180 %D - The current date formatted as in `document-date-element'
181 %S - System Change id, SCCS vers, major change comment, etc
182 %C - Auto comment area, cursor goes here for new elts."
186 (defcustom document-date-element "%M/%D/%y"
187 "Format for date elements.
188 Valid format chars are:
190 %h - Hours 24 hr format
199 %y - Year as 2 numbers 1994 -> 94"
203 (defcustom document-autocomment-function-alist
205 ("abort" . "Aborts the")
206 ;; trick to get re-alloc and alloc to pair into one sentence.
207 ("realloc" . "moves or ")
208 ("alloc\\(ate\\)?" . "Allocates and initializes a new ")
209 ("clean" . "Cleans up the")
210 ("clobber" . "Removes")
211 ("close" . "Cleanly closes")
212 ("check" . "Checks the")
213 ("comp\\(are\\)?" . "Compares the")
214 ("create" . "Creates a new ")
216 ("free" . "Frees up space")
217 ("gen\\(erate\\)?" . "Generates a new ")
218 ("get\\|find" . "Looks for the given ")
219 ("gobble" . "Removes")
220 ("he?lp" . "Provides help for")
221 ("li?ste?n" . "Listens for ")
222 ("connect" . "Connects to ")
223 ("acc?e?pt" . "Accepts a ")
224 ("load" . "Loads in ")
225 ("match" . "Check that parameters match")
226 ("name" . "Provides a name which ")
227 ("parse" . "Parses the parameters and returns ")
228 ("print\\|display" . "Prints out")
229 ("read" . "Reads from")
230 ("reset" . "Resets the parameters and returns")
231 ("scan" . "Scans the ")
232 ("setup\\|init\\(iallize\\)?" . "Initializes the ")
233 ("select" . "Chooses the ")
235 ("re?c\\(v\\|ieves?\\)" . "Receives a ")
236 ("wait" . "Waits for ")
237 ("write" . "Writes to")
239 "List of names to string match against the function name.
240 This is an alist with each element of the form:
242 MATCH is a regexp to match in the type field.
245 Certain prefixes may always mean the same thing, and the same comment
246 can be used as a beginning for the description. Regexp should be
247 lower case since the string they are compared to is downcased.
248 A string may end in a space, in which case, last-alist is searched to
249 see how best to describe what can be returned.
250 Doesn't always work correctly, but that is just because English
251 doesn't always work correctly."
253 :type '(repeat (cons (string :tag "Regexp")
254 (string :tag "Doc Text"))))
256 (defcustom document-autocomment-common-nouns-abbrevs
258 ("sock\\(et\\)?" . "socket")
259 ("addr\\(ess\\)?" . "address")
260 ("buf\\(f\\(er\\)?\\)?" . "buffer")
261 ("cur\\(r\\(ent\\)?\\)?" . "current")
262 ("dev\\(ice\\)?" . "device")
265 ("msg\\|message" . "message")
267 ("next\\|nxt" . "next")
270 ("obj\\|object" . "object")
271 ("previous\\|prev" . "previous")
272 ("str\\(ing\\)?" . "string")
274 ("num\\(ber\\)?" . "number")
275 ("\\(^\\|\\s-\\)id\\($\\|\\s-\\)" . "Identifier") ;complex cause ;commen sylable
277 "List of common English abbreviations or full words.
278 These are nouns (as opposed to verbs) for use in creating expanded
279 versions of names.This is an alist with each element of the form:
281 MATCH is a regexp to match in the type field.
284 :type '(repeat (cons (string :tag "Regexp")
285 (string :tag "Doc Text"))))
287 (defcustom document-autocomment-return-first-alist
289 ;; Static must be first in the list to provide the intro to the sentence
290 ("static" . "Locally defined function which ")
291 ("Bool\\|BOOL" . "Status of ")
293 "List of regexp matches for types.
294 They provide a little bit of text when typing information is
296 This is an alist with each element of the form:
298 MATCH is a regexp to match in the type field.
301 :type '(repeat (cons (string :tag "Regexp")
302 (string :tag "Doc Text"))))
304 (defcustom document-autocomment-return-last-alist
306 ("static[ \t\n]+struct \\([a-zA-Z0-9_]+\\)" . "%s")
307 ("struct \\([a-zA-Z0-9_]+\\)" . "%s")
308 ("static[ \t\n]+union \\([a-zA-Z0-9_]+\\)" . "%s")
309 ("union \\([a-zA-Z0-9_]+\\)" . "%s")
310 ("static[ \t\n]+enum \\([a-zA-Z0-9_]+\\)" . "%s")
311 ("enum \\([a-zA-Z0-9_]+\\)" . "%s")
312 ("static[ \t\n]+\\([a-zA-Z0-9_]+\\)" . "%s")
313 ("\\([a-zA-Z0-9_]+\\)" . "of type %s")
315 "List of regexps which provide the type of the return value.
316 This is an alist with each element of the form:
318 MATCH is a regexp to match in the type field.
319 RESULT is a string, which can contain %s, whih is replaced with
322 :type '(repeat (cons (string :tag "Regexp")
323 (string :tag "Doc Text"))))
325 (defcustom document-autocomment-param-alist
326 '( ("[Cc]txt" . "Context")
327 ("[Ii]d" . "Identifier of")
328 ("[Tt]ype" . "Type of")
329 ("[Nn]ame" . "Name of")
330 ("argc" . "Number of arguments")
331 ("argv" . "Argument vector")
332 ("envp" . "Environment variable vector")
334 "Alist of common variable names appearing as function parameters.
335 This is an alist with each element of the form:
337 MATCH is a regexp to match in the type field.
338 RESULT is a string of text to use to describe MATCH.
339 When one is encountered, document-insert-parameters will automatically
340 place this comment after the parameter name."
342 :type '(repeat (cons (string :tag "Regexp")
343 (string :tag "Doc Text"))))
345 (defcustom document-autocomment-param-type-alist
346 '(("const" . "Constant")
348 ("char[ ]*\\*" . "String ")
349 ("\\*\\*" . "Pointer to ")
351 ("char[ ]*\\([^ \t*]\\|$\\)" . "Character")
352 ("int\\|long" . "Number of")
354 ("float\\|double" . "Value of")
355 ;; How about some X things?
356 ("Bool\\|BOOL" . "Flag")
357 ("Window" . "Window")
358 ("GC" . "Graphic Context")
359 ("Widget" . "Widget")
361 "Alist of input parameter types and strings desribing them.
362 This is an alist with each element of the form:
364 MATCH is a regexp to match in the type field.
367 :type '(repeat (cons (string :tag "Regexp")
368 (string :tag "Doc Text"))))
370 (defcustom document-new-hist-comment "Created"
371 "Comment used in the history when something is created."
375 (defvar document-autocomment-modify-alist
376 '((document-newparam . "%s")
378 "Alist of history change calculations.
379 This is an alist with each element of the form:
381 FUNCTION is a function to run to check for chnges.
382 RESULT is a string with %s being filled with change text.")
384 ;;; A few fns to access some variables.
385 (defun document-comment-start ()
386 "Derive a string to start a comment in this mode."
387 (or document-comment-start
391 (defun document-comment-line-prefix ()
392 "Derive a string to end a comment in this mode."
393 (or document-comment-line-prefix
396 (defun document-comment-end ()
397 "Derive a string to end a comment in this mode."
398 (or document-comment-end
402 ;;; document-vars.el ends here