;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(cc-require 'cc-align)
(cc-require 'cc-menus)
-;; SILENCE the compiler.
+;; Silence the compiler.
(cc-bytecomp-defvar comment-line-break-function) ; (X)Emacs 20+
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs 20+
(cc-bytecomp-defun set-keymap-parents) ; XEmacs
+(cc-bytecomp-defun run-mode-hooks) ; Emacs 21.1+
+(cc-bytecomp-obsolete-fun make-local-hook) ; Marked obsolete in Emacs 21.1.
;; We set these variables during mode init, yet we don't require
;; font-lock.
(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
;; XEmacs
- ((fboundp 'set-keymap-parents)
+ ((cc-bytecomp-fboundp 'set-keymap-parents)
(set-keymap-parents map c-mode-base-map))
;; Emacs
- ((fboundp 'set-keymap-parent)
+ ((cc-bytecomp-fboundp 'set-keymap-parent)
(set-keymap-parent map c-mode-base-map))
;; incompatible
(t (error "CC Mode is incompatible with this version of Emacs")))
(let ((rfn (assq mode c-require-final-newline)))
(when rfn
(make-local-variable 'require-final-newline)
- (setq require-final-newline (cdr rfn)))))
+ (and (cdr rfn)
+ (setq require-final-newline mode-require-final-newline)))))
(defun c-postprocess-file-styles ()
"Function that post processes relevant file local variables in CC Mode.
(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
+ ;; require the use of the new function `run-mode-hooks'.
+ (if (cc-bytecomp-fboundp 'run-mode-hooks)
+ `(run-mode-hooks ,@hooks)
+ `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks))))
+
\f
;; Support for C
(c-common-init 'c-mode)
(easy-menu-add c-c-menu)
(cc-imenu-init cc-imenu-c-generic-expression)
- (run-mode-hooks 'c-mode-common-hook 'c-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'c-mode-hook)
(c-update-modeline))
\f
(c-common-init 'c++-mode)
(easy-menu-add c-c++-menu)
(cc-imenu-init cc-imenu-c++-generic-expression)
- (run-mode-hooks 'c-mode-common-hook 'c++-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'c++-mode-hook)
(c-update-modeline))
\f
(c-common-init 'objc-mode)
(easy-menu-add c-objc-menu)
(cc-imenu-init nil 'cc-imenu-objc-function)
- (run-mode-hooks 'c-mode-common-hook 'objc-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'objc-mode-hook)
(c-update-modeline))
\f
(c-common-init 'java-mode)
(easy-menu-add c-java-menu)
(cc-imenu-init cc-imenu-java-generic-expression)
- (run-mode-hooks 'c-mode-common-hook 'java-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'java-mode-hook)
(c-update-modeline))
\f
(c-common-init 'idl-mode)
(easy-menu-add c-idl-menu)
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO
- (run-mode-hooks 'c-mode-common-hook 'idl-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'idl-mode-hook)
(c-update-modeline))
\f
(c-common-init 'pike-mode)
(easy-menu-add c-pike-menu)
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO
- (run-mode-hooks 'c-mode-common-hook 'pike-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'pike-mode-hook)
(c-update-modeline))
\f
;;; Autoload directives must be on the top level, so we construct an
;;; autoload form instead.
-;;;###autoload (autoload 'awk-mode "cc-mode" "Major mode for editing AWK code.")
+;;;###autoload (autoload 'awk-mode "cc-mode" "Major mode for editing AWK code." t)
(if (not (memq 'syntax-properties c-emacs-features))
(autoload 'awk-mode "awk-mode" "Major mode for editing AWK code." t)
;; in cc-engine.el, just before (defun c-fast-in-literal ...
(defalias 'c-in-literal 'c-slow-in-literal)
- (run-mode-hooks 'c-mode-common-hook 'awk-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'awk-mode-hook)
(c-update-modeline))
) ;; closes the (if (not (memq 'syntax-properties c-emacs-features))