2003-07-03 12:30:59 +00:00
|
|
|
|
;;; cc-mode.el --- major mode for editing C and similar languages
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
2017-01-01 03:14:01 +00:00
|
|
|
|
;; Copyright (C) 1985, 1987, 1992-2017 Free Software Foundation, Inc.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; Authors: 2003- Alan Mackenzie
|
|
|
|
|
;; 1998- Martin Stjernholm
|
|
|
|
|
;; 1992-1999 Barry A. Warsaw
|
2009-01-11 00:37:05 +00:00
|
|
|
|
;; 1987 Dave Detlefs
|
|
|
|
|
;; 1987 Stewart Clamen
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;; 1985 Richard M. Stallman
|
1999-02-08 16:53:18 +00:00
|
|
|
|
;; Maintainer: bug-cc-mode@gnu.org
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;; Created: a long, long, time ago. adapted from the original c-mode.el
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Keywords: c languages
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
;; 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
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;;; Commentary:
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
;; NOTE: Read the commentary below for the right way to submit bug reports!
|
|
|
|
|
;; NOTE: See the accompanying texinfo manual for details on using this mode!
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; Note: The version string is in cc-defs.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
;; This package provides GNU Emacs major modes for editing C, C++,
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; Objective-C, Java, CORBA's IDL, Pike and AWK code. As of the
|
|
|
|
|
;; latest Emacs and XEmacs releases, it is the default package for
|
|
|
|
|
;; editing these languages. This package is called "CC Mode", and
|
|
|
|
|
;; should be spelled exactly this way.
|
1999-02-08 16:53:18 +00:00
|
|
|
|
|
|
|
|
|
;; CC Mode supports K&R and ANSI C, ANSI C++, Objective-C, Java,
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; CORBA's IDL, Pike and AWK with a consistent indentation model
|
|
|
|
|
;; across all modes. This indentation model is intuitive and very
|
|
|
|
|
;; flexible, so that almost any desired style of indentation can be
|
|
|
|
|
;; supported. Installation, usage, and programming details are
|
|
|
|
|
;; contained in an accompanying texinfo manual.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
;; CC Mode's immediate ancestors were, c++-mode.el, cplus-md.el, and
|
|
|
|
|
;; cplus-md1.el..
|
|
|
|
|
|
|
|
|
|
;; To submit bug reports, type "C-c C-b". These will be sent to
|
1999-02-08 16:53:18 +00:00
|
|
|
|
;; bug-gnu-emacs@gnu.org (mirrored as the Usenet newsgroup
|
|
|
|
|
;; gnu.emacs.bug) as well as bug-cc-mode@gnu.org, which directly
|
|
|
|
|
;; contacts the CC Mode maintainers. Questions can sent to
|
|
|
|
|
;; help-gnu-emacs@gnu.org (mirrored as gnu.emacs.help) and/or
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; bug-cc-mode@gnu.org. Please do not send bugs or questions to our
|
|
|
|
|
;; personal accounts; we reserve the right to ignore such email!
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
;; Many, many thanks go out to all the folks on the beta test list.
|
|
|
|
|
;; Without their patience, testing, insight, code contributions, and
|
|
|
|
|
;; encouragement CC Mode would be a far inferior package.
|
|
|
|
|
|
|
|
|
|
;; You can get the latest version of CC Mode, including PostScript
|
|
|
|
|
;; documentation and separate individual files from:
|
|
|
|
|
;;
|
2000-07-24 11:10:33 +00:00
|
|
|
|
;; http://cc-mode.sourceforge.net/
|
1999-02-08 16:53:18 +00:00
|
|
|
|
;;
|
|
|
|
|
;; You can join a moderated CC Mode announcement-only mailing list by
|
|
|
|
|
;; visiting
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;;
|
2000-07-24 11:10:33 +00:00
|
|
|
|
;; http://lists.sourceforge.net/mailman/listinfo/cc-mode-announce
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
2016-05-23 20:25:28 -04:00
|
|
|
|
;; Externally maintained major modes which use CC-mode's engine include:
|
|
|
|
|
;; - cuda-mode
|
|
|
|
|
;; - csharp-mode (https://github.com/josteink/csharp-mode)
|
|
|
|
|
;; - haxe-mode
|
|
|
|
|
;; - d-mode
|
|
|
|
|
;; - dart-mode
|
|
|
|
|
;; - cc-php-js-cs.el
|
|
|
|
|
;; - php-mode
|
|
|
|
|
;; - yang-mode
|
|
|
|
|
;; - math-mode (mathematica)
|
|
|
|
|
;; - unrealscript-mode
|
|
|
|
|
;; - groovy-mode
|
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2008-05-15 03:30:40 +00:00
|
|
|
|
;; For Emacs < 22.2.
|
|
|
|
|
(eval-and-compile
|
2014-03-03 23:03:34 -05:00
|
|
|
|
(unless (fboundp 'declare-function) (defmacro declare-function (&rest _r))))
|
2008-05-15 03:30:40 +00:00
|
|
|
|
|
1999-12-12 18:24:19 +00:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(let ((load-path
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(if (and (boundp 'byte-compile-dest-file)
|
|
|
|
|
(stringp byte-compile-dest-file))
|
|
|
|
|
(cons (file-name-directory byte-compile-dest-file) load-path)
|
1999-12-12 18:24:19 +00:00
|
|
|
|
load-path)))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(load "cc-bytecomp" nil t)))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
(cc-require 'cc-defs)
|
|
|
|
|
(cc-require 'cc-vars)
|
2013-05-30 19:18:39 -04:00
|
|
|
|
(cc-require-when-compile 'cc-langs)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(cc-require 'cc-engine)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cc-require 'cc-styles)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(cc-require 'cc-cmds)
|
|
|
|
|
(cc-require 'cc-align)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cc-require 'cc-menus)
|
2011-06-30 20:45:12 +00:00
|
|
|
|
(cc-require 'cc-guess)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
2014-09-10 21:38:11 +00:00
|
|
|
|
;; Silence the compiler.
|
|
|
|
|
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs
|
|
|
|
|
(cc-bytecomp-defun run-mode-hooks) ; Emacs 21.1
|
|
|
|
|
|
2015-11-24 22:20:47 +00:00
|
|
|
|
;; We set this variable during mode init, yet we don't require
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; font-lock.
|
2014-09-10 21:38:11 +00:00
|
|
|
|
(cc-bytecomp-defvar font-lock-defaults)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Menu support for both XEmacs and Emacs. If you don't have easymenu
|
|
|
|
|
;; with your version of Emacs, you are incompatible!
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cc-external-require 'easymenu)
|
|
|
|
|
|
|
|
|
|
;; Load cc-fonts first after font-lock is loaded, since it isn't
|
|
|
|
|
;; necessary until font locking is requested.
|
2006-07-10 13:19:14 +00:00
|
|
|
|
; (eval-after-load "font-lock" ; 2006-07-09: font-lock is now preloaded.
|
|
|
|
|
; '
|
|
|
|
|
(require 'cc-fonts) ;)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
1997-07-18 02:16:22 +00:00
|
|
|
|
|
|
|
|
|
;; Other modes and packages which depend on CC Mode should do the
|
|
|
|
|
;; following to make sure everything is loaded and available for their
|
|
|
|
|
;; use:
|
|
|
|
|
;;
|
|
|
|
|
;; (require 'cc-mode)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
;;
|
|
|
|
|
;; And in the major mode function:
|
|
|
|
|
;;
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; (c-initialize-cc-mode t)
|
|
|
|
|
;; (c-init-language-vars some-mode)
|
|
|
|
|
;; (c-common-init 'some-mode) ; Or perhaps (c-basic-common-init 'some-mode)
|
|
|
|
|
;;
|
2003-08-03 12:31:46 +00:00
|
|
|
|
;; If you're not writing a derived mode using the language variable
|
|
|
|
|
;; system, then some-mode is one of the language modes directly
|
|
|
|
|
;; supported by CC Mode. You can then use (c-init-language-vars-for
|
|
|
|
|
;; 'some-mode) instead of `c-init-language-vars'.
|
|
|
|
|
;; `c-init-language-vars-for' is a function that avoids the rather
|
|
|
|
|
;; large expansion of `c-init-language-vars'.
|
|
|
|
|
;;
|
|
|
|
|
;; If you use `c-basic-common-init' then you might want to call
|
|
|
|
|
;; `c-font-lock-init' too to set up CC Mode's font lock support.
|
|
|
|
|
;;
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; See cc-langs.el for further info. A small example of a derived mode
|
|
|
|
|
;; is also available at <http://cc-mode.sourceforge.net/
|
|
|
|
|
;; derived-mode-ex.el>.
|
1997-07-18 02:16:22 +00:00
|
|
|
|
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(defun c-leave-cc-mode-mode ()
|
2016-02-07 15:06:43 +00:00
|
|
|
|
(when c-buffer-is-cc-mode
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(c-save-buffer-state ()
|
|
|
|
|
(c-clear-char-properties (point-min) (point-max) 'category)
|
|
|
|
|
(c-clear-char-properties (point-min) (point-max) 'syntax-table)
|
|
|
|
|
(c-clear-char-properties (point-min) (point-max) 'c-is-sws)
|
|
|
|
|
(c-clear-char-properties (point-min) (point-max) 'c-in-sws)
|
|
|
|
|
(c-clear-char-properties (point-min) (point-max) 'c-type)
|
|
|
|
|
(if (c-major-mode-is 'awk-mode)
|
|
|
|
|
(c-clear-char-properties (point-min) (point-max) 'c-awk-NL-prop))))
|
|
|
|
|
(setq c-buffer-is-cc-mode nil)))
|
2002-04-22 00:35:36 +00:00
|
|
|
|
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(defun c-init-language-vars-for (mode)
|
|
|
|
|
"Initialize the language variables for one of the language modes
|
|
|
|
|
directly supported by CC Mode. This can be used instead of the
|
|
|
|
|
`c-init-language-vars' macro if the language you want to use is one of
|
|
|
|
|
those, rather than a derived language defined through the language
|
|
|
|
|
variable system (see \"cc-langs.el\")."
|
|
|
|
|
(cond ((eq mode 'c-mode) (c-init-language-vars c-mode))
|
|
|
|
|
((eq mode 'c++-mode) (c-init-language-vars c++-mode))
|
|
|
|
|
((eq mode 'objc-mode) (c-init-language-vars objc-mode))
|
|
|
|
|
((eq mode 'java-mode) (c-init-language-vars java-mode))
|
|
|
|
|
((eq mode 'idl-mode) (c-init-language-vars idl-mode))
|
|
|
|
|
((eq mode 'pike-mode) (c-init-language-vars pike-mode))
|
|
|
|
|
((eq mode 'awk-mode) (c-init-language-vars awk-mode))
|
|
|
|
|
(t (error "Unsupported mode %s" mode))))
|
|
|
|
|
|
1997-08-09 18:31:43 +00:00
|
|
|
|
;;;###autoload
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(defun c-initialize-cc-mode (&optional new-style-init)
|
|
|
|
|
"Initialize CC Mode for use in the current buffer.
|
|
|
|
|
If the optional NEW-STYLE-INIT is nil or left out then all necessary
|
|
|
|
|
initialization to run CC Mode for the C language is done. Otherwise
|
2003-08-03 12:31:46 +00:00
|
|
|
|
only some basic setup is done, and a call to `c-init-language-vars' or
|
|
|
|
|
`c-init-language-vars-for' is necessary too (which gives more
|
|
|
|
|
control). See \"cc-mode.el\" for more info."
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
1997-08-11 22:11:27 +00:00
|
|
|
|
(setq c-buffer-is-cc-mode t)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
1999-02-08 16:53:18 +00:00
|
|
|
|
(let ((initprop 'cc-mode-is-initialized)
|
|
|
|
|
c-initialization-ok)
|
|
|
|
|
(unless (get 'c-initialize-cc-mode initprop)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
1999-12-12 18:24:19 +00:00
|
|
|
|
(put 'c-initialize-cc-mode initprop t)
|
|
|
|
|
(c-initialize-builtin-style)
|
1999-02-08 16:53:18 +00:00
|
|
|
|
(run-hooks 'c-initialization-hook)
|
1999-12-12 18:24:19 +00:00
|
|
|
|
;; Fix obsolete variables.
|
|
|
|
|
(if (boundp 'c-comment-continuation-stars)
|
2014-10-04 00:03:49 -04:00
|
|
|
|
(setq c-block-comment-prefix c-comment-continuation-stars))
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode)
|
2014-02-17 18:16:32 +00:00
|
|
|
|
(setq c-initialization-ok t)
|
|
|
|
|
;; Connect up with Emacs's electric-indent-mode, for >= Emacs 24.4
|
2014-03-03 23:03:34 -05:00
|
|
|
|
(when (fboundp 'electric-indent-local-mode)
|
2014-02-17 18:16:32 +00:00
|
|
|
|
(add-hook 'electric-indent-mode-hook 'c-electric-indent-mode-hook)
|
2014-03-03 23:03:34 -05:00
|
|
|
|
(add-hook 'electric-indent-local-mode-hook
|
|
|
|
|
'c-electric-indent-local-mode-hook)))
|
1999-02-08 16:53:18 +00:00
|
|
|
|
;; Will try initialization hooks again if they failed.
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(put 'c-initialize-cc-mode initprop c-initialization-ok))))
|
|
|
|
|
|
|
|
|
|
(unless new-style-init
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'c-mode)))
|
1997-07-18 02:16:22 +00:00
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;;; Common routines.
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(defvar c-mode-base-map ()
|
|
|
|
|
"Keymap shared by all CC Mode related modes.")
|
|
|
|
|
|
|
|
|
|
(defun c-make-inherited-keymap ()
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2017-07-12 17:03:35 +00:00
|
|
|
|
(c-set-keymap-parent map c-mode-base-map)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
map))
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defun c-define-abbrev-table (name defs &optional doc)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
;; Compatibility wrapper for `define-abbrev' which passes a non-nil
|
|
|
|
|
;; sixth argument for SYSTEM-FLAG in emacsen that support it
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; (currently only Emacs >= 21.2).
|
2013-08-28 19:31:06 -04:00
|
|
|
|
(let ((table (or (and (boundp name) (symbol-value name))
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(progn (condition-case nil
|
|
|
|
|
(define-abbrev-table name nil doc)
|
|
|
|
|
(wrong-number-of-arguments ;E.g. Emacs<23.
|
|
|
|
|
(eval `(defvar ,name nil ,doc))
|
|
|
|
|
(define-abbrev-table name nil)))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(symbol-value name)))))
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(while defs
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(apply 'define-abbrev table (append (car defs) '(t)))
|
|
|
|
|
(wrong-number-of-arguments
|
|
|
|
|
(apply 'define-abbrev table (car defs))))
|
|
|
|
|
(setq defs (cdr defs)))))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(put 'c-define-abbrev-table 'lisp-indent-function 1)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(defun c-bind-special-erase-keys ()
|
|
|
|
|
;; Only used in Emacs to bind C-c C-<delete> and C-c C-<backspace>
|
|
|
|
|
;; to the proper keys depending on `normal-erase-is-backspace'.
|
|
|
|
|
(if normal-erase-is-backspace
|
|
|
|
|
(progn
|
|
|
|
|
(define-key c-mode-base-map (kbd "C-c C-<delete>")
|
|
|
|
|
'c-hungry-delete-forward)
|
|
|
|
|
(define-key c-mode-base-map (kbd "C-c C-<backspace>")
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
'c-hungry-delete-backwards))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map (kbd "C-c C-<delete>")
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
'c-hungry-delete-backwards)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map (kbd "C-c C-<backspace>")
|
|
|
|
|
'c-hungry-delete-forward)))
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(if c-mode-base-map
|
|
|
|
|
nil
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(setq c-mode-base-map (make-sparse-keymap))
|
2017-07-12 17:42:12 +00:00
|
|
|
|
(when (boundp 'prog-mode-map)
|
|
|
|
|
(c-set-keymap-parent c-mode-base-map prog-mode-map))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Separate M-BS from C-M-h. The former should remain
|
|
|
|
|
;; backward-kill-word.
|
|
|
|
|
(define-key c-mode-base-map [(control meta h)] 'c-mark-function)
|
|
|
|
|
(define-key c-mode-base-map "\e\C-q" 'c-indent-exp)
|
|
|
|
|
(substitute-key-definition 'backward-sentence
|
|
|
|
|
'c-beginning-of-statement
|
|
|
|
|
c-mode-base-map global-map)
|
|
|
|
|
(substitute-key-definition 'forward-sentence
|
|
|
|
|
'c-end-of-statement
|
|
|
|
|
c-mode-base-map global-map)
|
|
|
|
|
(substitute-key-definition 'indent-new-comment-line
|
|
|
|
|
'c-indent-new-comment-line
|
|
|
|
|
c-mode-base-map global-map)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(substitute-key-definition 'indent-for-tab-command
|
2007-09-24 17:48:50 +00:00
|
|
|
|
;; XXX Is this the right thing to do
|
|
|
|
|
;; here?
|
|
|
|
|
'c-indent-line-or-region
|
2005-12-02 12:30:36 +00:00
|
|
|
|
c-mode-base-map global-map)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(when (fboundp 'comment-indent-new-line)
|
|
|
|
|
;; indent-new-comment-line has changed name to
|
|
|
|
|
;; comment-indent-new-line in Emacs 21.
|
|
|
|
|
(substitute-key-definition 'comment-indent-new-line
|
|
|
|
|
'c-indent-new-comment-line
|
|
|
|
|
c-mode-base-map global-map))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; RMS says don't make these the default.
|
2007-01-01 22:11:28 +00:00
|
|
|
|
;; (April 2006): RMS has now approved these commands as defaults.
|
2008-06-27 21:12:46 +00:00
|
|
|
|
(unless (memq 'argumentative-bod-function c-emacs-features)
|
|
|
|
|
(define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun)
|
|
|
|
|
(define-key c-mode-base-map "\e\C-e" 'c-end-of-defun))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional)
|
|
|
|
|
(define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional)
|
|
|
|
|
(define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
;; It doesn't suffice to put `c-fill-paragraph' on
|
|
|
|
|
;; `fill-paragraph-function' since `c-fill-paragraph' must be called
|
|
|
|
|
;; before any fill prefix adaption is done. E.g. `filladapt-mode'
|
|
|
|
|
;; replaces `fill-paragraph' and does the adaption before calling
|
|
|
|
|
;; `fill-paragraph-function', and we have to mask comments etc
|
|
|
|
|
;; before that. Also, `c-fill-paragraph' chains on to
|
2011-11-19 18:29:42 -08:00
|
|
|
|
;; `fill-paragraph' and the value on `fill-paragraph-function' to
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; do the actual filling work.
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(substitute-key-definition 'fill-paragraph 'c-fill-paragraph
|
|
|
|
|
c-mode-base-map global-map)
|
|
|
|
|
;; In XEmacs the default fill function is called
|
|
|
|
|
;; fill-paragraph-or-region.
|
|
|
|
|
(substitute-key-definition 'fill-paragraph-or-region 'c-fill-paragraph
|
|
|
|
|
c-mode-base-map global-map)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; We bind the forward deletion key and (implicitly) C-d to
|
|
|
|
|
;; `c-electric-delete-forward', and the backward deletion key to
|
|
|
|
|
;; `c-electric-backspace'. The hungry variants are bound to the
|
|
|
|
|
;; same keys but prefixed with C-c. This implies that C-c C-d is
|
|
|
|
|
;; `c-hungry-delete-forward'. For consistency, we bind not only C-c
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
;; <backspace> to `c-hungry-delete-backwards' but also
|
|
|
|
|
;; C-c C-<backspace>, so that the Ctrl key can be held down during
|
|
|
|
|
;; the whole sequence regardless of the direction. This in turn
|
|
|
|
|
;; implies that we bind C-c C-<delete> to `c-hungry-delete-forward',
|
|
|
|
|
;; for the same reason.
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
2001-05-04 10:02:56 +00:00
|
|
|
|
;; Bind the electric deletion functions to C-d and DEL. Emacs 21
|
|
|
|
|
;; automatically maps the [delete] and [backspace] keys to these two
|
|
|
|
|
;; depending on window system and user preferences. (In earlier
|
|
|
|
|
;; versions it's possible to do the same by using `function-key-map'.)
|
|
|
|
|
(define-key c-mode-base-map "\C-d" 'c-electric-delete-forward)
|
|
|
|
|
(define-key c-mode-base-map "\177" 'c-electric-backspace)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-d" 'c-hungry-delete-forward)
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
(define-key c-mode-base-map [?\C-c ?\d] 'c-hungry-delete-backwards)
|
|
|
|
|
(define-key c-mode-base-map [?\C-c ?\C-\d] 'c-hungry-delete-backwards)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map [?\C-c deletechar] 'c-hungry-delete-forward) ; C-c <delete> on a tty.
|
|
|
|
|
(define-key c-mode-base-map [?\C-c (control deletechar)] ; C-c C-<delete> on a tty.
|
|
|
|
|
'c-hungry-delete-forward)
|
|
|
|
|
(when (boundp 'normal-erase-is-backspace)
|
|
|
|
|
;; The automatic C-d and DEL mapping functionality doesn't extend
|
|
|
|
|
;; to special combinations like C-c C-<delete>, so we have to hook
|
|
|
|
|
;; into the `normal-erase-is-backspace' system to bind it directly
|
|
|
|
|
;; as appropriate.
|
|
|
|
|
(add-hook 'normal-erase-is-backspace-hook 'c-bind-special-erase-keys)
|
|
|
|
|
(c-bind-special-erase-keys))
|
|
|
|
|
|
|
|
|
|
(when (fboundp 'delete-forward-p)
|
|
|
|
|
;; In XEmacs we fix the forward and backward deletion behavior by
|
|
|
|
|
;; binding the keysyms for the [delete] and [backspace] keys
|
|
|
|
|
;; directly, and use `delete-forward-p' to decide what [delete]
|
|
|
|
|
;; should do. That's done in the XEmacs specific
|
|
|
|
|
;; `c-electric-delete' and `c-hungry-delete' functions.
|
2001-05-04 10:02:56 +00:00
|
|
|
|
(define-key c-mode-base-map [delete] 'c-electric-delete)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map [backspace] 'c-electric-backspace)
|
|
|
|
|
(define-key c-mode-base-map (kbd "C-c <delete>") 'c-hungry-delete)
|
|
|
|
|
(define-key c-mode-base-map (kbd "C-c C-<delete>") 'c-hungry-delete)
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
(define-key c-mode-base-map (kbd "C-c <backspace>")
|
|
|
|
|
'c-hungry-delete-backwards)
|
|
|
|
|
(define-key c-mode-base-map (kbd "C-c C-<backspace>")
|
|
|
|
|
'c-hungry-delete-backwards))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
|
|
|
|
(define-key c-mode-base-map "#" 'c-electric-pound)
|
|
|
|
|
(define-key c-mode-base-map "{" 'c-electric-brace)
|
|
|
|
|
(define-key c-mode-base-map "}" 'c-electric-brace)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(define-key c-mode-base-map "/" 'c-electric-slash)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map "*" 'c-electric-star)
|
|
|
|
|
(define-key c-mode-base-map ";" 'c-electric-semi&comma)
|
|
|
|
|
(define-key c-mode-base-map "," 'c-electric-semi&comma)
|
|
|
|
|
(define-key c-mode-base-map ":" 'c-electric-colon)
|
|
|
|
|
(define-key c-mode-base-map "(" 'c-electric-paren)
|
|
|
|
|
(define-key c-mode-base-map ")" 'c-electric-paren)
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-newline)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report)
|
|
|
|
|
(define-key c-mode-base-map "\C-c\C-c" 'comment-region)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-l" 'c-toggle-electric-state)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-o" 'c-set-offset)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state) Commented out by ACM, 2005-03-05.
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c." 'c-set-style)
|
|
|
|
|
;; conflicts with OOBR
|
|
|
|
|
;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; (define-key c-mode-base-map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22.
|
2014-12-18 11:18:21 -05:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-w" 'c-subword-mode)
|
2017-06-15 20:47:11 +00:00
|
|
|
|
(define-key c-mode-base-map "\C-c\C-k" 'c-toggle-comment-style))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
;; We don't require the outline package, but we configure it a bit anyway.
|
|
|
|
|
(cc-bytecomp-defvar outline-level)
|
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(defun c-mode-menu (modestr)
|
|
|
|
|
"Return a menu spec suitable for `easy-menu-define' that is exactly
|
|
|
|
|
like the C mode menu except that the menu bar item name is MODESTR
|
|
|
|
|
instead of \"C\".
|
|
|
|
|
|
|
|
|
|
This function is provided for compatibility only; derived modes should
|
|
|
|
|
preferably use the `c-mode-menu' language constant directly."
|
|
|
|
|
(cons modestr (c-lang-const c-mode-menu c)))
|
|
|
|
|
|
|
|
|
|
;; Ugly hack to pull in the definition of `c-populate-syntax-table'
|
|
|
|
|
;; from cc-langs to make it available at runtime. It's either this or
|
|
|
|
|
;; moving the definition for it to cc-defs, but that would mean to
|
|
|
|
|
;; break up the syntax table setup over two files.
|
|
|
|
|
(defalias 'c-populate-syntax-table
|
|
|
|
|
(cc-eval-when-compile
|
|
|
|
|
(let ((f (symbol-function 'c-populate-syntax-table)))
|
|
|
|
|
(if (byte-code-function-p f) f (byte-compile f)))))
|
|
|
|
|
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; CAUTION: Try to avoid installing things on
|
|
|
|
|
;; `before-change-functions'. The macro `combine-after-change-calls'
|
|
|
|
|
;; is used and it doesn't work if there are things on that hook. That
|
|
|
|
|
;; can cause font lock functions to run in inconvenient places during
|
|
|
|
|
;; temporary changes in some font lock support modes, causing extra
|
|
|
|
|
;; unnecessary work and font lock glitches due to interactions between
|
|
|
|
|
;; various text properties.
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2007-03-08 21:50:51 +00:00
|
|
|
|
;; (2007-02-12): The macro `combine-after-change-calls' ISN'T used any
|
|
|
|
|
;; more.
|
|
|
|
|
|
|
|
|
|
(defun c-unfind-enclosing-token (pos)
|
|
|
|
|
;; If POS is wholly inside a token, remove that id from
|
|
|
|
|
;; `c-found-types', should it be present. Return t if we were in an
|
|
|
|
|
;; id, else nil.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((tok-beg (progn (goto-char pos)
|
|
|
|
|
(and (c-beginning-of-current-token) (point))))
|
|
|
|
|
(tok-end (progn (goto-char pos)
|
|
|
|
|
(and (c-end-of-current-token) (point)))))
|
|
|
|
|
(when (and tok-beg tok-end)
|
|
|
|
|
(c-unfind-type (buffer-substring-no-properties tok-beg tok-end))
|
|
|
|
|
t))))
|
|
|
|
|
|
|
|
|
|
(defun c-unfind-coalesced-tokens (beg end)
|
2017-07-13 19:56:00 +00:00
|
|
|
|
;; If removing the region (beg end) would coalesce an identifier ending at
|
|
|
|
|
;; beg with an identifier (fragment) beginning at end, or an identifier
|
|
|
|
|
;; fragment ending at beg with an identifier beginning at end, remove the
|
|
|
|
|
;; pertinent identifier(s) from `c-found-types'.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(when (< beg end)
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(when
|
|
|
|
|
(and (not (bobp))
|
|
|
|
|
(progn (c-backward-syntactic-ws) (eq (point) beg))
|
|
|
|
|
(/= (skip-chars-backward c-symbol-chars (1- (point))) 0)
|
|
|
|
|
(progn (goto-char beg) (c-forward-syntactic-ws) (<= (point) end))
|
|
|
|
|
(> (point) beg)
|
|
|
|
|
(goto-char end)
|
|
|
|
|
(looking-at c-symbol-char-key))
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(c-simple-skip-symbol-backward)
|
|
|
|
|
(c-unfind-type (buffer-substring-no-properties (point) beg)))
|
|
|
|
|
|
|
|
|
|
(goto-char end)
|
|
|
|
|
(when
|
|
|
|
|
(and (not (eobp))
|
|
|
|
|
(progn (c-forward-syntactic-ws) (eq (point) end))
|
|
|
|
|
(looking-at c-symbol-char-key)
|
|
|
|
|
(progn (c-backward-syntactic-ws) (>= (point) beg))
|
|
|
|
|
(< (point) end)
|
|
|
|
|
(/= (skip-chars-backward c-symbol-chars (1- (point))) 0))
|
|
|
|
|
(goto-char (1+ end))
|
|
|
|
|
(c-end-of-current-token)
|
|
|
|
|
(c-unfind-type (buffer-substring-no-properties end (point)))))))
|
2007-03-08 21:50:51 +00:00
|
|
|
|
|
|
|
|
|
;; c-maybe-stale-found-type records a place near the region being
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;; changed where an element of `found-types' might become stale. It
|
2007-03-08 21:50:51 +00:00
|
|
|
|
;; is set in c-before-change and is either nil, or has the form:
|
|
|
|
|
;;
|
|
|
|
|
;; (c-decl-id-start "foo" 97 107 " (* ooka) " "o"), where
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2007-03-08 21:50:51 +00:00
|
|
|
|
;; o - `c-decl-id-start' is the c-type text property value at buffer
|
|
|
|
|
;; pos 96.
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2007-03-08 21:50:51 +00:00
|
|
|
|
;; o - 97 107 is the region potentially containing the stale type -
|
|
|
|
|
;; this is delimited by a non-nil c-type text property at 96 and
|
|
|
|
|
;; either another one or a ";", "{", or "}" at 107.
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2007-03-08 21:50:51 +00:00
|
|
|
|
;; o - " (* ooka) " is the (before change) buffer portion containing
|
|
|
|
|
;; the suspect type (here "ooka").
|
|
|
|
|
;;
|
|
|
|
|
;; o - "o" is the buffer contents which is about to be deleted. This
|
|
|
|
|
;; would be the empty string for an insertion.
|
|
|
|
|
(defvar c-maybe-stale-found-type nil)
|
|
|
|
|
(make-variable-buffer-local 'c-maybe-stale-found-type)
|
|
|
|
|
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(defvar c-just-done-before-change nil)
|
|
|
|
|
(make-variable-buffer-local 'c-just-done-before-change)
|
|
|
|
|
;; This variable is set to t by `c-before-change' and to nil by
|
2016-08-09 16:09:18 +00:00
|
|
|
|
;; `c-after-change'. It is used for two purposes: (i) to detect a spurious
|
|
|
|
|
;; invocation of `before-change-functions' directly following on from a
|
|
|
|
|
;; correct one. This happens in some Emacsen, for example when
|
|
|
|
|
;; `basic-save-buffer' does (insert ?\n) when `require-final-newline' is
|
|
|
|
|
;; non-nil; (ii) to detect when Emacs fails to invoke
|
2016-08-21 04:17:30 -07:00
|
|
|
|
;; `before-change-functions'. This can happen when reverting a buffer - see
|
2016-08-09 16:09:18 +00:00
|
|
|
|
;; bug #24094. It seems these failures happen only in GNU Emacs; XEmacs
|
|
|
|
|
;; seems to maintain the strict alternation of calls to
|
|
|
|
|
;; `before-change-functions' and `after-change-functions'.
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(defun c-basic-common-init (mode default-style)
|
|
|
|
|
"Do the necessary initialization for the syntax handling routines
|
|
|
|
|
and the line breaking/filling code. Intended to be used by other
|
|
|
|
|
packages that embed CC Mode.
|
|
|
|
|
|
2015-11-17 15:28:50 -08:00
|
|
|
|
MODE is the CC Mode flavor to set up, e.g. `c-mode' or `java-mode'.
|
2003-07-03 12:30:59 +00:00
|
|
|
|
DEFAULT-STYLE tells which indentation style to install. It has the
|
|
|
|
|
same format as `c-default-style'.
|
|
|
|
|
|
|
|
|
|
Note that `c-init-language-vars' must be called before this function.
|
|
|
|
|
This function cannot do that since `c-init-language-vars' is a macro
|
|
|
|
|
that requires a literal mode spec at compile time."
|
|
|
|
|
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(setq c-buffer-is-cc-mode mode)
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; these variables should always be buffer local; they do not affect
|
|
|
|
|
;; indentation style.
|
|
|
|
|
(make-local-variable 'comment-start)
|
|
|
|
|
(make-local-variable 'comment-end)
|
|
|
|
|
(make-local-variable 'comment-start-skip)
|
2011-11-15 01:54:19 +01:00
|
|
|
|
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(make-local-variable 'paragraph-start)
|
|
|
|
|
(make-local-variable 'paragraph-separate)
|
|
|
|
|
(make-local-variable 'paragraph-ignore-fill-prefix)
|
|
|
|
|
(make-local-variable 'adaptive-fill-mode)
|
|
|
|
|
(make-local-variable 'adaptive-fill-regexp)
|
2012-01-13 10:59:27 +00:00
|
|
|
|
(make-local-variable 'fill-paragraph-handle-comment)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; now set their values
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(set (make-local-variable 'parse-sexp-ignore-comments) t)
|
|
|
|
|
(set (make-local-variable 'indent-line-function) 'c-indent-line)
|
|
|
|
|
(set (make-local-variable 'indent-region-function) 'c-indent-region)
|
|
|
|
|
(set (make-local-variable 'normal-auto-fill-function) 'c-do-auto-fill)
|
|
|
|
|
(set (make-local-variable 'comment-multi-line) t)
|
|
|
|
|
(set (make-local-variable 'comment-line-break-function)
|
|
|
|
|
'c-indent-new-comment-line)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
|
2015-04-21 14:02:10 +00:00
|
|
|
|
;; Prevent time-wasting activity on C-y.
|
|
|
|
|
(when (boundp 'yank-handled-properties)
|
|
|
|
|
(make-local-variable 'yank-handled-properties)
|
|
|
|
|
(let ((yank-cat-handler (assq 'category yank-handled-properties)))
|
|
|
|
|
(when yank-cat-handler
|
|
|
|
|
(setq yank-handled-properties (remq yank-cat-handler
|
|
|
|
|
yank-handled-properties)))))
|
|
|
|
|
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; For the benefit of adaptive fill, which otherwise mis-fills.
|
2012-01-13 10:59:27 +00:00
|
|
|
|
(setq fill-paragraph-handle-comment nil)
|
|
|
|
|
|
2003-02-09 01:46:04 +00:00
|
|
|
|
;; Install `c-fill-paragraph' on `fill-paragraph-function' so that a
|
|
|
|
|
;; direct call to `fill-paragraph' behaves better. This still
|
|
|
|
|
;; doesn't work with filladapt but it's better than nothing.
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(set (make-local-variable 'fill-paragraph-function) 'c-fill-paragraph)
|
2003-02-09 01:46:04 +00:00
|
|
|
|
|
2011-11-19 18:29:42 -08:00
|
|
|
|
;; Initialize the cache of brace pairs, and opening braces/brackets/parens.
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
(c-state-cache-init)
|
Correctly fontify C++ direct initializations with parens inside functions
Or, more clearly, when something looks like a function declaration and it's
inside a function, fontify it as a direct initialization.
For this purpose, introduce a "brace stack" for each buffer, where an entry on
the brace stack states how deeply nested a particular position is inside
braces inside a "top level", which includes classes and namespaces.
Also introduce a new "context", "top", with which c-font-lock-declarations
signals to c-forward-decl-or-cast-1 that point is at the top level.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): add
c-truncate-bs-cache.
(c-flat-decl-block-kwds, c-brace-stack-thing-key, c-brace-stack-no-semi-key)
(c-type-decl-operator-prefix-key): new language constants/variables.
* lisp/progmodes/cc-engine.el (c-bs-interval, c-bs-cache, c-bs-cache-limit)
(c-bs-prev-pos, c-bs-prev-stack): New mostly local variables for the brace
stack cache.
(c-init-bs-cache, c-truncate-bs-cache, c-truncate-bs-cache, c-brace-stack-at)
(c-bs-at-toplevel-p): New functions which manipulate the brace stack (cache).
(c-find-decl-prefix-search): Keep track of whether we're at top level.
(c-find-decl-spots): New local variable cfd-top-level which records what it
says. On calling cfd-fun, pass cfd-top-level as an additional argument.
(c-forward-declarator): Add new element DECORATED to the result list. Set it
to non-nil when a match for c-type-decl-operator-prefix-key is found.
(c-forward-decl-or-cast-1): Handle the newly introduced context "top".
Introduce "CASE 9.5", which recognizes direct initializations.
* lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare)
(c-font-lock-enum-tail, c-font-lock-cut-off-declarators)
(c-font-lock-enclosing-decls, c-simple-decl-matchers, c-basic-matchers-after):
Add appropriate `not-top' argument to calls to c-font-lock-declarators.
(c-font-lock-declarators): Additional parameter `not-top'. Use not-top to
participate in the decision whether to fontify an identifier as a function or
a variable.
(c-font-lock-declarations): The internal lambda function takes an additional
argument `toplev' from c-find-decl-spots, which it uses in determining the
"context" of a declaration. Add appropriate `not-top' argument to calls to
c-font-lock-declarators.
(c-font-lock-objc-methods): Add extra parameter to internal lambda function,
like for c-font-lock-declarators.
* lisp/progmodes/cc-mode.el (c-basic-common-init): Initialize the brace stack
cache.
2016-09-11 21:09:08 +00:00
|
|
|
|
;; Initialize the "brace stack" cache.
|
|
|
|
|
(c-init-bs-cache)
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(when (or c-recognize-<>-arglists
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(c-major-mode-is 'awk-mode)
|
2010-07-31 20:01:08 +00:00
|
|
|
|
(c-major-mode-is '(java-mode c-mode c++-mode objc-mode)))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; We'll use the syntax-table text property to change the syntax
|
|
|
|
|
;; of some chars for this language, so do the necessary setup for
|
|
|
|
|
;; that.
|
|
|
|
|
;;
|
|
|
|
|
;; Note to other package developers: It's ok to turn this on in CC
|
|
|
|
|
;; Mode buffers when CC Mode doesn't, but it's not ok to turn it
|
|
|
|
|
;; off if CC Mode has turned it on.
|
|
|
|
|
|
|
|
|
|
;; Emacs.
|
|
|
|
|
(when (boundp 'parse-sexp-lookup-properties)
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(set (make-local-variable 'parse-sexp-lookup-properties) t))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
|
|
|
|
;; Same as above for XEmacs.
|
|
|
|
|
(when (boundp 'lookup-syntax-properties)
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(set (make-local-variable 'lookup-syntax-properties) t)))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
2009-12-10 14:29:11 +00:00
|
|
|
|
;; Use this in Emacs 21+ to avoid meddling with the rear-nonsticky
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; property on each character.
|
|
|
|
|
(when (boundp 'text-property-default-nonsticky)
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(make-local-variable 'text-property-default-nonsticky)
|
2009-12-10 14:29:11 +00:00
|
|
|
|
(mapc (lambda (tprop)
|
|
|
|
|
(unless (assq tprop text-property-default-nonsticky)
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(setq text-property-default-nonsticky
|
|
|
|
|
(cons `(,tprop . t) text-property-default-nonsticky))))
|
2009-12-10 14:29:11 +00:00
|
|
|
|
'(syntax-table category c-type)))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
;; In Emacs 21 and later it's possible to turn off the ad-hoc
|
|
|
|
|
;; heuristic that open parens in column 0 are defun starters. Since
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; we have c-state-cache, that heuristic isn't useful and only causes
|
|
|
|
|
;; trouble, so turn it off.
|
2014-09-10 21:38:11 +00:00
|
|
|
|
;; 2006/12/17: This facility is somewhat confused, and doesn't really seem
|
|
|
|
|
;; helpful. Comment it out for now.
|
|
|
|
|
;; (when (memq 'col-0-paren c-emacs-features)
|
|
|
|
|
;; (make-local-variable 'open-paren-in-column-0-is-defun-start)
|
|
|
|
|
;; (setq open-paren-in-column-0-is-defun-start nil))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
(c-clear-found-types)
|
|
|
|
|
|
|
|
|
|
;; now set the mode style based on default-style
|
2011-06-30 20:45:12 +00:00
|
|
|
|
(let ((style (cc-choose-style-for-mode mode default-style)))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Override style variables if `c-old-style-variable-behavior' is
|
|
|
|
|
;; set. Also override if we are using global style variables,
|
|
|
|
|
;; have already initialized a style once, and are switching to a
|
|
|
|
|
;; different style. (It's doubtful whether this is desirable, but
|
|
|
|
|
;; the whole situation with nonlocal style variables is a bit
|
|
|
|
|
;; awkward. It's at least the most compatible way with the old
|
|
|
|
|
;; style init procedure.)
|
|
|
|
|
(c-set-style style (not (or c-old-style-variable-behavior
|
|
|
|
|
(and (not c-style-variables-are-local-p)
|
|
|
|
|
c-indentation-style
|
|
|
|
|
(not (string-equal c-indentation-style
|
|
|
|
|
style)))))))
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-setup-paragraph-variables)
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; we have to do something special for c-offsets-alist so that the
|
|
|
|
|
;; buffer local value has its own alist structure.
|
|
|
|
|
(setq c-offsets-alist (copy-alist c-offsets-alist))
|
2002-04-22 00:35:36 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; setup the comment indent variable in a Emacs version portable way
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(set (make-local-variable 'comment-indent-function) 'c-comment-indent)
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; What sort of comments are default for M-;?
|
|
|
|
|
(setq c-block-comment-flag c-block-comment-is-default)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
|
2014-02-17 18:16:32 +00:00
|
|
|
|
;; In Emacs 24.4 onwards, prevent Emacs's built in electric indentation from
|
|
|
|
|
;; messing up CC Mode's, and set `c-electric-flag' if `electric-indent-mode'
|
|
|
|
|
;; has been called by the user.
|
|
|
|
|
(when (boundp 'electric-indent-inhibit) (setq electric-indent-inhibit t))
|
2014-03-03 23:03:34 -05:00
|
|
|
|
;; CC-mode should obey Emacs's generic preferences, tho only do it if
|
|
|
|
|
;; Emacs's generic preferences can be set per-buffer (Emacs>=24.4).
|
|
|
|
|
(when (fboundp 'electric-indent-local-mode)
|
2014-02-17 18:16:32 +00:00
|
|
|
|
(setq c-electric-flag electric-indent-mode))
|
|
|
|
|
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
;; ;; Put submode indicators onto minor-mode-alist, but only once.
|
|
|
|
|
;; (or (assq 'c-submode-indicators minor-mode-alist)
|
|
|
|
|
;; (setq minor-mode-alist
|
|
|
|
|
;; (cons '(c-submode-indicators c-submode-indicators)
|
|
|
|
|
;; minor-mode-alist)))
|
|
|
|
|
(c-update-modeline)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; Install the functions that ensure that various internal caches
|
|
|
|
|
;; don't become invalid due to buffer changes.
|
2010-10-02 18:53:04 -07:00
|
|
|
|
(when (featurep 'xemacs)
|
|
|
|
|
(make-local-hook 'before-change-functions)
|
|
|
|
|
(make-local-hook 'after-change-functions))
|
2007-03-08 21:50:51 +00:00
|
|
|
|
(add-hook 'before-change-functions 'c-before-change nil t)
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(setq c-just-done-before-change nil)
|
2008-04-06 21:13:11 +00:00
|
|
|
|
(add-hook 'after-change-functions 'c-after-change nil t)
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(when (boundp 'font-lock-extend-after-change-region-function)
|
|
|
|
|
(set (make-local-variable 'font-lock-extend-after-change-region-function)
|
|
|
|
|
'c-extend-after-change-region))) ; Currently (2009-05) used by all
|
|
|
|
|
; languages with #define (C, C++,; ObjC), and by AWK.
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
(defun c-setup-doc-comment-style ()
|
|
|
|
|
"Initialize the variables that depend on the value of `c-doc-comment-style'."
|
|
|
|
|
(when (and (featurep 'font-lock)
|
|
|
|
|
(symbol-value 'font-lock-mode))
|
|
|
|
|
;; Force font lock mode to reinitialize itself.
|
|
|
|
|
(font-lock-mode 0)
|
|
|
|
|
(font-lock-mode 1)))
|
|
|
|
|
|
2010-08-16 23:54:03 -07:00
|
|
|
|
;; Buffer local variables defining the region to be fontified by a font lock
|
2016-01-04 22:29:33 +00:00
|
|
|
|
;; after-change function. They are initialized in c-before-change to
|
|
|
|
|
;; before-change-functions' BEG and END. `c-new-END' is amended in
|
|
|
|
|
;; c-after-change with after-change-functions' BEG, END, and OLD-LEN. These
|
|
|
|
|
;; variables may be modified by any before/after-change function, in
|
|
|
|
|
;; particular by functions in `c-get-state-before-change-functions' and
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;; `c-before-font-lock-functions'.
|
2010-08-16 23:54:03 -07:00
|
|
|
|
(defvar c-new-BEG 0)
|
|
|
|
|
(make-variable-buffer-local 'c-new-BEG)
|
|
|
|
|
(defvar c-new-END 0)
|
|
|
|
|
(make-variable-buffer-local 'c-new-END)
|
2016-06-09 12:24:27 +00:00
|
|
|
|
;; The following two variables record the values of `c-new-BEG' and
|
|
|
|
|
;; `c-new-END' just after `c-new-END' has been adjusted for the length of text
|
|
|
|
|
;; inserted or removed. They may be read by any after-change function (but
|
|
|
|
|
;; should not be altered by one).
|
|
|
|
|
(defvar c-old-BEG 0)
|
|
|
|
|
(make-variable-buffer-local 'c-old-BEG)
|
|
|
|
|
(defvar c-old-END 0)
|
|
|
|
|
(make-variable-buffer-local 'c-old-END)
|
2010-08-16 23:54:03 -07:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(defun c-common-init (&optional mode)
|
|
|
|
|
"Common initialization for all CC Mode modes.
|
|
|
|
|
In addition to the work done by `c-basic-common-init' and
|
|
|
|
|
`c-font-lock-init', this function sets up various other things as
|
|
|
|
|
customary in CC Mode modes but which aren't strictly necessary for CC
|
|
|
|
|
Mode to operate correctly.
|
|
|
|
|
|
2015-11-17 15:28:50 -08:00
|
|
|
|
MODE is the symbol for the mode to initialize, like `c-mode'. See
|
2003-07-03 12:30:59 +00:00
|
|
|
|
`c-basic-common-init' for details. It's only optional to be
|
2005-12-02 12:30:36 +00:00
|
|
|
|
compatible with old code; callers should always specify it."
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
(unless mode
|
|
|
|
|
;; Called from an old third party package. The fallback is to
|
|
|
|
|
;; initialize for C.
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'c-mode))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
(c-basic-common-init mode c-default-style)
|
|
|
|
|
(when mode
|
|
|
|
|
;; Only initialize font locking if we aren't called from an old package.
|
|
|
|
|
(c-font-lock-init))
|
|
|
|
|
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;; Starting a mode is a sort of "change". So call the change functions...
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
2010-06-21 21:08:26 +00:00
|
|
|
|
(setq c-new-BEG (point-min))
|
|
|
|
|
(setq c-new-END (point-max))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(save-excursion
|
2015-04-06 22:20:16 +00:00
|
|
|
|
(let (before-change-functions after-change-functions)
|
|
|
|
|
(mapc (lambda (fn)
|
|
|
|
|
(funcall fn (point-min) (point-max)))
|
|
|
|
|
c-get-state-before-change-functions)
|
|
|
|
|
(mapc (lambda (fn)
|
2016-04-25 17:08:26 +00:00
|
|
|
|
(funcall fn (point-min) (point-max)
|
|
|
|
|
(- (point-max) (point-min))))
|
2015-04-06 22:20:16 +00:00
|
|
|
|
c-before-font-lock-functions))))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(set (make-local-variable 'outline-regexp) "[^#\n\^M]")
|
|
|
|
|
(set (make-local-variable 'outline-level) 'c-outline-level)
|
2012-12-01 12:57:07 +08:00
|
|
|
|
(set (make-local-variable 'add-log-current-defun-function)
|
|
|
|
|
(lambda ()
|
|
|
|
|
(or (c-cpp-define-name) (c-defun-name))))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(let ((rfn (assq mode c-require-final-newline)))
|
|
|
|
|
(when rfn
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(if (boundp 'mode-require-final-newline)
|
|
|
|
|
(and (cdr rfn)
|
|
|
|
|
(set (make-local-variable 'require-final-newline)
|
|
|
|
|
mode-require-final-newline))
|
|
|
|
|
(set (make-local-variable 'require-final-newline) (cdr rfn))))))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
2010-07-18 20:28:00 +00:00
|
|
|
|
(defun c-count-cfss (lv-alist)
|
|
|
|
|
;; LV-ALIST is an alist like `file-local-variables-alist'. Count how many
|
|
|
|
|
;; elements with the key `c-file-style' there are in it.
|
|
|
|
|
(let ((elt-ptr lv-alist) elt (cownt 0))
|
|
|
|
|
(while elt-ptr
|
|
|
|
|
(setq elt (car elt-ptr)
|
|
|
|
|
elt-ptr (cdr elt-ptr))
|
|
|
|
|
(when (eq (car elt) 'c-file-style)
|
|
|
|
|
(setq cownt (1+ cownt))))
|
|
|
|
|
cownt))
|
2011-11-15 01:54:19 +01:00
|
|
|
|
|
2008-07-31 01:37:35 +00:00
|
|
|
|
(defun c-before-hack-hook ()
|
|
|
|
|
"Set the CC Mode style and \"offsets\" when in the buffer's local variables.
|
|
|
|
|
They are set only when, respectively, the pseudo variables
|
|
|
|
|
`c-file-style' and `c-file-offsets' are present in the list.
|
|
|
|
|
|
|
|
|
|
This function is called from the hook `before-hack-local-variables-hook'."
|
|
|
|
|
(when c-buffer-is-cc-mode
|
2010-06-20 16:17:05 +00:00
|
|
|
|
(let ((mode-cons (assq 'mode file-local-variables-alist))
|
|
|
|
|
(stile (cdr (assq 'c-file-style file-local-variables-alist)))
|
2008-07-31 01:37:35 +00:00
|
|
|
|
(offsets (cdr (assq 'c-file-offsets file-local-variables-alist))))
|
2010-06-20 16:17:05 +00:00
|
|
|
|
(when mode-cons
|
|
|
|
|
(hack-one-local-variable (car mode-cons) (cdr mode-cons))
|
|
|
|
|
(setq file-local-variables-alist
|
|
|
|
|
(delq mode-cons file-local-variables-alist)))
|
2008-07-31 01:37:35 +00:00
|
|
|
|
(when stile
|
|
|
|
|
(or (stringp stile) (error "c-file-style is not a string"))
|
2010-07-18 20:28:00 +00:00
|
|
|
|
(if (boundp 'dir-local-variables-alist)
|
|
|
|
|
;; Determine whether `c-file-style' was set in the file's local
|
|
|
|
|
;; variables or in a .dir-locals.el (a directory setting).
|
|
|
|
|
(let ((cfs-in-file-and-dir-count
|
|
|
|
|
(c-count-cfss file-local-variables-alist))
|
|
|
|
|
(cfs-in-dir-count (c-count-cfss dir-local-variables-alist)))
|
|
|
|
|
(c-set-style stile
|
2011-06-30 20:45:12 +00:00
|
|
|
|
(and (= cfs-in-file-and-dir-count cfs-in-dir-count)
|
|
|
|
|
'keep-defaults)))
|
2010-07-18 20:28:00 +00:00
|
|
|
|
(c-set-style stile)))
|
2008-07-31 01:37:35 +00:00
|
|
|
|
(when offsets
|
|
|
|
|
(mapc
|
|
|
|
|
(lambda (langentry)
|
|
|
|
|
(let ((langelem (car langentry))
|
|
|
|
|
(offset (cdr langentry)))
|
|
|
|
|
(c-set-offset langelem offset)))
|
|
|
|
|
offsets)))))
|
|
|
|
|
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
(defun c-remove-any-local-eval-or-mode-variables ()
|
|
|
|
|
;; If the buffer specifies `mode' or `eval' in its File Local Variable list
|
|
|
|
|
;; or on the first line, remove all occurrences. See
|
|
|
|
|
;; `c-postprocess-file-styles' for justification. There is no need to save
|
2007-06-20 08:27:53 +00:00
|
|
|
|
;; point here, or even bother too much about the buffer contents. However,
|
|
|
|
|
;; DON'T mess up the kill-ring.
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Most of the code here is derived from Emacs 21.3's `hack-local-variables'
|
|
|
|
|
;; in files.el.
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
|
|
|
|
|
(let (lv-point (prefix "") (suffix ""))
|
|
|
|
|
(when (let ((case-fold-search t))
|
|
|
|
|
(search-forward "Local Variables:" nil t))
|
|
|
|
|
(setq lv-point (point))
|
|
|
|
|
;; The prefix is what comes before "local variables:" in its line.
|
|
|
|
|
;; The suffix is what comes after "local variables:" in its line.
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(or (eolp)
|
|
|
|
|
(setq suffix (buffer-substring (point)
|
|
|
|
|
(progn (end-of-line) (point)))))
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(or (bolp)
|
|
|
|
|
(setq prefix
|
|
|
|
|
(buffer-substring (point)
|
|
|
|
|
(progn (beginning-of-line) (point)))))
|
|
|
|
|
|
|
|
|
|
(while (search-forward-regexp
|
|
|
|
|
(concat "^[ \t]*"
|
|
|
|
|
(regexp-quote prefix)
|
|
|
|
|
"\\(mode\\|eval\\):.*"
|
|
|
|
|
(regexp-quote suffix)
|
|
|
|
|
"$")
|
|
|
|
|
nil t)
|
2007-06-20 08:27:53 +00:00
|
|
|
|
(forward-line 0)
|
|
|
|
|
(delete-region (point) (progn (forward-line) (point)))))
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
|
|
|
|
|
;; Delete the first line, if we've got one, in case it contains a mode spec.
|
|
|
|
|
(unless (and lv-point
|
|
|
|
|
(progn (goto-char lv-point)
|
|
|
|
|
(forward-line 0)
|
|
|
|
|
(bobp)))
|
|
|
|
|
(goto-char (point-min))
|
2007-06-20 08:27:53 +00:00
|
|
|
|
(unless (eobp)
|
|
|
|
|
(delete-region (point) (progn (forward-line) (point)))))))
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(defun c-postprocess-file-styles ()
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Function that post processes relevant file local variables in CC Mode.
|
2001-03-21 12:59:36 +00:00
|
|
|
|
Currently, this function simply applies any style and offset settings
|
|
|
|
|
found in the file's Local Variable list. It first applies any style
|
|
|
|
|
setting found in `c-file-style', then it applies any offset settings
|
|
|
|
|
it finds in `c-file-offsets'.
|
|
|
|
|
|
|
|
|
|
Note that the style variables are always made local to the buffer."
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; apply file styles and offsets
|
2002-06-03 22:56:12 +00:00
|
|
|
|
(when c-buffer-is-cc-mode
|
|
|
|
|
(if (or c-file-style c-file-offsets)
|
|
|
|
|
(c-make-styles-buffer-local t))
|
2008-05-24 12:47:37 +00:00
|
|
|
|
(when c-file-style
|
|
|
|
|
(or (stringp c-file-style)
|
|
|
|
|
(error "c-file-style is not a string"))
|
2009-12-05 11:16:04 +00:00
|
|
|
|
(c-set-style c-file-style))
|
2008-05-24 12:31:59 +00:00
|
|
|
|
|
2002-06-03 22:56:12 +00:00
|
|
|
|
(and c-file-offsets
|
2007-10-12 03:03:25 +00:00
|
|
|
|
(mapc
|
2002-06-03 22:56:12 +00:00
|
|
|
|
(lambda (langentry)
|
|
|
|
|
(let ((langelem (car langentry))
|
|
|
|
|
(offset (cdr langentry)))
|
|
|
|
|
(c-set-offset langelem offset)))
|
2005-12-02 12:30:36 +00:00
|
|
|
|
c-file-offsets))
|
|
|
|
|
;; Problem: The file local variable block might have explicitly set a
|
|
|
|
|
;; style variable. The `c-set-style' or `mapcar' call might have
|
|
|
|
|
;; overwritten this. So we run `hack-local-variables' again to remedy
|
|
|
|
|
;; this. There are no guarantees this will work properly, particularly as
|
|
|
|
|
;; we have no control over what the other hook functions on
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
;; `hack-local-variables-hook' would have done. We now (2006/2/1) remove
|
|
|
|
|
;; any `eval' or `mode' expressions before we evaluate again (see below).
|
|
|
|
|
;; ACM, 2005/11/2.
|
|
|
|
|
;;
|
|
|
|
|
;; Problem (bug reported by Gustav Broberg): if one of the variables is
|
|
|
|
|
;; `mode', this will invoke c-mode (etc.) again, setting up the style etc.
|
|
|
|
|
;; We prevent this by temporarily removing `mode' from the Local Variables
|
|
|
|
|
;; section.
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(if (or c-file-style c-file-offsets)
|
2007-01-01 22:11:28 +00:00
|
|
|
|
(let ((hack-local-variables-hook nil) (inhibit-read-only t))
|
|
|
|
|
(c-tentative-buffer-changes
|
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: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
2006-02-24 15:33:02 +00:00
|
|
|
|
(c-remove-any-local-eval-or-mode-variables)
|
|
|
|
|
(hack-local-variables))
|
|
|
|
|
nil))))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
2008-07-31 01:37:35 +00:00
|
|
|
|
(if (boundp 'before-hack-local-variables-hook)
|
|
|
|
|
(add-hook 'before-hack-local-variables-hook 'c-before-hack-hook)
|
|
|
|
|
(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
CC Mode update to 5.30.10:
* cc-fonts.el (c-font-lock-declarators): Fixed bug where the point
could go past the limit in decoration level 2, thereby causing
errors during interactive fontification.
* cc-mode.el (c-make-inherited-keymap): Fixed cc-bytecomp bug when
the file is evaluated interactively.
* cc-engine.el (c-guess-basic-syntax): Handle operator
declarations somewhat better in C++.
* cc-styles.el, cc-mode.el (c-run-mode-hooks): New helper macro to
make use of run-mode-hooks' which has been added in Emacs 21.1.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode,
awk-mode): Use it.
(make-local-hook): Suppress warning about obsoleteness.
* cc-engine.el, cc-align.el, cc-cmds.el
(c-append-backslashes-forward, c-delete-backslashes-forward,
c-find-decl-spots, c-semi&comma-no-newlines-before-nonblanks):
Compensate for return value from forward-line' when it has moved
but not to a different line due to eob.
* cc-engine.el (c-guess-basic-syntax): Fixed anchoring in
objc-method-intro' and objc-method-args-cont'.
2005-05-23 Alan Mackenzie <bug-cc-mode@gnu.org>
CC Mode update to 5.30.10:
* cc-mode.el, cc-engine.el, cc-align.el: Change the FSF's address
in the copyright statement. Incidentally, change "along with GNU
Emacs" to "along with this program" where it occurs.
* cc-mode.el: Add a fourth parameter t' to the awk-mode autoload,
so that it is interactive, hence can be found by M-x awk-mode
whilst cc-mode is yet to be loaded. Reported by Glenn Morris
<gmorris+emacs@ast.cam.ac.uk>.
* cc-awk.el: Add character classes (e.g. "[:alpha:]") into AWK
Mode's regexps.
2005-05-23 Kevin Ryde <user42@zip.com.au>:
* cc-align.el (c-lineup-argcont): Ignore conses for {} pairs from
c-parse-state, to avoid a lisp error (on bad code).
2005-05-23 00:03:59 +00:00
|
|
|
|
(defmacro c-run-mode-hooks (&rest hooks)
|
|
|
|
|
;; Emacs 21.1 has introduced a system with delayed mode hooks that
|
2010-02-04 21:15:37 +00:00
|
|
|
|
;; requires the use of the new function `run-mode-hooks'.
|
2014-09-10 21:38:11 +00:00
|
|
|
|
(if (cc-bytecomp-fboundp 'run-mode-hooks)
|
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
CC Mode update to 5.30.10:
* cc-fonts.el (c-font-lock-declarators): Fixed bug where the point
could go past the limit in decoration level 2, thereby causing
errors during interactive fontification.
* cc-mode.el (c-make-inherited-keymap): Fixed cc-bytecomp bug when
the file is evaluated interactively.
* cc-engine.el (c-guess-basic-syntax): Handle operator
declarations somewhat better in C++.
* cc-styles.el, cc-mode.el (c-run-mode-hooks): New helper macro to
make use of run-mode-hooks' which has been added in Emacs 21.1.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode,
awk-mode): Use it.
(make-local-hook): Suppress warning about obsoleteness.
* cc-engine.el, cc-align.el, cc-cmds.el
(c-append-backslashes-forward, c-delete-backslashes-forward,
c-find-decl-spots, c-semi&comma-no-newlines-before-nonblanks):
Compensate for return value from forward-line' when it has moved
but not to a different line due to eob.
* cc-engine.el (c-guess-basic-syntax): Fixed anchoring in
objc-method-intro' and objc-method-args-cont'.
2005-05-23 Alan Mackenzie <bug-cc-mode@gnu.org>
CC Mode update to 5.30.10:
* cc-mode.el, cc-engine.el, cc-align.el: Change the FSF's address
in the copyright statement. Incidentally, change "along with GNU
Emacs" to "along with this program" where it occurs.
* cc-mode.el: Add a fourth parameter t' to the awk-mode autoload,
so that it is interactive, hence can be found by M-x awk-mode
whilst cc-mode is yet to be loaded. Reported by Glenn Morris
<gmorris+emacs@ast.cam.ac.uk>.
* cc-awk.el: Add character classes (e.g. "[:alpha:]") into AWK
Mode's regexps.
2005-05-23 Kevin Ryde <user42@zip.com.au>:
* cc-align.el (c-lineup-argcont): Ignore conses for {} pairs from
c-parse-state, to avoid a lisp error (on bad code).
2005-05-23 00:03:59 +00:00
|
|
|
|
`(run-mode-hooks ,@hooks)
|
|
|
|
|
`(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks))))
|
|
|
|
|
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
2014-02-17 18:16:32 +00:00
|
|
|
|
;;; Change hooks, linking with Font Lock and electric-indent-mode.
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
2015-04-21 14:02:10 +00:00
|
|
|
|
(defun c-called-from-text-property-change-p ()
|
|
|
|
|
;; Is the primitive which invoked `before-change-functions' or
|
|
|
|
|
;; `after-change-functions' one which merely changes text properties? This
|
|
|
|
|
;; function must be called directly from a member of one of the above hooks.
|
|
|
|
|
;;
|
|
|
|
|
;; In the following call, frame 0 is `backtrace-frame', frame 1 is
|
|
|
|
|
;; `c-called-from-text-property-change-p', frame 2 is
|
|
|
|
|
;; `c-before/after-change', frame 3 is the primitive invoking the change
|
|
|
|
|
;; hook.
|
|
|
|
|
(memq (cadr (backtrace-frame 3))
|
|
|
|
|
'(put-text-property remove-list-of-text-properties)))
|
|
|
|
|
|
2016-06-09 12:24:27 +00:00
|
|
|
|
(defun c-depropertize-CPP (beg end)
|
|
|
|
|
;; Remove the punctuation syntax-table text property from the CPP parts of
|
|
|
|
|
;; (c-new-BEG c-new-END).
|
|
|
|
|
;;
|
|
|
|
|
;; This function is in the C/C++/ObjC values of
|
|
|
|
|
;; `c-get-state-before-change-functions' and is called exclusively as a
|
|
|
|
|
;; before change function.
|
2016-08-09 10:23:31 +00:00
|
|
|
|
(c-save-buffer-state (m-beg ss-found)
|
2016-06-24 13:26:34 +00:00
|
|
|
|
(goto-char c-new-BEG)
|
|
|
|
|
(while (and (< (point) beg)
|
2016-08-09 10:23:31 +00:00
|
|
|
|
(search-forward-regexp c-anchored-cpp-prefix beg 'bound))
|
2016-06-24 13:26:34 +00:00
|
|
|
|
(goto-char (match-beginning 1))
|
2016-08-09 10:23:31 +00:00
|
|
|
|
(setq m-beg (point))
|
|
|
|
|
(c-end-of-macro)
|
|
|
|
|
(c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
|
|
|
|
|
|
|
|
|
|
(while (and (< (point) end)
|
|
|
|
|
(setq ss-found
|
|
|
|
|
(search-forward-regexp c-anchored-cpp-prefix end 'bound)))
|
|
|
|
|
(goto-char (match-beginning 1))
|
|
|
|
|
(setq m-beg (point))
|
|
|
|
|
(c-end-of-macro))
|
|
|
|
|
(if (and ss-found (> (point) end))
|
|
|
|
|
(c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
|
2016-06-24 13:26:34 +00:00
|
|
|
|
|
|
|
|
|
(while (and (< (point) c-new-END)
|
2016-08-09 10:23:31 +00:00
|
|
|
|
(search-forward-regexp c-anchored-cpp-prefix c-new-END 'bound))
|
2016-06-24 13:26:34 +00:00
|
|
|
|
(goto-char (match-beginning 1))
|
2016-08-09 10:23:31 +00:00
|
|
|
|
(setq m-beg (point))
|
|
|
|
|
(c-end-of-macro)
|
|
|
|
|
(c-clear-char-property-with-value
|
|
|
|
|
m-beg (point) 'syntax-table '(1)))))
|
2016-06-09 12:24:27 +00:00
|
|
|
|
|
2017-07-04 21:32:20 -04:00
|
|
|
|
(defun c-extend-region-for-CPP (_beg _end)
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;; Adjust `c-new-BEG', `c-new-END' respectively to the beginning and end of
|
2016-06-07 14:05:36 +02:00
|
|
|
|
;; any preprocessor construct they may be in.
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Point is undefined both before and after this function call; the buffer
|
|
|
|
|
;; has already been widened, and match-data saved. The return value is
|
|
|
|
|
;; meaningless.
|
|
|
|
|
;;
|
2010-02-04 21:15:37 +00:00
|
|
|
|
;; This function is in the C/C++/ObjC values of
|
|
|
|
|
;; `c-get-state-before-change-functions' and is called exclusively as a
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;; before change function.
|
2016-05-29 12:22:17 +00:00
|
|
|
|
(goto-char c-new-BEG)
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(c-beginning-of-macro)
|
2016-07-12 13:16:02 +00:00
|
|
|
|
(when (< (point) c-new-BEG)
|
|
|
|
|
(setq c-new-BEG (max (point) (c-determine-limit 500 c-new-BEG))))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
2016-05-29 12:22:17 +00:00
|
|
|
|
(goto-char c-new-END)
|
2010-04-29 14:48:32 +00:00
|
|
|
|
(when (c-beginning-of-macro)
|
|
|
|
|
(c-end-of-macro)
|
|
|
|
|
(or (eobp) (forward-char))) ; Over the terminating NL which may be marked
|
|
|
|
|
; with a c-cpp-delimiter category property
|
2016-07-12 13:16:02 +00:00
|
|
|
|
(when (> (point) c-new-END)
|
|
|
|
|
(setq c-new-END (min (point) (c-determine-+ve-limit 500 c-new-END)))))
|
2016-05-29 12:22:17 +00:00
|
|
|
|
|
2017-07-04 21:32:20 -04:00
|
|
|
|
(defun c-depropertize-new-text (beg end _old-len)
|
2016-06-24 13:26:34 +00:00
|
|
|
|
;; Remove from the new text in (BEG END) any and all text properties which
|
|
|
|
|
;; might interfere with CC Mode's proper working.
|
|
|
|
|
;;
|
|
|
|
|
;; This function is called exclusively as an after-change function. It
|
|
|
|
|
;; appears in the value (for all languages) of
|
|
|
|
|
;; `c-before-font-lock-functions'. The value of point is undefined both on
|
|
|
|
|
;; entry and exit, and the return value has no significance. The parameters
|
|
|
|
|
;; BEG, END, and OLD-LEN are the standard ones supplied to all after-change
|
|
|
|
|
;; functions.
|
|
|
|
|
(c-save-buffer-state ()
|
|
|
|
|
(when (> end beg)
|
|
|
|
|
(c-clear-char-properties beg end 'syntax-table)
|
|
|
|
|
(c-clear-char-properties beg end 'category)
|
|
|
|
|
(c-clear-char-properties beg end 'c-is-sws)
|
|
|
|
|
(c-clear-char-properties beg end 'c-in-sws)
|
|
|
|
|
(c-clear-char-properties beg end 'c-type)
|
|
|
|
|
(c-clear-char-properties beg end 'c-awk-NL-prop))))
|
|
|
|
|
|
2017-07-04 21:32:20 -04:00
|
|
|
|
(defun c-extend-font-lock-region-for-macros (_begg endd _old-len)
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;; Extend the region (c-new-BEG c-new-END) to cover all (possibly changed)
|
|
|
|
|
;; preprocessor macros; The return value has no significance.
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Point is undefined on both entry and exit to this function. The buffer
|
|
|
|
|
;; will have been widened on entry.
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;;
|
2016-07-12 13:16:02 +00:00
|
|
|
|
;; c-new-BEG has already been extended in `c-extend-region-for-CPP' so we
|
|
|
|
|
;; don't need to repeat the exercise here.
|
|
|
|
|
;;
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;; This function is in the C/C++/ObjC value of `c-before-font-lock-functions'.
|
|
|
|
|
(goto-char endd)
|
2016-07-12 13:16:02 +00:00
|
|
|
|
(when (c-beginning-of-macro)
|
|
|
|
|
(c-end-of-macro)
|
|
|
|
|
;; Determine the region, (c-new-BEG c-new-END), which will get font
|
|
|
|
|
;; locked. This restricts the region should there be long macros.
|
|
|
|
|
(setq c-new-END (min (max c-new-END (point))
|
|
|
|
|
(c-determine-+ve-limit 500 c-new-END)))))
|
2011-12-24 19:32:31 +00:00
|
|
|
|
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(defun c-neutralize-CPP-line (beg end)
|
2008-05-24 12:47:37 +00:00
|
|
|
|
;; BEG and END bound a region, typically a preprocessor line. Put a
|
|
|
|
|
;; "punctuation" syntax-table property on syntactically obtrusive
|
|
|
|
|
;; characters, ones which would interact syntactically with stuff outside
|
|
|
|
|
;; this region.
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;;
|
|
|
|
|
;; These are unmatched string delimiters, or unmatched
|
|
|
|
|
;; parens/brackets/braces. An unclosed comment is regarded as valid, NOT
|
|
|
|
|
;; obtrusive.
|
2008-05-24 12:47:37 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let (s)
|
|
|
|
|
(while
|
|
|
|
|
(progn
|
|
|
|
|
(setq s (parse-partial-sexp beg end -1))
|
|
|
|
|
(cond
|
|
|
|
|
((< (nth 0 s) 0) ; found an unmated ),},]
|
|
|
|
|
(c-put-char-property (1- (point)) 'syntax-table '(1))
|
|
|
|
|
t)
|
|
|
|
|
((nth 3 s) ; In a string
|
|
|
|
|
(c-put-char-property (nth 8 s) 'syntax-table '(1))
|
|
|
|
|
t)
|
|
|
|
|
((> (nth 0 s) 0) ; In a (,{,[
|
|
|
|
|
(c-put-char-property (nth 1 s) 'syntax-table '(1))
|
|
|
|
|
t)
|
|
|
|
|
(t nil)))))))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
2017-07-04 21:32:20 -04:00
|
|
|
|
(defun c-neutralize-syntax-in-and-mark-CPP (_begg _endd _old-len)
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;; (i) "Neutralize" every preprocessor line wholly or partially in the
|
|
|
|
|
;; changed region. "Restore" lines which were CPP lines before the change
|
|
|
|
|
;; and are no longer so.
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;; (ii) Mark each CPP construct by placing a `category' property value
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;; `c-cpp-delimiter' at its start and end. The marked characters are the
|
|
|
|
|
;; opening # and usually the terminating EOL, but sometimes the character
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;; before a comment delimiter.
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;; That is, set syntax-table properties on characters that would otherwise
|
|
|
|
|
;; interact syntactically with those outside the CPP line(s).
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;; This function is called from an after-change function, BEGG ENDD and
|
|
|
|
|
;; OLD-LEN being the standard parameters. It prepares the buffer for font
|
|
|
|
|
;; locking, hence must get called before `font-lock-after-change-function'.
|
|
|
|
|
;;
|
|
|
|
|
;; Point is undefined both before and after this function call, the buffer
|
|
|
|
|
;; has been widened, and match-data saved. The return value is ignored.
|
|
|
|
|
;;
|
2011-12-23 11:48:54 +00:00
|
|
|
|
;; This function is in the C/C++/ObjC value of `c-before-font-lock-functions'.
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;;
|
2008-05-24 12:47:37 +00:00
|
|
|
|
;; Note: SPEED _MATTERS_ IN THIS FUNCTION!!!
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2008-05-24 12:47:37 +00:00
|
|
|
|
;; This function might make hidden buffer changes.
|
2016-06-09 12:24:27 +00:00
|
|
|
|
(c-save-buffer-state (limits)
|
2016-05-29 12:22:17 +00:00
|
|
|
|
;; Clear 'syntax-table properties "punctuation":
|
2016-06-09 12:24:27 +00:00
|
|
|
|
;; (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
|
|
|
|
|
;; CPP "comment" markers:
|
|
|
|
|
(if (eval-when-compile (memq 'category-properties c-emacs-features));Emacs.
|
|
|
|
|
(c-clear-char-property-with-value
|
|
|
|
|
c-new-BEG c-new-END 'category 'c-cpp-delimiter))
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;; FIXME!!! What about the "<" and ">" category properties? 2009-11-16
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
2009-05-19 22:35:07 +00:00
|
|
|
|
;; Add needed properties to each CPP construct in the region.
|
|
|
|
|
(goto-char c-new-BEG)
|
2016-05-29 12:22:17 +00:00
|
|
|
|
(if (setq limits (c-literal-limits)) ; Go past any literal.
|
|
|
|
|
(goto-char (cdr limits)))
|
2013-04-15 16:10:24 +00:00
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(let ((pps-position (point)) pps-state mbeg)
|
2009-05-19 22:35:07 +00:00
|
|
|
|
(while (and (< (point) c-new-END)
|
|
|
|
|
(search-forward-regexp c-anchored-cpp-prefix c-new-END t))
|
2015-01-31 21:44:47 +00:00
|
|
|
|
;; If we've found a "#" inside a macro/string/comment, ignore it.
|
|
|
|
|
(unless
|
|
|
|
|
(or (save-excursion
|
|
|
|
|
(goto-char (match-beginning 0))
|
2015-04-06 22:20:16 +00:00
|
|
|
|
(let ((here (point)))
|
|
|
|
|
(and (save-match-data (c-beginning-of-macro))
|
|
|
|
|
(< (point) here))))
|
2015-01-31 21:44:47 +00:00
|
|
|
|
(progn
|
|
|
|
|
(setq pps-state
|
|
|
|
|
(parse-partial-sexp pps-position (point) nil nil pps-state)
|
|
|
|
|
pps-position (point))
|
|
|
|
|
(or (nth 3 pps-state) ; in a string?
|
2017-01-21 15:14:15 +00:00
|
|
|
|
(and (nth 4 pps-state)
|
|
|
|
|
(not (eq (nth 7 pps-state) 'syntax-table)))))) ; in a comment?
|
2013-04-15 16:10:24 +00:00
|
|
|
|
(goto-char (match-beginning 1))
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
(setq mbeg (point))
|
2016-05-29 12:22:17 +00:00
|
|
|
|
(if (> (c-no-comment-end-of-macro) mbeg)
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
(progn
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(c-neutralize-CPP-line mbeg (point)) ; "punctuation" properties
|
|
|
|
|
(if (eval-when-compile
|
|
|
|
|
(memq 'category-properties c-emacs-features)) ;Emacs.
|
|
|
|
|
(c-set-cpp-delimiters mbeg (point)))) ; "comment" markers
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
(forward-line)) ; no infinite loop with, e.g., "#//"
|
|
|
|
|
)))))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; Parsing of quotes.
|
|
|
|
|
;;
|
|
|
|
|
;; Valid digit separators in numbers will get the syntax-table "punctuation"
|
|
|
|
|
;; property, '(1), and also the text property `c-digit-separator' value t.
|
|
|
|
|
;;
|
|
|
|
|
;; Invalid other quotes (i.e. those not validly bounding a single character,
|
|
|
|
|
;; or escaped character) will get the syntax-table "punctuation" property,
|
|
|
|
|
;; '(1), too.
|
|
|
|
|
;;
|
|
|
|
|
;; Note that, for convenience, these properties are applied even inside
|
|
|
|
|
;; comments and strings.
|
|
|
|
|
|
|
|
|
|
(defconst c-maybe-quoted-number-head
|
|
|
|
|
(concat
|
|
|
|
|
"\\(0\\("
|
|
|
|
|
"\\([Xx]\\([0-9a-fA-F]\\('[0-9a-fA-F]\\|[0-9a-fA-F]\\)*'?\\)?\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\([Bb]\\([01]\\('[01]\\|[01]\\)*'?\\)?\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\('[0-7]\\|[0-7]\\)*'?"
|
|
|
|
|
"\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"[1-9]\\('[0-9]\\|[0-9]\\)*'?"
|
|
|
|
|
"\\)")
|
|
|
|
|
"Regexp matching the head of a numeric literal, including with digit separators.")
|
|
|
|
|
|
|
|
|
|
(defun c-quoted-number-head-before-point ()
|
|
|
|
|
;; Return non-nil when the head of a possibly quoted number is found
|
|
|
|
|
;; immediately before point. The value returned in this case is the buffer
|
2017-07-02 12:58:27 +00:00
|
|
|
|
;; position of the start of the head. That position is also in
|
|
|
|
|
;; (match-beginning 0).
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
(when c-has-quoted-numbers
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((here (point))
|
2017-07-02 12:58:27 +00:00
|
|
|
|
found)
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
(skip-chars-backward "0-9a-fA-F'")
|
|
|
|
|
(if (and (memq (char-before) '(?x ?X))
|
|
|
|
|
(eq (char-before (1- (point))) ?0))
|
|
|
|
|
(backward-char 2))
|
2017-07-02 12:58:27 +00:00
|
|
|
|
(while
|
|
|
|
|
(and
|
|
|
|
|
(setq found
|
|
|
|
|
(search-forward-regexp c-maybe-quoted-number-head here t))
|
|
|
|
|
(< found here)))
|
|
|
|
|
(and (eq found here) (match-beginning 0))))))
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
|
|
|
|
|
(defconst c-maybe-quoted-number-tail
|
|
|
|
|
(concat
|
|
|
|
|
"\\("
|
|
|
|
|
"\\([xX']?[0-9a-fA-F]\\('[0-9a-fA-F]\\|[0-9a-fA-F]\\)*\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\([bB']?[01]\\('[01]\\|[01]\\)*\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\('?[0-9]\\('[0-9]\\|[0-9]\\)*\\)"
|
|
|
|
|
"\\)")
|
|
|
|
|
"Regexp matching the tail of a numeric literal, including with digit separators.
|
|
|
|
|
Note that this is a strict tail, so won't match, e.g. \"0x....\".")
|
|
|
|
|
|
|
|
|
|
(defun c-quoted-number-tail-after-point ()
|
|
|
|
|
;; Return non-nil when a proper tail of a possibly quoted number is found
|
|
|
|
|
;; immediately after point. The value returned in this case is the buffer
|
2017-07-02 12:58:27 +00:00
|
|
|
|
;; position of the end of the tail. That position is also in (match-end 0).
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
(when c-has-quoted-numbers
|
|
|
|
|
(and (looking-at c-maybe-quoted-number-tail)
|
|
|
|
|
(match-end 0))))
|
|
|
|
|
|
|
|
|
|
(defconst c-maybe-quoted-number
|
|
|
|
|
(concat
|
|
|
|
|
"\\(0\\("
|
|
|
|
|
"\\([Xx][0-9a-fA-F]\\('[0-9a-fA-F]\\|[0-9a-fA-F]\\)*\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\([Bb][01]\\('[01]\\|[01]\\)*\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\('[0-7]\\|[0-7]\\)*"
|
|
|
|
|
"\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"[1-9]\\('[0-9]\\|[0-9]\\)*"
|
|
|
|
|
"\\)")
|
|
|
|
|
"Regexp matching a numeric literal, including with digit separators.")
|
|
|
|
|
|
|
|
|
|
(defun c-quoted-number-straddling-point ()
|
|
|
|
|
;; Return non-nil if a definitely quoted number starts before point and ends
|
|
|
|
|
;; after point. In this case the number is bounded by (match-beginning 0)
|
|
|
|
|
;; and (match-end 0).
|
|
|
|
|
(when c-has-quoted-numbers
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((here (point))
|
|
|
|
|
(bound (progn (skip-chars-forward "0-9a-fA-F'") (point))))
|
|
|
|
|
(goto-char here)
|
|
|
|
|
(when (< (skip-chars-backward "0-9a-fA-F'") 0)
|
|
|
|
|
(if (and (memq (char-before) '(?x ?X))
|
|
|
|
|
(eq (char-before (1- (point))) ?0))
|
|
|
|
|
(backward-char 2))
|
|
|
|
|
(while (and (search-forward-regexp c-maybe-quoted-number bound t)
|
|
|
|
|
(<= (match-end 0) here)))
|
|
|
|
|
(and (< (match-beginning 0) here)
|
|
|
|
|
(> (match-end 0) here)
|
|
|
|
|
(save-match-data
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(save-excursion (search-forward "'" (match-end 0) t)))))))))
|
|
|
|
|
|
|
|
|
|
(defun c-parse-quotes-before-change (beg end)
|
|
|
|
|
;; This function analyzes 's near the region (c-new-BEG c-new-END), amending
|
|
|
|
|
;; those two variables as needed to include 's into that region when they
|
|
|
|
|
;; might be syntactically relevant to the change in progress.
|
2016-06-24 13:26:34 +00:00
|
|
|
|
;;
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
;; Having amended that region, the function removes pertinent text
|
|
|
|
|
;; properties (syntax-table properties with value '(1) and c-digit-separator
|
|
|
|
|
;; props with value t) from 's in it. This operation is performed even
|
|
|
|
|
;; within strings and comments.
|
2016-06-24 13:26:34 +00:00
|
|
|
|
;;
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
;; This function is called exclusively as a before-change function via the
|
|
|
|
|
;; variable `c-get-state-before-change-functions'.
|
2017-09-03 11:01:21 +00:00
|
|
|
|
(c-save-buffer-state ()
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
(goto-char c-new-BEG)
|
2017-09-03 11:01:21 +00:00
|
|
|
|
;; We need to scan for 's from the BO (logical) line.
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
(beginning-of-line)
|
2017-09-03 11:01:21 +00:00
|
|
|
|
(while (eq (char-before (1- (point))) ?\\)
|
|
|
|
|
(beginning-of-line 0))
|
|
|
|
|
(while (and (< (point) c-new-BEG)
|
|
|
|
|
(search-forward "'" c-new-BEG t))
|
|
|
|
|
(cond
|
|
|
|
|
((c-quoted-number-straddling-point)
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(if (> (match-end 0) c-new-BEG)
|
|
|
|
|
(setq c-new-BEG (match-beginning 0))))
|
|
|
|
|
((c-quoted-number-head-before-point)
|
|
|
|
|
(if (>= (point) c-new-BEG)
|
|
|
|
|
(setq c-new-BEG (match-beginning 0))))
|
|
|
|
|
((looking-at "\\([^'\\]\\|\\\\.\\)'")
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(if (> (match-end 0) c-new-BEG)
|
|
|
|
|
(setq c-new-BEG (1- (match-beginning 0)))))
|
|
|
|
|
((or (>= (point) (1- c-new-BEG))
|
|
|
|
|
(and (eq (point) (- c-new-BEG 2))
|
|
|
|
|
(eq (char-after) ?\\)))
|
|
|
|
|
(setq c-new-BEG (1- (point))))
|
|
|
|
|
(t nil)))
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
|
2016-06-24 13:26:34 +00:00
|
|
|
|
(goto-char c-new-END)
|
2017-09-03 11:01:21 +00:00
|
|
|
|
;; We will scan from the BO (logical) line.
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(while (eq (char-before (1- (point))) ?\\)
|
|
|
|
|
(beginning-of-line 0))
|
|
|
|
|
(while (and (< (point) c-new-END)
|
|
|
|
|
(search-forward "'" c-new-END t))
|
|
|
|
|
(cond
|
|
|
|
|
((c-quoted-number-straddling-point)
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(if (> (match-end 0) c-new-END)
|
|
|
|
|
(setq c-new-END (match-end 0))))
|
|
|
|
|
((c-quoted-number-tail-after-point)
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(if (> (match-end 0) c-new-END)
|
|
|
|
|
(setq c-new-END (match-end 0))))
|
|
|
|
|
((looking-at "\\([^'\\]\\|\\\\.\\)'")
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(if (> (match-end 0) c-new-END)
|
|
|
|
|
(setq c-new-END (match-end 0))))
|
|
|
|
|
(t nil)))
|
|
|
|
|
;; Having reached c-new-END, handle any 's after it whose context may be
|
|
|
|
|
;; changed by the current buffer change.
|
|
|
|
|
(goto-char c-new-END)
|
|
|
|
|
(cond
|
|
|
|
|
((c-quoted-number-tail-after-point)
|
|
|
|
|
(setq c-new-END (match-end 0)))
|
|
|
|
|
((looking-at
|
|
|
|
|
"\\(\\\\.\\|.\\)?\\('\\([^'\\]\\|\\\\.\\)\\)*'")
|
|
|
|
|
(setq c-new-END (match-end 0))))
|
|
|
|
|
|
|
|
|
|
;; Remove the '(1) syntax-table property from any "'"s within (c-new-BEG
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
;; c-new-END).
|
2017-09-03 11:01:21 +00:00
|
|
|
|
(goto-char c-new-BEG)
|
|
|
|
|
(when (c-search-forward-char-property-with-value-on-char
|
|
|
|
|
'syntax-table '(1) ?\' c-new-END)
|
|
|
|
|
(c-invalidate-state-cache (1- (point)))
|
|
|
|
|
(c-truncate-semi-nonlit-pos-cache (1- (point)))
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
(c-clear-char-property-with-value-on-char
|
2017-09-03 11:01:21 +00:00
|
|
|
|
(1- (point)) c-new-END
|
|
|
|
|
'syntax-table '(1)
|
|
|
|
|
?')
|
|
|
|
|
;; Remove the c-digit-separator text property from the same "'"s.
|
|
|
|
|
(when c-has-quoted-numbers
|
|
|
|
|
(c-clear-char-property-with-value-on-char
|
|
|
|
|
(1- (point)) c-new-END
|
|
|
|
|
'c-digit-separator t
|
|
|
|
|
?')))))
|
|
|
|
|
|
|
|
|
|
(defun c-parse-quotes-after-change (beg end old-len)
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
;; This function applies syntax-table properties (value '(1)) and
|
|
|
|
|
;; c-digit-separator properties as needed to 's within the range (c-new-BEG
|
|
|
|
|
;; c-new-END). This operation is performed even within strings and
|
|
|
|
|
;; comments.
|
|
|
|
|
;;
|
|
|
|
|
;; This function is called exclusively as an after-change function via the
|
|
|
|
|
;; variable `c-before-font-lock-functions'.
|
2017-07-04 21:32:20 -04:00
|
|
|
|
(c-save-buffer-state (num-beg num-end)
|
Make C++ digit separators work. Amend the handling of single quotes generally
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
2017-07-01 15:43:07 +00:00
|
|
|
|
;; Apply the needed syntax-table and c-digit-separator text properties to
|
|
|
|
|
;; quotes.
|
2017-09-03 11:01:21 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(goto-char c-new-BEG)
|
|
|
|
|
(while (and (< (point) c-new-END)
|
|
|
|
|
(search-forward "'" c-new-END 'limit))
|
|
|
|
|
(cond ((and (eq (char-before (1- (point))) ?\\)
|
|
|
|
|
;; Check we've got an odd number of \s, here.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-char)
|
|
|
|
|
(eq (logand (skip-chars-backward "\\\\") 1) 1)))) ; not a real '.
|
|
|
|
|
((c-quoted-number-straddling-point)
|
|
|
|
|
(setq num-beg (match-beginning 0)
|
|
|
|
|
num-end (match-end 0))
|
|
|
|
|
(c-invalidate-state-cache num-beg)
|
|
|
|
|
(c-truncate-semi-nonlit-pos-cache num-beg)
|
|
|
|
|
(c-put-char-properties-on-char num-beg num-end
|
|
|
|
|
'syntax-table '(1) ?')
|
|
|
|
|
(c-put-char-properties-on-char num-beg num-end
|
|
|
|
|
'c-digit-separator t ?')
|
|
|
|
|
(goto-char num-end))
|
|
|
|
|
((looking-at "\\([^\\']\\|\\\\.\\)'") ; balanced quoted expression.
|
|
|
|
|
(goto-char (match-end 0)))
|
|
|
|
|
(t
|
|
|
|
|
(c-invalidate-state-cache (1- (point)))
|
|
|
|
|
(c-truncate-semi-nonlit-pos-cache (1- (point)))
|
|
|
|
|
(c-put-char-property (1- (point)) 'syntax-table '(1))))
|
|
|
|
|
;; Prevent the next `c-quoted-number-straddling-point' getting
|
|
|
|
|
;; confused by already processed single quotes.
|
|
|
|
|
(narrow-to-region (point) (point-max))))))
|
2016-08-15 11:52:32 +00:00
|
|
|
|
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(defun c-before-change (beg end)
|
2010-02-04 21:15:37 +00:00
|
|
|
|
;; Function to be put on `before-change-functions'. Primarily, this calls
|
|
|
|
|
;; the language dependent `c-get-state-before-change-functions'. It is
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;; otherwise used only to remove stale entries from the `c-found-types'
|
|
|
|
|
;; cache, and to record entries which a `c-after-change' function might
|
|
|
|
|
;; confirm as stale.
|
Enhance `c-parse-state' to run efficiently in "brace desserts".
* progmodes/cc-mode.el (c-basic-common-init): Call
c-state-cache-init.
(c-neutralize-syntax-in-and-mark-CPP): Renamed from
c-extend-and-neutralize-syntax-in-CPP. Mark each CPP construct by
placing `category' properties value 'c-cpp-delimiter at its
boundaries.
* progmodes/cc-langs.el (c-before-font-lock-function):
c-extend-and-neutralize-syntax-in-CPP has been renamed
c-neutralize-syntax-in-and-mark-CPP.
* progmodes/cc-fonts.el (c-cpp-matchers): Mark template brackets
with `category' properties now, not `syntax-table' ones.
* progmodes/cc-engine.el (c-syntactic-end-of-macro): A new
enhanced (but slower) version of c-end-of-macro that won't land
inside a literal or on another awkward character.
(c-state-cache-too-far, c-state-cache-start)
(c-state-nonlit-pos-interval, c-state-nonlit-pos-cache)
(c-state-nonlit-pos-cache-limit, c-state-point-min)
(c-state-point-min-lit-type, c-state-point-min-lit-start)
(c-state-min-scan-pos, c-state-brace-pair-desert)
(c-state-old-cpp-beg, c-state-old-cpp-end): New constants and
buffer local variables.
(c-state-literal-at, c-state-lit-beg)
(c-state-cache-non-literal-place, c-state-get-min-scan-pos)
(c-state-mark-point-min-literal, c-state-cache-top-lparen)
(c-state-cache-top-paren, c-state-cache-after-top-paren)
(c-get-cache-scan-pos, c-get-fallback-scan-pos)
(c-state-balance-parens-backwards, c-parse-state-get-strategy)
(c-renarrow-state-cache)
(c-append-lower-brace-pair-to-state-cache)
(c-state-push-any-brace-pair, c-append-to-state-cache)
(c-remove-stale-state-cache)
(c-remove-stale-state-cache-backwards, c-state-cache-init)
(c-invalidate-state-cache-1, c-parse-state-1)
(c-invalidate-state-cache): New defuns/defmacros/defsubsts.
(c-parse-state): Enhanced and refactored.
(c-debug-parse-state): Amended to deal with all the new variables.
* progmodes/cc-defs.el (c-<-as-paren-syntax, c-mark-<-as-paren)
(c->-as-paren-syntax, c-mark->-as-paren, c-unmark-<->-as-paren):
modify to use category text properties rather than syntax-table
ones.
(c-suppress-<->-as-parens, c-restore-<->-as-parens): new defsubsts
to switch off/on the syntactic paren property of C++ template
delimiters using the category property.
(c-with-<->-as-parens-suppressed): Macro to invoke code with
template delims suppressed.
(c-cpp-delimiter, c-set-cpp-delimiters, c-clear-cpp-delimiters):
New constant/macros which apply category properties to the start
and end of preprocessor constructs.
(c-comment-out-cpps, c-uncomment-out-cpps): defsubsts which
"comment out" the syntactic value of characters in preprocessor
constructs.
(c-with-cpps-commented-out)
(c-with-all-but-one-cpps-commented-out): Macros to invoke code
with characters in all or all but one preprocessor constructs
"commented out".
2009-12-03 16:02:10 +00:00
|
|
|
|
;;
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;; Note that this function must be FAST rather than accurate. Note
|
|
|
|
|
;; also that it only has any effect when font locking is enabled.
|
|
|
|
|
;; We exploit this by checking for font-lock-*-face instead of doing
|
2011-12-11 21:32:49 -08:00
|
|
|
|
;; rigorous syntactic analysis.
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
|
|
|
|
;; If either change boundary is wholly inside an identifier, delete
|
|
|
|
|
;; it/them from the cache. Don't worry about being inside a string
|
|
|
|
|
;; or a comment - "wrongly" removing a symbol from `c-found-types'
|
|
|
|
|
;; isn't critical.
|
2015-04-21 14:02:10 +00:00
|
|
|
|
(unless (or (c-called-from-text-property-change-p)
|
|
|
|
|
c-just-done-before-change) ; guard against a spurious second
|
|
|
|
|
; invocation of before-change-functions.
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(setq c-just-done-before-change t)
|
2016-01-04 22:29:33 +00:00
|
|
|
|
;; (c-new-BEG c-new-END) will be the region to fontify.
|
|
|
|
|
(setq c-new-BEG beg c-new-END end)
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(setq c-maybe-stale-found-type nil)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(save-match-data
|
|
|
|
|
(widen)
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; Are we inserting/deleting stuff in the middle of an identifier?
|
|
|
|
|
(c-unfind-enclosing-token beg)
|
|
|
|
|
(c-unfind-enclosing-token end)
|
|
|
|
|
;; Are we coalescing two tokens together, e.g. "fo o" -> "foo"?
|
|
|
|
|
(when (< beg end)
|
|
|
|
|
(c-unfind-coalesced-tokens beg end))
|
2017-01-11 18:25:39 +00:00
|
|
|
|
(c-invalidate-sws-region-before end)
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
;; Are we (potentially) disrupting the syntactic context which
|
|
|
|
|
;; makes a type a type? E.g. by inserting stuff after "foo" in
|
|
|
|
|
;; "foo bar;", or before "foo" in "typedef foo *bar;"?
|
|
|
|
|
;;
|
|
|
|
|
;; We search for appropriate c-type properties "near" the change.
|
|
|
|
|
;; First, find an appropriate boundary for this property search.
|
|
|
|
|
(let (lim
|
|
|
|
|
type type-pos
|
|
|
|
|
marked-id term-pos
|
|
|
|
|
(end1
|
|
|
|
|
(or (and (eq (get-text-property end 'face)
|
|
|
|
|
'font-lock-comment-face)
|
|
|
|
|
(previous-single-property-change end 'face))
|
|
|
|
|
end)))
|
|
|
|
|
(when (>= end1 beg) ; Don't hassle about changes entirely in comments.
|
|
|
|
|
;; Find a limit for the search for a `c-type' property
|
|
|
|
|
(while
|
|
|
|
|
(and (/= (skip-chars-backward "^;{}") 0)
|
|
|
|
|
(> (point) (point-min))
|
|
|
|
|
(memq (c-get-char-property (1- (point)) 'face)
|
|
|
|
|
'(font-lock-comment-face font-lock-string-face))))
|
|
|
|
|
(setq lim (max (point-min) (1- (point))))
|
|
|
|
|
|
|
|
|
|
;; Look for the latest `c-type' property before end1
|
|
|
|
|
(when (and (> end1 (point-min))
|
|
|
|
|
(setq type-pos
|
|
|
|
|
(if (get-text-property (1- end1) 'c-type)
|
|
|
|
|
end1
|
|
|
|
|
(previous-single-property-change end1 'c-type
|
|
|
|
|
nil lim))))
|
|
|
|
|
(setq type (get-text-property (max (1- type-pos) lim) 'c-type))
|
|
|
|
|
|
|
|
|
|
(when (memq type '(c-decl-id-start c-decl-type-start))
|
|
|
|
|
;; Get the identifier, if any, that the property is on.
|
|
|
|
|
(goto-char (1- type-pos))
|
|
|
|
|
(setq marked-id
|
|
|
|
|
(when (looking-at "\\(\\sw\\|\\s_\\)")
|
|
|
|
|
(c-beginning-of-current-token)
|
|
|
|
|
(buffer-substring-no-properties (point) type-pos)))
|
|
|
|
|
|
|
|
|
|
(goto-char end1)
|
|
|
|
|
(skip-chars-forward "^;{}") ;FIXME!!! loop for comment, maybe
|
|
|
|
|
(setq lim (point))
|
|
|
|
|
(setq term-pos
|
|
|
|
|
(or (c-next-single-property-change end 'c-type nil lim)
|
|
|
|
|
lim))
|
|
|
|
|
(setq c-maybe-stale-found-type
|
|
|
|
|
(list type marked-id
|
|
|
|
|
type-pos term-pos
|
|
|
|
|
(buffer-substring-no-properties type-pos
|
|
|
|
|
term-pos)
|
2014-01-19 12:32:47 +00:00
|
|
|
|
(buffer-substring-no-properties beg end)))))))
|
|
|
|
|
|
|
|
|
|
(if c-get-state-before-change-functions
|
2015-11-11 22:06:12 +00:00
|
|
|
|
(mapc (lambda (fn)
|
|
|
|
|
(funcall fn beg end))
|
|
|
|
|
c-get-state-before-change-functions))
|
2014-01-19 12:32:47 +00:00
|
|
|
|
)))
|
|
|
|
|
;; The following must be done here rather than in `c-after-change' because
|
|
|
|
|
;; newly inserted parens would foul up the invalidation algorithm.
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
(c-invalidate-state-cache beg)))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
2011-12-24 19:32:31 +00:00
|
|
|
|
(defvar c-in-after-change-fontification nil)
|
|
|
|
|
(make-variable-buffer-local 'c-in-after-change-fontification)
|
|
|
|
|
;; A flag to prevent region expanding stuff being done twice for after-change
|
|
|
|
|
;; fontification.
|
|
|
|
|
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(defun c-after-change (beg end old-len)
|
|
|
|
|
;; Function put on `after-change-functions' to adjust various caches
|
|
|
|
|
;; etc. Prefer speed to finesse here, since there will be an order
|
|
|
|
|
;; of magnitude more calls to this function than any of the
|
|
|
|
|
;; functions that use the caches.
|
|
|
|
|
;;
|
|
|
|
|
;; Note that care must be taken so that this is called before any
|
|
|
|
|
;; font-lock callbacks since we might get calls to functions using
|
|
|
|
|
;; these caches from inside them, and we must thus be sure that this
|
|
|
|
|
;; has already been executed.
|
|
|
|
|
;;
|
2011-12-23 11:48:54 +00:00
|
|
|
|
;; This calls the language variable c-before-font-lock-functions, if non nil.
|
2008-02-19 22:14:40 +00:00
|
|
|
|
;; This typically sets `syntax-table' properties.
|
|
|
|
|
|
2016-08-09 16:09:18 +00:00
|
|
|
|
;; We can sometimes get two consecutive calls to `after-change-functions'
|
|
|
|
|
;; without an intervening call to `before-change-functions' when reverting
|
|
|
|
|
;; the buffer (see bug #24094). Whatever the cause, assume that the entire
|
|
|
|
|
;; buffer has changed.
|
|
|
|
|
(when (not c-just-done-before-change)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(c-before-change (point-min) (point-max))
|
|
|
|
|
(setq beg (point-min)
|
|
|
|
|
end (point-max)
|
|
|
|
|
old-len (- end beg))))
|
|
|
|
|
|
2015-04-21 14:02:10 +00:00
|
|
|
|
;; (c-new-BEG c-new-END) will be the region to fontify. It may become
|
|
|
|
|
;; larger than (beg end).
|
2016-01-04 22:29:33 +00:00
|
|
|
|
(setq c-new-END (- (+ c-new-END (- end beg)) old-len))
|
2016-06-09 12:24:27 +00:00
|
|
|
|
(setq c-old-BEG c-new-BEG c-old-END c-new-END)
|
2015-04-21 14:02:10 +00:00
|
|
|
|
|
|
|
|
|
(unless (c-called-from-text-property-change-p)
|
|
|
|
|
(setq c-just-done-before-change nil)
|
2015-11-11 22:06:12 +00:00
|
|
|
|
(c-save-buffer-state (case-fold-search)
|
2015-04-21 14:02:10 +00:00
|
|
|
|
;; When `combine-after-change-calls' is used we might get calls
|
|
|
|
|
;; with regions outside the current narrowing. This has been
|
|
|
|
|
;; observed in Emacs 20.7.
|
|
|
|
|
(save-restriction
|
|
|
|
|
(save-match-data ; c-recognize-<>-arglists changes match-data
|
|
|
|
|
(widen)
|
|
|
|
|
|
|
|
|
|
(when (> end (point-max))
|
|
|
|
|
;; Some emacsen might return positions past the end. This has been
|
|
|
|
|
;; observed in Emacs 20.7 when rereading a buffer changed on disk
|
|
|
|
|
;; (haven't been able to minimize it, but Emacs 21.3 appears to
|
|
|
|
|
;; work).
|
|
|
|
|
(setq end (point-max))
|
|
|
|
|
(when (> beg end)
|
|
|
|
|
(setq beg end)))
|
|
|
|
|
|
|
|
|
|
;; C-y is capable of spuriously converting category properties
|
|
|
|
|
;; c-</>-as-paren-syntax and c-cpp-delimiter into hard syntax-table
|
|
|
|
|
;; properties. Remove these when it happens.
|
|
|
|
|
(when (eval-when-compile (memq 'category-properties c-emacs-features))
|
|
|
|
|
(c-save-buffer-state ()
|
|
|
|
|
(c-clear-char-property-with-value beg end 'syntax-table
|
|
|
|
|
c-<-as-paren-syntax)
|
|
|
|
|
(c-clear-char-property-with-value beg end 'syntax-table
|
|
|
|
|
c->-as-paren-syntax)
|
|
|
|
|
(c-clear-char-property-with-value beg end 'syntax-table nil)))
|
|
|
|
|
|
|
|
|
|
(c-trim-found-types beg end old-len) ; maybe we don't need all of these.
|
2017-01-11 18:25:39 +00:00
|
|
|
|
(c-invalidate-sws-region-after beg end old-len)
|
2015-04-21 14:02:10 +00:00
|
|
|
|
;; (c-invalidate-state-cache beg) ; moved to `c-before-change'.
|
|
|
|
|
(c-invalidate-find-decl-cache beg)
|
|
|
|
|
|
|
|
|
|
(when c-recognize-<>-arglists
|
|
|
|
|
(c-after-change-check-<>-operators beg end))
|
|
|
|
|
|
|
|
|
|
(setq c-in-after-change-fontification t)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(mapc (lambda (fn)
|
|
|
|
|
(funcall fn beg end old-len))
|
|
|
|
|
c-before-font-lock-functions)))))))
|
2011-12-23 11:48:54 +00:00
|
|
|
|
|
2015-03-30 16:37:04 +00:00
|
|
|
|
(defun c-fl-decl-start (pos)
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;; If the beginning of the line containing POS is in the middle of a "local"
|
Adapt CC Mode for C++11 uniform initialization.
For fontification, introduce a new "context", 'non-decl, to be used for
brace
lists; also a new value for the property 'c-type, called 'c-not-decl.
* lisp/progmodes/cc-engine.el (c-back-over-compound-identifier): Check that
an ostensible symbol we're going to move over isn't a keyword.
(c-forward-decl-or-cast-1): CASE 1: Where we have two consecutive identifiers
(hence a declaration), and an unmatched open paren, perform
c-fdoc-shift-type-backwards to recognize the partial construct correctly.
Whilst checking a type decl expression, check for and handle C++11's "copy
initialization", where we have <type>(<constant>). Recognize
<id><id>(... (where the paren is unclosed) as a declaration.
(c-looking-at-or-maybe-in-bracelist): New function, extracted from
c-inside-bracelist-p. Recognize as bracelists "{"s which are preceded by
valid tokens other than "=". Recognize a bracelist when preceded by a
template declaration.
(c-inside-bracelist-p): Call c-looking-at-or-maybe-in-bracelist in place of
much inline code.
(c-looking-at-inexpr-block): Amend so that it won't wrongly recognise an
initialization starting "({" as an in-expression block, by checking for
semicolons, as opposed to commas, separating elements inside it.
(c-guess-continued-construct): (CASE B-2): Recognize a brace-list-open by
calling c-looking-at-or-maybe-in-bracelist rather than checking for a
preceding "=". (CASE B-5): New code to recognize new construct "return {
...}".
(c-guess-basic-syntax): (CASE 5A.3): Additionally recognize a "{" preceded by
"return", or "{" preceded by <type><identifier> as a bracelist.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Recognize brace
lists, giving them `context' 'non-decl. Pass over elements of one by regexp
search for "," rather than calling c-forward-decl-or-cast-1.
* lisp/progmodes/cc-langs.el (c-return-kwds, c-return-key): New lang
constants/variables to recognize "return".
(c-pre-id-bracelist-key): New lang constant/variable to recognize tokens
which, when preceding an identifier followed by a brace, signify the brace as
a bracelist.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): When searching outwards for
the start of a "local" declaration, move out from an enclosing brace when
that is the start of a brace list.
2016-08-21 16:00:15 +00:00
|
|
|
|
;; declaration, return the beginning of that declaration. Otherwise return
|
|
|
|
|
;; nil. Note that declarations, in this sense, can be nested. (A local
|
|
|
|
|
;; declaration is one which does not start outside of struct braces (and
|
|
|
|
|
;; similar) enclosing POS. Brace list braces here are not "similar".
|
2011-12-23 11:48:54 +00:00
|
|
|
|
;;
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;; This function is called indirectly from font locking stuff - either from
|
2011-12-29 18:52:49 -08:00
|
|
|
|
;; c-after-change (to prepare for after-change font-locking) or from font
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;; lock context (etc.) fontification.
|
2017-03-30 20:24:39 +00:00
|
|
|
|
(goto-char pos)
|
Amend a cache so that typing into C++ raw strings has no undue delay.
Also amend the code so that low-level searches to the end of literals are done
only when these positions get used.
* lisp/progmodes/cc-engine.el (c-crosses-statement-barrier-p): Use the new
c-literal-start instead of c-literal-limit.
(c-state-semi-nonlit-pos-cache): Change the structure of this cache, such that
it stores details of the literal at a point, rather than merely points outside
of literals.
(c-state-semi-pp-to-literal, c-state-full-pp-to-literal)
(c-cache-to-parse-ps-state, c-parse-ps-state-to-cache, c-ps-state-cache-pos)
(c-parse-ps-state-below, c-literal-start): New functions.
(c-state-semi-safe-place): Removed.
(c-in-literal): Use c-state-semi-pp-to-literal, so as not to scan to its end.
(c-literal-limits, c-determine-limit-get-base): consequential amendments.
(c-find-decl-spots, c-before-change-check-<>-operators, c-raw-string-pos)
(c-guess-basic-syntax (CASE 2)): Avoid needless scans to end of literals.
* lisp/progmodes/cc-fonts.el (c-font-lock-doc-comments): Avoid needless scans
to end of literals.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): Avoid needless scans to end of
literals.
* lisp/progmodes/cc-cmds.el (c-beginning-of-defun, c-end-of-defun)
(c-defun-name, c-declaration-limits): Avoid needless scans to end of literals.
2016-06-27 11:34:02 +00:00
|
|
|
|
(let ((lit-start (c-literal-start))
|
2011-12-24 19:32:31 +00:00
|
|
|
|
(new-pos pos)
|
2016-08-15 11:52:32 +00:00
|
|
|
|
capture-opener
|
2011-12-24 19:32:31 +00:00
|
|
|
|
bod-lim bo-decl)
|
|
|
|
|
(goto-char (c-point 'bol new-pos))
|
Amend a cache so that typing into C++ raw strings has no undue delay.
Also amend the code so that low-level searches to the end of literals are done
only when these positions get used.
* lisp/progmodes/cc-engine.el (c-crosses-statement-barrier-p): Use the new
c-literal-start instead of c-literal-limit.
(c-state-semi-nonlit-pos-cache): Change the structure of this cache, such that
it stores details of the literal at a point, rather than merely points outside
of literals.
(c-state-semi-pp-to-literal, c-state-full-pp-to-literal)
(c-cache-to-parse-ps-state, c-parse-ps-state-to-cache, c-ps-state-cache-pos)
(c-parse-ps-state-below, c-literal-start): New functions.
(c-state-semi-safe-place): Removed.
(c-in-literal): Use c-state-semi-pp-to-literal, so as not to scan to its end.
(c-literal-limits, c-determine-limit-get-base): consequential amendments.
(c-find-decl-spots, c-before-change-check-<>-operators, c-raw-string-pos)
(c-guess-basic-syntax (CASE 2)): Avoid needless scans to end of literals.
* lisp/progmodes/cc-fonts.el (c-font-lock-doc-comments): Avoid needless scans
to end of literals.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): Avoid needless scans to end of
literals.
* lisp/progmodes/cc-cmds.el (c-beginning-of-defun, c-end-of-defun)
(c-defun-name, c-declaration-limits): Avoid needless scans to end of literals.
2016-06-27 11:34:02 +00:00
|
|
|
|
(when lit-start ; Comment or string.
|
|
|
|
|
(goto-char lit-start))
|
2012-02-13 17:18:07 +00:00
|
|
|
|
(setq bod-lim (c-determine-limit 500))
|
2011-12-24 19:32:31 +00:00
|
|
|
|
|
2016-08-15 11:52:32 +00:00
|
|
|
|
;; In C++ Mode, first check if we are within a (possibly nested) lambda
|
|
|
|
|
;; form capture list.
|
|
|
|
|
(when (c-major-mode-is 'c++-mode)
|
|
|
|
|
(let ((paren-state (c-parse-state))
|
|
|
|
|
opener)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (setq opener (c-pull-open-brace paren-state))
|
|
|
|
|
(goto-char opener)
|
|
|
|
|
(if (c-looking-at-c++-lambda-capture-list)
|
|
|
|
|
(setq capture-opener (point)))))))
|
|
|
|
|
|
2011-12-24 19:32:31 +00:00
|
|
|
|
(while
|
|
|
|
|
;; Go to a less nested declaration each time round this loop.
|
|
|
|
|
(and
|
2016-07-03 13:11:28 +00:00
|
|
|
|
(c-syntactic-skip-backward "^;{}" bod-lim t)
|
2015-04-06 22:20:16 +00:00
|
|
|
|
(> (point) bod-lim)
|
2016-07-03 13:11:28 +00:00
|
|
|
|
(progn (c-forward-syntactic-ws)
|
|
|
|
|
(setq bo-decl (point))
|
2017-09-16 11:31:38 +00:00
|
|
|
|
(or (not (looking-at c-protection-key))
|
|
|
|
|
(c-forward-keyword-clause 1)))
|
|
|
|
|
(progn
|
|
|
|
|
;; Are we looking at a keyword such as "template" or
|
|
|
|
|
;; "typedef" which can decorate a type, or the type itself?
|
|
|
|
|
(when (or (looking-at c-prefix-spec-kwds-re)
|
|
|
|
|
(c-forward-type t))
|
|
|
|
|
;; We've found another candidate position.
|
|
|
|
|
(setq new-pos (min new-pos bo-decl))
|
|
|
|
|
(goto-char bo-decl))
|
|
|
|
|
t)
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;; Try and go out a level to search again.
|
|
|
|
|
(progn
|
|
|
|
|
(c-backward-syntactic-ws bod-lim)
|
2012-02-13 17:18:07 +00:00
|
|
|
|
(and (> (point) bod-lim)
|
|
|
|
|
(or (memq (char-before) '(?\( ?\[))
|
|
|
|
|
(and (eq (char-before) ?\<)
|
|
|
|
|
(eq (c-get-char-property
|
|
|
|
|
(1- (point)) 'syntax-table)
|
Adapt CC Mode for C++11 uniform initialization.
For fontification, introduce a new "context", 'non-decl, to be used for
brace
lists; also a new value for the property 'c-type, called 'c-not-decl.
* lisp/progmodes/cc-engine.el (c-back-over-compound-identifier): Check that
an ostensible symbol we're going to move over isn't a keyword.
(c-forward-decl-or-cast-1): CASE 1: Where we have two consecutive identifiers
(hence a declaration), and an unmatched open paren, perform
c-fdoc-shift-type-backwards to recognize the partial construct correctly.
Whilst checking a type decl expression, check for and handle C++11's "copy
initialization", where we have <type>(<constant>). Recognize
<id><id>(... (where the paren is unclosed) as a declaration.
(c-looking-at-or-maybe-in-bracelist): New function, extracted from
c-inside-bracelist-p. Recognize as bracelists "{"s which are preceded by
valid tokens other than "=". Recognize a bracelist when preceded by a
template declaration.
(c-inside-bracelist-p): Call c-looking-at-or-maybe-in-bracelist in place of
much inline code.
(c-looking-at-inexpr-block): Amend so that it won't wrongly recognise an
initialization starting "({" as an in-expression block, by checking for
semicolons, as opposed to commas, separating elements inside it.
(c-guess-continued-construct): (CASE B-2): Recognize a brace-list-open by
calling c-looking-at-or-maybe-in-bracelist rather than checking for a
preceding "=". (CASE B-5): New code to recognize new construct "return {
...}".
(c-guess-basic-syntax): (CASE 5A.3): Additionally recognize a "{" preceded by
"return", or "{" preceded by <type><identifier> as a bracelist.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Recognize brace
lists, giving them `context' 'non-decl. Pass over elements of one by regexp
search for "," rather than calling c-forward-decl-or-cast-1.
* lisp/progmodes/cc-langs.el (c-return-kwds, c-return-key): New lang
constants/variables to recognize "return".
(c-pre-id-bracelist-key): New lang constant/variable to recognize tokens
which, when preceding an identifier followed by a brace, signify the brace as
a bracelist.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): When searching outwards for
the start of a "local" declaration, move out from an enclosing brace when
that is the start of a brace list.
2016-08-21 16:00:15 +00:00
|
|
|
|
c-<-as-paren-syntax))
|
|
|
|
|
(and (eq (char-before) ?{)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-char)
|
2016-08-30 15:36:15 +00:00
|
|
|
|
(consp (c-looking-at-or-maybe-in-bracelist))))
|
Adapt CC Mode for C++11 uniform initialization.
For fontification, introduce a new "context", 'non-decl, to be used for
brace
lists; also a new value for the property 'c-type, called 'c-not-decl.
* lisp/progmodes/cc-engine.el (c-back-over-compound-identifier): Check that
an ostensible symbol we're going to move over isn't a keyword.
(c-forward-decl-or-cast-1): CASE 1: Where we have two consecutive identifiers
(hence a declaration), and an unmatched open paren, perform
c-fdoc-shift-type-backwards to recognize the partial construct correctly.
Whilst checking a type decl expression, check for and handle C++11's "copy
initialization", where we have <type>(<constant>). Recognize
<id><id>(... (where the paren is unclosed) as a declaration.
(c-looking-at-or-maybe-in-bracelist): New function, extracted from
c-inside-bracelist-p. Recognize as bracelists "{"s which are preceded by
valid tokens other than "=". Recognize a bracelist when preceded by a
template declaration.
(c-inside-bracelist-p): Call c-looking-at-or-maybe-in-bracelist in place of
much inline code.
(c-looking-at-inexpr-block): Amend so that it won't wrongly recognise an
initialization starting "({" as an in-expression block, by checking for
semicolons, as opposed to commas, separating elements inside it.
(c-guess-continued-construct): (CASE B-2): Recognize a brace-list-open by
calling c-looking-at-or-maybe-in-bracelist rather than checking for a
preceding "=". (CASE B-5): New code to recognize new construct "return {
...}".
(c-guess-basic-syntax): (CASE 5A.3): Additionally recognize a "{" preceded by
"return", or "{" preceded by <type><identifier> as a bracelist.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Recognize brace
lists, giving them `context' 'non-decl. Pass over elements of one by regexp
search for "," rather than calling c-forward-decl-or-cast-1.
* lisp/progmodes/cc-langs.el (c-return-kwds, c-return-key): New lang
constants/variables to recognize "return".
(c-pre-id-bracelist-key): New lang constant/variable to recognize tokens
which, when preceding an identifier followed by a brace, signify the brace as
a bracelist.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): When searching outwards for
the start of a "local" declaration, move out from an enclosing brace when
that is the start of a brace list.
2016-08-21 16:00:15 +00:00
|
|
|
|
)))
|
2011-12-24 19:32:31 +00:00
|
|
|
|
(not (bobp)))
|
2015-03-30 16:37:04 +00:00
|
|
|
|
(backward-char)) ; back over (, [, <.
|
2016-08-15 11:52:32 +00:00
|
|
|
|
(when (and capture-opener (< capture-opener new-pos))
|
|
|
|
|
(setq new-pos capture-opener))
|
2015-03-30 16:37:04 +00:00
|
|
|
|
(and (/= new-pos pos) new-pos)))
|
|
|
|
|
|
2017-07-27 06:27:13 +00:00
|
|
|
|
(defun c-fl-decl-end (pos)
|
|
|
|
|
;; If POS is inside a declarator, return the end of the token that follows
|
|
|
|
|
;; the declarator, otherwise return nil.
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(let ((lit-start (c-literal-start))
|
|
|
|
|
pos1)
|
|
|
|
|
(if lit-start (goto-char lit-start))
|
|
|
|
|
(c-backward-syntactic-ws)
|
|
|
|
|
(when (setq pos1 (c-on-identifier))
|
|
|
|
|
(goto-char pos1)
|
2017-08-22 17:04:34 +00:00
|
|
|
|
(let ((lim (save-excursion
|
|
|
|
|
(and (c-beginning-of-macro)
|
|
|
|
|
(progn (c-end-of-macro) (point))))))
|
|
|
|
|
(when (and (c-forward-declarator lim)
|
2017-10-04 17:34:27 +00:00
|
|
|
|
(or (not (eq (char-after) ?\())
|
|
|
|
|
(c-go-list-forward nil lim))
|
2017-08-22 17:04:34 +00:00
|
|
|
|
(eq (c-forward-token-2 1 nil lim) 0))
|
|
|
|
|
(c-backward-syntactic-ws)
|
|
|
|
|
(point))))))
|
2017-07-27 06:27:13 +00:00
|
|
|
|
|
2016-05-23 20:25:28 -04:00
|
|
|
|
(defun c-change-expand-fl-region (_beg _end _old-len)
|
2015-03-30 16:37:04 +00:00
|
|
|
|
;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock
|
|
|
|
|
;; region. This will usually be the smallest sequence of whole lines
|
|
|
|
|
;; containing `c-new-BEG' and `c-new-END', but if `c-new-BEG' is in a
|
|
|
|
|
;; "local" declaration (see `c-fl-decl-start') the beginning of this is used
|
|
|
|
|
;; as the lower bound.
|
|
|
|
|
;;
|
|
|
|
|
;; This is called from an after-change-function, but the parameters BEG END
|
|
|
|
|
;; and OLD-LEN are not used.
|
2016-05-29 12:22:17 +00:00
|
|
|
|
(if font-lock-mode
|
|
|
|
|
(setq c-new-BEG
|
|
|
|
|
(or (c-fl-decl-start c-new-BEG) (c-point 'bol c-new-BEG))
|
|
|
|
|
c-new-END
|
2017-07-27 06:27:13 +00:00
|
|
|
|
(or (c-fl-decl-end c-new-END)
|
2017-10-04 17:34:27 +00:00
|
|
|
|
(c-point 'bonl c-new-END)))))
|
2015-03-30 16:37:04 +00:00
|
|
|
|
|
|
|
|
|
(defun c-context-expand-fl-region (beg end)
|
|
|
|
|
;; Return a cons (NEW-BEG . NEW-END), where NEW-BEG is the beginning of a
|
|
|
|
|
;; "local" declaration containing BEG (see `c-fl-decl-start') or BOL BEG is
|
|
|
|
|
;; in. NEW-END is beginning of the line after the one END is in.
|
2017-07-27 06:27:13 +00:00
|
|
|
|
(c-save-buffer-state ()
|
|
|
|
|
(cons (or (c-fl-decl-start beg) (c-point 'bol beg))
|
|
|
|
|
(or (c-fl-decl-end end) (c-point 'bonl (1- end))))))
|
2015-03-30 16:37:04 +00:00
|
|
|
|
|
|
|
|
|
(defun c-before-context-fl-expand-region (beg end)
|
|
|
|
|
;; Expand the region (BEG END) as specified by
|
|
|
|
|
;; `c-before-context-fontification-functions'. Return a cons of the bounds
|
|
|
|
|
;; of the new region.
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(save-excursion
|
2016-01-05 21:16:37 +00:00
|
|
|
|
(let ((new-beg beg) (new-end end)
|
|
|
|
|
(new-region (cons beg end)))
|
2015-03-30 16:37:04 +00:00
|
|
|
|
(mapc (lambda (fn)
|
|
|
|
|
(setq new-region (funcall fn new-beg new-end))
|
|
|
|
|
(setq new-beg (car new-region) new-end (cdr new-region)))
|
|
|
|
|
c-before-context-fontification-functions)
|
|
|
|
|
new-region))))
|
2011-12-24 19:32:31 +00:00
|
|
|
|
|
|
|
|
|
(defun c-font-lock-fontify-region (beg end &optional verbose)
|
|
|
|
|
;; Effectively advice around `font-lock-fontify-region' which extends the
|
|
|
|
|
;; region (BEG END), for example, to avoid context fontification chopping
|
2015-03-30 16:37:04 +00:00
|
|
|
|
;; off the start of the context. Do not extend the region if it's already
|
|
|
|
|
;; been done (i.e. from an after-change fontification. An example (C++)
|
|
|
|
|
;; where the chopping off used to happen is this:
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;;
|
|
|
|
|
;; template <typename T>
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;; void myfunc(T* p) {}
|
2015-09-24 09:13:36 -07:00
|
|
|
|
;;
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;; Type a space in the first blank line, and the fontification of the next
|
|
|
|
|
;; line was fouled up by context fontification.
|
2015-11-11 22:06:12 +00:00
|
|
|
|
(let (new-beg new-end new-region case-fold-search)
|
2015-03-30 16:37:04 +00:00
|
|
|
|
(if (and c-in-after-change-fontification
|
|
|
|
|
(< beg c-new-END) (> end c-new-BEG))
|
|
|
|
|
;; Region and the latest after-change fontification region overlap.
|
|
|
|
|
;; Determine the upper and lower bounds of our adjusted region
|
|
|
|
|
;; separately.
|
|
|
|
|
(progn
|
|
|
|
|
(if (<= beg c-new-BEG)
|
|
|
|
|
(setq c-in-after-change-fontification nil))
|
|
|
|
|
(setq new-beg
|
|
|
|
|
(if (and (>= beg (c-point 'bol c-new-BEG))
|
|
|
|
|
(<= beg c-new-BEG))
|
|
|
|
|
;; Either jit-lock has accepted `c-new-BEG', or has
|
|
|
|
|
;; (probably) extended the change region spuriously to
|
|
|
|
|
;; BOL, which position likely has a syntactically
|
|
|
|
|
;; different position. To ensure correct fontification,
|
|
|
|
|
;; we start at `c-new-BEG', assuming any characters to the
|
|
|
|
|
;; left of `c-new-BEG' on the line do not require
|
|
|
|
|
;; fontification.
|
|
|
|
|
c-new-BEG
|
|
|
|
|
(setq new-region (c-before-context-fl-expand-region beg end)
|
|
|
|
|
new-end (cdr new-region))
|
|
|
|
|
(car new-region)))
|
|
|
|
|
(setq new-end
|
|
|
|
|
(if (and (>= end (c-point 'bol c-new-END))
|
|
|
|
|
(<= end c-new-END))
|
|
|
|
|
c-new-END
|
|
|
|
|
(or new-end
|
|
|
|
|
(cdr (c-before-context-fl-expand-region beg end))))))
|
|
|
|
|
;; Context (etc.) fontification.
|
|
|
|
|
(setq new-region (c-before-context-fl-expand-region beg end)
|
|
|
|
|
new-beg (car new-region) new-end (cdr new-region)))
|
2013-05-02 11:18:18 +00:00
|
|
|
|
(funcall (default-value 'font-lock-fontify-region-function)
|
2011-12-24 19:32:31 +00:00
|
|
|
|
new-beg new-end verbose)))
|
2011-12-29 18:52:49 -08:00
|
|
|
|
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(defun c-after-font-lock-init ()
|
2011-12-24 19:32:31 +00:00
|
|
|
|
;; Put on `font-lock-mode-hook'. This function ensures our after-change
|
2013-05-02 11:18:18 +00:00
|
|
|
|
;; function will get executed before the font-lock one.
|
2015-10-09 16:34:20 -04:00
|
|
|
|
(when (memq #'c-after-change after-change-functions)
|
|
|
|
|
(remove-hook 'after-change-functions #'c-after-change t)
|
|
|
|
|
(add-hook 'after-change-functions #'c-after-change nil t)))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
|
|
|
|
(defun c-font-lock-init ()
|
|
|
|
|
"Set up the font-lock variables for using the font-lock support in CC Mode.
|
|
|
|
|
This does not load the font-lock package. Use after
|
2011-12-24 19:32:31 +00:00
|
|
|
|
`c-basic-common-init' and after cc-fonts has been loaded.
|
|
|
|
|
This function is called from `c-common-init', once per mode initialization."
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(set (make-local-variable 'font-lock-defaults)
|
2008-02-19 22:14:40 +00:00
|
|
|
|
`(,(if (c-major-mode-is 'awk-mode)
|
|
|
|
|
;; awk-mode currently has only one font lock level.
|
|
|
|
|
'awk-font-lock-keywords
|
|
|
|
|
(mapcar 'c-mode-symbol
|
|
|
|
|
'("font-lock-keywords" "font-lock-keywords-1"
|
|
|
|
|
"font-lock-keywords-2" "font-lock-keywords-3")))
|
|
|
|
|
nil nil
|
|
|
|
|
,c-identifier-syntax-modifications
|
|
|
|
|
c-beginning-of-syntax
|
|
|
|
|
(font-lock-mark-block-function
|
|
|
|
|
. c-mark-function)))
|
2011-12-24 19:32:31 +00:00
|
|
|
|
|
2015-02-01 21:20:35 +00:00
|
|
|
|
;; Prevent `font-lock-default-fontify-region' extending the region it will
|
2016-01-09 15:18:29 +00:00
|
|
|
|
;; fontify to whole lines by removing `font-lock-extend-region-wholelines'
|
|
|
|
|
;; from `font-lock-extend-region-functions'. (Emacs only). This fixes
|
|
|
|
|
;; Emacs bug #19669.
|
2015-02-01 21:20:35 +00:00
|
|
|
|
(when (boundp 'font-lock-extend-region-functions)
|
2016-01-09 15:18:29 +00:00
|
|
|
|
(setq font-lock-extend-region-functions
|
|
|
|
|
(delq 'font-lock-extend-region-wholelines
|
|
|
|
|
font-lock-extend-region-functions)))
|
2015-02-01 21:20:35 +00:00
|
|
|
|
|
2014-09-10 21:38:11 +00:00
|
|
|
|
(make-local-variable 'font-lock-fontify-region-function)
|
|
|
|
|
(setq font-lock-fontify-region-function 'c-font-lock-fontify-region)
|
2011-12-24 19:32:31 +00:00
|
|
|
|
|
2010-10-02 18:53:04 -07:00
|
|
|
|
(if (featurep 'xemacs)
|
|
|
|
|
(make-local-hook 'font-lock-mode-hook))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
(add-hook 'font-lock-mode-hook 'c-after-font-lock-init nil t))
|
|
|
|
|
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
;; Emacs 22 and later.
|
2015-04-21 14:02:10 +00:00
|
|
|
|
(defun c-extend-after-change-region (beg end _old-len)
|
2008-04-06 21:13:11 +00:00
|
|
|
|
"Extend the region to be fontified, if necessary."
|
2015-03-30 16:37:04 +00:00
|
|
|
|
;; Note: the parameter OLD-LEN is ignored here. This somewhat indirect
|
2008-04-06 21:13:11 +00:00
|
|
|
|
;; implementation exists because it is minimally different from the
|
|
|
|
|
;; stand-alone CC Mode which, lacking
|
|
|
|
|
;; font-lock-extend-after-change-region-function, is forced to use advice
|
|
|
|
|
;; instead.
|
|
|
|
|
;;
|
2009-05-19 22:35:07 +00:00
|
|
|
|
;; Of the seven CC Mode languages, currently (2009-05) only C, C++, Objc
|
|
|
|
|
;; (the languages with #define) and AWK Mode make non-null use of this
|
|
|
|
|
;; function.
|
2015-03-30 16:37:04 +00:00
|
|
|
|
(when (eq font-lock-support-mode 'jit-lock-mode)
|
2015-04-01 19:12:07 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
2015-04-21 14:02:10 +00:00
|
|
|
|
(c-save-buffer-state () ; Protect the undo-list from put-text-property.
|
|
|
|
|
(if (< c-new-BEG beg)
|
|
|
|
|
(put-text-property c-new-BEG beg 'fontified nil))
|
|
|
|
|
(if (> c-new-END end)
|
|
|
|
|
(put-text-property end c-new-END 'fontified nil)))))
|
2008-04-06 21:13:11 +00:00
|
|
|
|
(cons c-new-BEG c-new-END))
|
2008-02-19 22:14:40 +00:00
|
|
|
|
|
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.
* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
2014-12-01 15:06:49 -05:00
|
|
|
|
;; Emacs < 22 and XEmacs
|
|
|
|
|
(defmacro c-advise-fl-for-region (function)
|
|
|
|
|
`(defadvice ,function (before get-awk-region activate)
|
|
|
|
|
;; Make sure that any string/regexp is completely font-locked.
|
|
|
|
|
(when c-buffer-is-cc-mode
|
|
|
|
|
(save-excursion
|
|
|
|
|
(ad-set-arg 1 c-new-END) ; end
|
|
|
|
|
(ad-set-arg 0 c-new-BEG))))) ; beg
|
|
|
|
|
|
|
|
|
|
(unless (boundp 'font-lock-extend-after-change-region-function)
|
|
|
|
|
(c-advise-fl-for-region font-lock-after-change-function)
|
|
|
|
|
(c-advise-fl-for-region jit-lock-after-change)
|
|
|
|
|
(c-advise-fl-for-region lazy-lock-defer-rest-after-change)
|
|
|
|
|
(c-advise-fl-for-region lazy-lock-defer-line-after-change))
|
|
|
|
|
|
2014-02-17 18:16:32 +00:00
|
|
|
|
;; Connect up to `electric-indent-mode' (Emacs 24.4 and later).
|
|
|
|
|
(defun c-electric-indent-mode-hook ()
|
|
|
|
|
;; Emacs has en/disabled `electric-indent-mode'. Propagate this through to
|
|
|
|
|
;; each CC Mode buffer.
|
2014-03-03 23:03:34 -05:00
|
|
|
|
(mapc (lambda (buf)
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(when c-buffer-is-cc-mode
|
|
|
|
|
;; Don't use `c-toggle-electric-state' here due to recursion.
|
|
|
|
|
(setq c-electric-flag electric-indent-mode)
|
|
|
|
|
(c-update-modeline))))
|
|
|
|
|
(buffer-list)))
|
2014-02-17 18:16:32 +00:00
|
|
|
|
|
|
|
|
|
(defun c-electric-indent-local-mode-hook ()
|
|
|
|
|
;; Emacs has en/disabled `electric-indent-local-mode' for this buffer.
|
|
|
|
|
;; Propagate this through to this buffer's value of `c-electric-flag'
|
|
|
|
|
(when c-buffer-is-cc-mode
|
|
|
|
|
(setq c-electric-flag electric-indent-mode)
|
|
|
|
|
(c-update-modeline)))
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
;; Support for C
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar c-mode-syntax-table
|
|
|
|
|
(funcall (c-lang-const c-make-mode-syntax-table c))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Syntax table used in c-mode buffers.")
|
|
|
|
|
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-define-abbrev-table 'c-mode-abbrev-table
|
|
|
|
|
'(("else" "else" c-electric-continued-statement 0)
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
("while" "while" c-electric-continued-statement 0))
|
|
|
|
|
"Abbreviation table used in c-mode buffers.")
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar c-mode-map
|
|
|
|
|
(let ((map (c-make-inherited-keymap)))
|
|
|
|
|
map)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
"Keymap used in c-mode buffers.")
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; Add bindings which are only useful for C.
|
|
|
|
|
(define-key c-mode-map "\C-c\C-e" 'c-macro-expand)
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
(easy-menu-define c-c-menu c-mode-map "C Mode Commands"
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cons "C" (c-lang-const c-mode-menu c)))
|
|
|
|
|
|
|
|
|
|
;; In XEmacs >= 21.5 modes should add their own entries to
|
|
|
|
|
;; `auto-mode-alist'. The comment form of autoload is used to avoid
|
|
|
|
|
;; doing this on load. That since `add-to-list' prepends the value
|
|
|
|
|
;; which could cause it to clobber user settings. Later emacsen have
|
|
|
|
|
;; an append option, but it's not safe to use.
|
2003-07-05 19:53:33 +00:00
|
|
|
|
|
2009-01-30 21:24:22 +00:00
|
|
|
|
;; The extension ".C" is associated with C++ while the lowercase
|
|
|
|
|
;; variant goes with C. On case insensitive file systems, this means
|
2003-07-05 19:53:33 +00:00
|
|
|
|
;; that ".c" files also might open C++ mode if the C++ entry comes
|
|
|
|
|
;; first on `auto-mode-alist'. Thus we try to ensure that ".C" comes
|
|
|
|
|
;; after ".c", and since `add-to-list' adds the entry first we have to
|
|
|
|
|
;; add the ".C" entry first.
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.\\(cc\\|hh\\)\\'" . c++-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.\\(CC?\\|HH?\\)\\'" . c++-mode))
|
|
|
|
|
|
2016-06-07 14:05:36 +02:00
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.c\\'" . c-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.h\\'" . c-or-c++-mode))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
;; NB: The following two associate yacc and lex files to C Mode, which
|
|
|
|
|
;; is not really suitable for those formats. Anyway, afaik there's
|
|
|
|
|
;; currently no better mode for them, and besides this is legacy.
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.y\\(acc\\)?\\'" . c-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.lex\\'" . c-mode))
|
|
|
|
|
|
2008-07-24 02:55:59 +00:00
|
|
|
|
;; Preprocessed files generated by C and C++ compilers.
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.i\\'" . c-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.ii\\'" . c++-mode))
|
|
|
|
|
|
2014-10-04 00:03:49 -04:00
|
|
|
|
(unless (fboundp 'prog-mode) (defalias 'prog-mode 'fundamental-mode))
|
2008-07-24 02:55:59 +00:00
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;;;###autoload
|
2011-05-28 13:16:54 -04:00
|
|
|
|
(define-derived-mode c-mode prog-mode "C"
|
2015-09-24 09:13:36 -07:00
|
|
|
|
"Major mode for editing C code.
|
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
To submit a problem report, enter `\\[c-submit-bug-report]' from a
|
|
|
|
|
c-mode buffer. This automatically sets up a mail buffer with version
|
|
|
|
|
information already added. You just need to add a description of the
|
2003-07-05 19:53:33 +00:00
|
|
|
|
problem, including a reproducible test case, and send the message.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
To see what version of CC Mode you are running, enter `\\[c-version]'.
|
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
The hook `c-mode-common-hook' is run with no args at mode
|
|
|
|
|
initialization, then `c-mode-hook'.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
Key bindings:
|
|
|
|
|
\\{c-mode-map}"
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
:after-hook (progn (c-make-noise-macro-regexps)
|
|
|
|
|
(c-make-macro-with-semi-re)
|
|
|
|
|
(c-update-modeline))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(c-initialize-cc-mode t)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(setq abbrev-mode t)
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'c-mode)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-common-init 'c-mode)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(easy-menu-add c-c-menu)
|
1999-12-12 18:24:19 +00:00
|
|
|
|
(cc-imenu-init cc-imenu-c-generic-expression)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(c-run-mode-hooks 'c-mode-common-hook))
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
2016-06-07 14:05:36 +02:00
|
|
|
|
(defconst c-or-c++-mode--regexp
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(let ((id "[a-zA-Z0-9_]+") (ws "[ \t\r]+") (ws-maybe "[ \t\r]*"))
|
|
|
|
|
(concat "^" ws-maybe "\\(?:"
|
|
|
|
|
"using" ws "\\(?:namespace" ws "std;\\|std::\\)"
|
|
|
|
|
"\\|" "namespace" "\\(:?" ws id "\\)?" ws-maybe "{"
|
|
|
|
|
"\\|" "class" ws id ws-maybe "[:{\n]"
|
|
|
|
|
"\\|" "template" ws-maybe "<.*>"
|
|
|
|
|
"\\|" "#include" ws-maybe "<\\(?:string\\|iostream\\|map\\)>"
|
|
|
|
|
"\\)")))
|
|
|
|
|
"A regexp applied to C header files to check if they are really C++.")
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun c-or-c++-mode ()
|
|
|
|
|
"Analyse buffer and enable either C or C++ mode.
|
|
|
|
|
|
|
|
|
|
Some people and projects use .h extension for C++ header files
|
|
|
|
|
which is also the one used for C header files. This makes
|
|
|
|
|
matching on file name insufficient for detecting major mode that
|
|
|
|
|
should be used.
|
|
|
|
|
|
|
|
|
|
This function attempts to use file contents to determine whether
|
|
|
|
|
the code is C or C++ and based on that chooses whether to enable
|
|
|
|
|
`c-mode' or `c++-mode'."
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(save-match-data
|
|
|
|
|
(widen)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(re-search-forward c-or-c++-mode--regexp
|
|
|
|
|
(+ (point) c-guess-region-max) t))))
|
|
|
|
|
(c++-mode)
|
|
|
|
|
(c-mode)))
|
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Support for C++
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar c++-mode-syntax-table
|
|
|
|
|
(funcall (c-lang-const c-make-mode-syntax-table c++))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Syntax table used in c++-mode buffers.")
|
|
|
|
|
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-define-abbrev-table 'c++-mode-abbrev-table
|
|
|
|
|
'(("else" "else" c-electric-continued-statement 0)
|
|
|
|
|
("while" "while" c-electric-continued-statement 0)
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
("catch" "catch" c-electric-continued-statement 0))
|
|
|
|
|
"Abbreviation table used in c++-mode buffers.")
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar c++-mode-map
|
|
|
|
|
(let ((map (c-make-inherited-keymap)))
|
|
|
|
|
map)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
"Keymap used in c++-mode buffers.")
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; Add bindings which are only useful for C++.
|
|
|
|
|
(define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
|
|
|
|
|
(define-key c++-mode-map "\C-c:" 'c-scope-operator)
|
|
|
|
|
(define-key c++-mode-map "<" 'c-electric-lt-gt)
|
|
|
|
|
(define-key c++-mode-map ">" 'c-electric-lt-gt)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
(easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cons "C++" (c-lang-const c-mode-menu c++)))
|
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;;;###autoload
|
2011-05-28 13:16:54 -04:00
|
|
|
|
(define-derived-mode c++-mode prog-mode "C++"
|
1997-07-10 07:54:06 +00:00
|
|
|
|
"Major mode for editing C++ code.
|
|
|
|
|
To submit a problem report, enter `\\[c-submit-bug-report]' from a
|
|
|
|
|
c++-mode buffer. This automatically sets up a mail buffer with
|
|
|
|
|
version information already added. You just need to add a description
|
|
|
|
|
of the problem, including a reproducible test case, and send the
|
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
To see what version of CC Mode you are running, enter `\\[c-version]'.
|
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
The hook `c-mode-common-hook' is run with no args at mode
|
|
|
|
|
initialization, then `c++-mode-hook'.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
Key bindings:
|
|
|
|
|
\\{c++-mode-map}"
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
:after-hook (progn (c-make-noise-macro-regexps)
|
|
|
|
|
(c-make-macro-with-semi-re)
|
|
|
|
|
(c-update-modeline))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(c-initialize-cc-mode t)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(setq abbrev-mode t)
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'c++-mode)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-common-init 'c++-mode)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(easy-menu-add c-c++-menu)
|
1999-12-12 18:24:19 +00:00
|
|
|
|
(cc-imenu-init cc-imenu-c++-generic-expression)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(c-run-mode-hooks 'c-mode-common-hook))
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Support for Objective-C
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar objc-mode-syntax-table
|
|
|
|
|
(funcall (c-lang-const c-make-mode-syntax-table objc))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Syntax table used in objc-mode buffers.")
|
|
|
|
|
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-define-abbrev-table 'objc-mode-abbrev-table
|
|
|
|
|
'(("else" "else" c-electric-continued-statement 0)
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
("while" "while" c-electric-continued-statement 0))
|
|
|
|
|
"Abbreviation table used in objc-mode buffers.")
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar objc-mode-map
|
|
|
|
|
(let ((map (c-make-inherited-keymap)))
|
|
|
|
|
map)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
"Keymap used in objc-mode buffers.")
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; Add bindings which are only useful for Objective-C.
|
|
|
|
|
(define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
(easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cons "ObjC" (c-lang-const c-mode-menu objc)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.m\\'" . objc-mode))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;;;###autoload
|
2011-05-28 13:16:54 -04:00
|
|
|
|
(define-derived-mode objc-mode prog-mode "ObjC"
|
1997-07-10 07:54:06 +00:00
|
|
|
|
"Major mode for editing Objective C code.
|
|
|
|
|
To submit a problem report, enter `\\[c-submit-bug-report]' from an
|
|
|
|
|
objc-mode buffer. This automatically sets up a mail buffer with
|
|
|
|
|
version information already added. You just need to add a description
|
|
|
|
|
of the problem, including a reproducible test case, and send the
|
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
To see what version of CC Mode you are running, enter `\\[c-version]'.
|
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
The hook `c-mode-common-hook' is run with no args at mode
|
|
|
|
|
initialization, then `objc-mode-hook'.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
Key bindings:
|
|
|
|
|
\\{objc-mode-map}"
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
:after-hook (progn (c-make-noise-macro-regexps)
|
|
|
|
|
(c-make-macro-with-semi-re)
|
|
|
|
|
(c-update-modeline))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(c-initialize-cc-mode t)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(setq abbrev-mode t)
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'objc-mode)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-common-init 'objc-mode)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(easy-menu-add c-objc-menu)
|
|
|
|
|
(cc-imenu-init nil 'cc-imenu-objc-function)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(c-run-mode-hooks 'c-mode-common-hook))
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Support for Java
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar java-mode-syntax-table
|
|
|
|
|
(funcall (c-lang-const c-make-mode-syntax-table java))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Syntax table used in java-mode buffers.")
|
|
|
|
|
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-define-abbrev-table 'java-mode-abbrev-table
|
|
|
|
|
'(("else" "else" c-electric-continued-statement 0)
|
|
|
|
|
("while" "while" c-electric-continued-statement 0)
|
|
|
|
|
("catch" "catch" c-electric-continued-statement 0)
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
("finally" "finally" c-electric-continued-statement 0))
|
|
|
|
|
"Abbreviation table used in java-mode buffers.")
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar java-mode-map
|
|
|
|
|
(let ((map (c-make-inherited-keymap)))
|
|
|
|
|
map)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
"Keymap used in java-mode buffers.")
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; Add bindings which are only useful for Java.
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
;; Regexp trying to describe the beginning of a Java top-level
|
|
|
|
|
;; definition. This is not used by CC Mode, nor is it maintained
|
|
|
|
|
;; since it's practically impossible to write a regexp that reliably
|
|
|
|
|
;; matches such a construct. Other tools are necessary.
|
|
|
|
|
(defconst c-Java-defun-prompt-regexp
|
|
|
|
|
"^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f\v]*\\)+\\)?\\s-*")
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cons "Java" (c-lang-const c-mode-menu java)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.java\\'" . java-mode))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;;;###autoload
|
2011-05-28 13:16:54 -04:00
|
|
|
|
(define-derived-mode java-mode prog-mode "Java"
|
1997-07-10 07:54:06 +00:00
|
|
|
|
"Major mode for editing Java code.
|
1997-10-23 07:31:46 +00:00
|
|
|
|
To submit a problem report, enter `\\[c-submit-bug-report]' from a
|
1997-07-10 07:54:06 +00:00
|
|
|
|
java-mode buffer. This automatically sets up a mail buffer with
|
|
|
|
|
version information already added. You just need to add a description
|
2003-07-05 19:53:33 +00:00
|
|
|
|
of the problem, including a reproducible test case, and send the
|
1997-07-10 07:54:06 +00:00
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
To see what version of CC Mode you are running, enter `\\[c-version]'.
|
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
The hook `c-mode-common-hook' is run with no args at mode
|
|
|
|
|
initialization, then `java-mode-hook'.
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
Key bindings:
|
|
|
|
|
\\{java-mode-map}"
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
:after-hook (c-update-modeline)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(c-initialize-cc-mode t)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(setq abbrev-mode t)
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'java-mode)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-common-init 'java-mode)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(easy-menu-add c-java-menu)
|
1999-12-12 18:24:19 +00:00
|
|
|
|
(cc-imenu-init cc-imenu-java-generic-expression)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(c-run-mode-hooks 'c-mode-common-hook))
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
1997-08-09 18:31:43 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Support for CORBA's IDL language
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar idl-mode-syntax-table
|
|
|
|
|
(funcall (c-lang-const c-make-mode-syntax-table idl))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Syntax table used in idl-mode buffers.")
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(c-define-abbrev-table 'idl-mode-abbrev-table nil
|
2001-03-21 12:59:36 +00:00
|
|
|
|
"Abbreviation table used in idl-mode buffers.")
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar idl-mode-map
|
|
|
|
|
(let ((map (c-make-inherited-keymap)))
|
|
|
|
|
map)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
"Keymap used in idl-mode buffers.")
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; Add bindings which are only useful for IDL.
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
(easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cons "IDL" (c-lang-const c-mode-menu idl)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.idl\\'" . idl-mode))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
1997-08-09 18:31:43 +00:00
|
|
|
|
;;;###autoload
|
2011-05-28 13:16:54 -04:00
|
|
|
|
(define-derived-mode idl-mode prog-mode "IDL"
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Major mode for editing CORBA's IDL, PSDL and CIDL code.
|
1997-08-09 18:31:43 +00:00
|
|
|
|
To submit a problem report, enter `\\[c-submit-bug-report]' from an
|
|
|
|
|
idl-mode buffer. This automatically sets up a mail buffer with
|
|
|
|
|
version information already added. You just need to add a description
|
|
|
|
|
of the problem, including a reproducible test case, and send the
|
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
To see what version of CC Mode you are running, enter `\\[c-version]'.
|
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
The hook `c-mode-common-hook' is run with no args at mode
|
|
|
|
|
initialization, then `idl-mode-hook'.
|
1997-08-09 18:31:43 +00:00
|
|
|
|
|
|
|
|
|
Key bindings:
|
|
|
|
|
\\{idl-mode-map}"
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
:after-hook (c-update-modeline)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(c-initialize-cc-mode t)
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'idl-mode)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-common-init 'idl-mode)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(easy-menu-add c-idl-menu)
|
|
|
|
|
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(c-run-mode-hooks 'c-mode-common-hook))
|
1997-08-09 18:31:43 +00:00
|
|
|
|
|
1999-02-08 16:53:18 +00:00
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
;; Support for Pike
|
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar pike-mode-syntax-table
|
|
|
|
|
(funcall (c-lang-const c-make-mode-syntax-table pike))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
"Syntax table used in pike-mode buffers.")
|
|
|
|
|
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-define-abbrev-table 'pike-mode-abbrev-table
|
|
|
|
|
'(("else" "else" c-electric-continued-statement 0)
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
("while" "while" c-electric-continued-statement 0))
|
|
|
|
|
"Abbreviation table used in pike-mode buffers.")
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar pike-mode-map
|
|
|
|
|
(let ((map (c-make-inherited-keymap)))
|
|
|
|
|
map)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
"Keymap used in pike-mode buffers.")
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; Additional bindings.
|
|
|
|
|
(define-key pike-mode-map "\C-c\C-e" 'c-macro-expand)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
(easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(cons "Pike" (c-lang-const c-mode-menu pike)))
|
|
|
|
|
|
2012-05-25 19:34:16 -07:00
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode))
|
2013-09-10 23:44:35 -07:00
|
|
|
|
;;;###autoload (add-to-list 'interpreter-mode-alist '("pike" . pike-mode))
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
1999-02-08 16:53:18 +00:00
|
|
|
|
;;;###autoload
|
2011-05-28 13:16:54 -04:00
|
|
|
|
(define-derived-mode pike-mode prog-mode "Pike"
|
1999-02-08 16:53:18 +00:00
|
|
|
|
"Major mode for editing Pike code.
|
2002-04-22 00:35:36 +00:00
|
|
|
|
To submit a problem report, enter `\\[c-submit-bug-report]' from a
|
|
|
|
|
pike-mode buffer. This automatically sets up a mail buffer with
|
1999-02-08 16:53:18 +00:00
|
|
|
|
version information already added. You just need to add a description
|
|
|
|
|
of the problem, including a reproducible test case, and send the
|
|
|
|
|
message.
|
|
|
|
|
|
|
|
|
|
To see what version of CC Mode you are running, enter `\\[c-version]'.
|
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
The hook `c-mode-common-hook' is run with no args at mode
|
|
|
|
|
initialization, then `pike-mode-hook'.
|
1999-02-08 16:53:18 +00:00
|
|
|
|
|
|
|
|
|
Key bindings:
|
|
|
|
|
\\{pike-mode-map}"
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
:after-hook (c-update-modeline)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(c-initialize-cc-mode t)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(setq abbrev-mode t)
|
2003-08-03 12:31:46 +00:00
|
|
|
|
(c-init-language-vars-for 'pike-mode)
|
2002-04-22 00:35:36 +00:00
|
|
|
|
(c-common-init 'pike-mode)
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(easy-menu-add c-pike-menu)
|
|
|
|
|
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(c-run-mode-hooks 'c-mode-common-hook))
|
1999-02-08 16:53:18 +00:00
|
|
|
|
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
2005-12-02 12:30:36 +00:00
|
|
|
|
;; Support for AWK
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
2003-07-05 19:53:33 +00:00
|
|
|
|
;;;###autoload (add-to-list 'auto-mode-alist '("\\.awk\\'" . awk-mode))
|
2013-09-10 23:44:35 -07:00
|
|
|
|
;;;###autoload (add-to-list 'interpreter-mode-alist '("awk" . awk-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'interpreter-mode-alist '("mawk" . awk-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'interpreter-mode-alist '("nawk" . awk-mode))
|
|
|
|
|
;;;###autoload (add-to-list 'interpreter-mode-alist '("gawk" . awk-mode))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(c-define-abbrev-table 'awk-mode-abbrev-table
|
|
|
|
|
'(("else" "else" c-electric-continued-statement 0)
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
("while" "while" c-electric-continued-statement 0))
|
|
|
|
|
"Abbreviation table used in awk-mode buffers.")
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
* lisp/progmodes/cc-mode.el: Minor cleanup of var declarations.
(c-define-abbrev-table): Add `doc' argument.
(c-mode-abbrev-table, c++-mode-abbrev-table)
(objc-mode-abbrev-table, java-mode-abbrev-table)
(idl-mode-abbrev-table, pike-mode-abbrev-table)
(awk-mode-abbrev-table): Use it.
(c-mode-syntax-table, c-mode-map, c++-mode-syntax-table)
(c++-mode-map, objc-mode-syntax-table, objc-mode-map)
(java-mode-syntax-table, java-mode-map, idl-mode-syntax-table)
(idl-mode-map, pike-mode-syntax-table, pike-mode-map, awk-mode-map):
Move initialization into the declaration; and remove any
autoload cookie.
2013-08-28 16:24:18 -04:00
|
|
|
|
(defvar awk-mode-map
|
|
|
|
|
(let ((map (c-make-inherited-keymap)))
|
|
|
|
|
map)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
"Keymap used in awk-mode buffers.")
|
2017-06-15 20:47:11 +00:00
|
|
|
|
;; Add bindings which are only useful for awk.
|
|
|
|
|
(define-key awk-mode-map "#" 'self-insert-command);Overrides electric parent binding.
|
|
|
|
|
(define-key awk-mode-map "/" 'self-insert-command);Overrides electric parent binding.
|
|
|
|
|
(define-key awk-mode-map "*" 'self-insert-command);Overrides electric parent binding.
|
|
|
|
|
(define-key awk-mode-map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
|
|
|
|
|
(define-key awk-mode-map "\C-c\C-p" 'undefined)
|
|
|
|
|
(define-key awk-mode-map "\C-c\C-u" 'undefined)
|
|
|
|
|
(define-key awk-mode-map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
|
|
|
|
|
(define-key awk-mode-map "\M-e" 'c-end-of-statement) ; 2003/10/7
|
|
|
|
|
(define-key awk-mode-map "\C-\M-a" 'c-awk-beginning-of-defun)
|
|
|
|
|
(define-key awk-mode-map "\C-\M-e" 'c-awk-end-of-defun)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
|
|
|
|
|
(easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands"
|
|
|
|
|
(cons "AWK" (c-lang-const c-mode-menu awk)))
|
|
|
|
|
|
2008-05-15 03:30:40 +00:00
|
|
|
|
;; (require 'cc-awk) brings these in.
|
|
|
|
|
(defvar awk-mode-syntax-table)
|
|
|
|
|
(declare-function c-awk-unstick-NL-prop "cc-awk" ())
|
|
|
|
|
|
2011-05-28 13:16:54 -04:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-derived-mode awk-mode prog-mode "AWK"
|
2005-12-02 12:30:36 +00:00
|
|
|
|
"Major mode for editing AWK code.
|
2003-07-03 12:30:59 +00:00
|
|
|
|
To submit a problem report, enter `\\[c-submit-bug-report]' from an
|
|
|
|
|
awk-mode buffer. This automatically sets up a mail buffer with version
|
|
|
|
|
information already added. You just need to add a description of the
|
2003-07-05 19:53:33 +00:00
|
|
|
|
problem, including a reproducible test case, and send the message.
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
|
|
|
|
To see what version of CC Mode you are running, enter `\\[c-version]'.
|
|
|
|
|
|
|
|
|
|
The hook `c-mode-common-hook' is run with no args at mode
|
|
|
|
|
initialization, then `awk-mode-hook'.
|
|
|
|
|
|
|
|
|
|
Key bindings:
|
|
|
|
|
\\{awk-mode-map}"
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
:after-hook (c-update-modeline)
|
2011-09-09 09:52:26 +00:00
|
|
|
|
;; We need the next line to stop the macro defining
|
|
|
|
|
;; `awk-mode-syntax-table'. This would mask the real table which is
|
|
|
|
|
;; declared in cc-awk.el and hasn't yet been loaded.
|
|
|
|
|
:syntax-table nil
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(require 'cc-awk) ; Added 2003/6/10.
|
|
|
|
|
(c-initialize-cc-mode t)
|
2017-02-18 12:38:29 +00:00
|
|
|
|
(set-syntax-table awk-mode-syntax-table)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(setq abbrev-mode t)
|
2005-12-02 12:30:36 +00:00
|
|
|
|
(c-init-language-vars-for 'awk-mode)
|
|
|
|
|
(c-common-init 'awk-mode)
|
|
|
|
|
(c-awk-unstick-NL-prop)
|
CC Mode now uses the new :after-hook feature of define-derived-mode
It now runs internal variable setting functions after the mode hooks, no
longer runs the mode hooks twice, and declares the configuration variables for
noise macros and macros with semicolons as safe variables (when given suitable
arguments).
Fixes bug #16759 and bug #23476.
* .dir-locals: Put the c-noise-macros-with-paren-names setting back into the C
Mode value.
* lisp/progmodes/cc-mode.el: (c-basic-common-init): Remove the call to
c-make-macro-with-semi-re.
(c-mode, c++-mode, objc-mode, java-mode, idl-mode, pike-mode, awk-mode): Move
c-make-noise-macro-regexps and c-make-macro-with-semi-re (where appropriate)
and c-update-modeline into the :after-hook form. Remove the explicit settings
of the syntax table, the abbreviation table and the local key map, since they
duplicate forms generated by define-derived-mode. Remove the explicit
invocation of each mode's mode hook, since they duplicate ones generated by
define-derived-mode.
* lisp/progmodes/cc-vars.el: (c-string-list-p, c-string-or-string-list-p): New
functions.
(c-noise-macro-names, c-noise-macro-with-parens-names): give the
save-local-variable property c-string-list-p.
(c-macro-names-with-semicolon): give the save-local-variable property
c-string-or-string-list-p.
* doc/misc/cc-mode.texi: (Macros with ;, Noise Macros): Note that it's not
necessary to call the regexp generating functions after setting the pertinent
configuration values in a mode hook.
2016-05-09 17:49:45 +00:00
|
|
|
|
(c-run-mode-hooks 'c-mode-common-hook))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
1997-10-23 07:49:25 +00:00
|
|
|
|
;; bug reporting
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
(defconst c-mode-help-address
|
2015-05-26 23:29:25 -07:00
|
|
|
|
"submit@debbugs.gnu.org"
|
2002-04-22 00:35:36 +00:00
|
|
|
|
"Address(es) for CC Mode bug reports.")
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
(defun c-version ()
|
|
|
|
|
"Echo the current version of CC Mode in the minibuffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(message "Using CC Mode version %s" c-version)
|
|
|
|
|
(c-keep-region-active))
|
|
|
|
|
|
2012-10-23 11:06:07 -04:00
|
|
|
|
(define-obsolete-variable-alias 'c-prepare-bug-report-hooks
|
|
|
|
|
'c-prepare-bug-report-hook "24.3")
|
|
|
|
|
(defvar c-prepare-bug-report-hook nil)
|
2001-03-21 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
;; Dynamic variables used by reporter.
|
|
|
|
|
(defvar reporter-prompt-for-summary-p)
|
|
|
|
|
(defvar reporter-dont-compact-list)
|
|
|
|
|
|
2015-05-26 23:29:25 -07:00
|
|
|
|
;; This could be "emacs,cc-mode" in the version included in Emacs.
|
|
|
|
|
(defconst c-mode-bug-package "cc-mode"
|
|
|
|
|
"The package to use in the bug submission.")
|
|
|
|
|
|
|
|
|
|
;; reporter-submit-bug-report requires sendmail.
|
|
|
|
|
(declare-function mail-position-on-field "sendmail" (field &optional soft))
|
|
|
|
|
|
1997-07-10 07:54:06 +00:00
|
|
|
|
(defun c-submit-bug-report ()
|
|
|
|
|
"Submit via mail a bug report on CC Mode."
|
|
|
|
|
(interactive)
|
1998-02-17 07:11:40 +00:00
|
|
|
|
(require 'reporter)
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;; load in reporter
|
|
|
|
|
(let ((reporter-prompt-for-summary-p t)
|
|
|
|
|
(reporter-dont-compact-list '(c-offsets-alist))
|
|
|
|
|
(style c-indentation-style)
|
|
|
|
|
(c-features c-emacs-features))
|
|
|
|
|
(and
|
|
|
|
|
(if (y-or-n-p "Do you want to submit a report on CC Mode? ")
|
|
|
|
|
t (message "") nil)
|
|
|
|
|
(reporter-submit-bug-report
|
|
|
|
|
c-mode-help-address
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(concat "CC Mode " c-version " (" mode-name ")")
|
1999-12-12 18:24:19 +00:00
|
|
|
|
(let ((vars (append
|
|
|
|
|
c-style-variables
|
2003-07-03 12:30:59 +00:00
|
|
|
|
'(c-buffer-is-cc-mode
|
1999-12-12 18:24:19 +00:00
|
|
|
|
c-tab-always-indent
|
2003-07-03 12:30:59 +00:00
|
|
|
|
c-syntactic-indentation
|
|
|
|
|
c-syntactic-indentation-in-macros
|
|
|
|
|
c-ignore-auto-fill
|
|
|
|
|
c-auto-align-backslashes
|
|
|
|
|
c-backspace-function
|
|
|
|
|
c-delete-function
|
|
|
|
|
c-electric-pound-behavior
|
|
|
|
|
c-default-style
|
|
|
|
|
c-enable-xemacs-performance-kludge-p
|
|
|
|
|
c-old-style-variable-behavior
|
1999-12-12 18:24:19 +00:00
|
|
|
|
defun-prompt-regexp
|
|
|
|
|
tab-width
|
|
|
|
|
comment-column
|
|
|
|
|
parse-sexp-ignore-comments
|
2003-07-03 12:30:59 +00:00
|
|
|
|
parse-sexp-lookup-properties
|
|
|
|
|
lookup-syntax-properties
|
1999-12-12 18:24:19 +00:00
|
|
|
|
;; A brain-damaged XEmacs only variable that, if
|
|
|
|
|
;; set to nil can cause all kinds of chaos.
|
|
|
|
|
signal-error-on-buffer-boundary
|
|
|
|
|
;; Variables that affect line breaking and comments.
|
2003-07-03 12:30:59 +00:00
|
|
|
|
auto-fill-mode
|
2000-07-24 11:10:33 +00:00
|
|
|
|
auto-fill-function
|
1999-12-12 18:24:19 +00:00
|
|
|
|
filladapt-mode
|
|
|
|
|
comment-multi-line
|
|
|
|
|
comment-start-skip
|
|
|
|
|
fill-prefix
|
2003-07-03 12:30:59 +00:00
|
|
|
|
fill-column
|
1999-12-12 18:24:19 +00:00
|
|
|
|
paragraph-start
|
|
|
|
|
adaptive-fill-mode
|
|
|
|
|
adaptive-fill-regexp)
|
|
|
|
|
nil)))
|
2007-10-12 03:03:25 +00:00
|
|
|
|
(mapc (lambda (var) (unless (boundp var)
|
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
2010-12-10 15:00:25 -05:00
|
|
|
|
(setq vars (delq var vars))))
|
2007-10-12 03:03:25 +00:00
|
|
|
|
'(signal-error-on-buffer-boundary
|
|
|
|
|
filladapt-mode
|
|
|
|
|
defun-prompt-regexp
|
|
|
|
|
font-lock-mode
|
2014-01-30 21:39:40 -05:00
|
|
|
|
auto-fill-mode
|
2007-10-12 03:03:25 +00:00
|
|
|
|
font-lock-maximum-decoration
|
|
|
|
|
parse-sexp-lookup-properties
|
|
|
|
|
lookup-syntax-properties))
|
1999-12-12 18:24:19 +00:00
|
|
|
|
vars)
|
2001-11-26 21:15:29 +00:00
|
|
|
|
(lambda ()
|
2012-10-23 11:06:07 -04:00
|
|
|
|
(run-hooks 'c-prepare-bug-report-hook)
|
2015-05-26 23:29:25 -07:00
|
|
|
|
(save-excursion
|
|
|
|
|
(or (mail-position-on-field "X-Debbugs-Package")
|
|
|
|
|
(insert c-mode-bug-package)))
|
2003-07-03 12:30:59 +00:00
|
|
|
|
(insert (format "Buffer Style: %s\nc-emacs-features: %s\n"
|
2002-04-22 00:35:36 +00:00
|
|
|
|
style c-features)))))))
|
1997-07-10 07:54:06 +00:00
|
|
|
|
|
|
|
|
|
|
2001-03-21 12:59:36 +00:00
|
|
|
|
(cc-provide 'cc-mode)
|
2003-09-01 15:45:59 +00:00
|
|
|
|
|
2015-08-21 23:46:21 -04:00
|
|
|
|
;; Local Variables:
|
|
|
|
|
;; indent-tabs-mode: t
|
|
|
|
|
;; tab-width: 8
|
|
|
|
|
;; End:
|
1997-07-10 07:54:06 +00:00
|
|
|
|
;;; cc-mode.el ends here
|