From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Alan Mackenzie <acm@muc.de>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Further CC-mode changes
Date: Thu, 11 Sep 2014 09:55:29 -0400 [thread overview]
Message-ID: <jwvfvfye1oz.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvtx4iowv2.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 08 Sep 2014 13:28:32 -0400")
While waiting for your guidance as to which parts of my patches need to
be reverted and why, here's some candidate patch which (contrary to the
one you reverted) actually changes the code's behavior.
It's to be applied on top of the ones you removed (tho since the ones
you remove are mostly cosmetic, it shouldn't make much of a difference).
Questions:
- should C-c C-n and friends be moved to c-derivative-mode-map
(AFAIK neither Java nor IDL nor Pike have CPP conditionals)?
- I notice that all cc-mode enable abbrev-mode except for idl-mode.
Was that on purpose or is it just accidental?
- BTW, I think it would be better not to enable abbrev-mode (let it be
a user's choice). IIUC CC-mode relies on abbrev-mode internally
for some of its electric-indent functionality, so we'd have to use
some other approach (e.g. a post-self-insert-hook).
This is not really tested, especially not on XEmacs, but AFAIK it
doesn't depend on any feature specific to a particular Emacs version.
Stefan
- Move awk-mode's actual definition to cc-awk so as to get rid of the
(require 'cc-awk) and the ":syntax-table nil" hack.
- make awk-mode use syntax-propertize when available.
- Use define-derived-mode's built-in keymap inheritance rather than
c-make-inherited-keymap.
- initialize c-mode-base-map in its defvar.
- fix c-after-font-lock-init so it doesn't accidentally add
a c-after-change which wasn't there to begin with.
- Run c-update-modeline from after-change-major-mode-hook and
hack-local-variables-hook rather than from the major mode function.
This lets us fix the bug where c-mode-hook is run twice and saves us
from having to define c-run-mode-hooks.
- make c-mode-common into an actual parent mode. There is a naming problem
since we have c-mode-base-map for the "parent map" but
c-mode-common-hook for the "parent hook", and also because this "mode"
doesn't end in "-mode", but I think we can live with it.
- add a new parent mode c-derivative-mode which can hold those things
common to c, c++, and objc (i.e. languages which include C as a subset).
I was tempted to simply use c-mode as the parent for c++-mode and
objc-mode, but this would be a lot more intrusive and it would force
the presence of a "C" menu in both C++ and ObjC modes (we could fix
that for Emacs, but I'm not sure how to do it for XEmacs, and it
doesn't seem worth the trouble).
=== modified file 'lisp/progmodes/cc-awk.el'
--- lisp/progmodes/cc-awk.el 2014-09-09 15:08:08 +0000
+++ lisp/progmodes/cc-awk.el 2014-09-11 13:48:50 +0000
@@ -42,6 +42,7 @@
(require 'cc-defs)
(require 'cc-engine)
+(require 'cc-mode)
(defvar awk-mode-syntax-table
(let ((st (make-syntax-table)))
@@ -52,7 +53,7 @@
(modify-syntax-entry ?\# "< " st)
;; / can delimit regexes or be a division operator. By default we assume
;; that it is a division sign, and fix the regexp operator cases with
- ;; `font-lock-syntactic-keywords'.
+ ;; `syntax-table' text-properties.
(modify-syntax-entry ?/ "." st) ; ACM 2002/4/27.
(modify-syntax-entry ?* "." st)
(modify-syntax-entry ?+ "." st)
@@ -848,6 +849,17 @@
(max (+ (- c-awk-old-ByLL old-len) (- end beg))
(c-awk-beyond-logical-line end)))
+(defun c-awk-syntax-propertize (beg end)
+ (c-awk-clear-NL-props beg (point-max))
+ (goto-char beg)
+ (c-awk-set-syntax-table-properties end))
+
+(defun c-awk-syntax-propertize-extend-region (beg end)
+ (let ((newend (c-awk-beyond-logical-line end))
+ (newbeg (c-awk-beginning-of-logical-line beg)))
+ (if (or (< newbeg beg) (> newend end))
+ (cons newbeg newend))))
+
;; ACM 2002/5/25. When font-locking is invoked by a buffer change, the region
;; specified by the font-lock after-change function must be expanded to
;; include ALL of any string or regexp within the region. The simplest way to
@@ -1129,5 +1141,80 @@
(goto-char (min start-point end-point)))))))
\f
+;; Support for AWK
+
+;;;###autoload (add-to-list 'auto-mode-alist '("\\.awk\\'" . awk-mode))
+;;;###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))
+
+(c-define-abbrev-table 'awk-mode-abbrev-table
+ '(("else" "else" c-electric-continued-statement 0)
+ ("while" "while" c-electric-continued-statement 0))
+ "Abbreviation table used in awk-mode buffers.")
+
+(defvar awk-mode-map
+ (let ((map (make-sparse-keymap))
+ (sic (if (featurep 'xemacs) 'self-insert-command)))
+ ;; Add bindings which are only useful for awk.
+ (define-key map "#" sic) ; Override electric parent binding.
+ (define-key map "/" sic) ; Override electric parent binding.
+ (define-key map "*" sic) ; Override electric parent binding.
+ (define-key map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
+ (define-key map "\C-c\C-p" 'undefined)
+ (define-key map "\C-c\C-u" 'undefined)
+ (define-key map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
+ (define-key map "\M-e" 'c-end-of-statement) ; 2003/10/7
+ (define-key map "\C-\M-a" 'c-awk-beginning-of-defun)
+ (define-key map "\C-\M-e" 'c-awk-end-of-defun)
+ map)
+ "Keymap used in awk-mode buffers.")
+
+(easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands"
+ (cons "AWK" (c-lang-const c-mode-menu awk)))
+
+;;;###autoload
+(define-derived-mode awk-mode c-mode-common "AWK"
+ "Major mode for editing AWK code.
+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
+problem, including a reproducible test case, and send the message.
+
+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}"
+ (c-init-language-vars-for 'awk-mode)
+ (c-common-init 'awk-mode)
+ (c-awk-unstick-NL-prop)
+ (when (fboundp 'syntax-propertize)
+ ;; `c-basic-common-init' unconditionally adds `c-before-change' but this
+ ;; function does lots of irrelevant stuff for us (to do with maintaining
+ ;; `c-found-types' and `c-state-cache'). The only useful thing it does is
+ ;; run `c-get-state-before-change-functions' where we normally add
+ ;; `c-awk-record-region-clear-NL'.
+ (remove-hook 'before-change-functions #'c-before-change t)
+ ;; Same thing for `after-change-functions' with `c-after-change' vs
+ ;; `c-awk-extend-and-syntax-tablify-region' (via
+ ;; `c-before-font-lock-functions').
+ (remove-hook 'after-change-functions #'c-after-change t)
+ ;; CC-mode setq c-new-BEG/END in `c-after-change' and then uses them in
+ ;; `font-lock-extend-after-change-region-function'. We don't need that and
+ ;; additionally we don't maintain c-new-BEG/END any more, so we really need
+ ;; it out of the way.
+ (kill-local-variable 'font-lock-extend-after-change-region-function)
+ ;; Now, setup syntax-propertize.
+ (add-hook 'syntax-propertize-extend-region-functions
+ #'c-awk-syntax-propertize-extend-region
+ nil t)
+ (set (make-local-variable 'syntax-propertize-function)
+ #'c-awk-syntax-propertize)))
+
+\f
(provide 'cc-awk)
;;; cc-awk.el ends here
=== modified file 'lisp/progmodes/cc-mode.el'
--- lisp/progmodes/cc-mode.el 2014-09-10 16:32:36 +0000
+++ lisp/progmodes/cc-mode.el 2014-09-11 13:33:16 +0000
@@ -198,24 +183,7 @@
\f
;;; Common routines.
-(defvar c-mode-base-map ()
- "Keymap shared by all CC Mode related modes.")
-
-(defun c-make-inherited-keymap ()
- (let ((map (make-sparse-keymap)))
- ;; Necessary to use `cc-bytecomp-fboundp' below since this
- ;; function is called from top-level forms that are evaluated
- ;; while cc-bytecomp is active when one does M-x eval-buffer.
- (cond
- ;; Emacs
- ((cc-bytecomp-fboundp 'set-keymap-parent)
- (set-keymap-parent map c-mode-base-map))
- ;; XEmacs
- ((fboundp 'set-keymap-parents)
- (set-keymap-parents map c-mode-base-map))
- ;; incompatible
- (t (error "CC Mode is incompatible with this version of Emacs")))
- map))
+(defvar c-mode-base-map)
(defun c-define-abbrev-table (name defs &optional doc)
;; Compatibility wrapper for `define-abbrev' which passes a non-nil
@@ -236,59 +204,58 @@
(setq defs (cdr defs)))))
(put 'c-define-abbrev-table 'lisp-indent-function 1)
-(defun c-bind-special-erase-keys ()
+(defun c-bind-special-erase-keys (&optional map)
;; 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'.
+ (unless map (setq map c-mode-base-map))
(if normal-erase-is-backspace
(progn
- (define-key c-mode-base-map (kbd "C-c C-<delete>")
+ (define-key map (kbd "C-c C-<delete>")
'c-hungry-delete-forward)
- (define-key c-mode-base-map (kbd "C-c C-<backspace>")
+ (define-key map (kbd "C-c C-<backspace>")
'c-hungry-delete-backwards))
- (define-key c-mode-base-map (kbd "C-c C-<delete>")
+ (define-key map (kbd "C-c C-<delete>")
'c-hungry-delete-backwards)
- (define-key c-mode-base-map (kbd "C-c C-<backspace>")
+ (define-key map (kbd "C-c C-<backspace>")
'c-hungry-delete-forward)))
-(if c-mode-base-map
- nil
-
- (setq c-mode-base-map (make-sparse-keymap))
+(defvar c-mode-base-map
+ (let ((map (make-sparse-keymap)))
;; 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)
+ (define-key map [(control meta h)] 'c-mark-function)
+ (define-key map "\e\C-q" 'c-indent-exp)
(substitute-key-definition 'backward-sentence
'c-beginning-of-statement
- c-mode-base-map global-map)
+ map global-map)
(substitute-key-definition 'forward-sentence
'c-end-of-statement
- c-mode-base-map global-map)
+ map global-map)
(substitute-key-definition 'indent-new-comment-line
'c-indent-new-comment-line
- c-mode-base-map global-map)
+ map global-map)
(substitute-key-definition 'indent-for-tab-command
;; XXX Is this the right thing to do
;; here?
'c-indent-line-or-region
- c-mode-base-map global-map)
+ map global-map)
(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))
+ map global-map))
;; RMS says don't make these the default.
;; (April 2006): RMS has now approved these commands as defaults.
(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))
+ (define-key map "\e\C-a" 'c-beginning-of-defun)
+ (define-key map "\e\C-e" 'c-end-of-defun))
- (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)
+ (define-key map "\C-c\C-n" 'c-forward-conditional)
+ (define-key map "\C-c\C-p" 'c-backward-conditional)
+ (define-key map "\C-c\C-u" 'c-up-conditional)
;; It doesn't suffice to put `c-fill-paragraph' on
;; `fill-paragraph-function' since `c-fill-paragraph' must be called
@@ -299,11 +266,11 @@
;; `fill-paragraph' and the value on `fill-paragraph-function' to
;; do the actual filling work.
(substitute-key-definition 'fill-paragraph 'c-fill-paragraph
- c-mode-base-map global-map)
+ 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)
+ map global-map)
;; We bind the forward deletion key and (implicitly) C-d to
;; `c-electric-delete-forward', and the backward deletion key to
@@ -320,21 +287,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)
- (define-key c-mode-base-map "\C-c\C-d" 'c-hungry-delete-forward)
- (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)
- (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.
+ (define-key map "\C-d" 'c-electric-delete-forward)
+ (define-key map "\177" 'c-electric-backspace)
+ (define-key map "\C-c\C-d" 'c-hungry-delete-forward)
+ (define-key map [?\C-c ?\d] 'c-hungry-delete-backwards)
+ (define-key map [?\C-c ?\C-\d] 'c-hungry-delete-backwards)
+ (define-key map [?\C-c deletechar] 'c-hungry-delete-forward) ; C-c <delete> on a tty.
+ (define-key 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))
+ (add-hook 'normal-erase-is-backspace-hook #'c-bind-special-erase-keys)
+ (c-bind-special-erase-keys map))
(when (fboundp 'delete-forward-p)
;; In XEmacs we fix the forward and backward deletion behavior by
@@ -342,41 +309,42 @@
;; 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.
- (define-key c-mode-base-map [delete] 'c-electric-delete)
- (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)
- (define-key c-mode-base-map (kbd "C-c <backspace>")
+ (define-key map [delete] 'c-electric-delete)
+ (define-key map [backspace] 'c-electric-backspace)
+ (define-key map (kbd "C-c <delete>") 'c-hungry-delete)
+ (define-key map (kbd "C-c C-<delete>") 'c-hungry-delete)
+ (define-key map (kbd "C-c <backspace>")
'c-hungry-delete-backwards)
- (define-key c-mode-base-map (kbd "C-c C-<backspace>")
+ (define-key map (kbd "C-c C-<backspace>")
'c-hungry-delete-backwards))
- (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)
- (define-key c-mode-base-map "/" 'c-electric-slash)
- (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)
-
- (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
- (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-newline)
- (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)
- (define-key c-mode-base-map "\C-c\C-l" 'c-toggle-electric-state)
- (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset)
- (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
- (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information)
- ;; (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state) Commented out by ACM, 2005-03-05.
- (define-key c-mode-base-map "\C-c." 'c-set-style)
+ (define-key map "#" 'c-electric-pound)
+ (define-key map "{" 'c-electric-brace)
+ (define-key map "}" 'c-electric-brace)
+ (define-key map "/" 'c-electric-slash)
+ (define-key map "*" 'c-electric-star)
+ (define-key map ";" 'c-electric-semi&comma)
+ (define-key map "," 'c-electric-semi&comma)
+ (define-key map ":" 'c-electric-colon)
+ (define-key map "(" 'c-electric-paren)
+ (define-key map ")" 'c-electric-paren)
+
+ (define-key map "\C-c\C-\\" 'c-backslash-region)
+ (define-key map "\C-c\C-a" 'c-toggle-auto-newline)
+ (define-key map "\C-c\C-b" 'c-submit-bug-report)
+ (define-key map "\C-c\C-c" 'comment-region)
+ (define-key map "\C-c\C-l" 'c-toggle-electric-state)
+ (define-key map "\C-c\C-o" 'c-set-offset)
+ (define-key map "\C-c\C-q" 'c-indent-defun)
+ (define-key map "\C-c\C-s" 'c-show-syntactic-information)
+ ;; (define-key map "\C-c\C-t" 'c-toggle-auto-hungry-state) Commented out by ACM, 2005-03-05.
+ (define-key map "\C-c." 'c-set-style)
;; conflicts with OOBR
- ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
- ;; (define-key c-mode-base-map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22.
- (define-key c-mode-base-map "\C-c\C-w" 'subword-mode)
- )
+ ;;(define-key map "\C-c\C-v" 'c-version)
+ ;; (define-key map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22.
+ (define-key map "\C-c\C-w" 'subword-mode)
+ map)
+ "Keymap shared by all CC Mode related modes.")
;; We don't require the outline package, but we configure it a bit anyway.
(cc-bytecomp-defvar outline-level)
@@ -805,13 +773,6 @@
(add-hook 'before-hack-local-variables-hook 'c-before-hack-hook)
(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles))
-(defmacro c-run-mode-hooks (&rest hooks)
- ;; Emacs 21.1 has introduced a system with delayed mode hooks that
- ;; requires the use of the new function `run-mode-hooks'.
- (if (fboundp 'run-mode-hooks)
- `(run-mode-hooks ,@hooks)
- `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks))))
-
\f
;;; Change hooks, linking with Font Lock and electric-indent-mode.
@@ -1202,8 +1163,9 @@
(defun c-after-font-lock-init ()
;; Put on `font-lock-mode-hook'. This function ensures our after-change
;; function will get executed before the font-lock one.
+ (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))
+ (add-hook 'after-change-functions 'c-after-change nil t)))
(defun c-font-lock-init ()
"Set up the font-lock variables for using the font-lock support in CC Mode.
@@ -1264,6 +1226,30 @@
(c-update-modeline)))
\f
+(defvar c-mode-common-map c-mode-base-map)
+
+(define-derived-mode c-mode-common prog-mode "CC-generic"
+ "Pseudo major mode, parent of all modes using the CC engine."
+ (c-initialize-cc-mode t)
+ (setq abbrev-mode t) ;FIXME: Why?
+ ;; Refresh the modeline flags after running the major mode hooks.
+ (add-hook 'after-change-major-mode-hook #'c-update-modeline 'append t)
+ (add-hook 'hack-local-variables-hook #'c-update-modeline 'append t))
+
+(defvar c-derivative-mode-map
+ ;; FIXME: We can't have the menu on this keymap, because the menus for C,
+ ;; C++, and ObjC can't be shared: the only difference between them is their
+ ;; title, but easy-menu offers no way to compute the title dynamically.
+ (let ((map (make-sparse-keymap)))
+ ;; Add bindings which are useful for any C derivative.
+ (define-key map "\C-c\C-e" 'c-macro-expand)
+ map)
+ "Keymap used in c-derivative-mode buffers.")
+
+(define-derived-mode c-derivative-mode c-mode-common "C-derivative"
+ "Pseudo major mode, parent of all modes for C derivatives.
+A C derivative is a language which is a superset of C (or is C itself).")
+
;; Support for C
(defvar c-mode-syntax-table
@@ -1276,9 +1262,8 @@
"Abbreviation table used in c-mode buffers.")
(defvar c-mode-map
- (let ((map (c-make-inherited-keymap)))
+ (let ((map (make-sparse-keymap)))
;; Add bindings which are only useful for C.
- (define-key map "\C-c\C-e" 'c-macro-expand)
map)
"Keymap used in c-mode buffers.")
@@ -1314,9 +1299,8 @@
;;;###autoload (add-to-list 'auto-mode-alist '("\\.i\\'" . c-mode))
;;;###autoload (add-to-list 'auto-mode-alist '("\\.ii\\'" . c++-mode))
-
;;;###autoload
-(define-derived-mode c-mode prog-mode "C"
+(define-derived-mode c-mode c-derivative-mode "C"
"Major mode for editing K&R and ANSI 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
@@ -1330,18 +1314,11 @@
Key bindings:
\\{c-mode-map}"
- (c-initialize-cc-mode t)
- (set-syntax-table c-mode-syntax-table)
- (setq local-abbrev-table c-mode-abbrev-table
- abbrev-mode t)
- (use-local-map c-mode-map)
(c-init-language-vars-for 'c-mode)
(c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ;
(c-common-init 'c-mode)
(easy-menu-add c-c-menu)
- (cc-imenu-init cc-imenu-c-generic-expression)
- (c-run-mode-hooks 'c-mode-common-hook 'c-mode-hook)
- (c-update-modeline))
+ (cc-imenu-init cc-imenu-c-generic-expression))
\f
;; Support for C++
@@ -1357,9 +1334,8 @@
"Abbreviation table used in c++-mode buffers.")
(defvar c++-mode-map
- (let ((map (c-make-inherited-keymap)))
+ (let ((map (make-sparse-keymap)))
;; Add bindings which are only useful for C++.
- (define-key map "\C-c\C-e" 'c-macro-expand)
(define-key map "\C-c:" 'c-scope-operator)
(define-key map "<" 'c-electric-lt-gt)
(define-key map ">" 'c-electric-lt-gt)
@@ -1370,7 +1346,7 @@
(cons "C++" (c-lang-const c-mode-menu c++)))
;;;###autoload
-(define-derived-mode c++-mode prog-mode "C++"
+(define-derived-mode c++-mode c-derivative-mode "C++"
"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
@@ -1385,18 +1361,11 @@
Key bindings:
\\{c++-mode-map}"
- (c-initialize-cc-mode t)
- (set-syntax-table c++-mode-syntax-table)
- (setq local-abbrev-table c++-mode-abbrev-table
- abbrev-mode t)
- (use-local-map c++-mode-map)
(c-init-language-vars-for 'c++-mode)
(c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ;
(c-common-init 'c++-mode)
(easy-menu-add c-c++-menu)
- (cc-imenu-init cc-imenu-c++-generic-expression)
- (c-run-mode-hooks 'c-mode-common-hook 'c++-mode-hook)
- (c-update-modeline))
+ (cc-imenu-init cc-imenu-c++-generic-expression))
\f
;; Support for Objective-C
@@ -1411,9 +1380,8 @@
"Abbreviation table used in objc-mode buffers.")
(defvar objc-mode-map
- (let ((map (c-make-inherited-keymap)))
+ (let ((map (make-sparse-keymap)))
;; Add bindings which are only useful for Objective-C.
- (define-key map "\C-c\C-e" 'c-macro-expand)
map)
"Keymap used in objc-mode buffers.")
@@ -1423,7 +1391,7 @@
;;;###autoload (add-to-list 'auto-mode-alist '("\\.m\\'" . objc-mode))
;;;###autoload
-(define-derived-mode objc-mode prog-mode "ObjC"
+(define-derived-mode objc-mode c-derivative-mode "ObjC"
"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
@@ -1438,18 +1406,11 @@
Key bindings:
\\{objc-mode-map}"
- (c-initialize-cc-mode t)
- (set-syntax-table objc-mode-syntax-table)
- (setq local-abbrev-table objc-mode-abbrev-table
- abbrev-mode t)
- (use-local-map objc-mode-map)
(c-init-language-vars-for 'objc-mode)
(c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ;
(c-common-init 'objc-mode)
(easy-menu-add c-objc-menu)
- (cc-imenu-init nil 'cc-imenu-objc-function)
- (c-run-mode-hooks 'c-mode-common-hook 'objc-mode-hook)
- (c-update-modeline))
+ (cc-imenu-init nil 'cc-imenu-objc-function))
\f
;; Support for Java
@@ -1466,7 +1427,7 @@
"Abbreviation table used in java-mode buffers.")
(defvar java-mode-map
- (let ((map (c-make-inherited-keymap)))
+ (let ((map (make-sparse-keymap)))
;; Add bindings which are only useful for Java.
map)
"Keymap used in java-mode buffers.")
@@ -1484,7 +1445,7 @@
;;;###autoload (add-to-list 'auto-mode-alist '("\\.java\\'" . java-mode))
;;;###autoload
-(define-derived-mode java-mode prog-mode "Java"
+(define-derived-mode java-mode c-mode-common "Java"
"Major mode for editing Java code.
To submit a problem report, enter `\\[c-submit-bug-report]' from a
java-mode buffer. This automatically sets up a mail buffer with
@@ -1499,17 +1460,10 @@
Key bindings:
\\{java-mode-map}"
- (c-initialize-cc-mode t)
- (set-syntax-table java-mode-syntax-table)
- (setq local-abbrev-table java-mode-abbrev-table
- abbrev-mode t)
- (use-local-map java-mode-map)
(c-init-language-vars-for 'java-mode)
(c-common-init 'java-mode)
(easy-menu-add c-java-menu)
- (cc-imenu-init cc-imenu-java-generic-expression)
- (c-run-mode-hooks 'c-mode-common-hook 'java-mode-hook)
- (c-update-modeline))
+ (cc-imenu-init cc-imenu-java-generic-expression))
\f
;; Support for CORBA's IDL language
@@ -1522,7 +1476,7 @@
"Abbreviation table used in idl-mode buffers.")
(defvar idl-mode-map
- (let ((map (c-make-inherited-keymap)))
+ (let ((map (make-sparse-keymap)))
;; Add bindings which are only useful for IDL.
map)
"Keymap used in idl-mode buffers.")
@@ -1533,7 +1487,7 @@
;;;###autoload (add-to-list 'auto-mode-alist '("\\.idl\\'" . idl-mode))
;;;###autoload
-(define-derived-mode idl-mode prog-mode "IDL"
+(define-derived-mode idl-mode c-mode-common "IDL"
"Major mode for editing CORBA's IDL, PSDL and CIDL code.
To submit a problem report, enter `\\[c-submit-bug-report]' from an
idl-mode buffer. This automatically sets up a mail buffer with
@@ -1548,16 +1502,12 @@
Key bindings:
\\{idl-mode-map}"
- (c-initialize-cc-mode t)
- (set-syntax-table idl-mode-syntax-table)
- (setq local-abbrev-table idl-mode-abbrev-table)
- (use-local-map idl-mode-map)
+ (kill-local-variable 'abbrev-mode) ;FIXME: Only mode that doesn't enable it!?
(c-init-language-vars-for 'idl-mode)
(c-common-init 'idl-mode)
(easy-menu-add c-idl-menu)
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO
- (c-run-mode-hooks 'c-mode-common-hook 'idl-mode-hook)
- (c-update-modeline))
+ )
\f
;; Support for Pike
@@ -1572,7 +1522,7 @@
"Abbreviation table used in pike-mode buffers.")
(defvar pike-mode-map
- (let ((map (c-make-inherited-keymap)))
+ (let ((map (make-sparse-keymap)))
;; Additional bindings.
(define-key map "\C-c\C-e" 'c-macro-expand)
map)
@@ -1585,7 +1535,7 @@
;;;###autoload (add-to-list 'interpreter-mode-alist '("pike" . pike-mode))
;;;###autoload
-(define-derived-mode pike-mode prog-mode "Pike"
+(define-derived-mode pike-mode c-mode-common "Pike"
"Major mode for editing Pike code.
To submit a problem report, enter `\\[c-submit-bug-report]' from a
pike-mode buffer. This automatically sets up a mail buffer with
@@ -1600,86 +1550,11 @@
Key bindings:
\\{pike-mode-map}"
- (c-initialize-cc-mode t)
- (set-syntax-table pike-mode-syntax-table)
- (setq local-abbrev-table pike-mode-abbrev-table
- abbrev-mode t)
- (use-local-map pike-mode-map)
(c-init-language-vars-for 'pike-mode)
(c-common-init 'pike-mode)
(easy-menu-add c-pike-menu)
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO
- (c-run-mode-hooks 'c-mode-common-hook 'pike-mode-hook)
- (c-update-modeline))
-
-\f
-;; Support for AWK
-
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.awk\\'" . awk-mode))
-;;;###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))
-
-(c-define-abbrev-table 'awk-mode-abbrev-table
- '(("else" "else" c-electric-continued-statement 0)
- ("while" "while" c-electric-continued-statement 0))
- "Abbreviation table used in awk-mode buffers.")
-
-(defvar awk-mode-map
- (let ((map (c-make-inherited-keymap)))
- ;; Add bindings which are only useful for awk.
- (define-key map "#" 'self-insert-command)
- (define-key map "/" 'self-insert-command)
- (define-key map "*" 'self-insert-command)
- (define-key map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
- (define-key map "\C-c\C-p" 'undefined)
- (define-key map "\C-c\C-u" 'undefined)
- (define-key map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
- (define-key map "\M-e" 'c-end-of-statement) ; 2003/10/7
- (define-key map "\C-\M-a" 'c-awk-beginning-of-defun)
- (define-key map "\C-\M-e" 'c-awk-end-of-defun)
- map)
- "Keymap used in awk-mode buffers.")
-
-(easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands"
- (cons "AWK" (c-lang-const c-mode-menu awk)))
-
-;; (require 'cc-awk) brings these in.
-(defvar awk-mode-syntax-table)
-(declare-function c-awk-unstick-NL-prop "cc-awk" ())
-
-;;;###autoload
-(define-derived-mode awk-mode prog-mode "AWK"
- "Major mode for editing AWK code.
-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
-problem, including a reproducible test case, and send the message.
-
-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}"
- ;; 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
- (require 'cc-awk) ; Added 2003/6/10.
- (c-initialize-cc-mode t)
- (set-syntax-table awk-mode-syntax-table)
- (setq local-abbrev-table awk-mode-abbrev-table
- abbrev-mode t)
- (use-local-map awk-mode-map)
- (c-init-language-vars-for 'awk-mode)
- (c-common-init 'awk-mode)
- (c-awk-unstick-NL-prop)
-
- (c-run-mode-hooks 'c-mode-common-hook 'awk-mode-hook)
- (c-update-modeline))
+ )
\f
;; bug reporting
next prev parent reply other threads:[~2014-09-11 13:55 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-02 5:26 POC: customizable cc-mode keywords Daniel Colascione
2014-05-10 23:13 ` Daniel Colascione
2014-05-11 21:13 ` Alan Mackenzie
2014-05-11 21:23 ` Daniel Colascione
2014-05-16 17:52 ` Alan Mackenzie
2014-05-16 18:06 ` Daniel Colascione
2014-05-18 21:33 ` Alan Mackenzie
2014-05-18 22:28 ` Daniel Colascione
2014-05-19 2:25 ` Stefan Monnier
2014-05-25 18:08 ` Alan Mackenzie
2014-09-08 17:28 ` Stefan Monnier
2014-09-11 13:55 ` Stefan Monnier [this message]
2014-09-12 23:59 ` Further CC-mode changes Alan Mackenzie
2014-09-13 1:09 ` Ivan Andrus
2014-09-13 10:04 ` Alan Mackenzie
2014-09-13 3:04 ` Stefan Monnier
2014-09-13 15:10 ` Alan Mackenzie
2014-09-13 19:24 ` Stefan Monnier
2014-09-13 23:08 ` Syntax-propertize and CC-mode [Was: Further CC-mode changes] Alan Mackenzie
2014-09-14 4:04 ` Stefan Monnier
2014-09-16 17:30 ` Sync'ing cc-mode Stefan Monnier
2014-09-26 19:19 ` Stefan Monnier
[not found] ` <jwv4mvmjl0c.fsf-monnier+emacs@gnu.org>
[not found] ` <jwv4mvkqy4g.fsf-monnier+emacs@gnu.org>
[not found] ` <jwv4mv3mn2a.fsf-monnier+emacs@gnu.org>
[not found] ` <jwv38a644p7.fsf-monnier+emacs@gnu.org>
[not found] ` <jwvppd2wx7o.fsf-monnier+emacs@gnu.org>
[not found] ` <20141106104534.GA3385@acm.acm>
2014-11-06 14:06 ` bug#18022: " Stefan Monnier
2014-09-15 20:24 ` Further CC-mode changes Glenn Morris
2014-09-16 3:07 ` Stephen J. Turnbull
2014-09-16 13:39 ` Stefan Monnier
2014-09-16 14:22 ` David Kastrup
2014-09-16 23:40 ` Stephen J. Turnbull
2014-09-17 1:02 ` Stefan Monnier
2014-09-17 1:48 ` Stephen J. Turnbull
2014-09-17 5:22 ` David Kastrup
2014-09-17 13:00 ` Stefan Monnier
2014-09-17 18:31 ` Glenn Morris
2014-09-17 19:12 ` David Kastrup
2014-09-17 5:24 ` Eli Zaretskii
2014-09-17 6:54 ` Stephen J. Turnbull
2014-09-17 7:20 ` Eli Zaretskii
2014-09-17 7:30 ` David Kastrup
2014-09-17 13:04 ` Stefan Monnier
2014-09-17 18:25 ` Glenn Morris
2014-09-18 5:20 ` Stephen J. Turnbull
2014-09-18 9:44 ` Emilio Lopes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvfvfye1oz.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=acm@muc.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.