Initial commit

This commit is contained in:
John Doty 2012-03-22 07:16:09 -07:00
commit a491ef2093
813 changed files with 345031 additions and 0 deletions

665
site-lisp/ChangeLog Normal file
View file

@ -0,0 +1,665 @@
2002-04-19 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.2.5 released
2002-03-17 Lennart Staflin <lenst@lysator.liu.se>
* psgml-api.el (sgml-map-content): don't try to map empty
elements, no point and the code doesn't work for that case.
2002-02-13 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-auto-insert-required-elements): doc fix.
(sgml-balanced-tag-edit): doc fix.
* psgml-edit.el (sgml-edit-attrib-default): don't make text read-only
(sgml-insert-tag): doc fix.
2002-02-09 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el: Explicitly setup prefix keys
(sgml-prefix-f-map): new var
(sgml-prefix-u-map): new var
2002-02-08 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-set-buffer-multibyte): support setting to
default
(sgml-compile-dtd): removed sgml-set-buffer-multibyte, this is
done by sgml-write-dtd
(sgml-push-to-entity): reset buffer to default multibyte support
* psgml-dtd.el (sgml-write-dtd): fixes for multibyte handling
2001-12-20 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-xml-validate-command): new option. Default for
sgml-validate-command in XML mode.
(xml-mode): use sgml-xml-validate-command.
(xml-mode): remove conditional. Always set sgml-declaration to
sgml-xml-declaration.
2001-12-18 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-attribute-buffer): Don't write-protect the
"#DEFAULT" marker.
(sgml-extract-attribute-value): strip any remains of "#DEFAULT".
(sgml-edit-attrib-next): if point is before the attribute value,
move to beginning of line to avoid skipping this attribute.
2001-12-16 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.2.4 released
2001-12-16 Lennart Staflin <lenst@lysator.liu.se>
* psgml-info.el (sgml-eltype-refrenced-elements): use built-in
function copy-sequence
2001-12-14 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-set-buffer-multibyte): Mule/multibyte patch
from Yasushi Abe.
(sgml-compile-dtd): dito.
(sgml-bdtd-merge): dito.
(sgml-push-to-entity): dito.
(sgml-do-entity-ref): fix sgml-warn-about-undefined-entities behviour.
2001-12-06 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-update-display): take max-pos of top-tree
not current-tree as that is not always defined at that point.
2001-11-09 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.2.3 released
* psgml.el (sgml-running-lucid): make sure it gets defined during
compilation.
2001-11-04 Lennart Staflin <lenst@lysator.liu.se>
* psgml-other.el, psgml-parse.el, psgml-debug.el, psgml-edit.el:
Fix the obsolete variable `before-change-function' and
`after-change-function', which are no longer used by Emacs.
2001-02-10 Adrian Aichner <adrian@xemacs.org>
* psgml-dtd.el: Fix typos.
* psgml-edit.el: Ditto.
* psgml-fs.el: Ditto.
* psgml-info.el: Ditto.
* psgml-parse.el: Ditto.
* psgml.el: Ditto.
Wed Feb 28 00:02:45 2001 Lennart Staflin <lenst@lysator.liu.se>
* psgml-fs.el (fs-split-tokens): new helper function for use in
style sheets.
2001-02-28 Lennart Staflin <lennarts@infostream.no>
* psgml-other.el (sgml-split-long-menus): new
(sgml-popup-menu): use above
(sgml-popup-multi-menu): use above
Wed Feb 21 23:30:07 2001 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-parse-to): remove debug code
2001-02-20 Lennart Staflin <lennarts@infostream.no>
* psgml-dtd.el (sgml-check-content): check case of declared
content name.
(sgml-parse-exception): fix misspelled function name
(sgml-declare-entity): Fix wrong case on symbols
(sgml-parse-entity-type): for consistency, don't downcase entity
type name
(sgml-parse-entity-type): Remove case check and intern for
notation name. Notation name will be stored as a string.
* psgml-parse.el (sgml-push-to-entity): remove debugging code
(sgml-set-initial-state): Change to use change hooks
Fri Feb 9 01:06:27 2001 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.2.2 released
* psgml.el (sgml-mode-map): Bind (meta control h) instead of ESC
C-h, avoids redefining M-BS
Thu Feb 8 20:08:47 2001 Lennart Staflin <lenst@lysator.liu.se>
* psgml-info.el: Add provide psgml-info
Sun Oct 22 17:29:53 2000 Marc-Antoine Parent
* patch from Marc-Antoine Parent
* psgml-edit.el (sgml-read-attribute-value): include the element name, thus:
Value for {attribute name} in {element name} ({type} {Default}):
2000-10-11 Lennart Staflin <lennarts@infotek.no>
* psgml-edit.el (sgml-indent-line): new strategy for identifying
elements
2000-09-06 Lennart Staflin <lennarts@infotek.no>
* psgml-api.el (sgml-map-content): Use sgml-with-parser-syntax-ro
* psgml-parse.el (sgml-find-start-point): renamed to
sgml-goto-start-point, to indicate that this actually changes the
point and buffer. And should always be called inside
sgml-with-parser-syntax.
(sgml-with-parser-syntax-ro): As sgml-with-parser-syntax also
handle restoring buffer modification state.
(sgml-last-buffer): New state variable
(sgml-with-parser-syntax): set sgml-last-buffer
(sgml-mainbuf-point): new function
(sgml-max-pos-in-tree): new function
(sgml-update-display): don't call sgml-find-start-point, use
sgml-max-pos-in-tree to figure out if there is much to parse.
(sgml-parse-to): calls sgml-parser-loop directly no
sgml-parse-continue.
(sgml-parse-continue): use sgml-with-parser-syntax-ro and
set-buffer to sgml-last-buffer.
2000-08-24 Lennart Staflin <lennarts@infotek.no>
* psgml.el (sgml-insert-defaulted-attributes): new option
* psgml-edit.el (sgml-insert-attributes): check new option
* psgml-fs.el (style-format): set ps-left-header to include a
style-sheet specified title and the filename. (for ps-print-buffer)
(fs-special-styles): New special style 'title' for setting title.
(fs-do-style): handle title style
(fs-element-content): make element argument optional, defaults to
current element.
2000-08-08 Lennart Staflin <lennarts@infotek.no>
* psgml-edit.el (sgml-insert-element): Fix bug with empty element.
Thu Aug 3 07:52:46 2000 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-insert-element): Fix bug when inserting
element at end of buffer.
2000-08-03 Lennart Staflin <lennarts@infotek.no>
* psgml-edit.el (sgml-attribute-buffer): Fix missing space for
unspecified required attributes.
2000-06-05 Lennart Staflin <lennarts@infotek.no>
* psgml-dtd.el (sgml-parse-parameter-literal): use
buffer-substring-no-properties .
2000-05-31 Lennart Staflin <lennarts@infotek.no>
* psgml-api.el (sgml-parse-data): Don't call sgml-parse-loop
directly, use sgml-parse-continue.
Sat May 27 00:04:31 2000 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-attr-clean-and-insert): new command. Used to
automatically remove #DEFAULT when a character is typed.
(sgml-attr-default-keymap): keymap used as only for #DEFAULT in
attribute editing.
Mon Apr 24 09:55:14 2000 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-complete): Transform case on inserted names
using sgml-general-insert-case or sgml-entity-insert-case.
Sun Apr 16 16:07:55 2000 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-indent-line): compute indentation from
context, not element under point. Did this change once before but
had to back it out. This time take care of omitted end-tags by
choosing parent element as context, if point is at the very end of
the element. Don't do special attribute indenting for elements
that occur in data context.
(sgml-fill-region): Fix giving up to early.
(sgml-do-fill): indent tags of subelements in element context
* psgml-info.el (sgml-describe-element-type): Use sgml-princ-names
for occurs in section.
2000-03-22 Lennart Staflin <lennarts@infotek.no>
* psgml-edit.el (sgml-change-element-name): Add end-tag event if
original element is empty. (hmm this isn't quite right). Also use
sgml-find-context-of to find element, because -element-of gives
the element of the following char.
Tue Jan 4 19:51:03 2000 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-with-parser-syntax): Restore current buffer
before restoring syntax table.
Tue Dec 21 20:50:31 1999 Lennart Staflin <lenst@lysator.liu.se>
* psgml-other.el (sgml-set-face-for): set rear-nonsticky for face
when sgml-use-text-properties is true. (Suggested by Dirk Frömbgen)
Sat Dec 18 18:55:02 1999 Lennart Staflin <lenst@lysator.liu.se>
* psgml-charent.el (sgml-charent-to-display-char): use
buffer-substring-no-properties to allow for using text properties
for fontification.
1999-11-02 Tim Bradshaw <tfb@tfeb.org>
* psgml-edit.el (sgml-doctype-insert): made it not loop when it
gets a bogus nil
1999-12-16 Lennart Staflin <lennarts@infotek.no>
* psgml-parse.el (sgml-parse-prolog): restore buffer modified
after parsing. To allow using text properties for fontification.
(sgml-parse-continue): dito.
(sgml-parse-to): call sgml-parse-continue instead of calling
sgml-parser-loop directly.
1999-12-15 Lennart Staflin <lennarts@infotek.no>
* psgml.el: autoload for sgml-do-set-option
1999-12-03 Lennart Staflin <lennarts@infotek.no>
* psgml.el (sgml-mode-syntax-table): new variable
(sgml-mode): use sgml-mode-syntax-table
1999-11-29 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-validate-error-regexps): Also recognize warnings
(:W:) in output from nsgmls.
1999-11-11 Lennart Staflin <lennarts@infotek.no>
* psgml-parse.el (sgml-parse-to): Let sgml-with-parser-syntax wrap
a bigger chunk of the code to make sure the syntax table is set up
before any buffer changes.
Tue Nov 9 16:25:53 1999 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-modify-dtd): use sgml-general-case on names
from modifier.
Mon Nov 8 22:13:12 1999 Lennart Staflin <lenst@lysator.liu.se>
* psgml-info.el (sgml-eltype-refrenced-elements): Copy sequence
before sorting destructively.
(sgml-describe-element-type): Include exceptions in info display.
Thu Nov 4 19:07:09 1999 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-note-change-at): If in XML mode and
previous char is /, back up one char. This allows for the />
delimiter to be recognized even if the start tag has been
previously parsed as an improperly ended tag.
* psgml-edit.el (sgml-last-element): don't use sgml-last-element
for XML (there is not omitted tags to account for).
1999-10-21 Lennart Staflin <lennarts@infotek.no>
* psgml-parse.el (sgml-push-to-entity): restore the (erase-buffer)
that had been commented out. This is needed for the case when
sgml-try-merge-compiled-dtd fails and leaves junk in the buffer.
1999-10-19 Lennart Staflin <lennarts@infotek.no>
* Version 1.2.1 released
1999-10-14 Lennart Staflin <lennarts@infotek.no>
* psgml-parse.el (sgml-log-entity-stack): don't use
sgml-pop-entity, just loop thru the entity stack and print out the
files.
(sgml-load-ecat): bind sgml-xml-p while parsing catalog
1999-10-13 Lennart Staflin <lennarts@infotek.no>
* psgml-parse.el (sgml-current-file): New variable, holds the name
of file name (if any) of the entity beeing parsed in the buffer.
(sgml-parse-warning): New func. Log a parser warning, a warning
including information about where the error occured. Mostly for
DTD parsing.
(sgml-log-entity-stack): new factored function.
(*) Replaces some sgml-parse-error and sgml-log-warning with
sgml-parse-warning.
(sgml-parse-catalog-buffer): bind sgml-xml-p while parsing catalog
Sun Oct 10 15:53:12 1999 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.2 released
Wed Oct 6 00:43:37 1999 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.1.7 released
* psgml-parse.el (sgml-push-to-entity): carry XML-ness to parsed
text entities.
* psgml-charent.el (sgml-display-char-list-filename): new default
is "iso8859.map" in the same directory where psgml is installed.
Wed Sep 22 19:34:08 1999 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el: Apply sgml-general-case to attribute name for
interactive sgml-insert-attribute. Don't test for non empty asl in
sgml-edit-attrib. A lot of changes in handling text attributes
when in attribute edit mode.
Sat Aug 14 22:34:59 1999 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-tag-regexp): Recognize XMLs empty tags.
1998-11-16 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-set-local-variable): insert "mode: xml" for
xml-mode and "mode: sgml" otherwise
* psgml-edit.el (sgml-add-element-to-element): add end-tag to
empty xml-elements before inserting an element
1998-11-15 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.1.6 released
* psgml-parse.el (sgml-char-int): from XEmacs
(sgml-read-octet): modified for XEmacs
(sgml-read-peek): dito.
(sgml-read-number): dito.
* psgml.el (sgml-option-value-indicator): moved here.
(sgml-mode): activate-menubar-hook can't be local in XEmacs and
sgml-build-custom-menus need to be after the easy-menu-adds.
1998-11-14 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el, psgml-edit.el: Fix from David Megginson to some
regexps for _: in names.
(sgml-build-custom-menus): Do not call easy-menu-change with empty
menu.
* psgml-edit.el (sgml-do-set-option): Don't modify the *Help*
buffer directly, call sgml-append-to-help-buffer. Fixes problem
with read-only buffer.
(sgml-append-to-help-buffer): new func.
* psgml.el (sgml-main-menu): Options handling changed after
suggestion and code from Matthias Clasen
(sgml-update-all-options-menus): new func. called by
activate-menubar-hook
Thu Nov 5 20:59:08 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-parse-processing-instruction): removed let
of sgml-markup-start. Was probably wrong solution to problem with
sgml-markup-start beeing nil. Added in-declaration parameter. If
in a declaration, no fontification should be done.
(sgml-parse-prolog): do not call sgml-skip-ds, rather call
parse-s, parse-pi as this is what "other prolog" contains.
1998-10-31 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.1.5 released
* psgml-parse.el (sgml-declared-value-notation): change 'notation
to 'NOTATION
Sat Oct 31 20:00:22 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-cache-catalog): Use file-truename for
file-attributes, to get modification time from real file and not
from symlink.
* psgml.el (xml-mode): Do not build a syntax table
(sgml-dtd-menu): moved Custom DTD's to submenu
(sgml-markup-menu): moved Custom Markup to submenu
(sgml-build-custom-menus): Make submenus for Custom DTD and Markup
* psgml-parse.el (xml-parser-syntax): build special syntax table
for XML.
(sgml-with-parser-syntax): Use sgml-parser-syntax or
xml-parser-syntax depending on sgml-xml-p
Wed Oct 28 23:15:38 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-read-element-type): use
let (completion-ignore-case sgml-namecase-general)
Sat Oct 24 13:13:48 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-build-custom-menus): Construct sub-menus for
custom DTD and custom Markup insert, only if
easy-menu-filter-return is not defined otherwise use the :filter
facility to build menu when needed.
* psgml-edit.el (sgml-what-element): Guard call to
sgml-deref-shortmap
1998-10-20 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-edit-external-entity): fix from Matthias Clasen
* psgml.el (sgml-validate-error-regexps): modify regexp to work in
Emacs 20.3
1998-09-30 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.1.4 release
Mon Aug 31 21:53:45 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-bdtd-load): Increase version number
(sgml-read-dtd): Increase version number
* psgml-dtd.el (sgml-write-dtd): Increase version number
Sat Aug 15 18:58:25 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-complete): add completion of #-reserved words
Fri Jul 3 18:14:21 1998 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.1.3
* Makefile.in: Call install with only one source file.
Fri Jul 3 17:54:06 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-complete): ignore case
* psgml-parse.el (sgml-push-to-entity): use setf to set
sgml-entity-marked-undefined-p.
(setf sgml-entity-marked-undefined-p): define setf method
Tue Jun 30 22:06:20 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-do-set-option): Added file-list and
file-or-nil types contributed by Matthias Clasen
<mclasen@sun2.mathematik.uni-freiburg.de>
Tue Jun 30 21:48:39 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-mode-map): C-c C-i calls sgml-add-element-to-element
* psgml-edit.el (sgml-add-element-to-element): New command.
Wed Jun 24 23:23:38 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-attribute-buffer): Fixed another victim of
the case change.
(sgml-change-element-name): fix bug with empty XML element
Mon Jun 22 19:58:43 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (psgml-version): Version 1.1.2
* Installed patch from Matthias Clasen
<clasen@pong.mathematik.uni-freiburg.de>.
Adding notation to entities and a sgml-notation-handlers variable
used by sgml-edit-external-entity.
* psgml-edit.el (sgml-indent-line): Previous change of
sgml-indent-line did not work well with OMITTAG. Restore old
functionallity.
Fri Jun 19 18:54:27 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-attribute-buffer):
changed case of default value type, here and in many other functions.
(sgml-translate-attribute-specification-list): changed case for
declared value
* psgml-parse.el (sgml-parse-attribute-specification-list):
changed case of default value type
1998-06-16 Dave Love <d.love@dl.ac.uk>
* psgml-edit.el (sgml-read-element-name,
sgml-read-attribute-value, sgml-insert-attribute,
sgml-custom-markup): Use sgml-namecase-general to set
completion-ignore-case.
1998-06-16 Dave Love <d.love@dl.ac.uk>
* psgml-parse.el (sgml-push-to-entity): Don't use save-excursion
around insert-file-contents -- may break in Emacs 20.3.
Fri Jun 19 10:40:53 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-dtd.el (sgml-check-declared-value): upcase NOTATION
* psgml-parse.el (sgml-read-element-name): bind
completion-ignore-case as suggested by Mark Eichin. Also present
element names in the insert case.
Tue Jun 16 00:31:03 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-command-post): added ignore-errors
* psgml-parse.el (sgml-get-delim-string): new func.
(sgml-delim): changed to macro.
(sgml-do-usemap): upcase #EMPTY
(sgml-parse-xml-comment): set markup type
* psgml-dtd.el (sgml-validate-default-value-rn): upcase keywords
(sgml-declare-entity): remove case fiddling
* psgml-parse.el (sgml-check-case): remove case fiddling -- retain
check.
* psgml-dtd.el (sgml-validate-declared-value): upcase attribute types
(sgml-check-default-value): remove case fiddling -- reserved names
should be in upper case.
* psgml-parse.el (sgml-push-to-entity): use syntax table from
current buffer in entity buffer and not the sgml-parser-syntax as
XML will use another syntax table.
Wed Jun 10 23:28:42 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-catalog-lookup): Take additional catalogs
in right order.
Thu May 14 20:02:42 1998 Lennart Staflin <lenst@lysator.liu.se>
* Version 1.1.1
* psgml.el (psgml-version): new version 1.1.1
* psgml-dtd.el (sgml-parse-character-reference): upcase funchar
names.
* psgml-edit.el (sgml-indent-line): compute indentation from
context, not element under point. Removed special handling of
start-tag and document context. Extra indentation if in markup.
* psgml-parse.el (sgml-parse-external): use upper case keywords.
(sgml-check-case): use upper case instead of lower case.
Wed May 13 06:13:05 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-do-marked-section): Change keyword strings
to upper case.
(sgml-general-case): Use Upcase instead of Downcase.
(sgml-parse-markup-declaration): upcase keywords.
Sat Mar 14 21:31:09 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-do-processing-instruction): Added
recognition of PSGML NOFILL.
(sgml-parse-catalog-buffer): add catalog as a noname entry
(sgml-catalog-lookup): handle catalog entries
Thu Mar 12 00:04:52 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-current-element-name): make buffer local
Wed Mar 11 22:11:01 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-insert-start-tag): extended meaning of NET
paramenter to insert XML-TAGCE if XML.
(sgml-change-start-tag): keep XML-TAGCE
* psgml-parse.el (sgml-read-element-name): use completing read on
all defined element types if in an ANY context.
(sgml-check-tag-close): removed check for XML-TAGCE
(sgml-do-start-tag): added check for XML-TAGCE
(sgml-element-empty): In XML no special handling of elements with
declared content of EMPTY, but use conref to signal empty element tag.
* psgml-dtd.el (sgml-merge-attlists): reverse the list
Tue Mar 10 20:13:11 1998 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el: Merged David Megginson's latest xml modifications.
Sat Nov 15 20:50:35 1997 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-parse-attribute-value-specification): New func.
(sgml-parse-attribute-specification-list): use new func. This
changes an error to a warning to make better error recovery when
illegal characters occurs in starttag.
Sun Aug 17 20:22:28 1997 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-cache-catalog): remove file-truename. This
made relative filenames refer to the wrong directory if the
catalog file was a symlink.
Thu Jul 24 22:36:15 1997 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-modify-dtd): fixed bug in handling
sgml-parent-document.
Mon May 19 18:43:32 1997 Lennart Staflin <lenst@lysator.liu.se>
* psgml-edit.el (sgml-expand-entity-reference): changed to allow
point to be within entity referens, not only at start of ref. As
suggested by Matthias Clasen.
(sgml-edit-external-entity): new command contributed by Matthias
Clasen <clasen@netzservice.de>
* psgml-charent.el (sgml-charent-to-display-char): fix bug in regexp.
Sat Mar 15 19:20:57 1997 Lennart Staflin <lenst@lysator.liu.se>
* psgml-parse.el (sgml-check-tag-close): change sgml-error to
sgml-log-warning
Sun Jan 12 19:15:32 1997 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (psgml-version): bump version
Fri Nov 22 20:29:44 1996 Lennart Staflin <lenst@lysator.liu.se>
* psgml.el (sgml-parse-colon-path): use path-separator if
available.

181
site-lisp/INSTALL Normal file
View file

@ -0,0 +1,181 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

58
site-lisp/Makefile Normal file
View file

@ -0,0 +1,58 @@
# Generated automatically from Makefile.in by configure.
# Makefile.in
#
# Makefile for the GNU Emacs lisp library, PSGML
prefix = /usr/local
datadir = ${prefix}/share
lispdir = $(datadir)/emacs/site-lisp
srcdir = .
EMACS = emacs
XEMACS = xemacs
FLAGS = -batch -q -no-site-file -l ./psgml-maint.el
INSTALL = /usr/bin/install -c
INSTALL_DATA = ${INSTALL} -m 644
SHELL = /bin/sh
compile:
$(EMACS) $(FLAGS) -f psgml-compile-files
all:
rm -f *.elc ; $(EMACS) $(FLAGS) -f psgml-compile-files
install: compile installdirs
$(SHELL) mkinstalldirs $(lispdir)
for p in *.elc; do \
echo " $(INSTALL_DATA) $$p $(lispdir)/$$p"; \
$(INSTALL_DATA) $$p $(lispdir)/$$p; \
done
$(INSTALL_DATA) iso88591.map $(lispdir)
installdirs:
$(srcdir)/mkinstalldirs $(psgmldir)
install-info:
$(INSTALL_DATA) psgml.info $(infodir)
$(INSTALL_DATA) psgml-api.info $(infodir)
if $(SHELL) -c 'install-info --version' \
>/dev/null 2>&1; then \
install-info --info-dir=$(infodir) psgml.info; \
install-info --info-dir=$(infodir) psgml-api.info; \
else true; fi
xemacs:
$(MAKE) EMACS=xemacs all
install-xemacs:
$(MAKE) EMACS=xemacs install
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
# Makefile.in ends here

58
site-lisp/Makefile.in Normal file
View file

@ -0,0 +1,58 @@
# Makefile.in
#
# Makefile for the GNU Emacs lisp library, PSGML
prefix = @prefix@
datadir = @datadir@
lispdir = @lispdir@
infodir = @infodir@
srcdir = @srcdir@
@SET_MAKE@
EMACS = @EMACS@
XEMACS = xemacs
VPATH = @srcdir@
FLAGS = -batch -q -no-site-file -l ./psgml-maint.el
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
SHELL = /bin/sh
compile:
$(EMACS) $(FLAGS) -f psgml-compile-files
all:
rm -f *.elc ; $(EMACS) $(FLAGS) -f psgml-compile-files
install: compile
$(SHELL) mkinstalldirs $(lispdir)
for p in *.elc; do \
echo " $(INSTALL_DATA) $$p $(lispdir)/$$p"; \
$(INSTALL_DATA) $$p $(lispdir)/$$p; \
done
$(INSTALL_DATA) iso88591.map $(lispdir)
install-info:
$(INSTALL_DATA) psgml.info $(infodir)
$(INSTALL_DATA) psgml-api.info $(infodir)
if $(SHELL) -c 'install-info --version' \
>/dev/null 2>&1; then \
install-info --info-dir=$(infodir) psgml.info; \
install-info --info-dir=$(infodir) psgml-api.info; \
else true; fi
xemacs:
$(MAKE) EMACS=xemacs all
install-xemacs:
$(MAKE) EMACS=xemacs install
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
# Makefile.in ends here

View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View file

@ -0,0 +1,42 @@
Manifest for CC Mode 5.31
You should have received the following files in this distribution:
MANIFEST: This file.
README: Quick intro into how to get CC Mode up and running.
NEWS: A list of the user visible changes in each version.
cc-align.el, cc-awk.el, cc-cmds.el, cc-defs.el, cc-engine.el,
cc-fonts.el, cc-langs.el, cc-menus.el, cc-mode.el, cc-styles.el,
cc-subword.el, cc-vars.el: The source code.
cc-compat.el: Helps ease the transition from c-mode.el (BOCM) to
the new indentation engine. This is provided for your convenience
only, and is unguaranteed and unsupported.
cc-fix.el: (previously named cc-mode-19.el). Detects and corrects
bugs in various older (X)Emacs versions.
cc-guess.el: Experiments in style guessing. This is provided for
your convenience only, and is unguaranteed and unsupported.
cc-lobotomy.el: Performance vs. accuracy trade-offs. May not
work, yadda, yadda.
cc-bytecomp.el: Contains helpers used during byte compiling to
ensure that there's no mixup with earler versions of CC Mode which
might be loaded.
cc-mode.texi: The latest CC Mode Texinfo manual.
ANNOUNCEMENT: Release announcement as it appeared on various
forums.
Note that of the above files, the following are distributed with Emacs
and XEmacs:
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
cc-defs.el, cc-engine.el, cc-fonts.el, cc-langs.el, cc-menus.el,
cc-mode.el, cc-styles.el, cc-subword.el, cc-vars.el, cc-mode.texi

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,123 @@
README for CC Mode 5.31
Current maintainers: Martin Stjernholm and Alan Mackenzie
Contact address : bug-cc-mode@gnu.org
INTRODUCTION
The canonical web location for all knowledge CC Mode is:
<http://cc-mode.sourceforge.net/>
Please read the cc-mode.texi manual for details on using CC Mode.
This is available on-line from:
<http://cc-mode.sourceforge.net/cc-mode.html>
As of this writing (November 18, 2005), CC Mode currently works
out of the box with XEmacs versions 21.4 and later, and with Emacs
versions 20.4 and later, 21.x and 22.x. (It will very likely work
with later versions too, when they become available.)
Note that with CC Mode 5.31, we have finally dropped support for
Emacs 19.34 and XEmacs 19.15. CC Mode 5.31 _won't_ work with
these old versions. Upgrade them now!
Currently, the new Subword Mode doesn't work in Emacs 20.n.
MORE INFORMATION
Check out the CC Mode web site for the latest information,
updates, tips, installation and compatibility notes, etc. on using
CC Mode. The installation instructions given below are an excerpt
of the on-line instructions. If you have problems installing CC
Mode, please check out the URL above before submitting a bug
report. Thanks!
The MANIFEST file contains a description of all the files you
should have gotten with this distribution.
MANUALS
Preformatted versions of the manual in DVI, PostScript, and Info,
are all available at the CC Mode web page. The Info manual has
two variants, one for GNU Emacs, the other for XEmacs - the only
differences between them are the targets of some cross references
within the manual.
To build the manual yourself, you will need Texinfo 4.7 or later.
Simply type:
% makeinfo cc-mode.texi # For GNU Emacs
or
% makeinfo -DXEMACS cc-mode.texi # For XEmacs
To make the DVI version, type:
% texi2dvi cc-mode.texi
INSTALLATION
Here is a quick guide for installing CC Mode. For the latest
information on installing CC Mode, please see the CC Mode web site
given above.
Byte Compiling
It is highly recommended that you byte-compile CC Mode for
performance reasons. Running CC Mode non-byte-compiled is not
supported.
You can compile CC Mode in the same way as any other package. To
compile it from a running (X)Emacs session:
M-0 M-x byte-recompile-directory RET /path/to/cc-mode RET
To compile CC Mode from the shell:
% cd /path/to/cc-mode
% $(EMACS) -batch -no-site-file -q -f batch-byte-compile cc-*.el
where $(EMACS) is either emacs or xemacs depending on the flavor
you use. Note that the byte compiled files from one version of
(X)Emacs are likely not to work on a different version - compile
them fresh when you upgrade your (X)Emacs version.
Installing
Put the compiled files somewhere (X)Emacs will find them, i.e. in
some path that's in the load-path variable. You must make sure
they are found before any CC Mode files which are distributed with
(X)Emacs. A directory has higher precendence than all directories
after it in the load-path list.
If you're going to be using AWK Mode, insert the following line
into your .emacs or init.el file:
(autoload 'awk-mode "cc-mode" nil t)
This will cause (X)Emacs to use the new AWK Mode for AWK files,
rather than the older mode contained in the file awk-mode.elc.
(See also the note below under "Compatibility Issues".)
To test that you have things set up correctly, visit a C file and
then type:
M-x c-version RET
=> Using CC Mode version 5.XX
where XX is the correct minor revision number.
Compatibility Issues
CC Mode should work fine with most versions of Emacs and XEmacs
which aren't ancient (see the introduction above).
If you're using AWK, you can verify that you've got Emacs set up
to use CC Mode for AWK files by displaying the mode documentation
string with C-h m from an AWK buffer. The current mode's doc
string contains "to submit a problem report, enter `C-c C-b'" near
the top of the doc string where the obsolete awk-mode.el has "This
is much like C mode except ....".
For more details about interactions with different packages, see
the CC Mode web page.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,440 @@
;;; cc-bytecomp.el --- compile time setup for proper compilation
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
;; Inc.
;; Author: Martin Stjernholm
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 15-Jul-2000
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This file is used to ensure that the CC Mode files are correctly
;; compiled regardless the environment (e.g. if an older CC Mode with
;; outdated macros are loaded during compilation). It also provides
;; features to defeat the compiler warnings for selected symbols.
;;
;; There's really nothing CC Mode specific here; this functionality
;; ought to be provided by the byte compilers or some accompanying
;; library. To use it from some package "foo.el", begin by putting
;; the following blurb at the top of the file:
;;
;; (eval-when-compile
;; (let ((load-path
;; (if (and (boundp 'byte-compile-dest-file)
;; (stringp byte-compile-dest-file))
;; (cons (file-name-directory byte-compile-dest-file) load-path)
;; load-path)))
;; (load "cc-bytecomp" nil t))
;;
;; This (unfortunately rather clumsy) form will ensure that the
;; cc-bytecomp.el in the same directory as foo.el is loaded during
;; byte compilation of the latter.
;;
;; At the end of foo.el there should normally be a "(provide 'foo)".
;; Replace it with "(cc-provide 'foo)"; that is necessary to restore
;; the environment after the byte compilation. If you don't have a
;; `provide' at the end, you have to add the following as the very
;; last form in the file:
;;
;; (eval-when-compile (cc-bytecomp-restore-environment))
;;
;; Now everything is set to use the various functions and macros in
;; this package.
;;
;; If your package is split into several files, you should use
;; `cc-require', `cc-require-when-compile' or `cc-load' to load them.
;; That ensures that the files in the same directory always are
;; loaded, to avoid mixup with other versions of them that might exist
;; elsewhere in the load path.
;;
;; To suppress byte compiler warnings, use the macros
;; `cc-bytecomp-defun', `cc-bytecomp-defvar',
;; `cc-bytecomp-obsolete-fun', and `cc-bytecomp-obsolete-var'.
;;
;; This file is not used at all after the package has been byte
;; compiled. It is however necessary when running uncompiled.
;;; Code:
(defvar cc-bytecomp-unbound-variables nil)
(defvar cc-bytecomp-original-functions nil)
(defvar cc-bytecomp-original-properties nil)
(defvar cc-bytecomp-loaded-files nil)
(defvar cc-bytecomp-environment-set nil)
(defmacro cc-bytecomp-debug-msg (&rest args)
;;`(message ,@args)
)
(defun cc-bytecomp-setup-environment ()
;; Eval'ed during compilation to setup variables, functions etc
;; declared with `cc-bytecomp-defvar' et al.
(if (not load-in-progress)
;; Look at `load-in-progress' to tell whether we're called
;; directly in the file being compiled or just from some file
;; being loaded during compilation.
(let (p)
(if cc-bytecomp-environment-set
(error "Byte compilation environment already set - \
perhaps a `cc-bytecomp-restore-environment' is forgotten somewhere"))
(setq p cc-bytecomp-unbound-variables)
(while p
(if (not (boundp (car p)))
(progn
(eval `(defvar ,(car p)))
(set (car p) (intern (concat "cc-bytecomp-ignore-var:"
(symbol-name (car p)))))
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Covered variable %s"
(car p))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-functions)
(while p
(let ((fun (car (car p)))
(temp-macro (car (cdr (car p)))))
(if (not (fboundp fun))
(if temp-macro
(progn
(eval `(defmacro ,fun ,@temp-macro))
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Bound macro %s" fun))
(fset fun (intern (concat "cc-bytecomp-ignore-fun:"
(symbol-name fun))))
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Covered function %s" fun))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-properties)
(while p
(let ((sym (car (car (car p))))
(prop (cdr (car (car p))))
(tempdef (car (cdr (car p)))))
(put sym prop tempdef)
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Bound property %s for %s to %s"
prop sym tempdef))
(setq p (cdr p)))
(setq cc-bytecomp-environment-set t)
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Done"))))
(defun cc-bytecomp-restore-environment ()
;; Eval'ed during compilation to restore variables, functions etc
;; declared with `cc-bytecomp-defvar' et al.
(if (not load-in-progress)
(let (p)
(setq p cc-bytecomp-unbound-variables)
(while p
(let ((var (car p)))
(if (boundp var)
(if (eq (intern (concat "cc-bytecomp-ignore-var:"
(symbol-name var)))
(symbol-value var))
(progn
(makunbound var)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Unbound variable %s"
var))
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Not restoring variable %s"
var))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-functions)
(while p
(let ((fun (car (car p)))
(temp-macro (car (cdr (car p))))
(def (car (cdr (cdr (car p))))))
(if (fboundp fun)
(if (eq (or temp-macro
(intern (concat "cc-bytecomp-ignore-fun:"
(symbol-name fun))))
(symbol-function fun))
(if (eq def 'unbound)
(progn
(fmakunbound fun)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Unbound function %s"
fun))
(fset fun def)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Restored function %s"
fun))
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Not restoring function %s"
fun))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-properties)
(while p
(let ((sym (car (car (car p))))
(prop (cdr (car (car p))))
(tempdef (car (cdr (car p))))
(origdef (cdr (cdr (car p)))))
(if (eq (get sym prop) tempdef)
(progn
(put sym prop origdef)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Restored property %s for %s to %s"
prop sym origdef))
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Not restoring property %s for %s"
prop sym)))
(setq p (cdr p)))
(setq cc-bytecomp-environment-set nil)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Done"))))
(eval
;; This eval is to avoid byte compilation of the function below.
;; There's some bug in XEmacs 21.4.6 that can cause it to dump core
;; here otherwise. My theory is that `cc-bytecomp-load' might be
;; redefined recursively during the `load' inside it, and if it in
;; that case is byte compiled then the byte interpreter gets
;; confused. I haven't succeeded in isolating the bug, though. /mast
'(defun cc-bytecomp-load (cc-part)
;; Eval'ed during compilation to load a CC Mode file from the source
;; directory (assuming it's the same as the compiled file
;; destination dir).
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(progn
(cc-bytecomp-restore-environment)
(let ((load-path
(cons (file-name-directory byte-compile-dest-file)
load-path))
(cc-file (concat cc-part ".el")))
(if (member cc-file cc-bytecomp-loaded-files)
()
(setq cc-bytecomp-loaded-files
(cons cc-file cc-bytecomp-loaded-files))
(cc-bytecomp-debug-msg
"cc-bytecomp-load: Loading %S" cc-file)
(load cc-file nil t t)
(cc-bytecomp-debug-msg
"cc-bytecomp-load: Loaded %S" cc-file)))
(cc-bytecomp-setup-environment)
t))))
(defmacro cc-require (cc-part)
"Force loading of the corresponding .el file in the current directory
during compilation, but compile in a `require'. Don't use within
`eval-when-compile'.
Having cyclic cc-require's will result in infinite recursion. That's
somewhat intentional."
`(progn
(eval-when-compile (cc-bytecomp-load (symbol-name ,cc-part)))
(require ,cc-part)))
(defmacro cc-provide (feature)
"A replacement for the `provide' form that restores the environment
after the compilation. Don't use within `eval-when-compile'."
`(progn
(eval-when-compile (cc-bytecomp-restore-environment))
(provide ,feature)))
(defmacro cc-load (cc-part)
"Force loading of the corresponding .el file in the current directory
during compilation. Don't use outside `eval-when-compile' or
`eval-and-compile'.
Having cyclic cc-load's will result in infinite recursion. That's
somewhat intentional."
`(or (and (featurep 'cc-bytecomp)
(cc-bytecomp-load ,cc-part))
(load ,cc-part nil t nil)))
(defmacro cc-require-when-compile (cc-part)
"Force loading of the corresponding .el file in the current directory
during compilation, but do a compile time `require' otherwise. Don't
use within `eval-when-compile'."
`(eval-when-compile
(if (and (featurep 'cc-bytecomp)
(cc-bytecomp-is-compiling))
(if (or (not load-in-progress)
(not (featurep ,cc-part)))
(cc-bytecomp-load (symbol-name ,cc-part)))
(require ,cc-part))))
(defmacro cc-external-require (feature)
"Do a `require' of an external package.
This restores and sets up the compilation environment before and
afterwards. Don't use within `eval-when-compile'."
`(progn
(eval-when-compile (cc-bytecomp-restore-environment))
(require ,feature)
(eval-when-compile (cc-bytecomp-setup-environment))))
(defun cc-bytecomp-is-compiling ()
"Return non-nil if eval'ed during compilation. Don't use outside
`eval-when-compile'."
(and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file)))
(defmacro cc-bytecomp-defvar (var)
"Binds the symbol as a variable during compilation of the file,
to silence the byte compiler. Don't use within `eval-when-compile'."
`(eval-when-compile
(if (boundp ',var)
(cc-bytecomp-debug-msg
"cc-bytecomp-defvar: %s bound already as variable" ',var)
(if (not (memq ',var cc-bytecomp-unbound-variables))
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-defvar: Saving %s (as unbound)" ',var)
(setq cc-bytecomp-unbound-variables
(cons ',var cc-bytecomp-unbound-variables))))
(if (and (cc-bytecomp-is-compiling)
(not load-in-progress))
(progn
(defvar ,var)
(set ',var (intern (concat "cc-bytecomp-ignore-var:"
(symbol-name ',var))))
(cc-bytecomp-debug-msg
"cc-bytecomp-defvar: Covered variable %s" ',var))))))
(defmacro cc-bytecomp-defun (fun)
"Bind the symbol as a function during compilation of the file,
to silence the byte compiler. Don't use within `eval-when-compile'.
If the symbol already is bound as a function, it will keep that
definition. That means that this macro will not shut up warnings
about incorrect number of arguments. It's dangerous to try to replace
existing functions since the byte compiler might need the definition
at compile time, e.g. for macros and inline functions."
`(eval-when-compile
(if (fboundp ',fun)
(cc-bytecomp-debug-msg
"cc-bytecomp-defun: %s bound already as function" ',fun)
(if (not (assq ',fun cc-bytecomp-original-functions))
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-defun: Saving %s (as unbound)" ',fun)
(setq cc-bytecomp-original-functions
(cons (list ',fun nil 'unbound)
cc-bytecomp-original-functions))))
(if (and (cc-bytecomp-is-compiling)
(not load-in-progress))
(progn
(fset ',fun (intern (concat "cc-bytecomp-ignore-fun:"
(symbol-name ',fun))))
(cc-bytecomp-debug-msg
"cc-bytecomp-defun: Covered function %s" ',fun))))))
(put 'cc-bytecomp-defmacro 'lisp-indent-function 'defun)
(defmacro cc-bytecomp-defmacro (fun &rest temp-macro)
"Bind the symbol as a macro during compilation (and evaluation) of the
file. Don't use outside `eval-when-compile'."
`(let ((orig-fun (assq ',fun cc-bytecomp-original-functions)))
(if (not orig-fun)
(setq orig-fun
(list ',fun
nil
(if (fboundp ',fun)
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-defmacro: Saving %s" ',fun)
(symbol-function ',fun))
(cc-bytecomp-debug-msg
"cc-bytecomp-defmacro: Saving %s as unbound" ',fun)
'unbound))
cc-bytecomp-original-functions
(cons orig-fun cc-bytecomp-original-functions)))
(defmacro ,fun ,@temp-macro)
(cc-bytecomp-debug-msg
"cc-bytecomp-defmacro: Bound macro %s" ',fun)
(setcar (cdr orig-fun) (symbol-function ',fun))))
(defmacro cc-bytecomp-put (symbol propname value)
"Set a property on a symbol during compilation (and evaluation) of
the file. Don't use outside `eval-when-compile'."
`(eval-when-compile
(if (not (assoc (cons ,symbol ,propname) cc-bytecomp-original-properties))
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-put: Saving property %s for %s with value %s"
,propname ,symbol (get ,symbol ,propname))
(setq cc-bytecomp-original-properties
(cons (cons (cons ,symbol ,propname)
(cons ,value (get ,symbol ,propname)))
cc-bytecomp-original-properties))))
(put ,symbol ,propname ,value)
(cc-bytecomp-debug-msg
"cc-bytecomp-put: Bound property %s for %s to %s"
,propname ,symbol ,value)))
(defmacro cc-bytecomp-obsolete-var (symbol)
"Suppress warnings that the given symbol is an obsolete variable.
Don't use within `eval-when-compile'."
`(eval-when-compile
(if (get ',symbol 'byte-obsolete-variable)
(cc-bytecomp-put ',symbol 'byte-obsolete-variable nil)
;; This avoids a superfluous compiler warning
;; about calling `get' for effect.
t)))
(defun cc-bytecomp-ignore-obsolete (form)
;; Wraps a call to `byte-compile-obsolete' that suppresses the warning.
(let ((byte-compile-warnings
(delq 'obsolete (append byte-compile-warnings nil))))
(byte-compile-obsolete form)))
(defmacro cc-bytecomp-obsolete-fun (symbol)
"Suppress warnings that the given symbol is an obsolete function.
Don't use within `eval-when-compile'."
`(eval-when-compile
(if (eq (get ',symbol 'byte-compile) 'byte-compile-obsolete)
(cc-bytecomp-put ',symbol 'byte-compile
'cc-bytecomp-ignore-obsolete)
;; This avoids a superfluous compiler warning
;; about calling `get' for effect.
t)))
(defmacro cc-bytecomp-boundp (symbol)
"Return non-nil if the given symbol is bound as a variable outside
the compilation. This is the same as using `boundp' but additionally
exclude any variables that have been bound during compilation with
`cc-bytecomp-defvar'."
(if (and (cc-bytecomp-is-compiling)
(memq (car (cdr symbol)) cc-bytecomp-unbound-variables))
nil
`(boundp ,symbol)))
(defmacro cc-bytecomp-fboundp (symbol)
"Return non-nil if the given symbol is bound as a function outside
the compilation. This is the same as using `fboundp' but additionally
exclude any functions that have been bound during compilation with
`cc-bytecomp-defun'."
(let (fun-elem)
(if (and (cc-bytecomp-is-compiling)
(setq fun-elem (assq (car (cdr symbol))
cc-bytecomp-original-functions))
(eq (elt fun-elem 2) 'unbound))
nil
`(fboundp ,symbol))))
(provide 'cc-bytecomp)
;;; arch-tag: 2d71b3ad-57b0-4b13-abd3-ab836e08f975
;;; cc-bytecomp.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,166 @@
;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation,
;; Inc.
;; Authors: 1998- Martin Stjernholm
;; 1994-1999 Barry A. Warsaw
;; Maintainer: bug-cc-mode@gnu.org
;; Created: August 1994, split from cc-mode.el
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; Boring old c-mode.el (BOCM) is confusion and brain melt. cc-mode.el
;; is clarity of thought and purity of chi. If you are still unwilling
;; to accept enlightenment, this might help, or it may prolong your
;; agony.
;;
;; To use, add the following to your c-mode-hook:
;;
;; (require 'cc-compat)
;; (c-set-style "BOCM")
;;
;; This file is completely unsupported! Although it has been patched
;; superficially to keep pace with the rest of CC Mode, it hasn't been
;; tested for a long time.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-vars)
(cc-require 'cc-styles)
(cc-require 'cc-engine)
;; In case c-mode.el isn't loaded
(defvar c-indent-level 2
"*Indentation of C statements with respect to containing block.")
(defvar c-brace-imaginary-offset 0
"*Imagined indentation of a C open brace that actually follows a statement.")
(defvar c-brace-offset 0
"*Extra indentation for braces, compared with other text in same context.")
(defvar c-argdecl-indent 5
"*Indentation level of declarations of C function arguments.")
(defvar c-label-offset -2
"*Offset of C label lines and case statements relative to usual indentation.")
(defvar c-continued-statement-offset 2
"*Extra indent for lines not starting new statements.")
(defvar c-continued-brace-offset 0
"*Extra indent for substatements that start with open-braces.
This is in addition to c-continued-statement-offset.")
;; these offsets are taken by brute force testing c-mode.el, since
;; there's no logic to what it does.
(let* ((offsets '(c-offsets-alist .
((defun-block-intro . cc-block-intro-offset)
(statement-block-intro . cc-block-intro-offset)
(defun-open . 0)
(class-open . 0)
(inline-open . c-brace-offset)
(block-open . c-brace-offset)
(block-close . cc-block-close-offset)
(brace-list-open . c-brace-offset)
(substatement-open . cc-substatement-open-offset)
(substatement . c-continued-statement-offset)
(knr-argdecl-intro . c-argdecl-indent)
(case-label . c-label-offset)
(access-label . c-label-offset)
(label . c-label-offset)
))))
(c-add-style "BOCM" offsets))
(defun cc-block-intro-offset (langelem)
;; taken directly from calculate-c-indent confusion
(save-excursion
(c-backward-syntactic-ws)
(if (eq (char-before) ?{)
(forward-char -1)
(goto-char (cdr langelem)))
(let* ((curcol (save-excursion
(goto-char (cdr langelem))
(current-column)))
(bocm-lossage
;; If no previous statement, indent it relative to line
;; brace is on. For open brace in column zero, don't let
;; statement start there too. If c-indent-level is zero,
;; use c-brace-offset + c-continued-statement-offset
;; instead. For open-braces not the first thing in a line,
;; add in c-brace-imaginary-offset.
(+ (if (and (bolp) (zerop c-indent-level))
(+ c-brace-offset c-continued-statement-offset)
c-indent-level)
;; Move back over whitespace before the openbrace. If
;; openbrace is not first nonwhite thing on the line,
;; add the c-brace-imaginary-offset.
(progn (skip-chars-backward " \t")
(if (bolp) 0 c-brace-imaginary-offset))
;; If the openbrace is preceded by a parenthesized exp,
;; move to the beginning of that; possibly a different
;; line
(progn
(if (eq (char-before) ?\))
(c-forward-sexp -1))
;; Get initial indentation of the line we are on.
(current-indentation)))))
(- bocm-lossage curcol))))
(defun cc-block-close-offset (langelem)
(save-excursion
(let* ((here (point))
bracep
(curcol (progn
(goto-char (cdr langelem))
(current-column)))
(bocm-lossage (progn
(goto-char (cdr langelem))
(if (eq (char-after) ?{)
(setq bracep t)
(goto-char here)
(beginning-of-line)
(backward-up-list 1)
(forward-char 1)
(c-forward-syntactic-ws))
(current-column))))
(- bocm-lossage curcol
(if bracep 0 c-indent-level)))))
(defun cc-substatement-open-offset (langelem)
(+ c-continued-statement-offset c-continued-brace-offset))
(cc-provide 'cc-compat)
;;; arch-tag: 564dab2f-e6ad-499c-a4a3-fedec3ecc192
;;; cc-compat.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,141 @@
;;; cc-fix.el --- compatibility library for old (X)Emacs versions
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation,
;; Inc.
;; Authors: 2003- Alan Mackenzie
;; 1998- Martin Stjernholm
;; 1997-1999 Barry A. Warsaw
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 03-Jul-1997 (as cc-mode-19.el)
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This file is necessary in order to run CC Mode in older (X)Emacs
;; versions. It's not needed at all for the latest versions of Emacs
;; and XEmacs.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
;; Silence the compiler (in case this file is compiled by other
;; Emacsen even though it isn't used by them).
(cc-bytecomp-obsolete-fun byte-code-function-p)
(cc-bytecomp-defun regexp-opt-depth)
(cc-external-require 'advice)
;; Emacs 20.n doesn't have the macros push and pop. Here're the Emacs 21
;; definitions.
(or (fboundp 'push)
(defmacro push (newelt listname)
"Add NEWELT to the list stored in the symbol LISTNAME.
This is equivalent to (setq LISTNAME (cons NEWELT LISTNAME)).
LISTNAME must be a symbol."
(list 'setq listname
(list 'cons newelt listname))))
(or (fboundp 'pop)
(defmacro pop (listname)
"Return the first element of LISTNAME's value, and remove it from the list.
LISTNAME must be a symbol whose value is a list.
If the value is nil, `pop' returns nil but does not actually
change the list."
(list 'prog1 (list 'car listname)
(list 'setq listname (list 'cdr listname)))))
(if (/= (regexp-opt-depth "\\(\\(\\)\\)") 2)
(progn
;; Emacs 21.1 has a buggy regexp-opt-depth which prevents CC
;; Mode building. Those in Emacs 21.[23] are not entirely
;; accurate. The following definition comes from Emacs's
;; regexp-opt.el CVS version 1.25 and is believed to be a
;; rigorously correct implementation.
(defconst regexp-opt-not-groupie*-re
(let* ((harmless-ch "[^\\\\[]")
(esc-pair-not-lp "\\\\[^(]")
(class-harmless-ch "[^][]")
(class-lb-harmless "[^]:]")
(class-lb-colon-maybe-charclass ":\\([a-z]+:]\\)?")
(class-lb (concat "\\[\\(" class-lb-harmless
"\\|" class-lb-colon-maybe-charclass "\\)"))
(class
(concat "\\[^?]?"
"\\(" class-harmless-ch
"\\|" class-lb "\\)*"
"\\[?]")) ; special handling for bare [ at end of re
(shy-lp "\\\\(\\?:"))
(concat "\\(" harmless-ch "\\|" esc-pair-not-lp
"\\|" class "\\|" shy-lp "\\)*"))
"Matches any part of a regular expression EXCEPT for non-shy \"\\\\(\"s")
(defun regexp-opt-depth (regexp)
"Return the depth of REGEXP.
This means the number of regexp grouping constructs (parenthesised expressions)
in REGEXP."
(save-match-data
;; Hack to signal an error if REGEXP does not have balanced
;; parentheses.
(string-match regexp "")
;; Count the number of open parentheses in REGEXP.
(let ((count 0) start)
(while
(progn
(string-match regexp-opt-not-groupie*-re regexp start)
(setq start ( + (match-end 0) 2)) ; +2 for "\\(" after match-end.
(<= start (length regexp)))
(setq count (1+ count)))
count)))
))
;; Some XEmacs versions have a bug in which font-lock-compile-keywords
;; overwrites the variable font-lock-keywords with its result. This causes
;; havoc when what the function is compiling is font-lock-SYNTACTIC-keywords,
;; hence....
(eval-after-load "font-lock"
'(when (let (font-lock-keywords)
(font-lock-compile-keywords '("\\<\\>"))
font-lock-keywords) ; did the previous call foul this up?
(defun font-lock-compile-keywords (keywords)
"Compile KEYWORDS (a list) and return the list of compiled keywords.
Each keyword has the form (MATCHER HIGHLIGHT ...). See `font-lock-keywords'."
(if (eq (car-safe keywords) t)
keywords
(cons t (mapcar 'font-lock-compile-keyword keywords))))
(defadvice font-lock-fontify-keywords-region (before c-compile-font-lock-keywords
activate preactivate)
(unless (eq (car-safe font-lock-keywords) t)
(setq font-lock-keywords
(font-lock-compile-keywords font-lock-keywords))))
))
(cc-provide 'cc-fix)
;;; cc-fix.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,219 @@
;;; cc-guess.el --- guess indentation values by scanning existing code
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation,
;; Inc.
;; Author: 1994-1995 Barry A. Warsaw
;; Maintainer: Unmaintained
;; Created: August 1994, split from cc-mode.el
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; This file contains routines that help guess the cc-mode style in a
;; particular region/buffer. It is provided for example and
;; experimentation only. It is not supported in anyway. Note that
;; style guessing is lossy!
;;
;; The way this is intended to be run is for you to mark a region of
;; code to guess the style of, then run the command, `cc-guess-region'.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-engine)
(defvar cc-guessed-style nil
"Currently guessed style.")
(defvar cc-guess-delta-accumulator nil)
;; Accumulated sampled indent information. Information is represented
;; in a list. Each element in it has following structure:
;;
;; (syntactic-symbol ((indentation-delta1 . number-of-times1)
;; (indentation-delta2 . number-of-times2)
;; ...))
;;
;; This structure is built by `cc-guess-accumulate-delta'.
;;
;; Here we call the pair (indentation-delta1 . number-of-times1) a
;; counter. `cc-guess-sort-delta-accumulator' sorts the order of
;; counters by number-of-times.
(defconst cc-guess-conversions
'((c . c-lineup-C-comments)
(inher-cont . c-lineup-multi-inher)
(string . -1000)
(comment-intro . c-lineup-comment)
(arglist-cont-nonempty . c-lineup-arglist)
(arglist-close . c-lineup-close-paren)
(cpp-macro . -1000)))
(defun cc-guess (&optional accumulate)
"Apply `cc-guess-region' on the whole current buffer.
If given a prefix argument (or if the optional argument ACCUMULATE is
non-nil) then the previous guess is extended, otherwise a new guess is
made from scratch."
(interactive "P")
(cc-guess-region (point-min) (point-max) accumulate))
(defun cc-guess-install ()
"Set the indentation style from the last guessed style (`cc-guessed-style')."
(interactive)
(setq c-offsets-alist (cc-guess-merge-styles cc-guessed-style
c-offsets-alist)))
(defun cc-guess-region (start end &optional accumulate)
"Set the indentation style by examining the indentation in a region of code.
Every line of code in the region is examined and the indentation
values of the various syntactic symbols in `c-offset-alist' are
guessed. Frequencies of use are taken into account, so minor
inconsistencies in the indentation style shouldn't produce wrong
guesses.
The guessed style is put into `cc-guessed-style'. It's also merged
into `c-offsets-alist'. Guessed offsets takes precedence over
existing ones on `c-offsets-alist'.
If given a prefix argument (or if the optional argument ACCUMULATE is
non-nil) then the previous guess is extended, otherwise a new guess is
made from scratch.
Note that the larger the region to guess in, the slower the guessing."
(interactive "r\nP")
(let ((delta-accumulator (when accumulate cc-guess-delta-accumulator))
(reporter (when (fboundp 'make-progress-reporter)
(make-progress-reporter "Sampling Indentation " start end))))
;;
;; Sampling stage
;;
(save-excursion
(goto-char start)
(while (< (point) end)
(c-save-buffer-state
((syntax (c-guess-basic-syntax))
(relpos (car (cdr (car syntax))))
(symbol (car (car syntax))))
;; TBD: for now I can't guess indentation when more than 1
;; symbol is on the list, nor for symbols without relpos's
;;
;; I think it is too stricted for ((topmost-intro) (comment-intro)).
;; -- Masatake
(unless (or ; (/= 1 (length syntax))
(not (numberp relpos))
(eq (line-beginning-position)
(line-end-position)))
(setq delta-accumulator (cc-guess-accumulate-delta
delta-accumulator
symbol
(- (progn (back-to-indentation)
(current-column) )
(save-excursion
(goto-char relpos)
(current-column)))))))
(when reporter (progress-reporter-update reporter (point)))
(forward-line 1)))
(when reporter (progress-reporter-done reporter))
;;
;; Guessing stage
;;
(setq delta-accumulator (cc-guess-sort-delta-accumulator
delta-accumulator)
cc-guess-delta-accumulator delta-accumulator)
(let* ((typical-style (cc-guess-make-style delta-accumulator))
(merged-style (cc-guess-merge-styles
(copy-list cc-guess-conversions)
typical-style)))
(setq cc-guessed-style merged-style
c-offsets-alist (cc-guess-merge-styles
merged-style
c-offsets-alist)))))
(defun cc-guess-accumulate-delta (accumulator symbol delta)
;; Added SYMBOL and DELTA to ACCUMULATOR. See
;; `cc-guess-delta-accumulator' about the structure of ACCUMULATOR.
(let* ((entry (assoc symbol accumulator))
(counters (cdr entry))
counter)
(if entry
(progn
(setq counter (assoc delta counters))
(if counter
(setcdr counter (1+ (cdr counter)))
(setq counters (cons (cons delta 1) counters))
(setcdr entry counters))
accumulator)
(cons (cons symbol (cons (cons delta 1) nil)) accumulator))))
(defun cc-guess-sort-delta-accumulator (accumulator)
;; Sort the each element of ACCUMULATOR by the number-of-times. See
;; `cc-guess-delta-accumulator' for more details.
(mapcar
(lambda (entry)
(let ((symbol (car entry))
(counters (cdr entry)))
(cons symbol (sort counters
(lambda (a b)
(if (> (cdr a) (cdr b))
t
(and
(eq (cdr a) (cdr b))
(< (car a) (car b)))))))))
accumulator))
(defun cc-guess-make-style (accumulator)
;; Throw away the rare cases in accumulator and make a style structure.
(mapcar
(lambda (entry)
(cons (car entry)
(car (car (cdr entry)))))
accumulator))
(defun cc-guess-merge-styles (strong weak)
;; Merge two styles into one. When two styles has the same symbol
;; entry, give STRONG priority over WEAK.
(mapc
(lambda (weak-elt)
(unless (assoc (car weak-elt) strong)
(setq strong (cons weak-elt strong))))
weak)
strong)
(defun cc-guess-view-style ()
"Show `cc-guessed-style'."
(interactive)
(with-output-to-temp-buffer "*Indentation Guessing Result*"
(pp cc-guessed-style)))
(cc-provide 'cc-guess)
;;; cc-guess.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,160 @@
;;; cc-lobotomy.el --- excise portions of cc-mode's brain... for speed
;; Copyright (C) 1985,1987,1992-2003, 2005 Free Software Foundation, Inc.
;; Author: 1995 Barry A. Warsaw
;; Maintainer: Unmaintained
;; Created: March 1995, split from cc-mode.el
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; Every effort has been made to improve the performance of
;; cc-mode. However, due to the nature of the C, C++, and Objective-C
;; language definitions, a trade-off is often required between
;; accuracy of construct recognition and speed. I believe it is always
;; best to be correct, and that the mode is currently fast enough for
;; most normal usage. Others disagree. I have no intention of
;; including these hacks in the main distribution. When cc-mode
;; version 5 comes out, it will include a rewritten indentation engine
;; so that performance will be greatly improved automatically. This
;; was not included in this release of version 4 so that Emacs 18
;; could still be supported. Note that this implies that cc-mode
;; version 5 will *not* work on Emacs 18!
;;
;; To use, see the variable cc-lobotomy-pith-list and the function
;; cc-lobotomize. The variable contains a good explanation of the
;; speed/accuracy trade-offs for each option. Set it to what you'd
;; like, and call cc-lobotomy in your c-mode-hook.
;;
;; This will redefine certain cc-mode functions and affect all cc-mode
;; buffers globally.
;;
;; This file is completely unsupported! Although it has been patched
;; superficially to keep pace with the rest of CC Mode, it hasn't been
;; tested for a long time.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-engine)
(cc-require 'cc-cmds)
(defvar cc-lobotomy-pith-list ()
"*List of things to dumb-ify to speed up cc-mode. Note that each
incurs a penalty in correct identification of certain code constructs.
Possible values to put on this list:
'literal -- `c-in-literal' is lobotomized. This will significantly
speed up parsing over large lists of cpp macros, as seen
for instance in header files. The penalty is that you
cannot put the `#' character as the first non-whitespace
character on a line inside other multi-line literals
(i.e. comments or strings)
'class -- `c-narrow-out-enclosing-class' and `c-search-uplist for
classkey' are lobotomized. This speeds up some
indenting inside and around class and struct
definitions. The penalty is that elements inside of
classes and structs may not indent correctly.
'lists -- `c-inside-bracelist-p' is lobotomized. This speeds up
indenting inside and around brace lists (e.g. aggregate
initializers, enum lists, etc.). The penalty is that
elements inside these lists may not indent correctly.")
(defun cc-lobotomize ()
"Perform lobotomies on cc-mode as described in `cc-lobotomy-pith-list'."
(let (pithedp)
(if (memq 'literal cc-lobotomy-pith-list)
(progn
(fset 'c-in-literal 'cc-in-literal-lobotomized)
(setq pithedp t)))
(if (memq 'class cc-lobotomy-pith-list)
(progn
(fset 'c-narrow-out-enclosing-class
'cc-narrow-out-enclosing-class-lobotomized)
(fset 'c-search-uplist-for-classkey
'cc-search-uplist-for-classkey-lobotomized)
(setq pithedp t)))
(if (memq 'lists cc-lobotomy-pith-list)
(progn
(fset 'c-inside-bracelist-p 'cc-inside-bracelist-p-lobotomized)
(setq pithedp t)))
(if pithedp
(add-hook 'c-prepare-bug-report-hooks 'cc-lobo-bug-report-blurb))
))
;; This is a faster version of c-in-literal. It trades speed for one
;; approximation, namely that within other literals, the `#' character
;; cannot be the first non-whitespace on a line. This only happens if
;; detect-cpp is non-nil, which isn't very often.
(defun cc-in-literal-lobotomized (&optional lim detect-cpp)
;; first check the cache
(if (and (vectorp c-in-literal-cache)
(= (point) (aref c-in-literal-cache 0)))
(aref c-in-literal-cache 1)
;; quickly check for cpp macro. this breaks if the `#' character
;; appears as the first non-whitespace on a line inside another
;; literal.
(let* (state
(char-at-boi (char-after (c-point 'boi)))
(rtn (cond
((and detect-cpp char-at-boi (= char-at-boi ?#))
'pound)
((nth 3 (setq state (save-excursion
(parse-partial-sexp
(or lim (c-point 'bod))
(point)))))
'string)
((nth 4 state) (if (nth 7 state) 'c++ 'c))
(t nil))))
;; cache this result if the cache is enabled
(if (not c-in-literal-cache)
(setq c-in-literal-cache (vector (point) rtn)))
rtn)))
(defun cc-narrow-out-enclosing-class-lobotomized (dummy1 dummy2) nil)
(defun cc-search-uplist-for-classkey-lobotomized (dummy) nil)
(defun cc-inside-bracelist-p-lobotomized (dummy1 dummy2) nil)
(defun cc-lobo-bug-report-blurb ()
(insert
"\nYou are using cc-lobotomy.el. You realize that by doing\n"
"so you have already made the decision to trade off accuracy\n"
"for speed? Don't set your hopes too high that your problem\n"
"will be fixed.\n\n"))
(cc-provide 'cc-lobotomy)
;;; cc-lobotomy.el ends here

Binary file not shown.

View file

@ -0,0 +1,425 @@
;;; cc-menus.el --- imenu support for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation,
;; Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
;; 1987 Dave Detlefs and Stewart Clamen
;; 1985 Richard M. Stallman
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 22-Apr-1997 (split from cc-mode.el)
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
;; The things referenced in imenu, which we don't require.
(cc-bytecomp-defvar imenu-case-fold-search)
(cc-bytecomp-defvar imenu-generic-expression)
(cc-bytecomp-defvar imenu-create-index-function)
(cc-bytecomp-defun imenu-progress-message)
;; imenu integration
(defvar cc-imenu-c-prototype-macro-regexp nil
"RE matching macro names used to conditionally specify function prototypes.
For example:
#ifdef __STDC__
#define _P(x) x
#else
#define _P(x) /*nothing*/
#endif
int main _P( (int argc, char *argv[]) )
A sample value might look like: `\\(_P\\|_PROTO\\)'.")
(defvar cc-imenu-c++-generic-expression
`(
;; Try to match ::operator definitions first. Otherwise `X::operator new ()'
;; will be incorrectly recognised as function `new ()' because the regexps
;; work by backtracking from the end of the definition.
(nil
,(concat
"^\\<.*"
"[^" c-alnum "_:<>~]" ; match any non-identifier char
; (note: this can be `\n')
"\\("
"\\([" c-alnum "_:<>~]*::\\)?" ; match an operator
"operator\\>[ \t]*"
"\\(()\\|[^(]*\\)" ; special case for `()' operator
"\\)"
"[ \t]*([^)]*)[ \t]*[^ \t;]" ; followed by ws, arg list,
; require something other than
; a `;' after the (...) to
; avoid prototypes. Can't
; catch cases with () inside
; the parentheses surrounding
; the parameters. e.g.:
; `int foo(int a=bar()) {...}'
) 1)
;; Special case to match a line like `main() {}'
;; e.g. no return type, not even on the previous line.
(nil
,(concat
"^"
"\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
"[ \t]*(" ; see above, BUT
"[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
"[ \t]*[^ \t;(]" ; with an asterisk or parentheses
) 1)
;; General function name regexp
(nil
,(concat
"^\\<" ; line MUST start with word char
"[^()]*" ; no parentheses before
"[^" c-alnum "_:<>~]" ; match any non-identifier char
"\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
"\\([ \t\n]\\|\\\\\n\\)*(" ; see above, BUT the arg list
"\\([ \t\n]\\|\\\\\n\\)*\\([^ \t\n(*][^)]*\\)?)" ; must not start
"\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]" ; with an asterisk or parentheses
) 1)
;; Special case for definitions using phony prototype macros like:
;; `int main _PROTO( (int argc,char *argv[]) )'.
;; This case is only included if cc-imenu-c-prototype-macro-regexp is set.
;; Only supported in c-code, so no `:<>~' chars in function name!
,@(if cc-imenu-c-prototype-macro-regexp
`((nil
,(concat
"^\\<.*" ; line MUST start with word char
"[^" c-alnum "_]" ; match any non-identifier char
"\\([" c-alpha "_][" c-alnum "_]*\\)" ; match function name
"[ \t]*" ; whitespace before macro name
cc-imenu-c-prototype-macro-regexp
"[ \t]*(" ; ws followed by first paren.
"[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
) 1)))
;; Class definitions
("Class"
,(concat
"^" ; beginning of line is required
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'
"\\(class\\|struct\\)[ \t]+"
"\\(" ; the string we want to get
"[" c-alnum "_]+" ; class name
"\\(<[^>]+>\\)?" ; possibly explicitly specialized
"\\)"
"\\([ \t\n]\\|\\\\\n\\)*[:{]"
) 3))
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
(defvar cc-imenu-c-generic-expression
cc-imenu-c++-generic-expression
"Imenu generic expression for C mode. See `imenu-generic-expression'.")
(defvar cc-imenu-java-generic-expression
`((nil
,(concat
"[" c-alpha "_][\]\[." c-alnum "_]+[ \t\n\r]+" ; type spec
"\\([" c-alpha "_][" c-alnum "_]+\\)" ; method name
"[ \t\n\r]*"
;; An argument list that is either empty or contains at least
;; two identifiers with only space between them. This avoids
;; matching e.g. "else if (foo)".
(concat "([ \t\n\r]*"
"\\([\]\[.," c-alnum "_]+"
"[ \t\n\r]+"
"[\]\[.," c-alnum "_]"
"[\]\[.," c-alnum "_ \t\n\r]*"
"\\)?)")
"[.," c-alnum "_ \t\n\r]*"
"{"
) 1))
"Imenu generic expression for Java mode. See `imenu-generic-expression'.")
;; *Warning for cc-mode developers*
;;
;; `cc-imenu-objc-generic-expression' elements depend on
;; `cc-imenu-c++-generic-expression'. So if you change this
;; expression, you need to change following variables,
;; `cc-imenu-objc-generic-expression-*-index',
;; too. `cc-imenu-objc-function' uses these *-index variables, in
;; order to know where the each regexp *group \\(foobar\\)* elements
;; are started.
;;
;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
;; being initialized.
;;
;; Internal variables
(defvar cc-imenu-objc-generic-expression-noreturn-index nil)
(defvar cc-imenu-objc-generic-expression-general-func-index nil)
(defvar cc-imenu-objc-generic-expression-proto-index nil)
(defvar cc-imenu-objc-generic-expression-objc-base-index nil)
(defvar cc-imenu-objc-generic-expression
(concat
;;
;; For C
;;
;; > Special case to match a line like `main() {}'
;; > e.g. no return type, not even on the previous line.
;; Pick a token by (match-string 1)
(car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; -> index += 2
(prog2 (setq cc-imenu-objc-generic-expression-noreturn-index 1) "")
"\\|"
;; > General function name regexp
;; Pick a token by (match-string 3)
(car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 5
(prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "")
;; > Special case for definitions using phony prototype macros like:
;; > `int main _PROTO( (int argc,char *argv[]) )'.
;; Pick a token by (match-string 8)
(if cc-imenu-c-prototype-macro-regexp
(concat
"\\|"
(car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
(prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "")
)
(prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 8) "")
"") ; -> index += 0
(prog2 (setq cc-imenu-objc-generic-expression-proto-index 8) "")
;;
;; For Objective-C
;; Pick a token by (match-string 8 or 9)
;;
"\\|\\("
"^[-+][:" c-alnum "()*_<>\n\t ]*[;{]" ; Methods
"\\|"
"^@interface[\t ]+[" c-alnum "_]+[\t ]*:"
"\\|"
"^@interface[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
"\\|"
;; For NSObject, NSProxy and Object... They don't have super class.
"^@interface[\t ]+[" c-alnum "_]+[\t ]*.*$"
"\\|"
"^@implementation[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
"\\|"
"^@implementation[\t ]+[" c-alnum "_]+"
"\\|"
"^@protocol[\t ]+[" c-alnum "_]+" "\\)")
"Imenu generic expression for ObjC mode. See `imenu-generic-expression'.")
;; Imenu support for objective-c uses functions.
(defsubst cc-imenu-objc-method-to-selector (method)
"Return the objc selector style string of METHOD.
Example:
- perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD */
=>
-perform:withObject:withObject:withObject: /* selector */"
(let ((return "") ; String to be returned
(p 0) ; Current scanning position in METHOD
(pmax (length method)) ;
char ; Current scanning target
(betweenparen 0) ; CHAR is in parentheses.
argreq ; An argument is required.
inargvar) ; position of CHAR is in an argument variable.
(while (< p pmax)
(setq char (aref method p)
p (1+ p))
(cond
;; Is CHAR part of a objc token?
((and (not inargvar) ; Ignore if CHAR is part of an argument variable.
(eq 0 betweenparen) ; Ignore if CHAR is in parentheses.
(or (and (<= ?a char) (<= char ?z))
(and (<= ?A char) (<= char ?Z))
(and (<= ?0 char) (<= char ?9))
(= ?_ char)))
(if argreq
(setq inargvar t
argreq nil)
(setq return (concat return (char-to-string char)))))
;; Or a white space?
((and inargvar (or (eq ?\ char) (eq ?\n char))
(setq inargvar nil)))
;; Or a method separator?
;; If a method separator, the next token will be an argument variable.
((eq ?: char)
(setq argreq t
return (concat return (char-to-string char))))
;; Or an open parentheses?
((eq ?\( char)
(setq betweenparen (1+ betweenparen)))
;; Or a close parentheses?
((eq ?\) char)
(setq betweenparen (1- betweenparen)))))
return))
(defun cc-imenu-objc-remove-white-space (str)
"Remove all spaces and tabs from STR."
(let ((return "")
(p 0)
(max (length str))
char)
(while (< p max)
(setq char (aref str p))
(setq p (1+ p))
(if (or (= char ?\ ) (= char ?\t))
()
(setq return (concat return (char-to-string char)))))
return))
(defun cc-imenu-objc-function ()
"imenu supports for objc-mode."
(let (methodlist
clist
;;
;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
;;
;; *Warning for developers*
;; These constants depend on `cc-imenu-c++-generic-expression'.
;;
(OBJC cc-imenu-objc-generic-expression-objc-base-index)
;; Special case to match a line like `main() {}'
(Cnoreturn cc-imenu-objc-generic-expression-noreturn-index)
;; General function name regexp
(Cgeneralfunc cc-imenu-objc-generic-expression-general-func-index)
;; Special case for definitions using phony prototype macros like:
(Cproto cc-imenu-objc-generic-expression-proto-index)
langnum
;;
(classcount 0)
toplist
stupid
str
str2
(intflen (length "@interface"))
(implen (length "@implementation"))
(prtlen (length "@protocol"))
(func
;;
;; Does this emacs has buffer-substring-no-properties?
;;
(if (fboundp 'buffer-substring-no-properties)
'buffer-substring-no-properties
'buffer-substring)))
(goto-char (point-max))
(imenu-progress-message stupid 0)
;;
(while (re-search-backward cc-imenu-objc-generic-expression nil t)
(imenu-progress-message stupid)
(setq langnum (if (match-beginning OBJC)
OBJC
(cond
((match-beginning Cproto) Cproto)
((match-beginning Cgeneralfunc) Cgeneralfunc)
((match-beginning Cnoreturn) Cnoreturn))))
(setq str (funcall func (match-beginning langnum) (match-end langnum)))
;;
(cond
;;
;; C
;;
((not (eq langnum OBJC))
(setq clist (cons (cons str (match-beginning langnum)) clist)))
;;
;; ObjC
;;
;; An instance Method
((eq (aref str 0) ?-)
(setq str (concat "-" (cc-imenu-objc-method-to-selector str)))
(setq methodlist (cons (cons str
(match-beginning langnum))
methodlist)))
;; A factory Method
((eq (aref str 0) ?+)
(setq str (concat "+" (cc-imenu-objc-method-to-selector str)))
(setq methodlist (cons (cons str
(match-beginning langnum))
methodlist)))
;; Interface or implementation or protocol
((eq (aref str 0) ?@)
(setq classcount (1+ classcount))
(cond
((and (> (length str) implen)
(string= (substring str 0 implen) "@implementation"))
(setq str (substring str implen)
str2 "@implementation"))
((string= (substring str 0 intflen) "@interface")
(setq str (substring str intflen)
str2 "@interface"))
((string= (substring str 0 prtlen) "@protocol")
(setq str (substring str prtlen)
str2 "@protocol")))
(setq str (cc-imenu-objc-remove-white-space str))
(setq methodlist (cons (cons str2
(match-beginning langnum))
methodlist))
(setq toplist (cons nil (cons (cons str
methodlist) toplist))
methodlist nil))))
;;
(imenu-progress-message stupid 100)
(if (eq (car toplist) nil)
(setq toplist (cdr toplist)))
;; In this buffer, there is only one or zero @{interface|implementation|protocol}.
(if (< classcount 2)
(let ((classname (car (car toplist)))
(p (cdr (car (cdr (car toplist)))))
last)
(setq toplist (cons (cons classname p) (cdr (cdr (car toplist)))))
;; Add C lang token
(if clist
(progn
(setq last toplist)
(while (cdr last)
(setq last (cdr last)))
(setcdr last clist))))
;; Add C lang tokens as a sub menu
(if clist
(setq toplist (cons (cons "C" clist) toplist))))
;;
toplist
))
;(defvar cc-imenu-pike-generic-expression
; ())
; FIXME: Please contribute one!
(defun cc-imenu-init (mode-generic-expression
&optional mode-create-index-function)
(setq imenu-generic-expression mode-generic-expression
imenu-case-fold-search nil)
(when mode-create-index-function
(setq imenu-create-index-function mode-create-index-function)))
(cc-provide 'cc-menus)
;;; arch-tag: f6b60933-91f0-4145-ab44-70ca6d1b919b
;;; cc-menus.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,647 @@
;;; cc-styles.el --- support for styles in CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation,
;; Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
;; 1987 Dave Detlefs and Stewart Clamen
;; 1985 Richard M. Stallman
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 22-Apr-1997 (split from cc-mode.el)
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-vars)
(cc-require 'cc-align)
;; cc-align is only indirectly required: Styles added with
;; `c-add-style' often contains references to functions defined there.
;; Silence the compiler.
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs
(cc-bytecomp-obsolete-fun make-local-hook) ; Marked obsolete in Emacs 21.1.
(defvar c-style-alist
'(("gnu"
(c-basic-offset . 2)
(c-comment-only-line-offset . (0 . 0))
(c-hanging-braces-alist . ((substatement-open before after)))
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 5)
(substatement-open . +)
(substatement-label . 0)
(label . 0)
(statement-case-open . +)
(statement-cont . +)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-close . c-lineup-arglist)
(inline-open . 0)
(brace-list-open . +)))
(c-special-indent-hook . c-gnu-impose-minimum)
(c-block-comment-prefix . ""))
("k&r"
(c-basic-offset . 5)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +))))
("bsd"
(c-basic-offset . 8)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . +)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +)
(inline-open . 0)
(inexpr-class . 0))))
("stroustrup"
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +))))
("whitesmith"
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
;; It's obvious that the CC Mode way of choosing anchor positions
;; doesn't fit this style at all. :P
(c-offsets-alist . ((defun-open . +)
(defun-close . c-lineup-whitesmith-in-block)
(defun-block-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(class-open . +)
(class-close . +)
(inline-open . +)
(inline-close . c-lineup-whitesmith-in-block)
(knr-argdecl-intro . +)
(block-open . 0) ; Get indentation from `statement' instead.
(block-close . c-lineup-whitesmith-in-block)
(brace-list-open . +)
(brace-list-close . c-lineup-whitesmith-in-block)
(brace-list-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(brace-list-entry . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(brace-entry-open . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(statement . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(statement-block-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(substatement-open . +)
(substatement-label . +)
(label . 0)
(arglist-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(arglist-cont . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(arglist-cont-nonempty . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(arglist-close . c-lineup-whitesmith-in-block)
(inclass . c-lineup-whitesmith-in-block)
(extern-lang-open . +)
(namespace-open . +)
(module-open . +)
(composition-open . +)
(extern-lang-close . +)
(namespace-close . +)
(module-close . +)
(composition-close . +)
(inextern-lang . c-lineup-whitesmith-in-block)
(innamespace . c-lineup-whitesmith-in-block)
(inmodule . c-lineup-whitesmith-in-block)
(incomposition . c-lineup-whitesmith-in-block)
(inexpr-class . 0))))
("ellemtel"
(c-basic-offset . 3)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open before after)))
(c-offsets-alist . ((topmost-intro . 0)
(substatement . +)
(substatement-open . 0)
(case-label . +)
(access-label . -)
(inclass . ++)
(inline-open . 0))))
("linux"
(c-basic-offset . 8)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((brace-list-open)
(brace-entry-open)
(substatement-open after)
(block-close . c-snug-do-while)))
(c-cleanup-list . (brace-else-brace))
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +))))
("python"
(indent-tabs-mode . t)
(fill-column . 78)
(c-basic-offset . 8)
(c-offsets-alist . ((substatement-open . 0)
(inextern-lang . 0)
(arglist-intro . +)
(knr-argdecl-intro . +)))
(c-hanging-braces-alist . ((brace-list-open)
(brace-list-intro)
(brace-list-close)
(brace-entry-open)
(substatement-open after)
(block-close . c-snug-do-while)))
(c-block-comment-prefix . ""))
("java"
(c-basic-offset . 4)
(c-comment-only-line-offset . (0 . 0))
;; the following preserves Javadoc starter lines
(c-offsets-alist . ((inline-open . 0)
(topmost-intro-cont . +)
(statement-block-intro . +)
(knr-argdecl-intro . 5)
(substatement-open . +)
(substatement-label . +)
(label . +)
(statement-case-open . +)
(statement-cont . +)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-close . c-lineup-arglist)
(access-label . 0)
(inher-cont . c-lineup-java-inher)
(func-decl-cont . c-lineup-java-throws))))
;; awk style exists primarily for auto-newline settings. Otherwise it's
;; pretty much like k&r.
("awk"
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((defun-open after)
(defun-close . c-snug-1line-defun-close)
(substatement-open after)
(block-close . c-snug-do-while)))
(c-hanging-semi&comma-criteria . nil)
(c-cleanup-list . nil) ; You might want one-liner-defun here.
(c-offsets-alist . ((statement-block-intro . +)
(substatement-open . 0)
(statement-cont . +))))
)
"Styles of indentation.
Elements of this alist are of the form:
(STYLE-STRING [BASE-STYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
where STYLE-STRING is a short descriptive string used to select a
style, VARIABLE is any Emacs variable, and VALUE is the intended value
for that variable when using the selected style.
Optional BASE-STYLE if present, is a string and must follow
STYLE-STRING. BASE-STYLE names a style that this style inherits from.
By default, all styles inherit from the \"user\" style, which is
computed at run time. Style loops generate errors.
Two variables are treated specially. When VARIABLE is
`c-offsets-alist', the VALUE is a list containing elements of the
form:
(SYNTACTIC-SYMBOL . OFFSET)
as described in `c-offsets-alist'. These are passed directly to
`c-set-offset' so there is no need to set every syntactic symbol in
your style, only those that are different from the default.
When VARIABLE is `c-special-indent-hook', its VALUE is added to
`c-special-indent-hook' using `add-hook'. If VALUE is a list, each
element of the list is added with `add-hook'.
Do not change this variable directly. Use the function `c-add-style'
to add new styles or modify existing styles (it is not a good idea to
modify existing styles -- you should create a new style that inherits
the existing style.")
;; Functions that manipulate styles
(defun c-set-style-1 (conscell dont-override)
;; Set the style for one variable
(let ((attr (car conscell))
(val (cdr conscell)))
(cond
;; first special variable
((eq attr 'c-offsets-alist)
(let ((offsets (cond ((eq dont-override t)
c-offsets-alist)
(dont-override
(default-value 'c-offsets-alist)))))
(mapcar (lambda (langentry)
(let ((langelem (car langentry))
(offset (cdr langentry)))
(unless (assq langelem offsets)
(c-set-offset langelem offset))))
val)))
;; second special variable
((eq attr 'c-special-indent-hook)
;; Maybe we should ignore dont-override here and always add new
;; hooks?
(unless (cond ((eq dont-override t)
c-special-indent-hook)
(dont-override
(default-value 'c-special-indent-hook)))
(if (listp val)
(mapcar (lambda (func)
(add-hook 'c-special-indent-hook func t t))
val)
(add-hook 'c-special-indent-hook val t t))))
;; all other variables
(t (when (or (not dont-override)
(not (memq attr c-style-variables))
(eq (if (eq dont-override t)
(symbol-value attr)
(default-value attr))
'set-from-style))
(set attr val)
;; Must update a number of other variables if
;; c-comment-prefix-regexp is set.
(if (eq attr 'c-comment-prefix-regexp)
(c-setup-paragraph-variables)))))))
(defun c-get-style-variables (style basestyles)
;; Return all variables in a style by resolving inheritances.
(if (not style)
(copy-alist c-fallback-style)
(let ((vars (cdr (or (assoc (downcase style) c-style-alist)
(assoc (upcase style) c-style-alist)
(assoc style c-style-alist)
(progn
(c-benign-error "Undefined style: %s" style)
nil)))))
(let ((base (and (stringp (car-safe vars))
(prog1
(downcase (car vars))
(setq vars (cdr vars))))))
(if (memq base basestyles)
(c-benign-error "Style loop detected: %s in %s" base basestyles)
(nconc (c-get-style-variables base (cons base basestyles))
(copy-alist vars)))))))
(defvar c-set-style-history nil)
;;;###autoload
(defun c-set-style (stylename &optional dont-override)
"Set the current buffer to use the style STYLENAME.
STYLENAME, a string, must be an existing CC Mode style - These are contained
in the variable `c-style-alist'.
The variable `c-indentation-style' will get set to STYLENAME.
\"Setting the style\" is done by setting CC Mode's \"style variables\" to the
values indicated by the pertinent entry in `c-style-alist'. Other variables
might get set too.
If DONT-OVERRIDE is neither nil nor t, style variables whose default values
have been set (more precisely, whose default values are not the symbol
`set-from-style') will not be changed. This avoids overriding global settings
done in ~/.emacs. It is useful to call c-set-style from a mode hook in this
way.
If DONT-OVERRIDE is t, style variables that already have values (i.e., whose
values are not the symbol `set-from-style') will not be overridden. CC Mode
calls c-set-style internally in this way whilst initializing a buffer; if
cc-set-style is called like this from anywhere else, it will usually behave as
a null operation."
(interactive
(list (let ((completion-ignore-case t)
(prompt (format "Which %s indentation style? "
mode-name)))
(completing-read prompt c-style-alist nil t nil
'c-set-style-history
c-indentation-style))))
(or c-buffer-is-cc-mode
(error "Buffer %s is not a CC Mode buffer (c-set-style)" (buffer-name)))
(or (stringp stylename)
(error "Argument to c-set-style was not a string"))
(c-initialize-builtin-style)
(let ((vars (c-get-style-variables stylename nil)))
(unless dont-override
;; Since we always add to c-special-indent-hook we must reset it
;; first, or else the hooks from the preceding style will
;; remain. This is not necessary for c-offsets-alist, since
;; c-get-style-variables contains every valid offset type in the
;; fallback entry.
(setq c-special-indent-hook
(default-value 'c-special-indent-hook)))
(mapcar (lambda (elem)
(c-set-style-1 elem dont-override))
;; Need to go through the variables backwards when we
;; don't override any settings.
(if (eq dont-override t) (nreverse vars) vars)))
(setq c-indentation-style stylename)
(c-keep-region-active))
;;;###autoload
(defun c-add-style (style description &optional set-p)
"Adds a style to `c-style-alist', or updates an existing one.
STYLE is a string identifying the style to add or update. DESCRIPTION
is an association list describing the style and must be of the form:
([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
See the variable `c-style-alist' for the semantics of BASESTYLE,
VARIABLE and VALUE. This function also sets the current style to
STYLE using `c-set-style' if the optional SET-P flag is non-nil."
(interactive
(let ((stylename (completing-read "Style to add: " c-style-alist
nil nil nil 'c-set-style-history))
(descr (eval-minibuffer "Style description: ")))
(list stylename descr
(y-or-n-p "Set the style too? "))))
(setq style (downcase style))
(let ((s (assoc style c-style-alist)))
(if s
(setcdr s (copy-alist description)) ; replace
(setq c-style-alist (cons (cons style description) c-style-alist))))
(and set-p (c-set-style style)))
(defvar c-read-offset-history nil)
(defun c-read-offset (langelem)
;; read new offset value for LANGELEM from minibuffer. return a
;; legal value only
(let* ((oldoff (cdr-safe (or (assq langelem c-offsets-alist)
(assq langelem (get 'c-offsets-alist
'c-stylevar-fallback)))))
(symname (symbol-name langelem))
(defstr (format "(default %s): " oldoff))
(errmsg (concat "Offset must be int, func, var, vector, list, "
"or [+,-,++,--,*,/] "
defstr))
(prompt (concat symname " offset " defstr))
(keymap (make-sparse-keymap))
(minibuffer-completion-table obarray)
(minibuffer-completion-predicate 'fboundp)
offset input)
;; In principle completing-read is used here, but SPC is unbound
;; to make it less annoying to enter lists.
(set-keymap-parent keymap minibuffer-local-completion-map)
(define-key keymap " " 'self-insert-command)
(while (not offset)
(setq input (read-from-minibuffer prompt nil keymap t
'c-read-offset-history
(format "%s" oldoff)))
(if (c-valid-offset input)
(setq offset input)
;; error, but don't signal one, keep trying
;; to read an input value
(ding)
(setq prompt errmsg)))
offset))
;;;###autoload
(defun c-set-offset (symbol offset &optional ignored)
"Change the value of a syntactic element symbol in `c-offsets-alist'.
SYMBOL is the syntactic element symbol to change and OFFSET is the new
offset for that syntactic element. The optional argument is not used
and exists only for compatibility reasons."
(interactive
(let* ((langelem
(intern (completing-read
(concat "Syntactic symbol to change"
(if current-prefix-arg " or add" "")
": ")
(mapcar
#'(lambda (langelem)
(cons (format "%s" (car langelem)) nil))
(get 'c-offsets-alist 'c-stylevar-fallback))
nil (not current-prefix-arg)
;; initial contents tries to be the last element
;; on the syntactic analysis list for the current
;; line
(and c-buffer-is-cc-mode
(c-save-buffer-state
((syntax (c-guess-basic-syntax))
(len (length syntax))
(ic (format "%s" (car (nth (1- len) syntax)))))
(cons ic 0)))
)))
(offset (c-read-offset langelem)))
(list langelem offset current-prefix-arg)))
;; sanity check offset
(if (c-valid-offset offset)
(let ((entry (assq symbol c-offsets-alist)))
(if entry
(setcdr entry offset)
(if (assq symbol (get 'c-offsets-alist 'c-stylevar-fallback))
(setq c-offsets-alist (cons (cons symbol offset)
c-offsets-alist))
(c-benign-error "%s is not a valid syntactic symbol" symbol))))
(c-benign-error "Invalid indentation setting for symbol %s: %S"
symbol offset))
(c-keep-region-active))
(defun c-setup-paragraph-variables ()
"Fix things up for paragraph recognition and filling inside comments and
strings by incorporating the values of `c-comment-prefix-regexp',
`sentence-end', `paragraph-start' and `paragraph-separate' in the relevant
variables."
(interactive)
(or c-buffer-is-cc-mode
(error "Buffer %s is not a CC Mode buffer (c-setup-paragraph-variables)"
(buffer-name)))
;; Set up the values for use in comments.
(setq c-current-comment-prefix
(if (listp c-comment-prefix-regexp)
(cdr-safe (or (assoc major-mode c-comment-prefix-regexp)
(assoc 'other c-comment-prefix-regexp)))
c-comment-prefix-regexp))
(let ((comment-line-prefix
(concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*")))
(setq paragraph-start (concat comment-line-prefix
c-paragraph-start
"\\|"
page-delimiter)
paragraph-separate (concat comment-line-prefix
c-paragraph-separate
"\\|"
page-delimiter)
paragraph-ignore-fill-prefix t
adaptive-fill-mode t
adaptive-fill-regexp
(concat comment-line-prefix
(if (default-value 'adaptive-fill-regexp)
(concat "\\("
(default-value 'adaptive-fill-regexp)
"\\)")
"")))
(when (boundp 'adaptive-fill-first-line-regexp)
;; XEmacs adaptive fill mode doesn't have this.
(make-local-variable 'adaptive-fill-first-line-regexp)
(setq adaptive-fill-first-line-regexp
(concat "\\`" comment-line-prefix
;; Maybe we should incorporate the old value here,
;; but then we have to do all sorts of kludges to
;; deal with the \` and \' it probably contains.
"\\'"))))
;; Set up the values for use in strings. These are the default
;; paragraph-start/separate values, enhanced to accept escaped EOLs as
;; whitespace. Used in c-beginning/end-of-sentence-in-string in cc-cmds.
(setq c-string-par-start
;;(concat "\\(" (default-value 'paragraph-start) "\\)\\|[ \t]*\\\\$"))
"\f\\|[ \t]*\\\\?$")
(setq c-string-par-separate
;;(concat "\\(" (default-value 'paragraph-separate) "\\)\\|[ \t]*\\\\$"))
"[ \t\f]*\\\\?$")
(setq c-sentence-end-with-esc-eol
(concat "\\(\\(" (c-default-value-sentence-end) "\\)"
;; N.B.: "$" would be illegal when not enclosed like "\\($\\)".
"\\|" "[.?!][]\"')}]* ?\\\\\\($\\)[ \t\n]*"
"\\)")))
;; Helper for setting up Filladapt mode. It's not used by CC Mode itself.
(cc-bytecomp-defvar filladapt-token-table)
(cc-bytecomp-defvar filladapt-token-match-table)
(cc-bytecomp-defvar filladapt-token-conversion-table)
(defun c-setup-filladapt ()
"Convenience function to configure Kyle E. Jones' Filladapt mode for
CC Mode by making sure the proper entries are present on
`filladapt-token-table', `filladapt-token-match-table', and
`filladapt-token-conversion-table'. This is intended to be used on
`c-mode-common-hook' or similar."
;; This function is intended to be used explicitly by the end user
;; only.
;; The default configuration already handles C++ comments, but we
;; need to add handling of C block comments. A new filladapt token
;; `c-comment' is added for that.
(let (p)
(setq p filladapt-token-table)
(while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment)))
(setq p (cdr-safe p)))
(if p
(setcar (car p) c-current-comment-prefix)
(setq filladapt-token-table
(append (list (car filladapt-token-table)
(list c-current-comment-prefix 'c-comment))
(cdr filladapt-token-table)))))
(unless (assq 'c-comment filladapt-token-match-table)
(setq filladapt-token-match-table
(append '((c-comment c-comment))
filladapt-token-match-table)))
(unless (assq 'c-comment filladapt-token-conversion-table)
(setq filladapt-token-conversion-table
(append '((c-comment . exact))
filladapt-token-conversion-table))))
(defun c-initialize-builtin-style ()
;; Dynamically append the default value of most variables. This is
;; crucial because future c-set-style calls will always reset the
;; variables first to the `cc-mode' style before instituting the new
;; style. Only do this once!
(unless (get 'c-initialize-builtin-style 'is-run)
(put 'c-initialize-builtin-style 'is-run t)
;;(c-initialize-cc-mode)
(unless (assoc "user" c-style-alist)
(let ((vars c-style-variables) var val uservars)
(while vars
(setq var (car vars)
val (symbol-value var)
vars (cdr vars))
(cond ((eq var 'c-offsets-alist)
(or (null val)
(setq uservars (cons (cons 'c-offsets-alist val)
uservars))))
((not (eq val 'set-from-style))
(setq uservars (cons (cons var val)
uservars)))))
(c-add-style "user" uservars)))
(unless (assoc "cc-mode" c-style-alist)
(c-add-style "cc-mode" '("user")))
(if c-style-variables-are-local-p
(c-make-styles-buffer-local))))
(defun c-make-styles-buffer-local (&optional this-buf-only-p)
"Make all CC Mode style variables buffer local.
If `this-buf-only-p' is non-nil, the style variables will be made
buffer local only in the current buffer. Otherwise they'll be made
permanently buffer local in any buffer that changes their values.
The buffer localness of the style variables are normally controlled
with the variable `c-style-variables-are-local-p', so there's seldom
any reason to call this function directly."
;; style variables
(let ((func (if this-buf-only-p
'make-local-variable
'make-variable-buffer-local))
(varsyms (cons 'c-indentation-style (copy-alist c-style-variables))))
(delq 'c-special-indent-hook varsyms)
(mapcar func varsyms)
;; Hooks must be handled specially
(if this-buf-only-p
(make-local-hook 'c-special-indent-hook)
(make-variable-buffer-local 'c-special-indent-hook)
(setq c-style-variables-are-local-p t))
))
(cc-provide 'cc-styles)
;;; arch-tag: c764f61a-96ba-484a-a68f-101c0e9d5d2c
;;; cc-styles.el ends here

Binary file not shown.

View file

@ -0,0 +1,312 @@
;;; cc-subword.el --- Handling capitalized subwords in a nomenclature
;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
;; Author: Masatake YAMATO
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This package provides `subword' oriented commands and a minor mode
;; (`c-subword-mode') that substitutes the common word handling
;; functions with them.
;; In spite of GNU Coding Standards, it is popular to name a symbol by
;; mixing uppercase and lowercase letters, e.g. "GtkWidget",
;; "EmacsFrameClass", "NSGraphicsContext", etc. Here we call these
;; mixed case symbols `nomenclatures'. Also, each capitalized (or
;; completely uppercase) part of a nomenclature is called a `subword'.
;; Here are some examples:
;; Nomenclature Subwords
;; ===========================================================
;; GtkWindow => "Gtk" and "Window"
;; EmacsFrameClass => "Emacs", "Frame" and "Class"
;; NSGraphicsContext => "NS", "Graphics" and "Context"
;; The subword oriented commands defined in this package recognize
;; subwords in a nomenclature to move between them and to edit them as
;; words.
;; In the minor mode, all common key bindings for word oriented
;; commands are overridden by the subword oriented commands:
;; Key Word oriented command Subword oriented command
;; ============================================================
;; M-f `forward-word' `c-forward-subword'
;; M-b `backward-word' `c-backward-subword'
;; M-@ `mark-word' `c-mark-subword'
;; M-d `kill-word' `c-kill-subword'
;; M-DEL `backward-kill-word' `c-backward-kill-subword'
;; M-t `transpose-words' `c-transpose-subwords'
;; M-c `capitalize-word' `c-capitalize-subword'
;; M-u `upcase-word' `c-upcase-subword'
;; M-l `downcase-word' `c-downcase-subword'
;;
;; Note: If you have changed the key bindings for the word oriented
;; commands in your .emacs or a similar place, the keys you've changed
;; to are also used for the corresponding subword oriented commands.
;; To make the mode turn on automatically, put the following code in
;; your .emacs:
;;
;; (add-hook 'c-mode-common-hook
;; (lambda () (c-subword-mode 1)))
;;
;; Acknowledgment:
;; The regular expressions to detect subwords are mostly based on
;; the old `c-forward-into-nomenclature' originally contributed by
;; Terry_Glanfield dot Southern at rxuk dot xerox dot com.
;; TODO: ispell-word and subword oriented C-w in isearch.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-cmds)
;; Don't complain about the `define-minor-mode' form if it isn't defined.
(cc-bytecomp-defvar c-subword-mode)
;;; Autoload directives must be on the top level, so we construct an
;;; autoload form instead.
;;;###autoload (autoload 'c-subword-mode "cc-subword" "Mode enabling subword movement and editing keys." t)
(if (not (fboundp 'define-minor-mode))
(defun c-subword-mode ()
"(Missing) mode enabling subword movement and editing keys.
This mode is not (yet) available in this version of (X)Emacs. Sorry! If
you really want it, please send a request to <bug-gnu-emacs@gnu.org>,
telling us which (X)Emacs version you're using."
(interactive)
(error
"c-subword-mode is not (yet) available in this version of (X)Emacs. Sorry!"))
(defvar c-subword-mode-map
(let ((map (make-sparse-keymap)))
(substitute-key-definition 'forward-word
'c-forward-subword
map global-map)
(substitute-key-definition 'backward-word
'c-backward-subword
map global-map)
(substitute-key-definition 'mark-word
'c-mark-subword
map global-map)
(substitute-key-definition 'kill-word
'c-kill-subword
map global-map)
(substitute-key-definition 'backward-kill-word
'c-backward-kill-subword
map global-map)
(substitute-key-definition 'transpose-words
'c-transpose-subwords
map global-map)
(substitute-key-definition 'capitalize-word
'c-capitalize-subword
map global-map)
(substitute-key-definition 'upcase-word
'c-upcase-subword
map global-map)
(substitute-key-definition 'downcase-word
'c-downcase-subword
map global-map)
map)
"Keymap used in command `c-subword-mode' minor mode.")
(define-minor-mode c-subword-mode
"Mode enabling subword movement and editing keys.
In spite of GNU Coding Standards, it is popular to name a symbol by
mixing uppercase and lowercase letters, e.g. \"GtkWidget\",
\"EmacsFrameClass\", \"NSGraphicsContext\", etc. Here we call these
mixed case symbols `nomenclatures'. Also, each capitalized (or
completely uppercase) part of a nomenclature is called a `subword'.
Here are some examples:
Nomenclature Subwords
===========================================================
GtkWindow => \"Gtk\" and \"Window\"
EmacsFrameClass => \"Emacs\", \"Frame\" and \"Class\"
NSGraphicsContext => \"NS\", \"Graphics\" and \"Context\"
The subword oriented commands activated in this minor mode recognize
subwords in a nomenclature to move between subwords and to edit them
as words.
\\{c-subword-mode-map}"
nil
nil
c-subword-mode-map
(c-update-modeline))
)
(defun c-forward-subword (&optional arg)
"Do the same as `forward-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `forward-word'."
(interactive "p")
(unless arg (setq arg 1))
(c-keep-region-active)
(cond
((< 0 arg)
(dotimes (i arg (point))
(c-forward-subword-internal)))
((> 0 arg)
(dotimes (i (- arg) (point))
(c-backward-subword-internal)))
(t
(point))))
(defun c-backward-subword (&optional arg)
"Do the same as `backward-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `backward-word'."
(interactive "p")
(c-forward-subword (- (or arg 1))))
(defun c-mark-subword (arg)
"Do the same as `mark-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `mark-word'."
;; This code is almost copied from `mark-word' in GNU Emacs.
(interactive "p")
(cond ((and (eq last-command this-command) (mark t))
(set-mark
(save-excursion
(goto-char (mark))
(c-forward-subword arg)
(point))))
(t
(push-mark
(save-excursion
(c-forward-subword arg)
(point))
nil t))))
(defun c-kill-subword (arg)
"Do the same as `kill-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `kill-word'."
(interactive "p")
(kill-region (point) (c-forward-subword arg)))
(defun c-backward-kill-subword (arg)
"Do the same as `backward-kill-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `backward-kill-word'."
(interactive "p")
(c-kill-subword (- arg)))
(defun c-transpose-subwords (arg)
"Do the same as `transpose-words' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `transpose-words'."
(interactive "*p")
(transpose-subr 'c-forward-subword arg))
(defun c-capitalize-subword (arg)
"Do the same as `capitalize-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `capitalize-word'."
(interactive "p")
(let ((count (abs arg))
(direction (if (< 0 arg) 1 -1)))
(dotimes (i count)
(when (re-search-forward
(concat "[" c-alpha "]")
nil t)
(goto-char (match-beginning 0)))
(let* ((p (point))
(pp (1+ p))
(np (c-forward-subword direction)))
(upcase-region p pp)
(downcase-region pp np)
(goto-char np)))))
(defun c-downcase-subword (arg)
"Do the same as `downcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `downcase-word'."
(interactive "p")
(downcase-region (point) (c-forward-subword arg)))
(defun c-upcase-subword (arg)
"Do the same as `upcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `upcase-word'."
(interactive "p")
(upcase-region (point) (c-forward-subword arg)))
;;
;; Internal functions
;;
(defun c-forward-subword-internal ()
(if (and
(save-excursion
(let ((case-fold-search nil))
(re-search-forward
(concat "\\W*\\(\\([" c-upper "]*\\W?\\)[" c-lower c-digit "]*\\)")
nil t)))
(> (match-end 0) (point))) ; So we don't get stuck at a
; "word-constituent" which isn't c-upper,
; c-lower or c-digit
(goto-char
(cond
((< 1 (- (match-end 2) (match-beginning 2)))
(1- (match-end 2)))
(t
(match-end 0))))
(forward-word 1)))
(defun c-backward-subword-internal ()
(if (save-excursion
(let ((case-fold-search nil))
(re-search-backward
(concat
"\\(\\(\\W\\|[" c-lower c-digit "]\\)\\([" c-upper "]+\\W*\\)"
"\\|\\W\\w+\\)")
nil t)))
(goto-char
(cond
((and (match-end 3)
(< 1 (- (match-end 3) (match-beginning 3)))
(not (eq (point) (match-end 3))))
(1- (match-end 3)))
(t
(1+ (match-beginning 0)))))
(backward-word 1)))
(cc-provide 'cc-subword)
;;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3
;;; cc-subword.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,400 @@
;;; csharp-mode.el --- C# mode derived mode
;; Author: 2005 Dylan R. E. Moonfire
;; Maintainer: Dylan R. E. Moonfire <contact@mfgames.com>
;; Created: Feburary 2005
;; Modified: December 2005
;; Version: 0.5.0
;; Keywords: c# languages oop
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;
;; This is a separate mode to implement the C# constructs and
;; font-locking. It is based on the java-mode example from cc-mode.
;;
;; Note: The interface used in this file requires CC Mode 5.30 or
;; later.
;;; Bugs:
;;
;; Literal strings @"" do not fontify correctly.
;;
;; Method names are not fontified if you have an attribute before it.
;;
;; This code doesn't seem to work when you compile it, then
;; load/require in the emacs file. You will get an error (error
;; "`c-lang-defconst' must be used in a file") which happens because
;; cc-mode doesn't think it is in a buffer while loading directly
;; from the init. However, if you call it based on a file extension,
;; it works properly. Interestingly enough, this doesn't happen if
;; you don't byte-compile cc-mode.
;;; .emacs (don't put in (require 'csharp-mode))
;; (autoload 'csharp-mode "csharp-mode" "Major mode for editing C# code." t)
;; (setq auto-mode-alist
;; (append '(("\\.cs$" . csharp-mode)) auto-mode-alist))
;;; Versions:
;;
;; 0.1.0 - Initial release.
;; 0.2.0 - Fixed the identification on the "enum" keyword.
;; - Fixed the font-lock on the "base" keyword
;; 0.3.0 - Added a regex to fontify attributes. It isn't the
;; the best method, but it handles single-like attributes
;; well.
;; - Got "super" not to fontify as a keyword.
;; - Got extending classes and interfaces to fontify as something.
;; 0.4.0 - Removed the attribute matching because it broke more than
;; it fixed.
;; - Corrected a bug with namespace not being properly identified
;; and treating the class level as an inner object, which screwed
;; up formatting.
;; - Added "partial" to the keywords.
;; 0.5.0 - Found bugs with compiled cc-mode and loading from init files.
;; - Updated the eval-when-compile to code to let the mode be
;; compiled.
;;; Code:
(require 'cc-mode)
;; These are only required at compile time to get the sources for the
;; language constants. (The cc-fonts require and the font-lock
;; related constants could additionally be put inside an
;; (eval-after-load "font-lock" ...) but then some trickery is
;; necessary to get them compiled.)
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-mode" nil t)
(load "cc-fonts" nil t)
(load "cc-langs" nil t)))
(eval-and-compile
;; Make our mode known to the language constant system. Use Java
;; mode as the fallback for the constants we don't change here.
;; This needs to be done also at compile time since the language
;; constants are evaluated then.
(c-add-language 'csharp-mode 'java-mode))
;; TODO
;; Defines our constant for finding attributes.
;;(defconst csharp-attribute-regex "\\[\\([XmlType]+\\)(")
;;(defconst csharp-attribute-regex "\\[\\(.\\)")
;; Java uses a series of regexes to change the font-lock for class
;; references. The problem comes in because Java uses Pascal (leading
;; space in names, SomeClass) for class and package names, but
;; Camel-casing (initial lowercase, upper case in words,
;; i.e. someVariable) for variables. The notation suggested by EMCA is
;; to use Pasacal notation for everything, except inner variables. So,
;; the regex and formatting actually produces very wrong results.
;;(error (byte-compile-dest-file))
;;(error (c-get-current-file))
(c-lang-defconst c-opt-after-id-concat-key
csharp (if (c-lang-const c-opt-identifier-concat-key)
(c-lang-const c-symbol-start)))
(c-lang-defconst c-basic-matchers-before
csharp `(
;; Font-lock the attributes by searching for the
;; appropriate regex and marking it as TODO.
;;,`(,(concat "\\(" csharp-attribute-regex "\\)")
;; 0 font-lock-function-name-face)
;; Put a warning face on the opener of unclosed strings that
;; can't span lines. Later font
;; lock packages have a `font-lock-syntactic-face-function' for
;; this, but it doesn't give the control we want since any
;; fontification done inside the function will be
;; unconditionally overridden.
,(c-make-font-lock-search-function
;; Match a char before the string starter to make
;; `c-skip-comments-and-strings' work correctly.
(concat ".\\(" c-string-limit-regexp "\\)")
'((c-font-lock-invalid-string)))
;; Fontify keyword constants.
,@(when (c-lang-const c-constant-kwds)
(let ((re (c-make-keywords-re nil
(c-lang-const c-constant-kwds))))
`((eval . (list ,(concat "\\<\\(" re "\\)\\>")
1 c-constant-face-name)))))
;; Fontify all keywords except the primitive types.
,`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp))
1 font-lock-keyword-face)
;; Fontify leading identifiers in fully qualified names like
;; "Foo.Bar".
,@(when (c-lang-const c-opt-identifier-concat-key)
`((,(byte-compile
`(lambda (limit)
(while (re-search-forward
,(concat "\\(\\<" ; 1
"\\(" (c-lang-const c-symbol-key)
"\\)" ; 2
"[ \t\n\r\f\v]*"
(c-lang-const
c-opt-identifier-concat-key)
"[ \t\n\r\f\v]*"
"\\)"
"\\("
(c-lang-const
c-opt-after-id-concat-key)
"\\)")
limit t)
(unless (progn
(goto-char (match-beginning 0))
(c-skip-comments-and-strings limit))
(or (get-text-property (match-beginning 2) 'face)
(c-put-font-lock-face (match-beginning 2)
(match-end 2)
c-reference-face-name))
(goto-char (match-end 1)))))))))
))
;; C# does not allow a leading qualifier operator. It also doesn't
;; allow the ".*" construct of Java. So, we redo this regex without
;; the "\\|\\*" regex.
(c-lang-defconst c-identifier-key
csharp (concat "\\(" (c-lang-const c-symbol-key) "\\)" ; 1
(concat "\\("
"[ \t\n\r\f\v]*"
(c-lang-const c-opt-identifier-concat-key)
"[ \t\n\r\f\v]*"
(concat "\\("
"\\(" (c-lang-const c-symbol-key) "\\)"
"\\)")
"\\)*")))
;; C# has a few rules that are slightly different than Java for
;; operators. This also removed the Java's "super" and replaces it
;; with the C#'s "base".
(c-lang-defconst c-operators
csharp `((prefix "base")))
;; C#, unlike Java, does use CPP prefixes for the regions and other directives.
(c-lang-defconst c-opt-cpp-prefix
csharp "\\s *#\\s *")
;; C# uses the following assignment operators
(c-lang-defconst c-assignment-operators
csharp '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|="))
;; This defines the primative types for C#
(c-lang-defconst c-primitive-type-kwds
;; ECMA-344, S8
csharp '("object" "string" "sbyte" "short" "int" "long" "byte"
"ushort" "uint" "ulong" "float" "double" "bool" "char"
"decimal" "void"))
;; The keywords that define that the following is a type, such as a
;; class definition.
(c-lang-defconst c-type-prefix-kwds
;; ECMA-344, S?
csharp '("class" "interface" "enum" "struct"))
;; Type modifier keywords. They appear anywhere in types, but modifiy
;; instead create one.
(c-lang-defconst c-type-modifier-kwds
;; EMCA-344, S?
csharp '("readonly" "const"))
;; Structures that are similiar to classes.
(c-lang-defconst c-class-decl-kwds
;; EMCA-344, S?
csharp '("class" "interface"))
;; The various modifiers used for class and method descriptions.
(c-lang-defconst c-modifier-kwds
csharp '("public" "partial" "private" "const" "abstract"
"protected" "ref" "out" "static" "virtual"
"override" "params" "internal"))
;; We don't use the protection level stuff because it breaks the
;; method indenting. Not sure why, though.
(c-lang-defconst c-protection-kwds
csharp nil)
;; Define the keywords that can have something following after them.
(c-lang-defconst c-type-list-kwds
csharp '("struct" "class" "interface" "is" "as"
"delegate" "event"))
;; This allows the classes after the : in the class declartion to be
;; fontified.
(c-lang-defconst c-typeless-decl-kwds
csharp '(":"))
;; Sets up the enum to handle the list properly
(c-lang-defconst c-brace-list-decl-kwds
csharp '("enum"))
;; We need to remove Java's package keyword
(c-lang-defconst c-ref-list-kwds
csharp '("using" "namespace"))
;; Follow-on blocks that don't require a brace
(c-lang-defconst c-block-stmt-2-kwds
csharp '("for" "if" "switch" "while" "catch" "foreach"
"checked" "unchecked" "lock"))
;; Statements that break out of braces
(c-lang-defconst c-simple-stmt-kwds
csharp '("return" "continue" "break" "throw" "goto"))
;; Statements that allow a label
;; TODO?
(c-lang-defconst c-before-label-kwds
csharp nil)
;; Constant keywords
(c-lang-defconst c-constant-kwds
csharp '("true" "false" "null"))
;; Keywords that start "primary expressions."
(c-lang-defconst c-primary-expr-kwds
csharp '("this" "base"))
;; We need to treat namespace as an outer block to class indenting
;; works properly.
(c-lang-defconst c-other-block-decl-kwds
csharp '("namespace"))
;; We need to include the "as" for the foreach
(c-lang-defconst c-other-kwds
csharp '("in" "sizeof" "typeof"))
(c-lang-defconst c-overloadable-operators
;; EMCA-344, S14.2.1
csharp '("+" "-" "*" "/" "%" "&" "|" "^"
"<<" ">>" "==" "!=" ">" "<" ">=" "<="))
;; No cpp in this language, but there's still a "sharppragma" directive to
;; fontify. (The definitions for the extra keywords above are enough
;; to incorporate them into the fontification regexps for types and
;; keywords, so no additional font-lock patterns are required.)
(c-lang-defconst c-cpp-matchers
csharp (cons
;; Use the eval form for `font-lock-keywords' to be able to use
;; the `c-preprocessor-face-name' variable that maps to a
;; suitable face depending on the (X)Emacs version.
'(eval . (list "^\\s *\\(sharppragma\\)\\>\\(.*\\)"
(list 1 c-preprocessor-face-name)
'(2 font-lock-string-face)))
;; There are some other things in `c-cpp-matchers' besides the
;; preprocessor support, so include it.
(c-lang-const c-cpp-matchers)))
(defcustom csharp-font-lock-extra-types nil
"*List of extra types (aside from the type keywords) to recognize in C# mode.
Each list item should be a regexp matching a single identifier.")
(defconst csharp-font-lock-keywords-1 (c-lang-const c-matchers-1 csharp)
"Minimal highlighting for C# mode.")
(defconst csharp-font-lock-keywords-2 (c-lang-const c-matchers-2 csharp)
"Fast normal highlighting for C# mode.")
(defconst csharp-font-lock-keywords-3 (c-lang-const c-matchers-3 csharp)
"Accurate normal highlighting for C# mode.")
(defvar csharp-font-lock-keywords csharp-font-lock-keywords-3
"Default expressions to highlight in C# mode.")
(defvar csharp-mode-syntax-table nil
"Syntax table used in csharp-mode buffers.")
(or csharp-mode-syntax-table
(setq csharp-mode-syntax-table
(funcall (c-lang-const c-make-mode-syntax-table csharp))))
(defvar csharp-mode-abbrev-table nil
"Abbreviation table used in csharp-mode buffers.")
(c-define-abbrev-table 'csharp-mode-abbrev-table
;; Keywords that if they occur first on a line might alter the
;; syntactic context, and which therefore should trig reindentation
;; when they are completed.
'(("else" "else" c-electric-continued-statement 0)
("while" "while" c-electric-continued-statement 0)
("catch" "catch" c-electric-continued-statement 0)
("finally" "finally" c-electric-continued-statement 0)))
(defvar csharp-mode-map (let ((map (c-make-inherited-keymap)))
;; Add bindings which are only useful for C#
map)
"Keymap used in csharp-mode buffers.")
;;(easy-menu-define csharp-menu csharp-mode-map "C# Mode Commands"
;; ;; Can use `csharp' as the language for `c-mode-menu'
;; ;; since its definition covers any language. In
;; ;; this case the language is used to adapt to the
;; ;; nonexistence of a cpp pass and thus removing some
;; ;; irrelevant menu alternatives.
;; (cons "C#" (c-lang-const c-mode-menu csharp)))
;;; Autoload mode trigger
(add-to-list 'auto-mode-alist '("\\.cs" . csharp-mode))
;; Custom variables
(defcustom csharp-mode-hook nil
"*Hook called by `csharp-mode'."
:type 'hook
:group 'c)
;;; The entry point into the mode
(defun csharp-mode ()
"Major mode for editing C# (pronounced \"see sharp\") code.
This is a simple example of a separate mode derived from CC Mode to
support a language with syntax similar to C/C++/ObjC/Java/IDL/Pike.
The hook `c-mode-common-hook' is run with no args at mode
initialization, then `csharp-mode-hook'.
Key bindings:
\\{csharp-mode-map}"
(interactive)
(kill-all-local-variables)
(c-initialize-cc-mode t)
(set-syntax-table csharp-mode-syntax-table)
(setq major-mode 'csharp-mode
mode-name "C#"
local-abbrev-table csharp-mode-abbrev-table
abbrev-mode t)
(use-local-map c-mode-map)
;; `c-init-language-vars' is a macro that is expanded at compile
;; time to a large `setq' with all the language variables and their
;; customized values for our language.
(c-init-language-vars csharp-mode)
;; `c-common-init' initializes most of the components of a CC Mode
;; buffer, including setup of the mode menu, font-lock, etc.
;; There's also a lower level routine `c-basic-common-init' that
;; only makes the necessary initialization to get the syntactic
;; analysis and similar things working.
(c-common-init 'csharp-mode)
;;(easy-menu-add csharp-menu)
(run-hooks 'c-mode-common-hook)
(run-hooks 'csharp-mode-hook)
(c-update-modeline))
(provide 'csharp-mode)
;;; csharp-mode.el ends here

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View file

@ -0,0 +1,42 @@
Manifest for CC Mode 5.31
You should have received the following files in this distribution:
MANIFEST: This file.
README: Quick intro into how to get CC Mode up and running.
NEWS: A list of the user visible changes in each version.
cc-align.el, cc-awk.el, cc-cmds.el, cc-defs.el, cc-engine.el,
cc-fonts.el, cc-langs.el, cc-menus.el, cc-mode.el, cc-styles.el,
cc-subword.el, cc-vars.el: The source code.
cc-compat.el: Helps ease the transition from c-mode.el (BOCM) to
the new indentation engine. This is provided for your convenience
only, and is unguaranteed and unsupported.
cc-fix.el: (previously named cc-mode-19.el). Detects and corrects
bugs in various older (X)Emacs versions.
cc-guess.el: Experiments in style guessing. This is provided for
your convenience only, and is unguaranteed and unsupported.
cc-lobotomy.el: Performance vs. accuracy trade-offs. May not
work, yadda, yadda.
cc-bytecomp.el: Contains helpers used during byte compiling to
ensure that there's no mixup with earler versions of CC Mode which
might be loaded.
cc-mode.texi: The latest CC Mode Texinfo manual.
ANNOUNCEMENT: Release announcement as it appeared on various
forums.
Note that of the above files, the following are distributed with Emacs
and XEmacs:
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
cc-defs.el, cc-engine.el, cc-fonts.el, cc-langs.el, cc-menus.el,
cc-mode.el, cc-styles.el, cc-subword.el, cc-vars.el, cc-mode.texi

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,123 @@
README for CC Mode 5.31
Current maintainers: Martin Stjernholm and Alan Mackenzie
Contact address : bug-cc-mode@gnu.org
INTRODUCTION
The canonical web location for all knowledge CC Mode is:
<http://cc-mode.sourceforge.net/>
Please read the cc-mode.texi manual for details on using CC Mode.
This is available on-line from:
<http://cc-mode.sourceforge.net/cc-mode.html>
As of this writing (November 18, 2005), CC Mode currently works
out of the box with XEmacs versions 21.4 and later, and with Emacs
versions 20.4 and later, 21.x and 22.x. (It will very likely work
with later versions too, when they become available.)
Note that with CC Mode 5.31, we have finally dropped support for
Emacs 19.34 and XEmacs 19.15. CC Mode 5.31 _won't_ work with
these old versions. Upgrade them now!
Currently, the new Subword Mode doesn't work in Emacs 20.n.
MORE INFORMATION
Check out the CC Mode web site for the latest information,
updates, tips, installation and compatibility notes, etc. on using
CC Mode. The installation instructions given below are an excerpt
of the on-line instructions. If you have problems installing CC
Mode, please check out the URL above before submitting a bug
report. Thanks!
The MANIFEST file contains a description of all the files you
should have gotten with this distribution.
MANUALS
Preformatted versions of the manual in DVI, PostScript, and Info,
are all available at the CC Mode web page. The Info manual has
two variants, one for GNU Emacs, the other for XEmacs - the only
differences between them are the targets of some cross references
within the manual.
To build the manual yourself, you will need Texinfo 4.7 or later.
Simply type:
% makeinfo cc-mode.texi # For GNU Emacs
or
% makeinfo -DXEMACS cc-mode.texi # For XEmacs
To make the DVI version, type:
% texi2dvi cc-mode.texi
INSTALLATION
Here is a quick guide for installing CC Mode. For the latest
information on installing CC Mode, please see the CC Mode web site
given above.
Byte Compiling
It is highly recommended that you byte-compile CC Mode for
performance reasons. Running CC Mode non-byte-compiled is not
supported.
You can compile CC Mode in the same way as any other package. To
compile it from a running (X)Emacs session:
M-0 M-x byte-recompile-directory RET /path/to/cc-mode RET
To compile CC Mode from the shell:
% cd /path/to/cc-mode
% $(EMACS) -batch -no-site-file -q -f batch-byte-compile cc-*.el
where $(EMACS) is either emacs or xemacs depending on the flavor
you use. Note that the byte compiled files from one version of
(X)Emacs are likely not to work on a different version - compile
them fresh when you upgrade your (X)Emacs version.
Installing
Put the compiled files somewhere (X)Emacs will find them, i.e. in
some path that's in the load-path variable. You must make sure
they are found before any CC Mode files which are distributed with
(X)Emacs. A directory has higher precendence than all directories
after it in the load-path list.
If you're going to be using AWK Mode, insert the following line
into your .emacs or init.el file:
(autoload 'awk-mode "cc-mode" nil t)
This will cause (X)Emacs to use the new AWK Mode for AWK files,
rather than the older mode contained in the file awk-mode.elc.
(See also the note below under "Compatibility Issues".)
To test that you have things set up correctly, visit a C file and
then type:
M-x c-version RET
=> Using CC Mode version 5.XX
where XX is the correct minor revision number.
Compatibility Issues
CC Mode should work fine with most versions of Emacs and XEmacs
which aren't ancient (see the introduction above).
If you're using AWK, you can verify that you've got Emacs set up
to use CC Mode for AWK files by displaying the mode documentation
string with C-h m from an AWK buffer. The current mode's doc
string contains "to submit a problem report, enter `C-c C-b'" near
the top of the doc string where the obsolete awk-mode.el has "This
is much like C mode except ....".
For more details about interactions with different packages, see
the CC Mode web page.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,440 @@
;;; cc-bytecomp.el --- compile time setup for proper compilation
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Author: Martin Stjernholm
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 15-Jul-2000
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This file is used to ensure that the CC Mode files are correctly
;; compiled regardless the environment (e.g. if an older CC Mode with
;; outdated macros are loaded during compilation). It also provides
;; features to defeat the compiler warnings for selected symbols.
;;
;; There's really nothing CC Mode specific here; this functionality
;; ought to be provided by the byte compilers or some accompanying
;; library. To use it from some package "foo.el", begin by putting
;; the following blurb at the top of the file:
;;
;; (eval-when-compile
;; (let ((load-path
;; (if (and (boundp 'byte-compile-dest-file)
;; (stringp byte-compile-dest-file))
;; (cons (file-name-directory byte-compile-dest-file) load-path)
;; load-path)))
;; (load "cc-bytecomp" nil t))
;;
;; This (unfortunately rather clumsy) form will ensure that the
;; cc-bytecomp.el in the same directory as foo.el is loaded during
;; byte compilation of the latter.
;;
;; At the end of foo.el there should normally be a "(provide 'foo)".
;; Replace it with "(cc-provide 'foo)"; that is necessary to restore
;; the environment after the byte compilation. If you don't have a
;; `provide' at the end, you have to add the following as the very
;; last form in the file:
;;
;; (eval-when-compile (cc-bytecomp-restore-environment))
;;
;; Now everything is set to use the various functions and macros in
;; this package.
;;
;; If your package is split into several files, you should use
;; `cc-require', `cc-require-when-compile' or `cc-load' to load them.
;; That ensures that the files in the same directory always are
;; loaded, to avoid mixup with other versions of them that might exist
;; elsewhere in the load path.
;;
;; To suppress byte compiler warnings, use the macros
;; `cc-bytecomp-defun', `cc-bytecomp-defvar',
;; `cc-bytecomp-obsolete-fun', and `cc-bytecomp-obsolete-var'.
;;
;; This file is not used at all after the package has been byte
;; compiled. It is however necessary when running uncompiled.
;;; Code:
(defvar cc-bytecomp-unbound-variables nil)
(defvar cc-bytecomp-original-functions nil)
(defvar cc-bytecomp-original-properties nil)
(defvar cc-bytecomp-loaded-files nil)
(defvar cc-bytecomp-environment-set nil)
(defmacro cc-bytecomp-debug-msg (&rest args)
;;`(message ,@args)
)
(defun cc-bytecomp-setup-environment ()
;; Eval'ed during compilation to setup variables, functions etc
;; declared with `cc-bytecomp-defvar' et al.
(if (not load-in-progress)
;; Look at `load-in-progress' to tell whether we're called
;; directly in the file being compiled or just from some file
;; being loaded during compilation.
(let (p)
(if cc-bytecomp-environment-set
(error "Byte compilation environment already set - \
perhaps a `cc-bytecomp-restore-environment' is forgotten somewhere"))
(setq p cc-bytecomp-unbound-variables)
(while p
(if (not (boundp (car p)))
(progn
(eval `(defvar ,(car p)))
(set (car p) (intern (concat "cc-bytecomp-ignore-var:"
(symbol-name (car p)))))
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Covered variable %s"
(car p))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-functions)
(while p
(let ((fun (car (car p)))
(temp-macro (car (cdr (car p)))))
(if (not (fboundp fun))
(if temp-macro
(progn
(eval `(defmacro ,fun ,@temp-macro))
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Bound macro %s" fun))
(fset fun (intern (concat "cc-bytecomp-ignore-fun:"
(symbol-name fun))))
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Covered function %s" fun))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-properties)
(while p
(let ((sym (car (car (car p))))
(prop (cdr (car (car p))))
(tempdef (car (cdr (car p)))))
(put sym prop tempdef)
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Bound property %s for %s to %s"
prop sym tempdef))
(setq p (cdr p)))
(setq cc-bytecomp-environment-set t)
(cc-bytecomp-debug-msg
"cc-bytecomp-setup-environment: Done"))))
(defun cc-bytecomp-restore-environment ()
;; Eval'ed during compilation to restore variables, functions etc
;; declared with `cc-bytecomp-defvar' et al.
(if (not load-in-progress)
(let (p)
(setq p cc-bytecomp-unbound-variables)
(while p
(let ((var (car p)))
(if (boundp var)
(if (eq (intern (concat "cc-bytecomp-ignore-var:"
(symbol-name var)))
(symbol-value var))
(progn
(makunbound var)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Unbound variable %s"
var))
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Not restoring variable %s"
var))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-functions)
(while p
(let ((fun (car (car p)))
(temp-macro (car (cdr (car p))))
(def (car (cdr (cdr (car p))))))
(if (fboundp fun)
(if (eq (or temp-macro
(intern (concat "cc-bytecomp-ignore-fun:"
(symbol-name fun))))
(symbol-function fun))
(if (eq def 'unbound)
(progn
(fmakunbound fun)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Unbound function %s"
fun))
(fset fun def)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Restored function %s"
fun))
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Not restoring function %s"
fun))))
(setq p (cdr p)))
(setq p cc-bytecomp-original-properties)
(while p
(let ((sym (car (car (car p))))
(prop (cdr (car (car p))))
(tempdef (car (cdr (car p))))
(origdef (cdr (cdr (car p)))))
(if (eq (get sym prop) tempdef)
(progn
(put sym prop origdef)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Restored property %s for %s to %s"
prop sym origdef))
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Not restoring property %s for %s"
prop sym)))
(setq p (cdr p)))
(setq cc-bytecomp-environment-set nil)
(cc-bytecomp-debug-msg
"cc-bytecomp-restore-environment: Done"))))
(eval
;; This eval is to avoid byte compilation of the function below.
;; There's some bug in XEmacs 21.4.6 that can cause it to dump core
;; here otherwise. My theory is that `cc-bytecomp-load' might be
;; redefined recursively during the `load' inside it, and if it in
;; that case is byte compiled then the byte interpreter gets
;; confused. I haven't succeeded in isolating the bug, though. /mast
'(defun cc-bytecomp-load (cc-part)
;; Eval'ed during compilation to load a CC Mode file from the source
;; directory (assuming it's the same as the compiled file
;; destination dir).
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(progn
(cc-bytecomp-restore-environment)
(let ((load-path
(cons (file-name-directory byte-compile-dest-file)
load-path))
(cc-file (concat cc-part ".el")))
(if (member cc-file cc-bytecomp-loaded-files)
()
(setq cc-bytecomp-loaded-files
(cons cc-file cc-bytecomp-loaded-files))
(cc-bytecomp-debug-msg
"cc-bytecomp-load: Loading %S" cc-file)
(load cc-file nil t t)
(cc-bytecomp-debug-msg
"cc-bytecomp-load: Loaded %S" cc-file)))
(cc-bytecomp-setup-environment)
t))))
(defmacro cc-require (cc-part)
"Force loading of the corresponding .el file in the current directory
during compilation, but compile in a `require'. Don't use within
`eval-when-compile'.
Having cyclic cc-require's will result in infinite recursion. That's
somewhat intentional."
`(progn
(eval-when-compile (cc-bytecomp-load (symbol-name ,cc-part)))
(require ,cc-part)))
(defmacro cc-provide (feature)
"A replacement for the `provide' form that restores the environment
after the compilation. Don't use within `eval-when-compile'."
`(progn
(eval-when-compile (cc-bytecomp-restore-environment))
(provide ,feature)))
(defmacro cc-load (cc-part)
"Force loading of the corresponding .el file in the current directory
during compilation. Don't use outside `eval-when-compile' or
`eval-and-compile'.
Having cyclic cc-load's will result in infinite recursion. That's
somewhat intentional."
`(or (and (featurep 'cc-bytecomp)
(cc-bytecomp-load ,cc-part))
(load ,cc-part nil t nil)))
(defmacro cc-require-when-compile (cc-part)
"Force loading of the corresponding .el file in the current directory
during compilation, but do a compile time `require' otherwise. Don't
use within `eval-when-compile'."
`(eval-when-compile
(if (and (featurep 'cc-bytecomp)
(cc-bytecomp-is-compiling))
(if (or (not load-in-progress)
(not (featurep ,cc-part)))
(cc-bytecomp-load (symbol-name ,cc-part)))
(require ,cc-part))))
(defmacro cc-external-require (feature)
"Do a `require' of an external package.
This restores and sets up the compilation environment before and
afterwards. Don't use within `eval-when-compile'."
`(progn
(eval-when-compile (cc-bytecomp-restore-environment))
(require ,feature)
(eval-when-compile (cc-bytecomp-setup-environment))))
(defun cc-bytecomp-is-compiling ()
"Return non-nil if eval'ed during compilation. Don't use outside
`eval-when-compile'."
(and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file)))
(defmacro cc-bytecomp-defvar (var)
"Binds the symbol as a variable during compilation of the file,
to silence the byte compiler. Don't use within `eval-when-compile'."
`(eval-when-compile
(if (boundp ',var)
(cc-bytecomp-debug-msg
"cc-bytecomp-defvar: %s bound already as variable" ',var)
(if (not (memq ',var cc-bytecomp-unbound-variables))
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-defvar: Saving %s (as unbound)" ',var)
(setq cc-bytecomp-unbound-variables
(cons ',var cc-bytecomp-unbound-variables))))
(if (and (cc-bytecomp-is-compiling)
(not load-in-progress))
(progn
(defvar ,var)
(set ',var (intern (concat "cc-bytecomp-ignore-var:"
(symbol-name ',var))))
(cc-bytecomp-debug-msg
"cc-bytecomp-defvar: Covered variable %s" ',var))))))
(defmacro cc-bytecomp-defun (fun)
"Bind the symbol as a function during compilation of the file,
to silence the byte compiler. Don't use within `eval-when-compile'.
If the symbol already is bound as a function, it will keep that
definition. That means that this macro will not shut up warnings
about incorrect number of arguments. It's dangerous to try to replace
existing functions since the byte compiler might need the definition
at compile time, e.g. for macros and inline functions."
`(eval-when-compile
(if (fboundp ',fun)
(cc-bytecomp-debug-msg
"cc-bytecomp-defun: %s bound already as function" ',fun)
(if (not (assq ',fun cc-bytecomp-original-functions))
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-defun: Saving %s (as unbound)" ',fun)
(setq cc-bytecomp-original-functions
(cons (list ',fun nil 'unbound)
cc-bytecomp-original-functions))))
(if (and (cc-bytecomp-is-compiling)
(not load-in-progress))
(progn
(fset ',fun (intern (concat "cc-bytecomp-ignore-fun:"
(symbol-name ',fun))))
(cc-bytecomp-debug-msg
"cc-bytecomp-defun: Covered function %s" ',fun))))))
(put 'cc-bytecomp-defmacro 'lisp-indent-function 'defun)
(defmacro cc-bytecomp-defmacro (fun &rest temp-macro)
"Bind the symbol as a macro during compilation (and evaluation) of the
file. Don't use outside `eval-when-compile'."
`(let ((orig-fun (assq ',fun cc-bytecomp-original-functions)))
(if (not orig-fun)
(setq orig-fun
(list ',fun
nil
(if (fboundp ',fun)
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-defmacro: Saving %s" ',fun)
(symbol-function ',fun))
(cc-bytecomp-debug-msg
"cc-bytecomp-defmacro: Saving %s as unbound" ',fun)
'unbound))
cc-bytecomp-original-functions
(cons orig-fun cc-bytecomp-original-functions)))
(defmacro ,fun ,@temp-macro)
(cc-bytecomp-debug-msg
"cc-bytecomp-defmacro: Bound macro %s" ',fun)
(setcar (cdr orig-fun) (symbol-function ',fun))))
(defmacro cc-bytecomp-put (symbol propname value)
"Set a property on a symbol during compilation (and evaluation) of
the file. Don't use outside `eval-when-compile'."
`(eval-when-compile
(if (not (assoc (cons ,symbol ,propname) cc-bytecomp-original-properties))
(progn
(cc-bytecomp-debug-msg
"cc-bytecomp-put: Saving property %s for %s with value %s"
,propname ,symbol (get ,symbol ,propname))
(setq cc-bytecomp-original-properties
(cons (cons (cons ,symbol ,propname)
(cons ,value (get ,symbol ,propname)))
cc-bytecomp-original-properties))))
(put ,symbol ,propname ,value)
(cc-bytecomp-debug-msg
"cc-bytecomp-put: Bound property %s for %s to %s"
,propname ,symbol ,value)))
(defmacro cc-bytecomp-obsolete-var (symbol)
"Suppress warnings that the given symbol is an obsolete variable.
Don't use within `eval-when-compile'."
`(eval-when-compile
(if (get ',symbol 'byte-obsolete-variable)
(cc-bytecomp-put ',symbol 'byte-obsolete-variable nil)
;; This avoids a superfluous compiler warning
;; about calling `get' for effect.
t)))
(defun cc-bytecomp-ignore-obsolete (form)
;; Wraps a call to `byte-compile-obsolete' that suppresses the warning.
(let ((byte-compile-warnings
(delq 'obsolete (append byte-compile-warnings nil))))
(byte-compile-obsolete form)))
(defmacro cc-bytecomp-obsolete-fun (symbol)
"Suppress warnings that the given symbol is an obsolete function.
Don't use within `eval-when-compile'."
`(eval-when-compile
(if (eq (get ',symbol 'byte-compile) 'byte-compile-obsolete)
(cc-bytecomp-put ',symbol 'byte-compile
'cc-bytecomp-ignore-obsolete)
;; This avoids a superfluous compiler warning
;; about calling `get' for effect.
t)))
(defmacro cc-bytecomp-boundp (symbol)
"Return non-nil if the given symbol is bound as a variable outside
the compilation. This is the same as using `boundp' but additionally
exclude any variables that have been bound during compilation with
`cc-bytecomp-defvar'."
(if (and (cc-bytecomp-is-compiling)
(memq (car (cdr symbol)) cc-bytecomp-unbound-variables))
nil
`(boundp ,symbol)))
(defmacro cc-bytecomp-fboundp (symbol)
"Return non-nil if the given symbol is bound as a function outside
the compilation. This is the same as using `fboundp' but additionally
exclude any functions that have been bound during compilation with
`cc-bytecomp-defun'."
(let (fun-elem)
(if (and (cc-bytecomp-is-compiling)
(setq fun-elem (assq (car (cdr symbol))
cc-bytecomp-original-functions))
(eq (elt fun-elem 2) 'unbound))
nil
`(fboundp ,symbol))))
(provide 'cc-bytecomp)
;;; arch-tag: 2d71b3ad-57b0-4b13-abd3-ab836e08f975
;;; cc-bytecomp.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,166 @@
;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1994-1999 Barry A. Warsaw
;; Maintainer: bug-cc-mode@gnu.org
;; Created: August 1994, split from cc-mode.el
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; Boring old c-mode.el (BOCM) is confusion and brain melt. cc-mode.el
;; is clarity of thought and purity of chi. If you are still unwilling
;; to accept enlightenment, this might help, or it may prolong your
;; agony.
;;
;; To use, add the following to your c-mode-hook:
;;
;; (require 'cc-compat)
;; (c-set-style "BOCM")
;;
;; This file is completely unsupported! Although it has been patched
;; superficially to keep pace with the rest of CC Mode, it hasn't been
;; tested for a long time.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-vars)
(cc-require 'cc-styles)
(cc-require 'cc-engine)
;; In case c-mode.el isn't loaded
(defvar c-indent-level 2
"*Indentation of C statements with respect to containing block.")
(defvar c-brace-imaginary-offset 0
"*Imagined indentation of a C open brace that actually follows a statement.")
(defvar c-brace-offset 0
"*Extra indentation for braces, compared with other text in same context.")
(defvar c-argdecl-indent 5
"*Indentation level of declarations of C function arguments.")
(defvar c-label-offset -2
"*Offset of C label lines and case statements relative to usual indentation.")
(defvar c-continued-statement-offset 2
"*Extra indent for lines not starting new statements.")
(defvar c-continued-brace-offset 0
"*Extra indent for substatements that start with open-braces.
This is in addition to c-continued-statement-offset.")
;; these offsets are taken by brute force testing c-mode.el, since
;; there's no logic to what it does.
(let* ((offsets '(c-offsets-alist .
((defun-block-intro . cc-block-intro-offset)
(statement-block-intro . cc-block-intro-offset)
(defun-open . 0)
(class-open . 0)
(inline-open . c-brace-offset)
(block-open . c-brace-offset)
(block-close . cc-block-close-offset)
(brace-list-open . c-brace-offset)
(substatement-open . cc-substatement-open-offset)
(substatement . c-continued-statement-offset)
(knr-argdecl-intro . c-argdecl-indent)
(case-label . c-label-offset)
(access-label . c-label-offset)
(label . c-label-offset)
))))
(c-add-style "BOCM" offsets))
(defun cc-block-intro-offset (langelem)
;; taken directly from calculate-c-indent confusion
(save-excursion
(c-backward-syntactic-ws)
(if (eq (char-before) ?{)
(forward-char -1)
(goto-char (cdr langelem)))
(let* ((curcol (save-excursion
(goto-char (cdr langelem))
(current-column)))
(bocm-lossage
;; If no previous statement, indent it relative to line
;; brace is on. For open brace in column zero, don't let
;; statement start there too. If c-indent-level is zero,
;; use c-brace-offset + c-continued-statement-offset
;; instead. For open-braces not the first thing in a line,
;; add in c-brace-imaginary-offset.
(+ (if (and (bolp) (zerop c-indent-level))
(+ c-brace-offset c-continued-statement-offset)
c-indent-level)
;; Move back over whitespace before the openbrace. If
;; openbrace is not first nonwhite thing on the line,
;; add the c-brace-imaginary-offset.
(progn (skip-chars-backward " \t")
(if (bolp) 0 c-brace-imaginary-offset))
;; If the openbrace is preceded by a parenthesized exp,
;; move to the beginning of that; possibly a different
;; line
(progn
(if (eq (char-before) ?\))
(c-forward-sexp -1))
;; Get initial indentation of the line we are on.
(current-indentation)))))
(- bocm-lossage curcol))))
(defun cc-block-close-offset (langelem)
(save-excursion
(let* ((here (point))
bracep
(curcol (progn
(goto-char (cdr langelem))
(current-column)))
(bocm-lossage (progn
(goto-char (cdr langelem))
(if (eq (char-after) ?{)
(setq bracep t)
(goto-char here)
(beginning-of-line)
(backward-up-list 1)
(forward-char 1)
(c-forward-syntactic-ws))
(current-column))))
(- bocm-lossage curcol
(if bracep 0 c-indent-level)))))
(defun cc-substatement-open-offset (langelem)
(+ c-continued-statement-offset c-continued-brace-offset))
(cc-provide 'cc-compat)
;;; arch-tag: 564dab2f-e6ad-499c-a4a3-fedec3ecc192
;;; cc-compat.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,143 @@
;;; cc-fix.el --- compatibility library for old (X)Emacs versions
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 2003- Alan Mackenzie
;; 1998- Martin Stjernholm
;; 1997-1999 Barry A. Warsaw
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 03-Jul-1997 (as cc-mode-19.el)
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This file is necessary in order to run CC Mode in older (X)Emacs
;; versions. It's not needed at all for the latest versions of Emacs
;; and XEmacs.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
;; Silence the compiler (in case this file is compiled by other
;; Emacsen even though it isn't used by them).
(cc-bytecomp-obsolete-fun byte-code-function-p)
(cc-bytecomp-defun regexp-opt-depth)
(cc-external-require 'advice)
;; Emacs 20.n doesn't have the macros push and pop. Here're the Emacs 21
;; definitions.
(or (fboundp 'push)
(defmacro push (newelt listname)
"Add NEWELT to the list stored in the symbol LISTNAME.
This is equivalent to (setq LISTNAME (cons NEWELT LISTNAME)).
LISTNAME must be a symbol."
(list 'setq listname
(list 'cons newelt listname))))
(or (fboundp 'pop)
(defmacro pop (listname)
"Return the first element of LISTNAME's value, and remove it from the list.
LISTNAME must be a symbol whose value is a list.
If the value is nil, `pop' returns nil but does not actually
change the list."
(list 'prog1 (list 'car listname)
(list 'setq listname (list 'cdr listname)))))
(if (/= (regexp-opt-depth "\\(\\(\\)\\)") 2)
(progn
;; Emacs 21.1 has a buggy regexp-opt-depth which prevents CC
;; Mode building. Those in Emacs 21.[23] are not entirely
;; accurate. The following definition comes from Emacs's
;; regexp-opt.el CVS version 1.25 and is believed to be a
;; rigorously correct implementation.
(defconst regexp-opt-not-groupie*-re
(let* ((harmless-ch "[^\\\\[]")
(esc-pair-not-lp "\\\\[^(]")
(class-harmless-ch "[^][]")
(class-lb-harmless "[^]:]")
(class-lb-colon-maybe-charclass ":\\([a-z]+:]\\)?")
(class-lb (concat "\\[\\(" class-lb-harmless
"\\|" class-lb-colon-maybe-charclass "\\)"))
(class
(concat "\\[^?]?"
"\\(" class-harmless-ch
"\\|" class-lb "\\)*"
"\\[?]")) ; special handling for bare [ at end of re
(shy-lp "\\\\(\\?:"))
(concat "\\(" harmless-ch "\\|" esc-pair-not-lp
"\\|" class "\\|" shy-lp "\\)*"))
"Matches any part of a regular expression EXCEPT for non-shy \"\\\\(\"s")
(defun regexp-opt-depth (regexp)
"Return the depth of REGEXP.
This means the number of regexp grouping constructs (parenthesised expressions)
in REGEXP."
(save-match-data
;; Hack to signal an error if REGEXP does not have balanced
;; parentheses.
(string-match regexp "")
;; Count the number of open parentheses in REGEXP.
(let ((count 0) start)
(while
(progn
(string-match regexp-opt-not-groupie*-re regexp start)
(setq start ( + (match-end 0) 2)) ; +2 for "\\(" after match-end.
(<= start (length regexp)))
(setq count (1+ count)))
count)))
))
;; Some XEmacs versions have a bug in which font-lock-compile-keywords
;; overwrites the variable font-lock-keywords with its result. This causes
;; havoc when what the function is compiling is font-lock-SYNTACTIC-keywords,
;; hence....
(eval-after-load "font-lock"
'(when (and (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
; to make the call to f-l-c-k throw an error.
(let (font-lock-keywords)
(font-lock-compile-keywords '("\\<\\>"))
font-lock-keywords)) ; did the previous call foul this up?
(defun font-lock-compile-keywords (keywords)
"Compile KEYWORDS (a list) and return the list of compiled keywords.
Each keyword has the form (MATCHER HIGHLIGHT ...). See `font-lock-keywords'."
(if (eq (car-safe keywords) t)
keywords
(cons t (mapcar 'font-lock-compile-keyword keywords))))
(defadvice font-lock-fontify-keywords-region (before c-compile-font-lock-keywords
activate preactivate)
(unless (eq (car-safe font-lock-keywords) t)
(setq font-lock-keywords
(font-lock-compile-keywords font-lock-keywords))))
))
(cc-provide 'cc-fix)
;;; cc-fix.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,219 @@
;;; cc-guess.el --- guess indentation values by scanning existing code
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Author: 1994-1995 Barry A. Warsaw
;; Maintainer: Unmaintained
;; Created: August 1994, split from cc-mode.el
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; This file contains routines that help guess the cc-mode style in a
;; particular region/buffer. It is provided for example and
;; experimentation only. It is not supported in anyway. Note that
;; style guessing is lossy!
;;
;; The way this is intended to be run is for you to mark a region of
;; code to guess the style of, then run the command, `cc-guess-region'.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-engine)
(defvar cc-guessed-style nil
"Currently guessed style.")
(defvar cc-guess-delta-accumulator nil)
;; Accumulated sampled indent information. Information is represented
;; in a list. Each element in it has following structure:
;;
;; (syntactic-symbol ((indentation-delta1 . number-of-times1)
;; (indentation-delta2 . number-of-times2)
;; ...))
;;
;; This structure is built by `cc-guess-accumulate-delta'.
;;
;; Here we call the pair (indentation-delta1 . number-of-times1) a
;; counter. `cc-guess-sort-delta-accumulator' sorts the order of
;; counters by number-of-times.
(defconst cc-guess-conversions
'((c . c-lineup-C-comments)
(inher-cont . c-lineup-multi-inher)
(string . -1000)
(comment-intro . c-lineup-comment)
(arglist-cont-nonempty . c-lineup-arglist)
(arglist-close . c-lineup-close-paren)
(cpp-macro . -1000)))
(defun cc-guess (&optional accumulate)
"Apply `cc-guess-region' on the whole current buffer.
If given a prefix argument (or if the optional argument ACCUMULATE is
non-nil) then the previous guess is extended, otherwise a new guess is
made from scratch."
(interactive "P")
(cc-guess-region (point-min) (point-max) accumulate))
(defun cc-guess-install ()
"Set the indentation style from the last guessed style (`cc-guessed-style')."
(interactive)
(setq c-offsets-alist (cc-guess-merge-styles cc-guessed-style
c-offsets-alist)))
(defun cc-guess-region (start end &optional accumulate)
"Set the indentation style by examining the indentation in a region of code.
Every line of code in the region is examined and the indentation
values of the various syntactic symbols in `c-offset-alist' are
guessed. Frequencies of use are taken into account, so minor
inconsistencies in the indentation style shouldn't produce wrong
guesses.
The guessed style is put into `cc-guessed-style'. It's also merged
into `c-offsets-alist'. Guessed offsets takes precedence over
existing ones on `c-offsets-alist'.
If given a prefix argument (or if the optional argument ACCUMULATE is
non-nil) then the previous guess is extended, otherwise a new guess is
made from scratch.
Note that the larger the region to guess in, the slower the guessing."
(interactive "r\nP")
(let ((delta-accumulator (when accumulate cc-guess-delta-accumulator))
(reporter (when (fboundp 'make-progress-reporter)
(make-progress-reporter "Sampling Indentation " start end))))
;;
;; Sampling stage
;;
(save-excursion
(goto-char start)
(while (< (point) end)
(c-save-buffer-state
((syntax (c-guess-basic-syntax))
(relpos (car (cdr (car syntax))))
(symbol (car (car syntax))))
;; TBD: for now I can't guess indentation when more than 1
;; symbol is on the list, nor for symbols without relpos's
;;
;; I think it is too stricted for ((topmost-intro) (comment-intro)).
;; -- Masatake
(unless (or ; (/= 1 (length syntax))
(not (numberp relpos))
(eq (line-beginning-position)
(line-end-position)))
(setq delta-accumulator (cc-guess-accumulate-delta
delta-accumulator
symbol
(- (progn (back-to-indentation)
(current-column) )
(save-excursion
(goto-char relpos)
(current-column)))))))
(when reporter (progress-reporter-update reporter (point)))
(forward-line 1)))
(when reporter (progress-reporter-done reporter))
;;
;; Guessing stage
;;
(setq delta-accumulator (cc-guess-sort-delta-accumulator
delta-accumulator)
cc-guess-delta-accumulator delta-accumulator)
(let* ((typical-style (cc-guess-make-style delta-accumulator))
(merged-style (cc-guess-merge-styles
(copy-list cc-guess-conversions)
typical-style)))
(setq cc-guessed-style merged-style
c-offsets-alist (cc-guess-merge-styles
merged-style
c-offsets-alist)))))
(defun cc-guess-accumulate-delta (accumulator symbol delta)
;; Added SYMBOL and DELTA to ACCUMULATOR. See
;; `cc-guess-delta-accumulator' about the structure of ACCUMULATOR.
(let* ((entry (assoc symbol accumulator))
(counters (cdr entry))
counter)
(if entry
(progn
(setq counter (assoc delta counters))
(if counter
(setcdr counter (1+ (cdr counter)))
(setq counters (cons (cons delta 1) counters))
(setcdr entry counters))
accumulator)
(cons (cons symbol (cons (cons delta 1) nil)) accumulator))))
(defun cc-guess-sort-delta-accumulator (accumulator)
;; Sort the each element of ACCUMULATOR by the number-of-times. See
;; `cc-guess-delta-accumulator' for more details.
(mapcar
(lambda (entry)
(let ((symbol (car entry))
(counters (cdr entry)))
(cons symbol (sort counters
(lambda (a b)
(if (> (cdr a) (cdr b))
t
(and
(eq (cdr a) (cdr b))
(< (car a) (car b)))))))))
accumulator))
(defun cc-guess-make-style (accumulator)
;; Throw away the rare cases in accumulator and make a style structure.
(mapcar
(lambda (entry)
(cons (car entry)
(car (car (cdr entry)))))
accumulator))
(defun cc-guess-merge-styles (strong weak)
;; Merge two styles into one. When two styles has the same symbol
;; entry, give STRONG priority over WEAK.
(mapc
(lambda (weak-elt)
(unless (assoc (car weak-elt) strong)
(setq strong (cons weak-elt strong))))
weak)
strong)
(defun cc-guess-view-style ()
"Show `cc-guessed-style'."
(interactive)
(with-output-to-temp-buffer "*Indentation Guessing Result*"
(pp cc-guessed-style)))
(cc-provide 'cc-guess)
;;; cc-guess.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,161 @@
;;; cc-lobotomy.el --- excise portions of cc-mode's brain... for speed
;; Copyright (C) 1985,1987,1992-2003, 2005, 2006 Free Software Foundation,
;; Inc.
;; Author: 1995 Barry A. Warsaw
;; Maintainer: Unmaintained
;; Created: March 1995, split from cc-mode.el
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; Every effort has been made to improve the performance of
;; cc-mode. However, due to the nature of the C, C++, and Objective-C
;; language definitions, a trade-off is often required between
;; accuracy of construct recognition and speed. I believe it is always
;; best to be correct, and that the mode is currently fast enough for
;; most normal usage. Others disagree. I have no intention of
;; including these hacks in the main distribution. When cc-mode
;; version 5 comes out, it will include a rewritten indentation engine
;; so that performance will be greatly improved automatically. This
;; was not included in this release of version 4 so that Emacs 18
;; could still be supported. Note that this implies that cc-mode
;; version 5 will *not* work on Emacs 18!
;;
;; To use, see the variable cc-lobotomy-pith-list and the function
;; cc-lobotomize. The variable contains a good explanation of the
;; speed/accuracy trade-offs for each option. Set it to what you'd
;; like, and call cc-lobotomy in your c-mode-hook.
;;
;; This will redefine certain cc-mode functions and affect all cc-mode
;; buffers globally.
;;
;; This file is completely unsupported! Although it has been patched
;; superficially to keep pace with the rest of CC Mode, it hasn't been
;; tested for a long time.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-engine)
(cc-require 'cc-cmds)
(defvar cc-lobotomy-pith-list ()
"*List of things to dumb-ify to speed up cc-mode. Note that each
incurs a penalty in correct identification of certain code constructs.
Possible values to put on this list:
'literal -- `c-in-literal' is lobotomized. This will significantly
speed up parsing over large lists of cpp macros, as seen
for instance in header files. The penalty is that you
cannot put the `#' character as the first non-whitespace
character on a line inside other multi-line literals
(i.e. comments or strings)
'class -- `c-narrow-out-enclosing-class' and `c-search-uplist for
classkey' are lobotomized. This speeds up some
indenting inside and around class and struct
definitions. The penalty is that elements inside of
classes and structs may not indent correctly.
'lists -- `c-inside-bracelist-p' is lobotomized. This speeds up
indenting inside and around brace lists (e.g. aggregate
initializers, enum lists, etc.). The penalty is that
elements inside these lists may not indent correctly.")
(defun cc-lobotomize ()
"Perform lobotomies on cc-mode as described in `cc-lobotomy-pith-list'."
(let (pithedp)
(if (memq 'literal cc-lobotomy-pith-list)
(progn
(fset 'c-in-literal 'cc-in-literal-lobotomized)
(setq pithedp t)))
(if (memq 'class cc-lobotomy-pith-list)
(progn
(fset 'c-narrow-out-enclosing-class
'cc-narrow-out-enclosing-class-lobotomized)
(fset 'c-search-uplist-for-classkey
'cc-search-uplist-for-classkey-lobotomized)
(setq pithedp t)))
(if (memq 'lists cc-lobotomy-pith-list)
(progn
(fset 'c-inside-bracelist-p 'cc-inside-bracelist-p-lobotomized)
(setq pithedp t)))
(if pithedp
(add-hook 'c-prepare-bug-report-hooks 'cc-lobo-bug-report-blurb))
))
;; This is a faster version of c-in-literal. It trades speed for one
;; approximation, namely that within other literals, the `#' character
;; cannot be the first non-whitespace on a line. This only happens if
;; detect-cpp is non-nil, which isn't very often.
(defun cc-in-literal-lobotomized (&optional lim detect-cpp)
;; first check the cache
(if (and (vectorp c-in-literal-cache)
(= (point) (aref c-in-literal-cache 0)))
(aref c-in-literal-cache 1)
;; quickly check for cpp macro. this breaks if the `#' character
;; appears as the first non-whitespace on a line inside another
;; literal.
(let* (state
(char-at-boi (char-after (c-point 'boi)))
(rtn (cond
((and detect-cpp char-at-boi (= char-at-boi ?#))
'pound)
((nth 3 (setq state (save-excursion
(parse-partial-sexp
(or lim (c-point 'bod))
(point)))))
'string)
((nth 4 state) (if (nth 7 state) 'c++ 'c))
(t nil))))
;; cache this result if the cache is enabled
(if (not c-in-literal-cache)
(setq c-in-literal-cache (vector (point) rtn)))
rtn)))
(defun cc-narrow-out-enclosing-class-lobotomized (dummy1 dummy2) nil)
(defun cc-search-uplist-for-classkey-lobotomized (dummy) nil)
(defun cc-inside-bracelist-p-lobotomized (dummy1 dummy2) nil)
(defun cc-lobo-bug-report-blurb ()
(insert
"\nYou are using cc-lobotomy.el. You realize that by doing\n"
"so you have already made the decision to trade off accuracy\n"
"for speed? Don't set your hopes too high that your problem\n"
"will be fixed.\n\n"))
(cc-provide 'cc-lobotomy)
;;; cc-lobotomy.el ends here

Binary file not shown.

View file

@ -0,0 +1,425 @@
;;; cc-menus.el --- imenu support for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
;; 1987 Dave Detlefs and Stewart Clamen
;; 1985 Richard M. Stallman
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 22-Apr-1997 (split from cc-mode.el)
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
;; The things referenced in imenu, which we don't require.
(cc-bytecomp-defvar imenu-case-fold-search)
(cc-bytecomp-defvar imenu-generic-expression)
(cc-bytecomp-defvar imenu-create-index-function)
(cc-bytecomp-defun imenu-progress-message)
;; imenu integration
(defvar cc-imenu-c-prototype-macro-regexp nil
"RE matching macro names used to conditionally specify function prototypes.
For example:
#ifdef __STDC__
#define _P(x) x
#else
#define _P(x) /*nothing*/
#endif
int main _P( (int argc, char *argv[]) )
A sample value might look like: `\\(_P\\|_PROTO\\)'.")
(defvar cc-imenu-c++-generic-expression
`(
;; Try to match ::operator definitions first. Otherwise `X::operator new ()'
;; will be incorrectly recognised as function `new ()' because the regexps
;; work by backtracking from the end of the definition.
(nil
,(concat
"^\\<.*"
"[^" c-alnum "_:<>~]" ; match any non-identifier char
; (note: this can be `\n')
"\\("
"\\([" c-alnum "_:<>~]*::\\)?" ; match an operator
"operator\\>[ \t]*"
"\\(()\\|[^(]*\\)" ; special case for `()' operator
"\\)"
"[ \t]*([^)]*)[ \t]*[^ \t;]" ; followed by ws, arg list,
; require something other than
; a `;' after the (...) to
; avoid prototypes. Can't
; catch cases with () inside
; the parentheses surrounding
; the parameters. e.g.:
; `int foo(int a=bar()) {...}'
) 1)
;; Special case to match a line like `main() {}'
;; e.g. no return type, not even on the previous line.
(nil
,(concat
"^"
"\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
"[ \t]*(" ; see above, BUT
"[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
"[ \t]*[^ \t;(]" ; with an asterisk or parentheses
) 1)
;; General function name regexp
(nil
,(concat
"^\\<" ; line MUST start with word char
"[^()]*" ; no parentheses before
"[^" c-alnum "_:<>~]" ; match any non-identifier char
"\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
"\\([ \t\n]\\|\\\\\n\\)*(" ; see above, BUT the arg list
"\\([ \t\n]\\|\\\\\n\\)*\\([^ \t\n(*][^)]*\\)?)" ; must not start
"\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]" ; with an asterisk or parentheses
) 1)
;; Special case for definitions using phony prototype macros like:
;; `int main _PROTO( (int argc,char *argv[]) )'.
;; This case is only included if cc-imenu-c-prototype-macro-regexp is set.
;; Only supported in c-code, so no `:<>~' chars in function name!
,@(if cc-imenu-c-prototype-macro-regexp
`((nil
,(concat
"^\\<.*" ; line MUST start with word char
"[^" c-alnum "_]" ; match any non-identifier char
"\\([" c-alpha "_][" c-alnum "_]*\\)" ; match function name
"[ \t]*" ; whitespace before macro name
cc-imenu-c-prototype-macro-regexp
"[ \t]*(" ; ws followed by first paren.
"[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
) 1)))
;; Class definitions
("Class"
,(concat
"^" ; beginning of line is required
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'
"\\(class\\|struct\\)[ \t]+"
"\\(" ; the string we want to get
"[" c-alnum "_]+" ; class name
"\\(<[^>]+>\\)?" ; possibly explicitly specialized
"\\)"
"\\([ \t\n]\\|\\\\\n\\)*[:{]"
) 3))
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
(defvar cc-imenu-c-generic-expression
cc-imenu-c++-generic-expression
"Imenu generic expression for C mode. See `imenu-generic-expression'.")
(defvar cc-imenu-java-generic-expression
`((nil
,(concat
"[" c-alpha "_][\]\[." c-alnum "_]+[ \t\n\r]+" ; type spec
"\\([" c-alpha "_][" c-alnum "_]+\\)" ; method name
"[ \t\n\r]*"
;; An argument list that is either empty or contains at least
;; two identifiers with only space between them. This avoids
;; matching e.g. "else if (foo)".
(concat "([ \t\n\r]*"
"\\([\]\[.," c-alnum "_]+"
"[ \t\n\r]+"
"[\]\[.," c-alnum "_]"
"[\]\[.," c-alnum "_ \t\n\r]*"
"\\)?)")
"[.," c-alnum "_ \t\n\r]*"
"{"
) 1))
"Imenu generic expression for Java mode. See `imenu-generic-expression'.")
;; *Warning for cc-mode developers*
;;
;; `cc-imenu-objc-generic-expression' elements depend on
;; `cc-imenu-c++-generic-expression'. So if you change this
;; expression, you need to change following variables,
;; `cc-imenu-objc-generic-expression-*-index',
;; too. `cc-imenu-objc-function' uses these *-index variables, in
;; order to know where the each regexp *group \\(foobar\\)* elements
;; are started.
;;
;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
;; being initialized.
;;
;; Internal variables
(defvar cc-imenu-objc-generic-expression-noreturn-index nil)
(defvar cc-imenu-objc-generic-expression-general-func-index nil)
(defvar cc-imenu-objc-generic-expression-proto-index nil)
(defvar cc-imenu-objc-generic-expression-objc-base-index nil)
(defvar cc-imenu-objc-generic-expression
(concat
;;
;; For C
;;
;; > Special case to match a line like `main() {}'
;; > e.g. no return type, not even on the previous line.
;; Pick a token by (match-string 1)
(car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; -> index += 2
(prog2 (setq cc-imenu-objc-generic-expression-noreturn-index 1) "")
"\\|"
;; > General function name regexp
;; Pick a token by (match-string 3)
(car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 5
(prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "")
;; > Special case for definitions using phony prototype macros like:
;; > `int main _PROTO( (int argc,char *argv[]) )'.
;; Pick a token by (match-string 8)
(if cc-imenu-c-prototype-macro-regexp
(concat
"\\|"
(car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
(prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "")
)
(prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 8) "")
"") ; -> index += 0
(prog2 (setq cc-imenu-objc-generic-expression-proto-index 8) "")
;;
;; For Objective-C
;; Pick a token by (match-string 8 or 9)
;;
"\\|\\("
"^[-+][:" c-alnum "()*_<>\n\t ]*[;{]" ; Methods
"\\|"
"^@interface[\t ]+[" c-alnum "_]+[\t ]*:"
"\\|"
"^@interface[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
"\\|"
;; For NSObject, NSProxy and Object... They don't have super class.
"^@interface[\t ]+[" c-alnum "_]+[\t ]*.*$"
"\\|"
"^@implementation[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
"\\|"
"^@implementation[\t ]+[" c-alnum "_]+"
"\\|"
"^@protocol[\t ]+[" c-alnum "_]+" "\\)")
"Imenu generic expression for ObjC mode. See `imenu-generic-expression'.")
;; Imenu support for objective-c uses functions.
(defsubst cc-imenu-objc-method-to-selector (method)
"Return the objc selector style string of METHOD.
Example:
- perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD */
=>
-perform:withObject:withObject:withObject: /* selector */"
(let ((return "") ; String to be returned
(p 0) ; Current scanning position in METHOD
(pmax (length method)) ;
char ; Current scanning target
(betweenparen 0) ; CHAR is in parentheses.
argreq ; An argument is required.
inargvar) ; position of CHAR is in an argument variable.
(while (< p pmax)
(setq char (aref method p)
p (1+ p))
(cond
;; Is CHAR part of a objc token?
((and (not inargvar) ; Ignore if CHAR is part of an argument variable.
(eq 0 betweenparen) ; Ignore if CHAR is in parentheses.
(or (and (<= ?a char) (<= char ?z))
(and (<= ?A char) (<= char ?Z))
(and (<= ?0 char) (<= char ?9))
(= ?_ char)))
(if argreq
(setq inargvar t
argreq nil)
(setq return (concat return (char-to-string char)))))
;; Or a white space?
((and inargvar (or (eq ?\ char) (eq ?\n char))
(setq inargvar nil)))
;; Or a method separator?
;; If a method separator, the next token will be an argument variable.
((eq ?: char)
(setq argreq t
return (concat return (char-to-string char))))
;; Or an open parentheses?
((eq ?\( char)
(setq betweenparen (1+ betweenparen)))
;; Or a close parentheses?
((eq ?\) char)
(setq betweenparen (1- betweenparen)))))
return))
(defun cc-imenu-objc-remove-white-space (str)
"Remove all spaces and tabs from STR."
(let ((return "")
(p 0)
(max (length str))
char)
(while (< p max)
(setq char (aref str p))
(setq p (1+ p))
(if (or (= char ?\ ) (= char ?\t))
()
(setq return (concat return (char-to-string char)))))
return))
(defun cc-imenu-objc-function ()
"imenu supports for objc-mode."
(let (methodlist
clist
;;
;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
;;
;; *Warning for developers*
;; These constants depend on `cc-imenu-c++-generic-expression'.
;;
(OBJC cc-imenu-objc-generic-expression-objc-base-index)
;; Special case to match a line like `main() {}'
(Cnoreturn cc-imenu-objc-generic-expression-noreturn-index)
;; General function name regexp
(Cgeneralfunc cc-imenu-objc-generic-expression-general-func-index)
;; Special case for definitions using phony prototype macros like:
(Cproto cc-imenu-objc-generic-expression-proto-index)
langnum
;;
(classcount 0)
toplist
stupid
str
str2
(intflen (length "@interface"))
(implen (length "@implementation"))
(prtlen (length "@protocol"))
(func
;;
;; Does this emacs has buffer-substring-no-properties?
;;
(if (fboundp 'buffer-substring-no-properties)
'buffer-substring-no-properties
'buffer-substring)))
(goto-char (point-max))
(imenu-progress-message stupid 0)
;;
(while (re-search-backward cc-imenu-objc-generic-expression nil t)
(imenu-progress-message stupid)
(setq langnum (if (match-beginning OBJC)
OBJC
(cond
((match-beginning Cproto) Cproto)
((match-beginning Cgeneralfunc) Cgeneralfunc)
((match-beginning Cnoreturn) Cnoreturn))))
(setq str (funcall func (match-beginning langnum) (match-end langnum)))
;;
(cond
;;
;; C
;;
((not (eq langnum OBJC))
(setq clist (cons (cons str (match-beginning langnum)) clist)))
;;
;; ObjC
;;
;; An instance Method
((eq (aref str 0) ?-)
(setq str (concat "-" (cc-imenu-objc-method-to-selector str)))
(setq methodlist (cons (cons str
(match-beginning langnum))
methodlist)))
;; A factory Method
((eq (aref str 0) ?+)
(setq str (concat "+" (cc-imenu-objc-method-to-selector str)))
(setq methodlist (cons (cons str
(match-beginning langnum))
methodlist)))
;; Interface or implementation or protocol
((eq (aref str 0) ?@)
(setq classcount (1+ classcount))
(cond
((and (> (length str) implen)
(string= (substring str 0 implen) "@implementation"))
(setq str (substring str implen)
str2 "@implementation"))
((string= (substring str 0 intflen) "@interface")
(setq str (substring str intflen)
str2 "@interface"))
((string= (substring str 0 prtlen) "@protocol")
(setq str (substring str prtlen)
str2 "@protocol")))
(setq str (cc-imenu-objc-remove-white-space str))
(setq methodlist (cons (cons str2
(match-beginning langnum))
methodlist))
(setq toplist (cons nil (cons (cons str
methodlist) toplist))
methodlist nil))))
;;
(imenu-progress-message stupid 100)
(if (eq (car toplist) nil)
(setq toplist (cdr toplist)))
;; In this buffer, there is only one or zero @{interface|implementation|protocol}.
(if (< classcount 2)
(let ((classname (car (car toplist)))
(p (cdr (car (cdr (car toplist)))))
last)
(setq toplist (cons (cons classname p) (cdr (cdr (car toplist)))))
;; Add C lang token
(if clist
(progn
(setq last toplist)
(while (cdr last)
(setq last (cdr last)))
(setcdr last clist))))
;; Add C lang tokens as a sub menu
(if clist
(setq toplist (cons (cons "C" clist) toplist))))
;;
toplist
))
;(defvar cc-imenu-pike-generic-expression
; ())
; FIXME: Please contribute one!
(defun cc-imenu-init (mode-generic-expression
&optional mode-create-index-function)
(setq imenu-generic-expression mode-generic-expression
imenu-case-fold-search nil)
(when mode-create-index-function
(setq imenu-create-index-function mode-create-index-function)))
(cc-provide 'cc-menus)
;;; arch-tag: f6b60933-91f0-4145-ab44-70ca6d1b919b
;;; cc-menus.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,647 @@
;;; cc-styles.el --- support for styles in CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
;; 1987 Dave Detlefs and Stewart Clamen
;; 1985 Richard M. Stallman
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 22-Apr-1997 (split from cc-mode.el)
;; Version: See cc-mode.el
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-vars)
(cc-require 'cc-align)
;; cc-align is only indirectly required: Styles added with
;; `c-add-style' often contains references to functions defined there.
;; Silence the compiler.
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs
(cc-bytecomp-obsolete-fun make-local-hook) ; Marked obsolete in Emacs 21.1.
(defvar c-style-alist
'(("gnu"
(c-basic-offset . 2)
(c-comment-only-line-offset . (0 . 0))
(c-hanging-braces-alist . ((substatement-open before after)))
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 5)
(substatement-open . +)
(substatement-label . 0)
(label . 0)
(statement-case-open . +)
(statement-cont . +)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-close . c-lineup-arglist)
(inline-open . 0)
(brace-list-open . +)))
(c-special-indent-hook . c-gnu-impose-minimum)
(c-block-comment-prefix . ""))
("k&r"
(c-basic-offset . 5)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +))))
("bsd"
(c-basic-offset . 8)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . +)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +)
(inline-open . 0)
(inexpr-class . 0))))
("stroustrup"
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +))))
("whitesmith"
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
;; It's obvious that the CC Mode way of choosing anchor positions
;; doesn't fit this style at all. :P
(c-offsets-alist . ((defun-open . +)
(defun-close . c-lineup-whitesmith-in-block)
(defun-block-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(class-open . +)
(class-close . +)
(inline-open . +)
(inline-close . c-lineup-whitesmith-in-block)
(knr-argdecl-intro . +)
(block-open . 0) ; Get indentation from `statement' instead.
(block-close . c-lineup-whitesmith-in-block)
(brace-list-open . +)
(brace-list-close . c-lineup-whitesmith-in-block)
(brace-list-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(brace-list-entry . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(brace-entry-open . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(statement . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(statement-block-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(substatement-open . +)
(substatement-label . +)
(label . 0)
(arglist-intro . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(arglist-cont . (add c-lineup-after-whitesmith-blocks
c-indent-multi-line-block))
(arglist-cont-nonempty . (add c-lineup-whitesmith-in-block
c-indent-multi-line-block))
(arglist-close . c-lineup-whitesmith-in-block)
(inclass . c-lineup-whitesmith-in-block)
(extern-lang-open . +)
(namespace-open . +)
(module-open . +)
(composition-open . +)
(extern-lang-close . +)
(namespace-close . +)
(module-close . +)
(composition-close . +)
(inextern-lang . c-lineup-whitesmith-in-block)
(innamespace . c-lineup-whitesmith-in-block)
(inmodule . c-lineup-whitesmith-in-block)
(incomposition . c-lineup-whitesmith-in-block)
(inexpr-class . 0))))
("ellemtel"
(c-basic-offset . 3)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open before after)))
(c-offsets-alist . ((topmost-intro . 0)
(substatement . +)
(substatement-open . 0)
(case-label . +)
(access-label . -)
(inclass . ++)
(inline-open . 0))))
("linux"
(c-basic-offset . 8)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((brace-list-open)
(brace-entry-open)
(substatement-open after)
(block-close . c-snug-do-while)))
(c-cleanup-list . (brace-else-brace))
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(statement-cont . +))))
("python"
(indent-tabs-mode . t)
(fill-column . 78)
(c-basic-offset . 8)
(c-offsets-alist . ((substatement-open . 0)
(inextern-lang . 0)
(arglist-intro . +)
(knr-argdecl-intro . +)))
(c-hanging-braces-alist . ((brace-list-open)
(brace-list-intro)
(brace-list-close)
(brace-entry-open)
(substatement-open after)
(block-close . c-snug-do-while)))
(c-block-comment-prefix . ""))
("java"
(c-basic-offset . 4)
(c-comment-only-line-offset . (0 . 0))
;; the following preserves Javadoc starter lines
(c-offsets-alist . ((inline-open . 0)
(topmost-intro-cont . +)
(statement-block-intro . +)
(knr-argdecl-intro . 5)
(substatement-open . +)
(substatement-label . +)
(label . +)
(statement-case-open . +)
(statement-cont . +)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-close . c-lineup-arglist)
(access-label . 0)
(inher-cont . c-lineup-java-inher)
(func-decl-cont . c-lineup-java-throws))))
;; awk style exists primarily for auto-newline settings. Otherwise it's
;; pretty much like k&r.
("awk"
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((defun-open after)
(defun-close . c-snug-1line-defun-close)
(substatement-open after)
(block-close . c-snug-do-while)))
(c-hanging-semi&comma-criteria . nil)
(c-cleanup-list . nil) ; You might want one-liner-defun here.
(c-offsets-alist . ((statement-block-intro . +)
(substatement-open . 0)
(statement-cont . +))))
)
"Styles of indentation.
Elements of this alist are of the form:
(STYLE-STRING [BASE-STYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
where STYLE-STRING is a short descriptive string used to select a
style, VARIABLE is any Emacs variable, and VALUE is the intended value
for that variable when using the selected style.
Optional BASE-STYLE if present, is a string and must follow
STYLE-STRING. BASE-STYLE names a style that this style inherits from.
By default, all styles inherit from the \"user\" style, which is
computed at run time. Style loops generate errors.
Two variables are treated specially. When VARIABLE is
`c-offsets-alist', the VALUE is a list containing elements of the
form:
(SYNTACTIC-SYMBOL . OFFSET)
as described in `c-offsets-alist'. These are passed directly to
`c-set-offset' so there is no need to set every syntactic symbol in
your style, only those that are different from the default.
When VARIABLE is `c-special-indent-hook', its VALUE is added to
`c-special-indent-hook' using `add-hook'. If VALUE is a list, each
element of the list is added with `add-hook'.
Do not change this variable directly. Use the function `c-add-style'
to add new styles or modify existing styles (it is not a good idea to
modify existing styles -- you should create a new style that inherits
the existing style.")
;; Functions that manipulate styles
(defun c-set-style-1 (conscell dont-override)
;; Set the style for one variable
(let ((attr (car conscell))
(val (cdr conscell)))
(cond
;; first special variable
((eq attr 'c-offsets-alist)
(let ((offsets (cond ((eq dont-override t)
c-offsets-alist)
(dont-override
(default-value 'c-offsets-alist)))))
(mapcar (lambda (langentry)
(let ((langelem (car langentry))
(offset (cdr langentry)))
(unless (assq langelem offsets)
(c-set-offset langelem offset))))
val)))
;; second special variable
((eq attr 'c-special-indent-hook)
;; Maybe we should ignore dont-override here and always add new
;; hooks?
(unless (cond ((eq dont-override t)
c-special-indent-hook)
(dont-override
(default-value 'c-special-indent-hook)))
(if (listp val)
(mapcar (lambda (func)
(add-hook 'c-special-indent-hook func t t))
val)
(add-hook 'c-special-indent-hook val t t))))
;; all other variables
(t (when (or (not dont-override)
(not (memq attr c-style-variables))
(eq (if (eq dont-override t)
(symbol-value attr)
(default-value attr))
'set-from-style))
(set attr val)
;; Must update a number of other variables if
;; c-comment-prefix-regexp is set.
(if (eq attr 'c-comment-prefix-regexp)
(c-setup-paragraph-variables)))))))
(defun c-get-style-variables (style basestyles)
;; Return all variables in a style by resolving inheritances.
(if (not style)
(copy-alist c-fallback-style)
(let ((vars (cdr (or (assoc (downcase style) c-style-alist)
(assoc (upcase style) c-style-alist)
(assoc style c-style-alist)
(progn
(c-benign-error "Undefined style: %s" style)
nil)))))
(let ((base (and (stringp (car-safe vars))
(prog1
(downcase (car vars))
(setq vars (cdr vars))))))
(if (memq base basestyles)
(c-benign-error "Style loop detected: %s in %s" base basestyles)
(nconc (c-get-style-variables base (cons base basestyles))
(copy-alist vars)))))))
(defvar c-set-style-history nil)
;;;###autoload
(defun c-set-style (stylename &optional dont-override)
"Set the current buffer to use the style STYLENAME.
STYLENAME, a string, must be an existing CC Mode style - These are contained
in the variable `c-style-alist'.
The variable `c-indentation-style' will get set to STYLENAME.
\"Setting the style\" is done by setting CC Mode's \"style variables\" to the
values indicated by the pertinent entry in `c-style-alist'. Other variables
might get set too.
If DONT-OVERRIDE is neither nil nor t, style variables whose default values
have been set (more precisely, whose default values are not the symbol
`set-from-style') will not be changed. This avoids overriding global settings
done in ~/.emacs. It is useful to call c-set-style from a mode hook in this
way.
If DONT-OVERRIDE is t, style variables that already have values (i.e., whose
values are not the symbol `set-from-style') will not be overridden. CC Mode
calls c-set-style internally in this way whilst initializing a buffer; if
cc-set-style is called like this from anywhere else, it will usually behave as
a null operation."
(interactive
(list (let ((completion-ignore-case t)
(prompt (format "Which %s indentation style? "
mode-name)))
(completing-read prompt c-style-alist nil t nil
'c-set-style-history
c-indentation-style))))
(or c-buffer-is-cc-mode
(error "Buffer %s is not a CC Mode buffer (c-set-style)" (buffer-name)))
(or (stringp stylename)
(error "Argument to c-set-style was not a string"))
(c-initialize-builtin-style)
(let ((vars (c-get-style-variables stylename nil)))
(unless dont-override
;; Since we always add to c-special-indent-hook we must reset it
;; first, or else the hooks from the preceding style will
;; remain. This is not necessary for c-offsets-alist, since
;; c-get-style-variables contains every valid offset type in the
;; fallback entry.
(setq c-special-indent-hook
(default-value 'c-special-indent-hook)))
(mapcar (lambda (elem)
(c-set-style-1 elem dont-override))
;; Need to go through the variables backwards when we
;; don't override any settings.
(if (eq dont-override t) (nreverse vars) vars)))
(setq c-indentation-style stylename)
(c-keep-region-active))
;;;###autoload
(defun c-add-style (style description &optional set-p)
"Adds a style to `c-style-alist', or updates an existing one.
STYLE is a string identifying the style to add or update. DESCRIPTION
is an association list describing the style and must be of the form:
([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
See the variable `c-style-alist' for the semantics of BASESTYLE,
VARIABLE and VALUE. This function also sets the current style to
STYLE using `c-set-style' if the optional SET-P flag is non-nil."
(interactive
(let ((stylename (completing-read "Style to add: " c-style-alist
nil nil nil 'c-set-style-history))
(descr (eval-minibuffer "Style description: ")))
(list stylename descr
(y-or-n-p "Set the style too? "))))
(setq style (downcase style))
(let ((s (assoc style c-style-alist)))
(if s
(setcdr s (copy-alist description)) ; replace
(setq c-style-alist (cons (cons style description) c-style-alist))))
(and set-p (c-set-style style)))
(defvar c-read-offset-history nil)
(defun c-read-offset (langelem)
;; read new offset value for LANGELEM from minibuffer. return a
;; legal value only
(let* ((oldoff (cdr-safe (or (assq langelem c-offsets-alist)
(assq langelem (get 'c-offsets-alist
'c-stylevar-fallback)))))
(symname (symbol-name langelem))
(defstr (format "(default %s): " oldoff))
(errmsg (concat "Offset must be int, func, var, vector, list, "
"or [+,-,++,--,*,/] "
defstr))
(prompt (concat symname " offset " defstr))
(keymap (make-sparse-keymap))
(minibuffer-completion-table obarray)
(minibuffer-completion-predicate 'fboundp)
offset input)
;; In principle completing-read is used here, but SPC is unbound
;; to make it less annoying to enter lists.
(set-keymap-parent keymap minibuffer-local-completion-map)
(define-key keymap " " 'self-insert-command)
(while (not offset)
(setq input (read-from-minibuffer prompt nil keymap t
'c-read-offset-history
(format "%s" oldoff)))
(if (c-valid-offset input)
(setq offset input)
;; error, but don't signal one, keep trying
;; to read an input value
(ding)
(setq prompt errmsg)))
offset))
;;;###autoload
(defun c-set-offset (symbol offset &optional ignored)
"Change the value of a syntactic element symbol in `c-offsets-alist'.
SYMBOL is the syntactic element symbol to change and OFFSET is the new
offset for that syntactic element. The optional argument is not used
and exists only for compatibility reasons."
(interactive
(let* ((langelem
(intern (completing-read
(concat "Syntactic symbol to change"
(if current-prefix-arg " or add" "")
": ")
(mapcar
#'(lambda (langelem)
(cons (format "%s" (car langelem)) nil))
(get 'c-offsets-alist 'c-stylevar-fallback))
nil (not current-prefix-arg)
;; initial contents tries to be the last element
;; on the syntactic analysis list for the current
;; line
(and c-buffer-is-cc-mode
(c-save-buffer-state
((syntax (c-guess-basic-syntax))
(len (length syntax))
(ic (format "%s" (car (nth (1- len) syntax)))))
(cons ic 0)))
)))
(offset (c-read-offset langelem)))
(list langelem offset current-prefix-arg)))
;; sanity check offset
(if (c-valid-offset offset)
(let ((entry (assq symbol c-offsets-alist)))
(if entry
(setcdr entry offset)
(if (assq symbol (get 'c-offsets-alist 'c-stylevar-fallback))
(setq c-offsets-alist (cons (cons symbol offset)
c-offsets-alist))
(c-benign-error "%s is not a valid syntactic symbol" symbol))))
(c-benign-error "Invalid indentation setting for symbol %s: %S"
symbol offset))
(c-keep-region-active))
(defun c-setup-paragraph-variables ()
"Fix things up for paragraph recognition and filling inside comments and
strings by incorporating the values of `c-comment-prefix-regexp',
`sentence-end', `paragraph-start' and `paragraph-separate' in the relevant
variables."
(interactive)
(or c-buffer-is-cc-mode
(error "Buffer %s is not a CC Mode buffer (c-setup-paragraph-variables)"
(buffer-name)))
;; Set up the values for use in comments.
(setq c-current-comment-prefix
(if (listp c-comment-prefix-regexp)
(cdr-safe (or (assoc major-mode c-comment-prefix-regexp)
(assoc 'other c-comment-prefix-regexp)))
c-comment-prefix-regexp))
(let ((comment-line-prefix
(concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*")))
(setq paragraph-start (concat comment-line-prefix
c-paragraph-start
"\\|"
page-delimiter)
paragraph-separate (concat comment-line-prefix
c-paragraph-separate
"\\|"
page-delimiter)
paragraph-ignore-fill-prefix t
adaptive-fill-mode t
adaptive-fill-regexp
(concat comment-line-prefix
(if (default-value 'adaptive-fill-regexp)
(concat "\\("
(default-value 'adaptive-fill-regexp)
"\\)")
"")))
(when (boundp 'adaptive-fill-first-line-regexp)
;; XEmacs adaptive fill mode doesn't have this.
(make-local-variable 'adaptive-fill-first-line-regexp)
(setq adaptive-fill-first-line-regexp
(concat "\\`" comment-line-prefix
;; Maybe we should incorporate the old value here,
;; but then we have to do all sorts of kludges to
;; deal with the \` and \' it probably contains.
"\\'"))))
;; Set up the values for use in strings. These are the default
;; paragraph-start/separate values, enhanced to accept escaped EOLs as
;; whitespace. Used in c-beginning/end-of-sentence-in-string in cc-cmds.
(setq c-string-par-start
;;(concat "\\(" (default-value 'paragraph-start) "\\)\\|[ \t]*\\\\$"))
"\f\\|[ \t]*\\\\?$")
(setq c-string-par-separate
;;(concat "\\(" (default-value 'paragraph-separate) "\\)\\|[ \t]*\\\\$"))
"[ \t\f]*\\\\?$")
(setq c-sentence-end-with-esc-eol
(concat "\\(\\(" (c-default-value-sentence-end) "\\)"
;; N.B.: "$" would be illegal when not enclosed like "\\($\\)".
"\\|" "[.?!][]\"')}]* ?\\\\\\($\\)[ \t\n]*"
"\\)")))
;; Helper for setting up Filladapt mode. It's not used by CC Mode itself.
(cc-bytecomp-defvar filladapt-token-table)
(cc-bytecomp-defvar filladapt-token-match-table)
(cc-bytecomp-defvar filladapt-token-conversion-table)
(defun c-setup-filladapt ()
"Convenience function to configure Kyle E. Jones' Filladapt mode for
CC Mode by making sure the proper entries are present on
`filladapt-token-table', `filladapt-token-match-table', and
`filladapt-token-conversion-table'. This is intended to be used on
`c-mode-common-hook' or similar."
;; This function is intended to be used explicitly by the end user
;; only.
;; The default configuration already handles C++ comments, but we
;; need to add handling of C block comments. A new filladapt token
;; `c-comment' is added for that.
(let (p)
(setq p filladapt-token-table)
(while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment)))
(setq p (cdr-safe p)))
(if p
(setcar (car p) c-current-comment-prefix)
(setq filladapt-token-table
(append (list (car filladapt-token-table)
(list c-current-comment-prefix 'c-comment))
(cdr filladapt-token-table)))))
(unless (assq 'c-comment filladapt-token-match-table)
(setq filladapt-token-match-table
(append '((c-comment c-comment))
filladapt-token-match-table)))
(unless (assq 'c-comment filladapt-token-conversion-table)
(setq filladapt-token-conversion-table
(append '((c-comment . exact))
filladapt-token-conversion-table))))
(defun c-initialize-builtin-style ()
;; Dynamically append the default value of most variables. This is
;; crucial because future c-set-style calls will always reset the
;; variables first to the `cc-mode' style before instituting the new
;; style. Only do this once!
(unless (get 'c-initialize-builtin-style 'is-run)
(put 'c-initialize-builtin-style 'is-run t)
;;(c-initialize-cc-mode)
(unless (assoc "user" c-style-alist)
(let ((vars c-style-variables) var val uservars)
(while vars
(setq var (car vars)
val (symbol-value var)
vars (cdr vars))
(cond ((eq var 'c-offsets-alist)
(or (null val)
(setq uservars (cons (cons 'c-offsets-alist val)
uservars))))
((not (eq val 'set-from-style))
(setq uservars (cons (cons var val)
uservars)))))
(c-add-style "user" uservars)))
(unless (assoc "cc-mode" c-style-alist)
(c-add-style "cc-mode" '("user")))
(if c-style-variables-are-local-p
(c-make-styles-buffer-local))))
(defun c-make-styles-buffer-local (&optional this-buf-only-p)
"Make all CC Mode style variables buffer local.
If `this-buf-only-p' is non-nil, the style variables will be made
buffer local only in the current buffer. Otherwise they'll be made
permanently buffer local in any buffer that changes their values.
The buffer localness of the style variables are normally controlled
with the variable `c-style-variables-are-local-p', so there's seldom
any reason to call this function directly."
;; style variables
(let ((func (if this-buf-only-p
'make-local-variable
'make-variable-buffer-local))
(varsyms (cons 'c-indentation-style (copy-alist c-style-variables))))
(delq 'c-special-indent-hook varsyms)
(mapcar func varsyms)
;; Hooks must be handled specially
(if this-buf-only-p
(make-local-hook 'c-special-indent-hook)
(make-variable-buffer-local 'c-special-indent-hook)
(setq c-style-variables-are-local-p t))
))
(cc-provide 'cc-styles)
;;; arch-tag: c764f61a-96ba-484a-a68f-101c0e9d5d2c
;;; cc-styles.el ends here

Binary file not shown.

View file

@ -0,0 +1,312 @@
;;; cc-subword.el --- Handling capitalized subwords in a nomenclature
;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
;; Author: Masatake YAMATO
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This package provides `subword' oriented commands and a minor mode
;; (`c-subword-mode') that substitutes the common word handling
;; functions with them.
;; In spite of GNU Coding Standards, it is popular to name a symbol by
;; mixing uppercase and lowercase letters, e.g. "GtkWidget",
;; "EmacsFrameClass", "NSGraphicsContext", etc. Here we call these
;; mixed case symbols `nomenclatures'. Also, each capitalized (or
;; completely uppercase) part of a nomenclature is called a `subword'.
;; Here are some examples:
;; Nomenclature Subwords
;; ===========================================================
;; GtkWindow => "Gtk" and "Window"
;; EmacsFrameClass => "Emacs", "Frame" and "Class"
;; NSGraphicsContext => "NS", "Graphics" and "Context"
;; The subword oriented commands defined in this package recognize
;; subwords in a nomenclature to move between them and to edit them as
;; words.
;; In the minor mode, all common key bindings for word oriented
;; commands are overridden by the subword oriented commands:
;; Key Word oriented command Subword oriented command
;; ============================================================
;; M-f `forward-word' `c-forward-subword'
;; M-b `backward-word' `c-backward-subword'
;; M-@ `mark-word' `c-mark-subword'
;; M-d `kill-word' `c-kill-subword'
;; M-DEL `backward-kill-word' `c-backward-kill-subword'
;; M-t `transpose-words' `c-transpose-subwords'
;; M-c `capitalize-word' `c-capitalize-subword'
;; M-u `upcase-word' `c-upcase-subword'
;; M-l `downcase-word' `c-downcase-subword'
;;
;; Note: If you have changed the key bindings for the word oriented
;; commands in your .emacs or a similar place, the keys you've changed
;; to are also used for the corresponding subword oriented commands.
;; To make the mode turn on automatically, put the following code in
;; your .emacs:
;;
;; (add-hook 'c-mode-common-hook
;; (lambda () (c-subword-mode 1)))
;;
;; Acknowledgment:
;; The regular expressions to detect subwords are mostly based on
;; the old `c-forward-into-nomenclature' originally contributed by
;; Terry_Glanfield dot Southern at rxuk dot xerox dot com.
;; TODO: ispell-word and subword oriented C-w in isearch.
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-cmds)
;; Don't complain about the `define-minor-mode' form if it isn't defined.
(cc-bytecomp-defvar c-subword-mode)
;;; Autoload directives must be on the top level, so we construct an
;;; autoload form instead.
;;;###autoload (autoload 'c-subword-mode "cc-subword" "Mode enabling subword movement and editing keys." t)
(if (not (fboundp 'define-minor-mode))
(defun c-subword-mode ()
"(Missing) mode enabling subword movement and editing keys.
This mode is not (yet) available in this version of (X)Emacs. Sorry! If
you really want it, please send a request to <bug-gnu-emacs@gnu.org>,
telling us which (X)Emacs version you're using."
(interactive)
(error
"c-subword-mode is not (yet) available in this version of (X)Emacs. Sorry!"))
(defvar c-subword-mode-map
(let ((map (make-sparse-keymap)))
(substitute-key-definition 'forward-word
'c-forward-subword
map global-map)
(substitute-key-definition 'backward-word
'c-backward-subword
map global-map)
(substitute-key-definition 'mark-word
'c-mark-subword
map global-map)
(substitute-key-definition 'kill-word
'c-kill-subword
map global-map)
(substitute-key-definition 'backward-kill-word
'c-backward-kill-subword
map global-map)
(substitute-key-definition 'transpose-words
'c-transpose-subwords
map global-map)
(substitute-key-definition 'capitalize-word
'c-capitalize-subword
map global-map)
(substitute-key-definition 'upcase-word
'c-upcase-subword
map global-map)
(substitute-key-definition 'downcase-word
'c-downcase-subword
map global-map)
map)
"Keymap used in command `c-subword-mode' minor mode.")
(define-minor-mode c-subword-mode
"Mode enabling subword movement and editing keys.
In spite of GNU Coding Standards, it is popular to name a symbol by
mixing uppercase and lowercase letters, e.g. \"GtkWidget\",
\"EmacsFrameClass\", \"NSGraphicsContext\", etc. Here we call these
mixed case symbols `nomenclatures'. Also, each capitalized (or
completely uppercase) part of a nomenclature is called a `subword'.
Here are some examples:
Nomenclature Subwords
===========================================================
GtkWindow => \"Gtk\" and \"Window\"
EmacsFrameClass => \"Emacs\", \"Frame\" and \"Class\"
NSGraphicsContext => \"NS\", \"Graphics\" and \"Context\"
The subword oriented commands activated in this minor mode recognize
subwords in a nomenclature to move between subwords and to edit them
as words.
\\{c-subword-mode-map}"
nil
nil
c-subword-mode-map
(c-update-modeline))
)
(defun c-forward-subword (&optional arg)
"Do the same as `forward-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `forward-word'."
(interactive "p")
(unless arg (setq arg 1))
(c-keep-region-active)
(cond
((< 0 arg)
(dotimes (i arg (point))
(c-forward-subword-internal)))
((> 0 arg)
(dotimes (i (- arg) (point))
(c-backward-subword-internal)))
(t
(point))))
(defun c-backward-subword (&optional arg)
"Do the same as `backward-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `backward-word'."
(interactive "p")
(c-forward-subword (- (or arg 1))))
(defun c-mark-subword (arg)
"Do the same as `mark-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `mark-word'."
;; This code is almost copied from `mark-word' in GNU Emacs.
(interactive "p")
(cond ((and (eq last-command this-command) (mark t))
(set-mark
(save-excursion
(goto-char (mark))
(c-forward-subword arg)
(point))))
(t
(push-mark
(save-excursion
(c-forward-subword arg)
(point))
nil t))))
(defun c-kill-subword (arg)
"Do the same as `kill-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `kill-word'."
(interactive "p")
(kill-region (point) (c-forward-subword arg)))
(defun c-backward-kill-subword (arg)
"Do the same as `backward-kill-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `backward-kill-word'."
(interactive "p")
(c-kill-subword (- arg)))
(defun c-transpose-subwords (arg)
"Do the same as `transpose-words' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `transpose-words'."
(interactive "*p")
(transpose-subr 'c-forward-subword arg))
(defun c-capitalize-subword (arg)
"Do the same as `capitalize-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `capitalize-word'."
(interactive "p")
(let ((count (abs arg))
(direction (if (< 0 arg) 1 -1)))
(dotimes (i count)
(when (re-search-forward
(concat "[" c-alpha "]")
nil t)
(goto-char (match-beginning 0)))
(let* ((p (point))
(pp (1+ p))
(np (c-forward-subword direction)))
(upcase-region p pp)
(downcase-region pp np)
(goto-char np)))))
(defun c-downcase-subword (arg)
"Do the same as `downcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `downcase-word'."
(interactive "p")
(downcase-region (point) (c-forward-subword arg)))
(defun c-upcase-subword (arg)
"Do the same as `upcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `upcase-word'."
(interactive "p")
(upcase-region (point) (c-forward-subword arg)))
;;
;; Internal functions
;;
(defun c-forward-subword-internal ()
(if (and
(save-excursion
(let ((case-fold-search nil))
(re-search-forward
(concat "\\W*\\(\\([" c-upper "]*\\W?\\)[" c-lower c-digit "]*\\)")
nil t)))
(> (match-end 0) (point))) ; So we don't get stuck at a
; "word-constituent" which isn't c-upper,
; c-lower or c-digit
(goto-char
(cond
((< 1 (- (match-end 2) (match-beginning 2)))
(1- (match-end 2)))
(t
(match-end 0))))
(forward-word 1)))
(defun c-backward-subword-internal ()
(if (save-excursion
(let ((case-fold-search nil))
(re-search-backward
(concat
"\\(\\(\\W\\|[" c-lower c-digit "]\\)\\([" c-upper "]+\\W*\\)"
"\\|\\W\\w+\\)")
nil t)))
(goto-char
(cond
((and (match-end 3)
(< 1 (- (match-end 3) (match-beginning 3)))
(not (eq (point) (match-end 3))))
(1- (match-end 3)))
(t
(1+ (match-beginning 0)))))
(backward-word 1)))
(cc-provide 'cc-subword)
;;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3
;;; cc-subword.el ends here

Binary file not shown.

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more