emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-defs.el


From: Alan Mackenzie
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/cc-defs.el
Date: Fri, 02 Dec 2005 07:30:41 -0500

Index: emacs/lisp/progmodes/cc-defs.el
diff -c emacs/lisp/progmodes/cc-defs.el:1.34 
emacs/lisp/progmodes/cc-defs.el:1.35
*** emacs/lisp/progmodes/cc-defs.el:1.34        Mon Aug  1 08:37:49 2005
--- emacs/lisp/progmodes/cc-defs.el     Fri Dec  2 12:30:35 2005
***************
*** 1,6 ****
  ;;; cc-defs.el --- compile time definitions for CC Mode
  
! ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation, 
Inc.
  
  ;; Authors:    1998- Martin Stjernholm
  ;;             1992-1999 Barry A. Warsaw
--- 1,7 ----
  ;;; cc-defs.el --- compile time definitions for CC Mode
  
! ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation,
! ;; Inc.
  
  ;; Authors:    1998- Martin Stjernholm
  ;;             1992-1999 Barry A. Warsaw
***************
*** 24,30 ****
  ;; GNU General Public License for more details.
  
  ;; You should have received a copy of the GNU General Public License
! ;; along with GNU Emacs; see the file COPYING.  If not, write to
  ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  ;; Boston, MA 02110-1301, USA.
  
--- 25,31 ----
  ;; 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.
  
***************
*** 43,50 ****
           load-path)))
      (load "cc-bytecomp" nil t)))
  
! ;; `require' in XEmacs doesn't have the third NOERROR argument.
! (condition-case nil (require 'regexp-opt) (file-error nil))
  
  ;; Silence the compiler.
  (cc-bytecomp-defvar c-enable-xemacs-performance-kludge-p) ; In cc-vars.el
--- 44,51 ----
           load-path)))
      (load "cc-bytecomp" nil t)))
  
! (eval-when-compile (require 'cl)) ; was (cc-external-require 'cl).  ACM 
2005/11/29.
! (cc-external-require 'regexp-opt)
  
  ;; Silence the compiler.
  (cc-bytecomp-defvar c-enable-xemacs-performance-kludge-p) ; In cc-vars.el
***************
*** 55,85 ****
  (cc-bytecomp-defvar mark-active)      ; Emacs
  (cc-bytecomp-defvar deactivate-mark)  ; Emacs
  (cc-bytecomp-defvar inhibit-point-motion-hooks) ; Emacs
! (cc-bytecomp-defvar parse-sexp-lookup-properties) ; Emacs 20+
  (cc-bytecomp-defvar text-property-default-nonsticky) ; Emacs 21
! (cc-bytecomp-defvar lookup-syntax-properties) ; XEmacs 21
  (cc-bytecomp-defun string-to-syntax)  ; Emacs 21
- (cc-bytecomp-defun regexp-opt-depth)  ; (X)Emacs 20+
  
  
  ;; cc-fix.el contains compatibility macros that should be used if
  ;; needed.
  (eval-and-compile
!   (if (or (not (fboundp 'functionp))
!         (not (condition-case nil
!                  (progn (eval '(char-before)) t)
!                (error nil)))
!         (not (condition-case nil
!                  (progn (eval '(char-after)) t)
!                (error nil)))
!         (not (fboundp 'when))
!         (not (fboundp 'unless))
!         (not (fboundp 'regexp-opt))
!         (not (cc-bytecomp-fboundp 'regexp-opt-depth))
!         (/= (regexp-opt-depth "\\(\\(\\)\\)") 2))
!       (cc-load "cc-fix")
!     (defalias 'c-regexp-opt 'regexp-opt)
!     (defalias 'c-regexp-opt-depth 'regexp-opt-depth)))
  
  (eval-after-load "font-lock"
    '(if (and (not (featurep 'cc-fix)) ; only load the file once.
--- 56,73 ----
  (cc-bytecomp-defvar mark-active)      ; Emacs
  (cc-bytecomp-defvar deactivate-mark)  ; Emacs
  (cc-bytecomp-defvar inhibit-point-motion-hooks) ; Emacs
! (cc-bytecomp-defvar parse-sexp-lookup-properties) ; Emacs
  (cc-bytecomp-defvar text-property-default-nonsticky) ; Emacs 21
! (cc-bytecomp-defvar lookup-syntax-properties) ; XEmacs
  (cc-bytecomp-defun string-to-syntax)  ; Emacs 21
  
  
  ;; cc-fix.el contains compatibility macros that should be used if
  ;; needed.
  (eval-and-compile
!   (if (or (/= (regexp-opt-depth "\\(\\(\\)\\)") 2)
!         (not (fboundp 'push)))
!       (cc-load "cc-fix")))
  
  (eval-after-load "font-lock"
    '(if (and (not (featurep 'cc-fix)) ; only load the file once.
***************
*** 99,110 ****
               font-lock-keywords)))
        (cc-load "cc-fix")))
  
- (eval-when-compile (require 'cl))
- 
  
  ;;; Variables also used at compile time.
  
! (defconst c-version "5.30.10"
    "CC Mode version number.")
  
  (defconst c-version-sym (intern c-version))
--- 87,96 ----
               font-lock-keywords)))
        (cc-load "cc-fix")))
  
  
  ;;; Variables also used at compile time.
  
! (defconst c-version "5.31"
    "CC Mode version number.")
  
  (defconst c-version-sym (intern c-version))
***************
*** 192,220 ****
  The current point is used if POINT isn't specified.  POSITION can be
  one of the following symbols:
  
! `bol'  -- beginning of line
! `eol'  -- end of line
! `bod'  -- beginning of defun
! `eod'  -- end of defun
! `boi'  -- beginning of indentation
! `ionl' -- indentation of next line
! `iopl' -- indentation of previous line
! `bonl' -- beginning of next line
! `eonl' -- end of next line
! `bopl' -- beginning of previous line
! `eopl' -- end of previous line
  
  If the referenced position doesn't exist, the closest accessible point
! to it is returned.  This function does not modify point or mark.
! 
! This function does not do any hidden buffer changes."
  
    (if (eq (car-safe position) 'quote)
        (let ((position (eval position)))
        (cond
  
         ((eq position 'bol)
!         (if (and (fboundp 'line-beginning-position) (not point))
              `(line-beginning-position)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
--- 178,206 ----
  The current point is used if POINT isn't specified.  POSITION can be
  one of the following symbols:
  
! `bol'   -- beginning of line
! `eol'   -- end of line
! `bod'   -- beginning of defun
! `eod'   -- end of defun
! `boi'   -- beginning of indentation
! `ionl'  -- indentation of next line
! `iopl'  -- indentation of previous line
! `bonl'  -- beginning of next line
! `eonl'  -- end of next line
! `bopl'  -- beginning of previous line
! `eopl'  -- end of previous line
! `bosws' -- beginning of syntactic whitespace
! `eosws' -- end of syntactic whitespace
  
  If the referenced position doesn't exist, the closest accessible point
! to it is returned.  This function does not modify the point or the mark."
  
    (if (eq (car-safe position) 'quote)
        (let ((position (eval position)))
        (cond
  
         ((eq position 'bol)
!         (if (and (cc-bytecomp-fboundp 'line-beginning-position) (not point))
              `(line-beginning-position)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
***************
*** 222,228 ****
               (point))))
  
         ((eq position 'eol)
!         (if (and (fboundp 'line-end-position) (not point))
              `(line-end-position)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
--- 208,214 ----
               (point))))
  
         ((eq position 'eol)
!         (if (and (cc-bytecomp-fboundp 'line-end-position) (not point))
              `(line-end-position)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
***************
*** 248,254 ****
             (point)))
  
         ((eq position 'bopl)
!         (if (and (fboundp 'line-beginning-position) (not point))
              `(line-beginning-position 0)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
--- 234,240 ----
             (point)))
  
         ((eq position 'bopl)
!         (if (and (cc-bytecomp-fboundp 'line-beginning-position) (not point))
              `(line-beginning-position 0)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
***************
*** 256,262 ****
               (point))))
  
         ((eq position 'bonl)
!         (if (and (fboundp 'line-beginning-position) (not point))
              `(line-beginning-position 2)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
--- 242,248 ----
               (point))))
  
         ((eq position 'bonl)
!         (if (and (cc-bytecomp-fboundp 'line-beginning-position) (not point))
              `(line-beginning-position 2)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
***************
*** 264,270 ****
               (point))))
  
         ((eq position 'eopl)
!         (if (and (fboundp 'line-end-position) (not point))
              `(line-end-position 0)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
--- 250,256 ----
               (point))))
  
         ((eq position 'eopl)
!         (if (and (cc-bytecomp-fboundp 'line-end-position) (not point))
              `(line-end-position 0)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
***************
*** 273,279 ****
               (point))))
  
         ((eq position 'eonl)
!         (if (and (fboundp 'line-end-position) (not point))
              `(line-end-position 2)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
--- 259,265 ----
               (point))))
  
         ((eq position 'eonl)
!         (if (and (cc-bytecomp-fboundp 'line-end-position) (not point))
              `(line-end-position 2)
            `(save-excursion
               ,@(if point `((goto-char ,point)))
***************
*** 295,348 ****
             (back-to-indentation)
             (point)))
  
         (t (error "Unknown buffer position requested: %s" position))))
  
!     ;;(message "c-point long expansion")
      `(save-excursion
         ,@(if point `((goto-char ,point)))
         (let ((position ,position))
         (cond
!         ((eq position 'bol)  (beginning-of-line))
!         ((eq position 'eol)  (end-of-line))
!         ((eq position 'boi)  (back-to-indentation))
!         ((eq position 'bod)  (c-beginning-of-defun-1))
!         ((eq position 'eod)  (c-end-of-defun-1))
!         ((eq position 'bopl) (forward-line -1))
!         ((eq position 'bonl) (forward-line 1))
!         ((eq position 'eopl) (progn
!                                (beginning-of-line)
!                                (or (bobp) (backward-char))))
!         ((eq position 'eonl) (progn
!                                (forward-line 1)
!                                (end-of-line)))
!         ((eq position 'iopl) (progn
!                                (forward-line -1)
!                                (back-to-indentation)))
!         ((eq position 'ionl) (progn
!                                (forward-line 1)
!                                (back-to-indentation)))
          (t (error "Unknown buffer position requested: %s" position))))
         (point))))
  
  (defmacro c-safe (&rest body)
    ;; safely execute BODY, return nil if an error occurred
-   ;;
-   ;; This function does not do any hidden buffer changes.
    `(condition-case nil
         (progn ,@body)
       (error nil)))
  (put 'c-safe 'lisp-indent-function 0)
  
  ;; The following is essentially `save-buffer-state' from lazy-lock.el.
  ;; It ought to be a standard macro.
  (defmacro c-save-buffer-state (varlist &rest body)
    "Bind variables according to VARLIST (in `let*' style) and eval BODY,
  then restore the buffer state under the assumption that no significant
! modification has been made.  A change is considered significant if it
! affects the buffer text in any way that isn't completely restored
! again.  Changes in text properties like `face' or `syntax-table' are
! considered insignificant.  This macro allows text properties to be
! changed, even in a read-only buffer.
  
  The return value is the value of the last form in BODY."
    `(let* ((modified (buffer-modified-p)) (buffer-undo-list t)
--- 281,418 ----
             (back-to-indentation)
             (point)))
  
+        ((eq position 'bosws)
+         `(save-excursion
+            ,@(if point `((goto-char ,point)))
+            (c-backward-syntactic-ws)
+            (point)))
+ 
+        ((eq position 'eosws)
+         `(save-excursion
+            ,@(if point `((goto-char ,point)))
+            (c-forward-syntactic-ws)
+            (point)))
+ 
         (t (error "Unknown buffer position requested: %s" position))))
  
!     ;; The bulk of this should perhaps be in a function to avoid large
!     ;; expansions, but this case is not used anywhere in CC Mode (and
!     ;; probably not anywhere else either) so we only have it to be on
!     ;; the safe side.
!     (message "Warning: c-point long expansion")
      `(save-excursion
         ,@(if point `((goto-char ,point)))
         (let ((position ,position))
         (cond
!         ((eq position 'bol)   (beginning-of-line))
!         ((eq position 'eol)   (end-of-line))
!         ((eq position 'boi)   (back-to-indentation))
!         ((eq position 'bod)   (c-beginning-of-defun-1))
!         ((eq position 'eod)   (c-end-of-defun-1))
!         ((eq position 'bopl)  (forward-line -1))
!         ((eq position 'bonl)  (forward-line 1))
!         ((eq position 'eopl)  (progn
!                                 (beginning-of-line)
!                                 (or (bobp) (backward-char))))
!         ((eq position 'eonl)  (progn
!                                 (forward-line 1)
!                                 (end-of-line)))
!         ((eq position 'iopl)  (progn
!                                 (forward-line -1)
!                                 (back-to-indentation)))
!         ((eq position 'ionl)  (progn
!                                 (forward-line 1)
!                               (back-to-indentation)))
!         ((eq position 'bosws) (c-backward-syntactic-ws))
!         ((eq position 'eosws) (c-forward-syntactic-ws))
          (t (error "Unknown buffer position requested: %s" position))))
         (point))))
  
+ (defmacro c-region-is-active-p ()
+   ;; Return t when the region is active.  The determination of region
+   ;; activeness is different in both Emacs and XEmacs.
+   (if (cc-bytecomp-fboundp 'region-active-p)
+       ;; XEmacs.
+       '(region-active-p)
+     ;; Emacs.
+     'mark-active))
+ 
+ (defmacro c-set-region-active (activate)
+   ;; Activate the region if ACTIVE is non-nil, deactivate it
+   ;; otherwise.  Covers the differences between Emacs and XEmacs.
+   (if (cc-bytecomp-fboundp 'zmacs-activate-region)
+       ;; XEmacs.
+       `(if ,activate
+          (zmacs-activate-region)
+        (zmacs-deactivate-region))
+     ;; Emacs.
+     `(setq mark-active ,activate)))
+ 
+ (defmacro c-delete-and-extract-region (start end)
+   "Delete the text between START and END and return it."
+   (if (cc-bytecomp-fboundp 'delete-and-extract-region)
+       ;; Emacs 21.1 and later
+       `(delete-and-extract-region ,start ,end)
+     ;; XEmacs and Emacs 20.x
+     `(prog1
+        (buffer-substring ,start ,end)
+        (delete-region ,start ,end))))
+ 
  (defmacro c-safe (&rest body)
    ;; safely execute BODY, return nil if an error occurred
    `(condition-case nil
         (progn ,@body)
       (error nil)))
  (put 'c-safe 'lisp-indent-function 0)
  
+ (defmacro c-int-to-char (integer)
+   ;; In GNU Emacs, a character is an integer.  In XEmacs, a character is a
+   ;; type distinct from an integer.  Sometimes we need to convert integers to
+   ;; characters.  `c-int-to-char' makes this conversion, if necessary.
+   (if (fboundp 'int-to-char)
+       `(int-to-char ,integer)
+     integer))
+ 
+ (defmacro c-sentence-end ()
+   ;; Get the regular expression `sentence-end'.
+   (if (cc-bytecomp-fboundp 'sentence-end)
+       ;; Emacs 22:
+       `(sentence-end)
+     ;; Emacs <22 + XEmacs
+     `sentence-end))
+ 
+ (defmacro c-default-value-sentence-end ()
+   ;; Get the default value of the variable sentence end.
+   (if (cc-bytecomp-fboundp 'sentence-end)
+       ;; Emacs 22:
+       `(let (sentence-end) (sentence-end))
+     ;; Emacs <22 + XEmacs
+     `(default-value 'sentence-end)))
+ 
  ;; The following is essentially `save-buffer-state' from lazy-lock.el.
  ;; It ought to be a standard macro.
  (defmacro c-save-buffer-state (varlist &rest body)
    "Bind variables according to VARLIST (in `let*' style) and eval BODY,
  then restore the buffer state under the assumption that no significant
! modification has been made in BODY.  A change is considered
! significant if it affects the buffer text in any way that isn't
! completely restored again.  Changes in text properties like `face' or
! `syntax-table' are considered insignificant.  This macro allows text
! properties to be changed, even in a read-only buffer.
! 
! This macro should be placed around all calculations which set
! \"insignificant\" text properties in a buffer, even when the buffer is
! known to be writeable.  That way, these text properties remain set
! even if the user undoes the command which set them.
! 
! This macro should ALWAYS be placed around \"temporary\" internal buffer
! changes \(like adding a newline to calculate a text-property then
! deleting it again\), so that the user never sees them on his
! `buffer-undo-list'.  See also `c-tentative-buffer-changes'.
! 
! However, any user-visible changes to the buffer \(like auto-newlines\)
! must not be within a `c-save-buffer-state', since the user then
! wouldn't be able to undo them.
  
  The return value is the value of the last form in BODY."
    `(let* ((modified (buffer-modified-p)) (buffer-undo-list t)
***************
*** 350,361 ****
          before-change-functions after-change-functions
          deactivate-mark
          ,@varlist)
!      (prog1 (progn ,@body)
         (and (not modified)
            (buffer-modified-p)
            (set-buffer-modified-p nil)))))
  (put 'c-save-buffer-state 'lisp-indent-function 1)
  
  (defmacro c-forward-syntactic-ws (&optional limit)
    "Forward skip over syntactic whitespace.
  Syntactic whitespace is defined as whitespace characters, comments,
--- 420,499 ----
          before-change-functions after-change-functions
          deactivate-mark
          ,@varlist)
!      (unwind-protect
!        (progn ,@body)
         (and (not modified)
            (buffer-modified-p)
            (set-buffer-modified-p nil)))))
  (put 'c-save-buffer-state 'lisp-indent-function 1)
  
+ (defmacro c-tentative-buffer-changes (&rest body)
+   "Eval BODY and optionally restore the buffer contents to the state it
+ was in before BODY.  Any changes are kept if the last form in BODY
+ returns non-nil.  Otherwise it's undone using the undo facility, and
+ various other buffer state that might be affected by the changes is
+ restored.  That includes the current buffer, point, mark, mark
+ activation \(similar to `save-excursion'), and the modified state.
+ The state is also restored if BODY exits nonlocally.
+ 
+ If BODY makes a change that unconditionally is undone then wrap this
+ macro inside `c-save-buffer-state'.  That way the change can be done
+ even when the buffer is read-only, and without interference from
+ various buffer change hooks."
+   `(let (-tnt-chng-keep
+        -tnt-chng-state)
+      (unwind-protect
+        ;; Insert an undo boundary for use with `undo-more'.  We
+        ;; don't use `undo-boundary' since it doesn't insert one
+        ;; unconditionally.
+        (setq buffer-undo-list (cons nil buffer-undo-list)
+              -tnt-chng-state (c-tnt-chng-record-state)
+              -tnt-chng-keep (progn ,@body))
+        (c-tnt-chng-cleanup -tnt-chng-keep -tnt-chng-state))))
+ (put 'c-tentative-buffer-changes 'lisp-indent-function 0)
+ 
+ (defun c-tnt-chng-record-state ()
+   ;; Used internally in `c-tentative-buffer-changes'.
+   (vector buffer-undo-list            ; 0
+         (current-buffer)              ; 1
+         ;; No need to use markers for the point and mark; if the
+         ;; undo got out of synch we're hosed anyway.
+         (point)                       ; 2
+         (mark t)                      ; 3
+         (c-region-is-active-p)        ; 4
+         (buffer-modified-p)))         ; 5
+ 
+ (defun c-tnt-chng-cleanup (keep saved-state)
+   ;; Used internally in `c-tentative-buffer-changes'.
+ 
+   (let ((saved-undo-list (elt saved-state 0)))
+     (if (eq buffer-undo-list saved-undo-list)
+       ;; No change was done afterall.
+       (setq buffer-undo-list (cdr saved-undo-list))
+ 
+       (if keep
+         ;; Find and remove the undo boundary.
+         (let ((p buffer-undo-list))
+           (while (not (eq (cdr p) saved-undo-list))
+             (setq p (cdr p)))
+           (setcdr p (cdr saved-undo-list)))
+ 
+       ;; `primitive-undo' will remove the boundary.
+       (setq saved-undo-list (cdr saved-undo-list))
+       (let ((undo-in-progress t))
+         (while (not (eq (setq buffer-undo-list
+                               (primitive-undo 1 buffer-undo-list))
+                         saved-undo-list))))
+ 
+       (when (buffer-live-p (elt saved-state 1))
+         (set-buffer (elt saved-state 1))
+         (goto-char (elt saved-state 2))
+         (set-mark (elt saved-state 3))
+         (c-set-region-active (elt saved-state 4))
+         (and (not (elt saved-state 5))
+              (buffer-modified-p)
+              (set-buffer-modified-p nil)))))))
+ 
  (defmacro c-forward-syntactic-ws (&optional limit)
    "Forward skip over syntactic whitespace.
  Syntactic whitespace is defined as whitespace characters, comments,
***************
*** 402,492 ****
  This is like `forward-sexp' except that it isn't interactive and does
  not do any user friendly adjustments of the point and that it isn't
  susceptible to user configurations such as disabling of signals in
! certain situations.
! 
! This function does not do any hidden buffer changes."
    (or count (setq count 1))
!   `(goto-char (or (scan-sexps (point) ,count)
!                 ,(if (numberp count)
!                      (if (> count 0) `(point-max) `(point-min))
!                    `(if (> ,count 0) (point-max) (point-min))))))
  
  (defmacro c-backward-sexp (&optional count)
    "See `c-forward-sexp' and reverse directions."
    (or count (setq count 1))
    `(c-forward-sexp ,(if (numberp count) (- count) `(- ,count))))
  
! (defmacro c-safe-scan-lists (from count depth)
!   "Like `scan-lists' but returns nil instead of signaling errors.
! 
! This function does not do any hidden buffer changes."
!   (if (featurep 'xemacs)
!       `(scan-lists ,from ,count ,depth nil t)
!     `(c-safe (scan-lists ,from ,count ,depth))))
  
  
  ;; Wrappers for common scan-lists cases, mainly because it's almost
  ;; impossible to get a feel for how that function works.
  
! (defmacro c-up-list-forward (&optional pos)
    "Return the first position after the list sexp containing POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! This function does not do any hidden buffer changes."
!   `(c-safe-scan-lists ,(or pos `(point)) 1 1))
  
! (defmacro c-up-list-backward (&optional pos)
    "Return the position of the start of the list sexp containing POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! This function does not do any hidden buffer changes."
!   `(c-safe-scan-lists ,(or pos `(point)) -1 1))
  
! (defmacro c-down-list-forward (&optional pos)
    "Return the first position inside the first list sexp after POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! This function does not do any hidden buffer changes."
!   `(c-safe-scan-lists ,(or pos `(point)) 1 -1))
  
! (defmacro c-down-list-backward (&optional pos)
    "Return the last position inside the last list sexp before POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! This function does not do any hidden buffer changes."
!   `(c-safe-scan-lists ,(or pos `(point)) -1 -1))
  
! (defmacro c-go-up-list-forward (&optional pos)
    "Move the point to the first position after the list sexp containing POS,
! or the point if POS is left out.  Return t if such a position exists,
! otherwise nil is returned and the point isn't moved.
  
! This function does not do any hidden buffer changes."
!   `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 1)) t))
  
! (defmacro c-go-up-list-backward (&optional pos)
    "Move the point to the position of the start of the list sexp containing 
POS,
! or the point if POS is left out.  Return t if such a position exists,
! otherwise nil is returned and the point isn't moved.
  
! This function does not do any hidden buffer changes."
!   `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 1)) t))
  
! (defmacro c-go-down-list-forward (&optional pos)
    "Move the point to the first position inside the first list sexp after POS,
! or the point if POS is left out.  Return t if such a position exists,
! otherwise nil is returned and the point isn't moved.
  
! This function does not do any hidden buffer changes."
!   `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 -1)) t))
  
! (defmacro c-go-down-list-backward (&optional pos)
    "Move the point to the last position inside the last list sexp before POS,
! or the point if POS is left out.  Return t if such a position exists,
! otherwise nil is returned and the point isn't moved.
  
! This function does not do any hidden buffer changes."
!   `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 -1)) t))
  
  
  (defmacro c-beginning-of-defun-1 ()
--- 540,666 ----
  This is like `forward-sexp' except that it isn't interactive and does
  not do any user friendly adjustments of the point and that it isn't
  susceptible to user configurations such as disabling of signals in
! certain situations."
    (or count (setq count 1))
!   `(goto-char (scan-sexps (point) ,count)))
  
  (defmacro c-backward-sexp (&optional count)
    "See `c-forward-sexp' and reverse directions."
    (or count (setq count 1))
    `(c-forward-sexp ,(if (numberp count) (- count) `(- ,count))))
  
! (defmacro c-safe-scan-lists (from count depth &optional limit)
!   "Like `scan-lists' but returns nil instead of signalling errors
! for unbalanced parens.
! 
! A limit for the search may be given.  FROM is assumed to be on the
! right side of it."
!   (let ((res (if (featurep 'xemacs)
!                `(scan-lists ,from ,count ,depth nil t)
!              `(c-safe (scan-lists ,from ,count ,depth)))))
!     (if limit
!       `(save-restriction
!          ,(if (numberp count)
!               (if (< count 0)
!                   `(narrow-to-region ,limit (point-max))
!                 `(narrow-to-region (point-min) ,limit))
!             `(if (< ,count 0)
!                  (narrow-to-region ,limit (point-max))
!                (narrow-to-region (point-min) ,limit)))
!          ,res)
!       res)))
  
  
  ;; Wrappers for common scan-lists cases, mainly because it's almost
  ;; impossible to get a feel for how that function works.
  
! (defmacro c-up-list-forward (&optional pos limit)
    "Return the first position after the list sexp containing POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! A limit for the search may be given.  The start position is assumed to
! be before it."
!   `(c-safe-scan-lists ,(or pos `(point)) 1 1 ,limit))
  
! (defmacro c-up-list-backward (&optional pos limit)
    "Return the position of the start of the list sexp containing POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! A limit for the search may be given.  The start position is assumed to
! be after it."
!   `(c-safe-scan-lists ,(or pos `(point)) -1 1 ,limit))
  
! (defmacro c-down-list-forward (&optional pos limit)
    "Return the first position inside the first list sexp after POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! A limit for the search may be given.  The start position is assumed to
! be before it."
!   `(c-safe-scan-lists ,(or pos `(point)) 1 -1 ,limit))
  
! (defmacro c-down-list-backward (&optional pos limit)
    "Return the last position inside the last list sexp before POS,
  or nil if no such position exists.  The point is used if POS is left out.
  
! A limit for the search may be given.  The start position is assumed to
! be after it."
!   `(c-safe-scan-lists ,(or pos `(point)) -1 -1 ,limit))
  
! (defmacro c-go-up-list-forward (&optional pos limit)
    "Move the point to the first position after the list sexp containing POS,
! or containing the point if POS is left out.  Return t if such a
! position exists, otherwise nil is returned and the point isn't moved.
  
! A limit for the search may be given.  The start position is assumed to
! be before it."
!   (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 1)) t)))
!     (if limit
!       `(save-restriction
!          (narrow-to-region (point-min) ,limit)
!          ,res)
!       res)))
  
! (defmacro c-go-up-list-backward (&optional pos limit)
    "Move the point to the position of the start of the list sexp containing 
POS,
! or containing the point if POS is left out.  Return t if such a
! position exists, otherwise nil is returned and the point isn't moved.
  
! A limit for the search may be given.  The start position is assumed to
! be after it."
!   (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 1)) t)))
!     (if limit
!       `(save-restriction
!          (narrow-to-region ,limit (point-max))
!          ,res)
!       res)))
  
! (defmacro c-go-down-list-forward (&optional pos limit)
    "Move the point to the first position inside the first list sexp after POS,
! or before the point if POS is left out.  Return t if such a position
! exists, otherwise nil is returned and the point isn't moved.
  
! A limit for the search may be given.  The start position is assumed to
! be before it."
!   (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 -1)) t)))
!     (if limit
!       `(save-restriction
!          (narrow-to-region (point-min) ,limit)
!          ,res)
!       res)))
  
! (defmacro c-go-down-list-backward (&optional pos limit)
    "Move the point to the last position inside the last list sexp before POS,
! or before the point if POS is left out.  Return t if such a position
! exists, otherwise nil is returned and the point isn't moved.
  
! A limit for the search may be given.  The start position is assumed to
! be after it."
!   (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 -1)) t)))
!     (if limit
!       `(save-restriction
!          (narrow-to-region ,limit (point-max))
!          ,res)
!       res)))
  
  
  (defmacro c-beginning-of-defun-1 ()
***************
*** 501,508 ****
    ;; This is really a bit too large to be a macro but that isn't a
    ;; problem as long as it only is used in one place in
    ;; `c-parse-state'.
-   ;;
-   ;; This function does not do any hidden buffer changes.
  
    `(progn
       (if (and ,(cc-bytecomp-fboundp 'buffer-syntactic-context-depth)
--- 675,680 ----
***************
*** 542,572 ****
          (looking-at defun-prompt-regexp)
          (goto-char (match-end 0)))))
  
  (defmacro c-benign-error (format &rest args)
    ;; Formats an error message for the echo area and dings, i.e. like
    ;; `error' but doesn't abort.
-   ;;
-   ;; This function does not do any hidden buffer changes.
    `(progn
       (message ,format ,@args)
       (ding)))
  
- (defmacro c-update-modeline ()
-   ;; set the c-auto-hungry-string for the correct designation on the modeline
-   ;;
-   ;; This function does not do any hidden buffer changes.
-   `(progn
-      (setq c-auto-hungry-string
-          (if c-auto-newline
-              (if c-hungry-delete-key "/ah" "/a")
-            (if c-hungry-delete-key "/h" nil)))
-      (force-mode-line-update)))
- 
  (defmacro c-with-syntax-table (table &rest code)
    ;; Temporarily switches to the specified syntax table in a failsafe
    ;; way to execute code.
-   ;;
-   ;; This function does not do any hidden buffer changes.
    `(let ((c-with-syntax-table-orig-table (syntax-table)))
       (unwind-protect
         (progn
--- 714,797 ----
          (looking-at defun-prompt-regexp)
          (goto-char (match-end 0)))))
  
+ 
+ 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; V i r t u a l   S e m i c o l o n s 
+ ;;
+ ;; In most CC Mode languages, statements are terminated explicitly by
+ ;; semicolons or closing braces.  In some of the CC modes (currently only AWK
+ ;; Mode (April 2004)), statements are (or can be) terminated by EOLs.  Such a
+ ;; statement is said to be terminated by a "virtual semicolon" (VS).  A
+ ;; statement terminated by an actual semicolon or brace is never considered to
+ ;; have a VS.
+ ;;
+ ;; The indentation engine (or whatever) tests for a VS at a specific position
+ ;; by invoking the macro `c-at-vsemi-p', which in its turn calls the mode
+ ;; specific function (if any) which is the value of the language variable
+ ;; `c-at-vsemi-p-fn'.  The actual details of what constitutes a VS in a
+ ;; language are thus encapsulated in code specific to that language
+ ;; (e.g. cc-awk.el).  `c-at-vsemi-p' returns non-nil if point (or the optional
+ ;; parameter POS) is at a VS, nil otherwise.
+ ;;
+ ;; The language specific function might well do extensive analysis of the
+ ;; source text, and may use a cacheing scheme to speed up repeated calls.
+ ;;
+ ;; The "virtual semicolon" lies just after the last non-ws token on the line.
+ ;; Like POINT, it is considered to lie between two characters.  For example,
+ ;; at the place shown in the following AWK source line:
+ ;;
+ ;;          kbyte = 1024             # 1000 if you're not picky
+ ;;                      ^
+ ;;                      |
+ ;;              Virtual Semicolon
+ ;;
+ ;; In addition to `c-at-vsemi-p-fn', a mode may need to supply a function for
+ ;; `c-vsemi-status-unknown-p-fn'.  The macro `c-vsemi-status-unknown-p' is a
+ ;; rather recondite kludge.  It exists because the function
+ ;; `c-beginning-of-statement-1' sometimes tests for VSs as an optimisation,
+ ;; but `c-at-vsemi-p' might well need to call `c-beginning-of-statement-1' in
+ ;; its calculations, thus potentially leading to infinite recursion.
+ ;;
+ ;; The macro `c-vsemi-status-unknown-p' resolves this problem; it may return
+ ;; non-nil at any time; returning nil is a guarantee that an immediate
+ ;; invocation of `c-at-vsemi-p' at point will NOT call
+ ;; `c-beginning-of-statement-1'.  `c-vsemi-status-unknown-p' may not itself
+ ;; call `c-beginning-of-statement-1'.
+ ;;
+ ;; The macro `c-vsemi-status-unknown-p' will typically check the cacheing
+ ;; scheme used by the `c-at-vsemp-p-fn', hence the name - the status is
+ ;; "unknown" if there is no cache entry current for the line. 
+ 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ 
+ (defmacro c-at-vsemi-p (&optional pos)
+   ;; Is there a virtual semicolon (not a real one or a }) at POS (defaults to
+   ;; point)?  Always returns nil for languages which don't have Virtual
+   ;; semicolons.
+   ;; This macro might do hidden buffer changes.
+   `(if c-at-vsemi-p-fn
+        (funcall c-at-vsemi-p-fn ,@(if pos `(,pos)))))
+ 
+ (defmacro c-vsemi-status-unknown-p ()
+   ;; Return NIL only if it can be guaranteed that an immediate
+   ;; (c-at-vsemi-p) will NOT call c-beginning-of-statement-1.  Otherwise,
+   ;; return non-nil.  (See comments above).  The function invoked by this
+   ;; macro MUST NOT UNDER ANY CIRCUMSTANCES itself call
+   ;; c-beginning-of-statement-1.
+   ;; Languages which don't have EOL terminated statements always return NIL
+   ;; (they _know_ there's no vsemi ;-).
+   `(if c-vsemi-status-unknown-p-fn (funcall c-vsemi-status-unknown-p-fn)))
+ 
+ 
  (defmacro c-benign-error (format &rest args)
    ;; Formats an error message for the echo area and dings, i.e. like
    ;; `error' but doesn't abort.
    `(progn
       (message ,format ,@args)
       (ding)))
  
  (defmacro c-with-syntax-table (table &rest code)
    ;; Temporarily switches to the specified syntax table in a failsafe
    ;; way to execute code.
    `(let ((c-with-syntax-table-orig-table (syntax-table)))
       (unwind-protect
         (progn
***************
*** 578,586 ****
  (defmacro c-skip-ws-forward (&optional limit)
    "Skip over any whitespace following point.
  This function skips over horizontal and vertical whitespace and line
! continuations.
! 
! This function does not do any hidden buffer changes."
    (if limit
        `(let ((limit (or ,limit (point-max))))
         (while (progn
--- 803,809 ----
  (defmacro c-skip-ws-forward (&optional limit)
    "Skip over any whitespace following point.
  This function skips over horizontal and vertical whitespace and line
! continuations."
    (if limit
        `(let ((limit (or ,limit (point-max))))
         (while (progn
***************
*** 601,609 ****
  (defmacro c-skip-ws-backward (&optional limit)
    "Skip over any whitespace preceding point.
  This function skips over horizontal and vertical whitespace and line
! continuations.
! 
! This function does not do any hidden buffer changes."
    (if limit
        `(let ((limit (or ,limit (point-min))))
         (while (progn
--- 824,830 ----
  (defmacro c-skip-ws-backward (&optional limit)
    "Skip over any whitespace preceding point.
  This function skips over horizontal and vertical whitespace and line
! continuations."
    (if limit
        `(let ((limit (or ,limit (point-min))))
         (while (progn
***************
*** 624,632 ****
  
  (defmacro c-major-mode-is (mode)
    "Return non-nil if the current CC Mode major mode is MODE.
! MODE is either a mode symbol or a list of mode symbols.
! 
! This function does not do any hidden buffer changes."
  
    (if c-langs-are-parametric
        ;; Inside a `c-lang-defconst'.
--- 845,851 ----
  
  (defmacro c-major-mode-is (mode)
    "Return non-nil if the current CC Mode major mode is MODE.
! MODE is either a mode symbol or a list of mode symbols."
  
    (if c-langs-are-parametric
        ;; Inside a `c-lang-defconst'.
***************
*** 643,670 ****
             (memq c-buffer-is-cc-mode mode)
           (eq c-buffer-is-cc-mode mode))))))
  
- (defmacro c-mode-is-new-awk-p ()
-   ;; Is the current mode the "new" awk mode?  It is important for
-   ;; (e.g.) the cc-engine functions do distinguish between the old and
-   ;; new awk-modes.
-   '(and (c-major-mode-is 'awk-mode)
-       (memq 'syntax-properties c-emacs-features)))
- 
- (defmacro c-parse-sexp-lookup-properties ()
-   ;; Return the value of the variable that says whether the
-   ;; syntax-table property affects the sexp routines.  Always return
-   ;; nil in (X)Emacsen without support for that.
-   ;;
-   ;; This function does not do any hidden buffer changes.
-   (cond ((cc-bytecomp-boundp 'parse-sexp-lookup-properties)
-        `parse-sexp-lookup-properties)
-       ((cc-bytecomp-boundp 'lookup-syntax-properties)
-        `lookup-syntax-properties)
-       (t nil)))
- 
  
  ;; Macros/functions to handle so-called "char properties", which are
! ;; properties set on a single character and that never spreads to any
  ;; other characters.
  
  (eval-and-compile
--- 862,870 ----
             (memq c-buffer-is-cc-mode mode)
           (eq c-buffer-is-cc-mode mode))))))
  
  
  ;; Macros/functions to handle so-called "char properties", which are
! ;; properties set on a single character and that never spread to any
  ;; other characters.
  
  (eval-and-compile
***************
*** 719,724 ****
--- 919,926 ----
    ;;
    ;; If there's a `text-property-default-nonsticky' variable (Emacs
    ;; 21) then it's assumed that the property is present on it.
+   ;;
+   ;; This macro does a hidden buffer change.
    (setq property (eval property))
    (if (or c-use-extents
          (not (cc-bytecomp-boundp 'text-property-default-nonsticky)))
***************
*** 761,766 ****
--- 963,970 ----
    ;; Remove the given property on the character at POS if it's been put
    ;; there by `c-put-char-property'.  PROPERTY is assumed to be
    ;; constant.
+   ;;
+   ;; This macro does a hidden buffer change.
    (setq property (eval property))
    (cond (c-use-extents
         ;; XEmacs.
***************
*** 785,790 ****
--- 989,996 ----
    ;; lists of the `rear-nonsticky' properties in the region, if such
    ;; are used.  Thus it should not be used for common properties like
    ;; `syntax-table'.
+   ;;
+   ;; This macro does hidden buffer changes.
    (setq property (eval property))
    (if c-use-extents
        ;; XEmacs.
***************
*** 795,806 ****
--- 1001,1044 ----
      `(remove-text-properties ,from ,to '(,property nil))))
  
  
+ ;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text.
+ ;; For our purposes, these are characterized by being possible to
+ ;; remove again without affecting the other text properties in the
+ ;; buffer that got overridden when they were put.
+ 
+ (defmacro c-put-overlay (from to property value)
+   ;; Put an overlay/extent covering the given range in the current
+   ;; buffer.  It's currently undefined whether it's front/end sticky
+   ;; or not.  The overlay/extent object is returned.
+   (if (cc-bytecomp-fboundp 'make-overlay)
+       ;; Emacs.
+       `(let ((ol (make-overlay ,from ,to)))
+        (overlay-put ol ,property ,value)
+        ol)
+     ;; XEmacs.
+     `(let ((ext (make-extent ,from ,to)))
+        (set-extent-property ext ,property ,value)
+        ext)))
+ 
+ (defmacro c-delete-overlay (overlay)
+   ;; Deletes an overlay/extent object previously retrieved using
+   ;; `c-put-overlay'.
+   (if (cc-bytecomp-fboundp 'make-overlay)
+       ;; Emacs.
+       `(delete-overlay ,overlay)
+     ;; XEmacs.
+     `(delete-extent ,overlay)))
+ 
+ 
  ;; Make edebug understand the macros.
  (eval-after-load "edebug"
    '(progn
+      (def-edebug-spec cc-eval-when-compile t)
       (def-edebug-spec c-point t)
+      (def-edebug-spec c-set-region-active t)
       (def-edebug-spec c-safe t)
       (def-edebug-spec c-save-buffer-state let*)
+      (def-edebug-spec c-tentative-buffer-changes t)
       (def-edebug-spec c-forward-syntactic-ws t)
       (def-edebug-spec c-backward-syntactic-ws t)
       (def-edebug-spec c-forward-sexp t)
***************
*** 820,826 ****
       (def-edebug-spec c-get-char-property t)
       (def-edebug-spec c-clear-char-property t)
       (def-edebug-spec c-clear-char-properties t)
!      (def-edebug-spec cc-eval-when-compile t)))
  
  
  ;;; Functions.
--- 1058,1065 ----
       (def-edebug-spec c-get-char-property t)
       (def-edebug-spec c-clear-char-property t)
       (def-edebug-spec c-clear-char-properties t)
!      (def-edebug-spec c-put-overlay t)
!      (def-edebug-spec c-delete-overlay t)))
  
  
  ;;; Functions.
***************
*** 847,871 ****
  
  (defsubst c-mark-<-as-paren (pos)
    ;; Mark the "<" character at POS as an sexp list opener using the
!   ;; syntax-table property.  Note that Emacs 19 and XEmacs <= 20
!   ;; doesn't support syntax properties, so this function might not
!   ;; have any effect.
    (c-put-char-property pos 'syntax-table c-<-as-paren-syntax))
  
  (defconst c->-as-paren-syntax '(5 . ?<))
  
  (defsubst c-mark->-as-paren (pos)
    ;; Mark the ">" character at POS as an sexp list closer using the
!   ;; syntax-table property.  Note that Emacs 19 and XEmacs <= 20
!   ;; doesn't support syntax properties, so this function might not
!   ;; have any effect.
    (c-put-char-property pos 'syntax-table c->-as-paren-syntax))
  
  (defsubst c-intersect-lists (list alist)
    ;; return the element of ALIST that matches the first element found
    ;; in LIST.  Uses assq.
-   ;;
-   ;; This function does not do any hidden buffer changes.
    (let (match)
      (while (and list
                (not (setq match (assq (car list) alist))))
--- 1086,1108 ----
  
  (defsubst c-mark-<-as-paren (pos)
    ;; Mark the "<" character at POS as an sexp list opener using the
!   ;; syntax-table property.
!   ;;
!   ;; This function does a hidden buffer change.
    (c-put-char-property pos 'syntax-table c-<-as-paren-syntax))
  
  (defconst c->-as-paren-syntax '(5 . ?<))
  
  (defsubst c-mark->-as-paren (pos)
    ;; Mark the ">" character at POS as an sexp list closer using the
!   ;; syntax-table property.
!   ;;
!   ;; This function does a hidden buffer change.
    (c-put-char-property pos 'syntax-table c->-as-paren-syntax))
  
  (defsubst c-intersect-lists (list alist)
    ;; return the element of ALIST that matches the first element found
    ;; in LIST.  Uses assq.
    (let (match)
      (while (and list
                (not (setq match (assq (car list) alist))))
***************
*** 875,915 ****
  (defsubst c-lookup-lists (list alist1 alist2)
    ;; first, find the first entry from LIST that is present in ALIST1,
    ;; then find the entry in ALIST2 for that entry.
-   ;;
-   ;; This function does not do any hidden buffer changes.
    (assq (car (c-intersect-lists list alist1)) alist2))
  
  (defsubst c-langelem-sym (langelem)
    "Return the syntactic symbol in LANGELEM.
  
! LANGELEM is a syntactic element, i.e. either a cons cell on the
! \"old\" form given as the first argument to lineup functions or a list
! on the \"new\" form as used in `c-syntactic-element'.
! 
! This function does not do any hidden buffer changes."
    (car langelem))
  
  (defsubst c-langelem-pos (langelem)
!   "Return the (primary) anchor position in LANGELEM, or nil if there is none.
  
! LANGELEM is a syntactic element, i.e. either a cons cell on the
! \"old\" form given as the first argument to lineup functions or a list
! on the \"new\" form as used in `c-syntactic-element'.
! 
! This function does not do any hidden buffer changes."
    (if (consp (cdr langelem))
        (car-safe (cdr langelem))
      (cdr langelem)))
  
  (defun c-langelem-col (langelem &optional preserve-point)
!   "Return the column of the (primary) anchor position in LANGELEM.
! Leave point at that position unless PRESERVE-POINT is non-nil.
! 
! LANGELEM is a syntactic element, i.e. either a cons cell on the
! \"old\" form given as the first argument to lineup functions or a list
! on the \"new\" form as used in `c-syntactic-element'.
  
! This function does not do any hidden buffer changes."
    (let ((pos (c-langelem-pos langelem))
        (here (point)))
      (if pos
--- 1112,1144 ----
  (defsubst c-lookup-lists (list alist1 alist2)
    ;; first, find the first entry from LIST that is present in ALIST1,
    ;; then find the entry in ALIST2 for that entry.
    (assq (car (c-intersect-lists list alist1)) alist2))
  
  (defsubst c-langelem-sym (langelem)
    "Return the syntactic symbol in LANGELEM.
  
! LANGELEM is either a cons cell on the \"old\" form given as the first
! argument to lineup functions or a syntactic element on the \"new\"
! form as used in `c-syntactic-element'."
    (car langelem))
  
  (defsubst c-langelem-pos (langelem)
!   "Return the anchor position in LANGELEM, or nil if there is none.
  
! LANGELEM is either a cons cell on the \"old\" form given as the first
! argument to lineup functions or a syntactic element on the \"new\"
! form as used in `c-syntactic-element'."
    (if (consp (cdr langelem))
        (car-safe (cdr langelem))
      (cdr langelem)))
  
  (defun c-langelem-col (langelem &optional preserve-point)
!   "Return the column of the anchor position in LANGELEM.
! Also move the point to that position unless PRESERVE-POINT is non-nil.
  
! LANGELEM is either a cons cell on the \"old\" form given as the first
! argument to lineup functions or a syntactic element on the \"new\"
! form as used in `c-syntactic-element'."
    (let ((pos (c-langelem-pos langelem))
        (here (point)))
      (if pos
***************
*** 923,960 ****
  (defsubst c-langelem-2nd-pos (langelem)
    "Return the secondary position in LANGELEM, or nil if there is none.
  
! LANGELEM is a syntactic element, typically on the \"new\" form as used
! in `c-syntactic-element'.  It may be on the \"old\" form that is used
! as the first argument to lineup functions, but then the returned value
! always will be nil.
! 
! This function does not do any hidden buffer changes."
    (car-safe (cdr-safe (cdr-safe langelem))))
  
  (defsubst c-keep-region-active ()
    ;; Do whatever is necessary to keep the region active in XEmacs.
    ;; This is not needed for Emacs.
-   ;;
-   ;; This function does not do any hidden buffer changes.
    (and (boundp 'zmacs-region-stays)
         (setq zmacs-region-stays t)))
  
- (defsubst c-region-is-active-p ()
-   ;; Return t when the region is active.  The determination of region
-   ;; activeness is different in both Emacs and XEmacs.
-   ;;
-   ;; This function does not do any hidden buffer changes.
-   (cond
-    ;; XEmacs
-    ((and (fboundp 'region-active-p)
-        (boundp 'zmacs-regions)
-        zmacs-regions)
-     (region-active-p))
-    ;; Emacs
-    ((boundp 'mark-active) mark-active)
-    ;; fallback; shouldn't get here
-    (t (mark t))))
- 
  (put 'c-mode    'c-mode-prefix "c-")
  (put 'c++-mode  'c-mode-prefix "c++-")
  (put 'objc-mode 'c-mode-prefix "objc-")
--- 1152,1169 ----
  (defsubst c-langelem-2nd-pos (langelem)
    "Return the secondary position in LANGELEM, or nil if there is none.
  
! LANGELEM is typically a syntactic element on the \"new\" form as used
! in `c-syntactic-element'.  It may also be a cons cell as passed in the
! first argument to lineup functions, but then the returned value always
! will be nil."
    (car-safe (cdr-safe (cdr-safe langelem))))
  
  (defsubst c-keep-region-active ()
    ;; Do whatever is necessary to keep the region active in XEmacs.
    ;; This is not needed for Emacs.
    (and (boundp 'zmacs-region-stays)
         (setq zmacs-region-stays t)))
  
  (put 'c-mode    'c-mode-prefix "c-")
  (put 'c++-mode  'c-mode-prefix "c++-")
  (put 'objc-mode 'c-mode-prefix "objc-")
***************
*** 965,973 ****
  
  (defsubst c-mode-symbol (suffix)
    "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return
! the corresponding symbol.
! 
! This function does not do any hidden buffer changes."
    (or c-buffer-is-cc-mode
        (error "Not inside a CC Mode based mode"))
    (let ((mode-prefix (get c-buffer-is-cc-mode 'c-mode-prefix)))
--- 1174,1180 ----
  
  (defsubst c-mode-symbol (suffix)
    "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return
! the corresponding symbol."
    (or c-buffer-is-cc-mode
        (error "Not inside a CC Mode based mode"))
    (let ((mode-prefix (get c-buffer-is-cc-mode 'c-mode-prefix)))
***************
*** 978,993 ****
  
  (defsubst c-mode-var (suffix)
    "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return
! the value of the variable with that name.
! 
! This function does not do any hidden buffer changes."
    (symbol-value (c-mode-symbol suffix)))
  
  (defsubst c-got-face-at (pos faces)
    "Return non-nil if position POS in the current buffer has any of the
! faces in the list FACES.
! 
! This function does not do any hidden buffer changes."
    (let ((pos-faces (get-text-property pos 'face)))
      (if (consp pos-faces)
        (progn
--- 1185,1196 ----
  
  (defsubst c-mode-var (suffix)
    "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return
! the value of the variable with that name."
    (symbol-value (c-mode-symbol suffix)))
  
  (defsubst c-got-face-at (pos faces)
    "Return non-nil if position POS in the current buffer has any of the
! faces in the list FACES."
    (let ((pos-faces (get-text-property pos 'face)))
      (if (consp pos-faces)
        (progn
***************
*** 1003,1033 ****
    ;; face objects (while it's only their names that are used just
    ;; about anywhere else) without providing a predicate that tests
    ;; face names.
-   ;;
-   ;; This function does not do any hidden buffer changes.
    (memq facename (face-list)))
  
  (defun c-make-keywords-re (adorn list &optional mode)
    "Make a regexp that matches all the strings the list.
! Duplicates in the list are removed.  The resulting regexp may contain
! zero or more submatch expressions.
  
! If ADORN is non-nil there will be at least one submatch and the first
! matches the whole keyword, and the regexp will also not match a prefix
! of any identifier.  Adorned regexps cannot be appended.  The language
! variable `c-nonsymbol-key' is used to make the adornment.  The
! optional MODE specifies the language to get it in.  The default is the
! current language (taken from `c-buffer-is-cc-mode')."
  
    (let (unique)
      (dolist (elt list)
        (unless (member elt unique)
        (push elt unique)))
!     (setq list unique))
    (if list
!       (let ((re (c-regexp-opt list)))
  
!       ;; Emacs < 21 and XEmacs (all versions so far) has a buggy
        ;; regexp-opt that doesn't always cope with strings containing
        ;; newlines.  This kludge doesn't handle shy parens correctly
        ;; so we can't advice regexp-opt directly with it.
--- 1206,1277 ----
    ;; face objects (while it's only their names that are used just
    ;; about anywhere else) without providing a predicate that tests
    ;; face names.
    (memq facename (face-list)))
  
+ (defun c-concat-separated (list separator)
+   "Like `concat' on LIST, but separate each element with SEPARATOR.
+ Notably, null elements in LIST are ignored."
+   (mapconcat 'identity (delete nil (append list nil)) separator))
+ 
  (defun c-make-keywords-re (adorn list &optional mode)
    "Make a regexp that matches all the strings the list.
! Duplicates and nil elements in the list are removed.  The resulting
! regexp may contain zero or more submatch expressions.
  
! If ADORN is t there will be at least one submatch and the first
! surrounds the matched alternative, and the regexp will also not match
! a prefix of any identifier.  Adorned regexps cannot be appended.  The
! language variable `c-nonsymbol-key' is used to make the adornment.
! 
! A value 'appendable for ADORN is like above, but all alternatives in
! the list that end with a word constituent char will have \\> appended
! instead, so that the regexp remains appendable.  Note that this
! variant doesn't always guarantee that an identifier prefix isn't
! matched since the symbol constituent '_' is normally considered a
! nonword token by \\>.
! 
! The optional MODE specifies the language to get `c-nonsymbol-key' from
! when it's needed.  The default is the current language taken from
! `c-buffer-is-cc-mode'."
  
    (let (unique)
      (dolist (elt list)
        (unless (member elt unique)
        (push elt unique)))
!     (setq list (delete nil unique)))
    (if list
!       (let (re)
! 
!       (if (eq adorn 'appendable)
!           ;; This is kludgy but it works: Search for a string that
!           ;; doesn't occur in any word in LIST.  Append it to all
!           ;; the alternatives where we want to add \>.  Run through
!           ;; `regexp-opt' and then replace it with \>.
!           (let ((unique "") pos)
!             (while (let (found)
!                      (setq unique (concat unique "@")
!                            pos list)
!                      (while (and pos
!                                  (if (string-match unique (car pos))
!                                      (progn (setq found t)
!                                             nil)
!                                    t))
!                        (setq pos (cdr pos)))
!                      found))
!             (setq pos list)
!             (while pos
!               (if (string-match "\\w\\'" (car pos))
!                   (setcar pos (concat (car pos) unique)))
!               (setq pos (cdr pos)))
!             (setq re (regexp-opt list))
!             (setq pos 0)
!             (while (string-match unique re pos)
!               (setq pos (+ (match-beginning 0) 2)
!                     re (replace-match "\\>" t t re))))
! 
!         (setq re (regexp-opt list)))
  
!       ;; Emacs 20 and XEmacs (all versions so far) has a buggy
        ;; regexp-opt that doesn't always cope with strings containing
        ;; newlines.  This kludge doesn't handle shy parens correctly
        ;; so we can't advice regexp-opt directly with it.
***************
*** 1041,1061 ****
          (when fail-list
            (setq re (concat re
                             "\\|"
!                            (mapconcat 'regexp-quote
!                                       (sort fail-list
!                                             (lambda (a b)
!                                               (> (length a) (length b))))
!                                       "\\|")))))
  
        ;; Add our own grouping parenthesis around re instead of
        ;; passing adorn to `regexp-opt', since in XEmacs it makes the
        ;; top level grouping "shy".
!       (if adorn
!           (concat "\\(" re "\\)"
!                   "\\("
!                   (c-get-lang-constant 'c-nonsymbol-key nil mode)
!                   "\\|$\\)")
!         re))
  
      ;; Produce a regexp that matches nothing.
      (if adorn
--- 1285,1315 ----
          (when fail-list
            (setq re (concat re
                             "\\|"
!                            (mapconcat
!                             (if (eq adorn 'appendable)
!                                 (lambda (str)
!                                   (if (string-match "\\w\\'" str)
!                                       (concat (regexp-quote str)
!                                               "\\>")
!                                     (regexp-quote str)))
!                               'regexp-quote)
!                             (sort fail-list
!                                   (lambda (a b)
!                                     (> (length a) (length b))))
!                             "\\|")))))
  
        ;; Add our own grouping parenthesis around re instead of
        ;; passing adorn to `regexp-opt', since in XEmacs it makes the
        ;; top level grouping "shy".
!       (cond ((eq adorn 'appendable)
!              (concat "\\(" re "\\)"))
!             (adorn
!              (concat "\\(" re "\\)"
!                      "\\("
!                      (c-get-lang-constant 'c-nonsymbol-key nil mode)
!                      "\\|$\\)"))
!             (t
!              re)))
  
      ;; Produce a regexp that matches nothing.
      (if adorn
***************
*** 1064,1069 ****
--- 1318,1352 ----
  
  (put 'c-make-keywords-re 'lisp-indent-function 1)
  
+ (defun c-make-bare-char-alt (chars &optional inverted)
+   "Make a character alternative string from the list of characters CHARS.
+ The returned string is of the type that can be used with
+ `skip-chars-forward' and `skip-chars-backward'.  If INVERTED is
+ non-nil, a caret is prepended to invert the set."
+   ;; This function ought to be in the elisp core somewhere.
+   (let ((str (if inverted "^" "")) char char2)
+     (setq chars (sort (append chars nil) `<))
+     (while chars
+       (setq char (pop chars))
+       (if (memq char '(?\\ ?^ ?-))
+         ;; Quoting necessary (this method only works in the skip
+         ;; functions).
+         (setq str (format "%s\\%c" str char))
+       (setq str (format "%s%c" str char)))
+       ;; Check for range.
+       (setq char2 char)
+       (while (and chars (>= (1+ char2) (car chars)))
+       (setq char2 (pop chars)))
+       (unless (= char char2)
+       (if (< (1+ char) char2)
+           (setq str (format "%s-%c" str char2))
+         (push char2 chars))))
+     str))
+ 
+ ;; Leftovers from (X)Emacs 19 compatibility.
+ (defalias 'c-regexp-opt 'regexp-opt)
+ (defalias 'c-regexp-opt-depth 'regexp-opt-depth)
+ 
  
  ;; Figure out what features this Emacs has
  
***************
*** 1076,1099 ****
        ;; I've no idea what this actually is, but it's legacy. /mast
        (setq list (cons 'infodock list)))
  
!     ;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags.
!     ;; Emacs 19 uses a 1-bit flag.  We will have to set up our
      ;; syntax tables differently to handle this.
      (let ((table (copy-syntax-table))
          entry)
        (modify-syntax-entry ?a ". 12345678" table)
        (cond
!        ;; XEmacs 19, and beyond Emacs 19.34
         ((arrayp table)
        (setq entry (aref table ?a))
        ;; In Emacs, table entries are cons cells
        (if (consp entry) (setq entry (car entry))))
!        ;; XEmacs 20
!        ((fboundp 'get-char-table) (setq entry (get-char-table ?a table)))
!        ;; before and including Emacs 19.34
!        ((and (fboundp 'char-table-p)
!            (char-table-p table))
!       (setq entry (car (char-table-range table [?a]))))
         ;; incompatible
         (t (error "CC Mode is incompatible with this version of Emacs")))
        (setq list (cons (if (= (logand (lsh entry -16) 255) 255)
--- 1359,1379 ----
        ;; I've no idea what this actually is, but it's legacy. /mast
        (setq list (cons 'infodock list)))
  
!     ;; XEmacs uses 8-bit modify-syntax-entry flags.
!     ;; Emacs uses a 1-bit flag.  We will have to set up our
      ;; syntax tables differently to handle this.
      (let ((table (copy-syntax-table))
          entry)
        (modify-syntax-entry ?a ". 12345678" table)
        (cond
!        ;; Emacs
         ((arrayp table)
        (setq entry (aref table ?a))
        ;; In Emacs, table entries are cons cells
        (if (consp entry) (setq entry (car entry))))
!        ;; XEmacs
!        ((fboundp 'get-char-table)
!       (setq entry (get-char-table ?a table)))
         ;; incompatible
         (t (error "CC Mode is incompatible with this version of Emacs")))
        (setq list (cons (if (= (logand (lsh entry -16) 255) 255)
***************
*** 1125,1131 ****
        (goto-char 1)
        (c-forward-sexp)
        (if (= (point) 5)
!           (setq list (cons 'syntax-properties list)))
  
        ;; Find out if generic comment delimiters work.
        (c-safe
--- 1405,1415 ----
        (goto-char 1)
        (c-forward-sexp)
        (if (= (point) 5)
!           (setq list (cons 'syntax-properties list))
!         (error (concat
!                 "CC Mode is incompatible with this version of Emacs - "
!                 "support for the `syntax-table' text property "
!                 "is required.")))
  
        ;; Find out if generic comment delimiters work.
        (c-safe
***************
*** 1153,1159 ****
          (setq list (cons 'posix-char-classes list)))
  
        ;; See if `open-paren-in-column-0-is-defun-start' exists and
!       ;; isn't buggy.
        (when (boundp 'open-paren-in-column-0-is-defun-start)
          (let ((open-paren-in-column-0-is-defun-start nil)
                (parse-sexp-ignore-comments t))
--- 1437,1443 ----
          (setq list (cons 'posix-char-classes list)))
  
        ;; See if `open-paren-in-column-0-is-defun-start' exists and
!       ;; isn't buggy (Emacs >= 21.4).
        (when (boundp 'open-paren-in-column-0-is-defun-start)
          (let ((open-paren-in-column-0-is-defun-start nil)
                (parse-sexp-ignore-comments t))
***************
*** 1180,1187 ****
        (kill-buffer buf))
  
      ;; See if `parse-partial-sexp' returns the eighth element.
!     (when (c-safe (>= (length (save-excursion (parse-partial-sexp 1 1))) 10))
!       (setq list (cons 'pps-extended-state list)))
  
      ;;(message "c-emacs-features: %S" list)
      list)
--- 1464,1474 ----
        (kill-buffer buf))
  
      ;; See if `parse-partial-sexp' returns the eighth element.
!     (if (c-safe (>= (length (save-excursion (parse-partial-sexp 1 1))) 10))
!       (setq list (cons 'pps-extended-state list))
!       (error (concat
!             "CC Mode is incompatible with this version of Emacs - "
!             "`parse-partial-sexp' has to return at least 10 elements.")))
  
      ;;(message "c-emacs-features: %S" list)
      list)
***************
*** 1193,1206 ****
  '8-bit              8 bit syntax entry flags (XEmacs style).
  '1-bit              1 bit syntax entry flags (Emacs style).
  'syntax-properties  It works to override the syntax for specific characters
!                   in the buffer with the 'syntax-table property.
  'gen-comment-delim  Generic comment delimiters work
                    (i.e. the syntax class `!').
  'gen-string-delim   Generic string delimiters work
                    (i.e. the syntax class `|').
  'pps-extended-state `parse-partial-sexp' returns a list with at least 10
!                   elements, i.e. it contains the position of the
!                   start of the last comment or string.
  'posix-char-classes The regexp engine understands POSIX character classes.
  'col-0-paren        It's possible to turn off the ad-hoc rule that a paren
                    in column zero is the start of a defun.
--- 1480,1496 ----
  '8-bit              8 bit syntax entry flags (XEmacs style).
  '1-bit              1 bit syntax entry flags (Emacs style).
  'syntax-properties  It works to override the syntax for specific characters
!                   in the buffer with the 'syntax-table property.  It's
!                   always set - CC Mode no longer works in emacsen without
!                   this feature.
  'gen-comment-delim  Generic comment delimiters work
                    (i.e. the syntax class `!').
  'gen-string-delim   Generic string delimiters work
                    (i.e. the syntax class `|').
  'pps-extended-state `parse-partial-sexp' returns a list with at least 10
!                   elements, i.e. it contains the position of the start of
!                   the last comment or string. It's always set - CC Mode no
!                   longer works in emacsen without this feature.
  'posix-char-classes The regexp engine understands POSIX character classes.
  'col-0-paren        It's possible to turn off the ad-hoc rule that a paren
                    in column zero is the start of a defun.
***************
*** 1359,1367 ****
  one `c-lang-defconst' for each NAME is permitted per file.  If there
  already is one it will be completely replaced; the value in the
  earlier definition will not affect `c-lang-const' on the same
! constant.  A file is identified by its base name.
! 
! This macro does not do any hidden buffer changes."
  
    (let* ((sym (intern (symbol-name name) c-lang-constants))
         ;; Make `c-lang-const' expand to a straightforward call to
--- 1649,1655 ----
  one `c-lang-defconst' for each NAME is permitted per file.  If there
  already is one it will be completely replaced; the value in the
  earlier definition will not affect `c-lang-const' on the same
! constant.  A file is identified by its base name."
  
    (let* ((sym (intern (symbol-name name) c-lang-constants))
         ;; Make `c-lang-const' expand to a straightforward call to
***************
*** 1451,1458 ****
       (&define name [&optional stringp] [&rest sexp def-form])))
  
  (defun c-define-lang-constant (name bindings &optional pre-files)
!   ;; Used by `c-lang-defconst'.  This function does not do any hidden
!   ;; buffer changes.
  
    (let* ((sym (intern (symbol-name name) c-lang-constants))
         (source (get sym 'source))
--- 1739,1745 ----
       (&define name [&optional stringp] [&rest sexp def-form])))
  
  (defun c-define-lang-constant (name bindings &optional pre-files)
!   ;; Used by `c-lang-defconst'.
  
    (let* ((sym (intern (symbol-name name) c-lang-constants))
         (source (get sym 'source))
***************
*** 1504,1512 ****
  \"-mode\" suffix.  If used inside `c-lang-defconst' or
  `c-lang-defvar', LANG may be left out to refer to the current
  language.  NAME and LANG are not evaluated so they should not be
! quoted.
! 
! This macro does not do any hidden buffer changes."
  
    (or (symbolp name)
        (error "Not a symbol: %s" name))
--- 1791,1797 ----
  \"-mode\" suffix.  If used inside `c-lang-defconst' or
  `c-lang-defvar', LANG may be left out to refer to the current
  language.  NAME and LANG are not evaluated so they should not be
! quoted."
  
    (or (symbolp name)
        (error "Not a symbol: %s" name))
***************
*** 1516,1533 ****
    (let ((sym (intern (symbol-name name) c-lang-constants))
        mode source-files args)
  
!     (if lang
!       (progn
!         (setq mode (intern (concat (symbol-name lang) "-mode")))
!         (unless (get mode 'c-mode-prefix)
!           (error
!            "Unknown language %S since it got no `c-mode-prefix' property"
!            (symbol-name lang))))
!       (if c-buffer-is-cc-mode
!         (setq lang c-buffer-is-cc-mode)
!       (or c-langs-are-parametric
!           (error
!            "`c-lang-const' requires a literal language in this context"))))
  
      (if (eq c-lang-const-expansion 'immediate)
        ;; No need to find out the source file(s) when we evaluate
--- 1801,1812 ----
    (let ((sym (intern (symbol-name name) c-lang-constants))
        mode source-files args)
  
!     (when lang
!       (setq mode (intern (concat (symbol-name lang) "-mode")))
!       (unless (get mode 'c-mode-prefix)
!       (error
!        "Unknown language %S since it got no `c-mode-prefix' property"
!        (symbol-name lang))))
  
      (if (eq c-lang-const-expansion 'immediate)
        ;; No need to find out the source file(s) when we evaluate
***************
*** 1550,1556 ****
                                               (list (car elem))))
                                           (get sym 'source))))))
  
!       ;; Spend some effort to make a compact call to
        ;; `c-get-lang-constant' since it will be compiled in.
        (setq args (and mode `(',mode)))
        (if (or source-files args)
--- 1829,1835 ----
                                               (list (car elem))))
                                           (get sym 'source))))))
  
!       ;; Make some effort to do a compact call to
        ;; `c-get-lang-constant' since it will be compiled in.
        (setq args (and mode `(',mode)))
        (if (or source-files args)
***************
*** 1558,1569 ****
                           args)))
  
        (if (or (eq c-lang-const-expansion 'call)
              load-in-progress
              (not (boundp 'byte-compile-dest-file))
              (not (stringp byte-compile-dest-file)))
          ;; Either a straight call is requested in the context, or
!         ;; we're not being byte compiled so the compile time stuff
!         ;; below is unnecessary.
          `(c-get-lang-constant ',name ,@args)
  
        ;; Being compiled.  If the loading and compiling version is
--- 1837,1851 ----
                           args)))
  
        (if (or (eq c-lang-const-expansion 'call)
+             (and (not c-lang-const-expansion)
+                  (not mode))
              load-in-progress
              (not (boundp 'byte-compile-dest-file))
              (not (stringp byte-compile-dest-file)))
          ;; Either a straight call is requested in the context, or
!         ;; we're in an "uncontrolled" context and got no language,
!         ;; or we're not being byte compiled so the compile time
!         ;; stuff below is unnecessary.
          `(c-get-lang-constant ',name ,@args)
  
        ;; Being compiled.  If the loading and compiling version is
***************
*** 1577,1584 ****
  (defvar c-lang-constants-under-evaluation nil)
  
  (defun c-get-lang-constant (name &optional source-files mode)
!   ;; Used by `c-lang-const'.  This function does not do any hidden
!   ;; buffer changes.
  
    (or mode
        (setq mode c-buffer-is-cc-mode)
--- 1859,1865 ----
  (defvar c-lang-constants-under-evaluation nil)
  
  (defun c-get-lang-constant (name &optional source-files mode)
!   ;; Used by `c-lang-const'.
  
    (or mode
        (setq mode c-buffer-is-cc-mode)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]