From 125a8a62db96c5e3c3e93c34fdb1429098b0d3f6 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Wed, 12 Jul 2017 17:03:35 +0000 Subject: [PATCH] CC Mode: create and use c-set-keymap-parent. * lisp/progmodes/cc-defs.el (c-set-keymap-parent): New macro. * lisp/progmodes/cc-mode.el (top-level): Remove cc-bytecomp-defun for set-keymap-parents. (c-make-inherited-keymap): Use c-set-keymap-parent in place of inline code. --- lisp/progmodes/cc-defs.el | 12 ++++++++++++ lisp/progmodes/cc-mode.el | 13 +------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index eb7bde0f767..ab910ab7dec 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -417,6 +417,17 @@ to it is returned. This function does not modify the point or the mark." ;; Emacs. `(setq mark-active ,activate))) +(defmacro c-set-keymap-parent (map parent) + (cond + ;; XEmacs + ((cc-bytecomp-fboundp 'set-keymap-parents) + `(set-keymap-parents ,map ,parent)) + ;; Emacs + ((cc-bytecomp-fboundp 'set-keymap-parent) + `(set-keymap-parent ,map ,parent)) + ;; incompatible + (t (error "CC Mode is incompatible with this version of Emacs")))) + (defmacro c-delete-and-extract-region (start end) "Delete the text between START and END and return it." (if (cc-bytecomp-fboundp 'delete-and-extract-region) @@ -1266,6 +1277,7 @@ with value CHAR in the region [FROM to)." (def-edebug-spec cc-eval-when-compile (&rest def-form)) (def-edebug-spec c-point t) (def-edebug-spec c-set-region-active t) +(def-edebug-spec c-set-keymap-parent t) (def-edebug-spec c-safe t) (def-edebug-spec c-save-buffer-state let*) (def-edebug-spec c-tentative-buffer-changes t) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 9b89681c3bf..1150ebd33b5 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -225,18 +225,7 @@ control). See \"cc-mode.el\" for more info." (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) -- 2.39.2