Subject: Re: bug#26658: 25.2; cc-mode doesn't use prog-mode-map as parent for c-mode-base-map

From: Vasilij Schneidermann <[email-masked]>
Date: Tue, 2 May 2017 23:17:14 +0200

Hello again,

I've ensured the bug is present and wrote a patch that fixes the issue.
A workaround for people not using the latest cc-mode is to put the
following into their init file:

(eval-after-load 'cc-mode
  '(set-keymap-parent c-mode-base-map prog-mode-map))
>From d60e354b809f8a551fcdf7322ab16a623153f02f Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <[email-masked]>
Date: Tue, 2 May 2017 23:12:21 +0200
Subject: [PATCH] Set c-mode-base-map parent to prog-mode-map

* cc-mode.el (c-set-keymap-parent):
New helper function for XEmacs and GNU Emacs.
(c-mode-base-map): Set keymap parent for the map to prog-mode-map
---
 lisp/progmodes/cc-mode.el | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 20c63d4dbe..dc06a30f29 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -223,20 +223,23 @@ c-initialize-cc-mode
 (defvar c-mode-base-map ()
   "Keymap shared by all CC Mode related modes.")
 
+(defun c-set-keymap-parent (map parent)
+  ;; 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 parent))
+   ;; XEmacs
+   ((fboundp 'set-keymap-parents)
+    (set-keymap-parents map parent))
+   ;; incompatible
+   (t (error "CC Mode is incompatible with this version of Emacs"))))
+
 (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")))
+    (c-set-keymap-parent map c-mode-base-map)
     map))
 
 (defun c-define-abbrev-table (name defs &optional doc)
@@ -276,6 +279,7 @@ c-bind-special-erase-keys
     nil
 
   (setq c-mode-base-map (make-sparse-keymap))
+  (c-set-keymap-parent c-mode-base-map prog-mode-map)
 
   ;; Separate M-BS from C-M-h.  The former should remain
   ;; backward-kill-word.
-- 
2.12.2