/[emacs]/emacs/lisp/progmodes/cc-defs.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/cc-defs.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by mast, Wed Sep 24 13:59:18 2003 UTC revision 1.28 by mast, Sun Nov 16 16:55:07 2003 UTC
# Line 105  Line 105 
105    
106  ;;; Variables also used at compile time.  ;;; Variables also used at compile time.
107    
108  (defconst c-version "5.30.7"  (defconst c-version "5.30.8"
109    "CC Mode version number.")    "CC Mode version number.")
110    
111  (defconst c-version-sym (intern c-version))  (defconst c-version-sym (intern c-version))
# Line 1001  This function does not do any hidden buf Line 1001  This function does not do any hidden buf
1001    
1002  (defun c-make-keywords-re (adorn list &optional mode)  (defun c-make-keywords-re (adorn list &optional mode)
1003    "Make a regexp that matches all the strings the list.    "Make a regexp that matches all the strings the list.
1004  Duplicates in the list are removed.  The regexp may contain zero or  Duplicates in the list are removed.  The resulting regexp may contain
1005  more submatch expressions.  zero or more submatch expressions.
1006    
1007  If ADORN is non-nil there will be at least one submatch and the first  If ADORN is non-nil there will be at least one submatch and the first
1008  matches the whole keyword, and the regexp will also not match a prefix  matches the whole keyword, and the regexp will also not match a prefix
# Line 1010  of any identifier.  Adorned regexps cann Line 1010  of any identifier.  Adorned regexps cann
1010  variable `c-nonsymbol-key' is used to make the adornment.  The  variable `c-nonsymbol-key' is used to make the adornment.  The
1011  optional MODE specifies the language to get it in.  The default is the  optional MODE specifies the language to get it in.  The default is the
1012  current language (taken from `c-buffer-is-cc-mode')."  current language (taken from `c-buffer-is-cc-mode')."
1013    
1014    (let (unique)    (let (unique)
1015      (dolist (elt list)      (dolist (elt list)
1016        (unless (member elt unique)        (unless (member elt unique)
# Line 1017  current language (taken from `c-buffer-i Line 1018  current language (taken from `c-buffer-i
1018      (setq list unique))      (setq list unique))
1019    (if list    (if list
1020        (let ((re (c-regexp-opt list)))        (let ((re (c-regexp-opt list)))
1021    
1022            ;; Emacs < 21 and XEmacs (all versions so far) has a buggy
1023            ;; regexp-opt that doesn't always cope with strings containing
1024            ;; newlines.  This kludge doesn't handle shy parens correctly
1025            ;; so we can't advice regexp-opt directly with it.
1026            (let (fail-list)
1027              (while list
1028                (and (string-match "\n" (car list)) ; To speed it up a little.
1029                     (not (string-match (concat "\\`\\(" re "\\)\\'")
1030                                        (car list)))
1031                     (setq fail-list (cons (car list) fail-list)))
1032                (setq list (cdr list)))
1033              (when fail-list
1034                (setq re (concat re
1035                                 "\\|"
1036                                 (mapconcat 'regexp-quote
1037                                            (sort fail-list
1038                                                  (lambda (a b)
1039                                                    (> (length a) (length b))))
1040                                            "\\|")))))
1041    
1042          ;; Add our own grouping parenthesis around re instead of          ;; Add our own grouping parenthesis around re instead of
1043          ;; passing adorn to `regexp-opt', since in XEmacs it makes the          ;; passing adorn to `regexp-opt', since in XEmacs it makes the
1044          ;; top level grouping "shy".          ;; top level grouping "shy".
# Line 1026  current language (taken from `c-buffer-i Line 1048  current language (taken from `c-buffer-i
1048                      (c-get-lang-constant 'c-nonsymbol-key nil mode)                      (c-get-lang-constant 'c-nonsymbol-key nil mode)
1049                      "\\|$\\)")                      "\\|$\\)")
1050            re))            re))
1051    
1052      ;; Produce a regexp that matches nothing.      ;; Produce a regexp that matches nothing.
1053      (if adorn      (if adorn
1054          "\\(\\<\\>\\)"          "\\(\\<\\>\\)"
1055        "\\<\\>")))        "\\<\\>")))
1056    
1057  (put 'c-make-keywords-re 'lisp-indent-function 1)  (put 'c-make-keywords-re 'lisp-indent-function 1)
1058    
1059    

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26