syntax highlighting in sub-mode (C in ConTeXt)

Asked by Peter

Hello,

How can I get syntax highlighting in the C sub-mode, when the major mode
is context?

Here my setup (latest versions of emacs, nxhtml and auctex):

file test.el:
--8<---------------cut here---------------start------------->8---
(load "~/emacs/packages/nxhtml/autostart")
(add-to-list 'load-path "~/emacs/packages/auctex")
(load "auctex")

(defun mumamo-chunk-ctx-c (pos max)
  (mumamo-quick-chunk-forward pos max "\\startC" "\\stopC"
                              'borders 'c-mode))

(add-to-list 'auto-mode-alist '("\\.tex\\'" . context-mumamo-mode))

(define-mumamo-multi-major-mode context-mumamo-mode
  "Turn on multiple major modes for ConTeXt with main mode `context-mode'."
  ("ConTeXt Family" context-mode (mumamo-chunk-ctx-c)))
--8<---------------cut here---------------end--------------->8---

file test.tex:
--8<---------------cut here---------------start------------->8---
\starttext
\startC
/* comment */
void func(void)
{
    if(bla)
        blub;
}
\stopC
$a+b$ % math
\stoptext
--8<---------------cut here---------------end--------------->8---

command: "emacs -l test.el test.tex"

Result: no syntax highlighting in C-mode, and some error messages.

compile-log buffer:
--8<---------------cut here---------------start------------->8---
Error: Wrong type argument: number-or-marker-p, nil
--8<---------------cut here---------------end--------------->8---

message buffer:
--8<---------------cut here---------------start------------->8---
Assertion failed: (functionp byte-compiled-fun)
- Please try M-: (mumamo-post-command-1) to see what happened.
nil
Symbol's function definition is void: mumamo-border-mode
- Please try M-: (mumamo-post-command-1) to see what happened.
--8<---------------cut here---------------end--------------->8---

And in the backtrace buffer after invoking (mumamo-post-command-1):
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (void-function mumamo-border-mode)
  mumamo-border-mode()
  funcall(mumamo-border-mode)
  (let ((mumamo-fetching-major t)) (funcall major))
  (save-current-buffer (set-buffer temp-buf) (let ((mumamo-fetching-major t)) (funcall major)) (setq local-map (current-local-map)) (when local-map (setq local-map (copy-keymap (current-local-map)))) (add-to-list (quote mumamo-major-modes-local-maps) (cons major-mode local-map)) (unless (eq major major-mode) (add-to-list (quote mumamo-major-modes-local-maps) (cons major local-map))))
  (with-current-buffer temp-buf (let ((mumamo-fetching-major t)) (funcall major)) (setq local-map (current-local-map)) (when local-map (setq local-map (copy-keymap (current-local-map)))) (add-to-list (quote mumamo-major-modes-local-maps) (cons major-mode local-map)) (unless (eq major major-mode) (add-to-list (quote mumamo-major-modes-local-maps) (cons major local-map))))
  (let (temp-buf-name temp-buf local-map) (setq temp-buf-name (concat "mumamo-fetch-major-mode-local-" (symbol-name major))) (setq temp-buf (get-buffer temp-buf-name)) (when temp-buf (kill-buffer temp-buf)) (setq temp-buf (get-buffer-create temp-buf-name)) (with-current-buffer temp-buf (let ((mumamo-fetching-major t)) (funcall major)) (setq local-map (current-local-map)) (when local-map (setq local-map (copy-keymap (current-local-map)))) (add-to-list (quote mumamo-major-modes-local-maps) (cons major-mode local-map)) (unless (eq major major-mode) (add-to-list (quote mumamo-major-modes-local-maps) (cons major local-map)))) (kill-buffer temp-buf) local-map)
  mumamo-fetch-local-map(mumamo-border-mode)
  (setq map (mumamo-fetch-local-map major))
  (if map nil (setq map (mumamo-fetch-local-map major)))
  (unless map (setq map (mumamo-fetch-local-map major)))
  (let* ((map-rec (assoc major mumamo-major-modes-local-maps)) (map (cdr map-rec))) (unless map (setq map (mumamo-fetch-local-map major))) (unless (eq map (quote no-local-map)) (use-local-map map)) (add-hook (quote pre-command-hook) (quote mumamo-set-major-pre-command) nil t) (mumamo-request-idle-set-major-mode))
  (if (<= 0 mumamo-set-major-mode-delay) (let* ((map-rec (assoc major mumamo-major-modes-local-maps)) (map (cdr map-rec))) (unless map (setq map (mumamo-fetch-local-map major))) (unless (eq map (quote no-local-map)) (use-local-map map)) (add-hook (quote pre-command-hook) (quote mumamo-set-major-pre-command) nil t) (mumamo-request-idle-set-major-mode)) (mumamo-set-major major ovl) (message "Switched to %s" major-mode))
  (if mumamo-done-first-set-major (if (<= 0 mumamo-set-major-mode-delay) (let* ((map-rec (assoc major mumamo-major-modes-local-maps)) (map (cdr map-rec))) (unless map (setq map (mumamo-fetch-local-map major))) (unless (eq map (quote no-local-map)) (use-local-map map)) (add-hook (quote pre-command-hook) (quote mumamo-set-major-pre-command) nil t) (mumamo-request-idle-set-major-mode)) (mumamo-set-major major ovl) (message "Switched to %s" major-mode)) (mumamo-set-major major ovl))
  (if (not set-it-now) (unless (mumamo-fun-eq major major-mode) (when mumamo-idle-set-major-mode-timer (mumamo-request-idle-set-major-mode))) (if mumamo-done-first-set-major (if (<= 0 mumamo-set-major-mode-delay) (let* ((map-rec (assoc major mumamo-major-modes-local-maps)) (map (cdr map-rec))) (unless map (setq map (mumamo-fetch-local-map major))) (unless (eq map (quote no-local-map)) (use-local-map map)) (add-hook (quote pre-command-hook) (quote mumamo-set-major-pre-command) nil t) (mumamo-request-idle-set-major-mode)) (mumamo-set-major major ovl) (message "Switched to %s" major-mode)) (mumamo-set-major major ovl)))
  (let* ((in-pre-hook (memq (quote mumamo-set-major-pre-command) pre-command-hook)) (ovl (unless in-pre-hook (mumamo-post-command-get-chunk (point)))) (major (when ovl (mumamo-chunk-keyboard-major-mode ovl (point)))) (set-it-now (not (or in-pre-hook (mumamo-fun-eq major major-mode))))) (if (not set-it-now) (unless (mumamo-fun-eq major major-mode) (when mumamo-idle-set-major-mode-timer (mumamo-request-idle-set-major-mode))) (if mumamo-done-first-set-major (if (<= 0 mumamo-set-major-mode-delay) (let* ((map-rec (assoc major mumamo-major-modes-local-maps)) (map (cdr map-rec))) (unless map (setq map (mumamo-fetch-local-map major))) (unless (eq map (quote no-local-map)) (use-local-map map)) (add-hook (quote pre-command-hook) (quote mumamo-set-major-pre-command) nil t) (mumamo-request-idle-set-major-mode)) (mumamo-set-major major ovl) (message "Switched to %s" major-mode)) (mumamo-set-major major ovl))))
  mumamo-set-major-post-command()
  (if font-lock-mode (mumamo-set-major-post-command))
  mumamo-post-command-1()
  eval((mumamo-post-command-1) nil)
  eval-expression((mumamo-post-command-1) nil)
  call-interactively(eval-expression nil nil)
--8<---------------cut here---------------end--------------->8---

I don't know, if the missing syntax highlighting is related to the error
messages...

TIA for any help!
Peter

Question information

Language:
English Edit question
Status:
Open
For:
nXhtml Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Peter (pmlists) said :
#1

Hello,

I've just discovered, that auctex is not needed, to reproduce the problem:

file test.php:
--8<---------------cut here---------------start------------->8---
<?php
function func($bla)
{
  if($bla)
    return $blub;
}
?>
--8<---------------cut here---------------end--------------->8---

command: emacs -Q --eval '(load "path/to/nxhtml/autostart")' test.php

There is no syntax highlighting, and just one error message in the compile-log
buffer:
--8<---------------cut here---------------start------------->8---
Error: Wrong type argument: number-or-marker-p, nil
--8<---------------cut here---------------end--------------->8---

And another one in the messages buffer:
--8<---------------cut here---------------start------------->8---
File mode specification error: (cl-assertion-failed (functionp byte-compiled-fun))
--8<---------------cut here---------------end--------------->8---

Greetings, Peter

Can you help with this problem?

Provide an answer of your own, or ask Peter for more information if necessary.

To post a message you must log in.