emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New major mode using cc-mode => cc-mode intrudes unrelated modes


From: Alan Mackenzie
Subject: Re: New major mode using cc-mode => cc-mode intrudes unrelated modes
Date: Mon, 16 Jul 2007 23:42:32 +0100
User-agent: Mutt/1.5.9i

Hi, Jens.

On Wed, Jun 27, 2007 at 09:28:06PM +0200, Jens Peter Secher wrote:
> I have been trying to create a major mode for a programming language
> called haXe, but I have run into problems.  haxe-mode is basically just
> a cut-down version of java-mode, as you can see from the first attached
> file.

A quick observation here: I think you will need to make your file GPL
licensed before you release it, since it will be a derivative of Emacs, a
GPL program.  But RMS is the expert on this.

> The problems is that, efter putting a buffer in haxe-mode, cc-mode
> functions intrude into others modes, eg. lisp-mode.  More specifically,
> after visiting the haxe-mode test file in the second attachment, a newly
> created lisp-mode buffer will have eg. beginning-of-defun-function set
> to c-beginning-of-defun.

> Another strange thing is that I have to set comment-start-skip
> explicitly in haxe-mode, otherwise it gets a nil value when visiting
> haxe-mode files.

> So obviously I am doing something wrong, but I cannot figure out what.

No, on the contrary, I've done something wrong.  ;-)  There's a macro
c-make-emacs-variables-local, which does what its name says on the five
variables: comment-start, comment-end, comment-start-skip,
beginning-of-defun-function, and end-of-defun-function.  I had put this
macro call in a position which worked only for C, C++, ...., Pike, AWK,
but not for derived modes.

> I am using Emacs 22.0.99.1 (including cc-mode 5.31.4).

Would you please try this patch out, and let me know whether it fixes
everything.  Thanks for taking the trouble to report this bug, and thanks
for making it so easy for me to track down.


2007-07-16  Alan Mackenzie  <address@hidden>

        * progmodes/cc-mode.el (c-init-language-vars-for):
        * progmodes/cc-langs.el (c-make-init-lang-vars-fun): Move the
        invocation of c-make-emacs-variables-local from the former
        function to the latter, because derived modes bypass the former.


Index: cc-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-mode.el,v
retrieving revision 1.58.2.2
diff -c -r1.58.2.2 cc-mode.el
*** cc-mode.el  20 Jun 2007 08:27:53 -0000      1.58.2.2
--- cc-mode.el  16 Jul 2007 20:50:17 -0000
***************
*** 168,174 ****
  `c-init-language-vars' macro if the language you want to use is one of
  those, rather than a derived language defined through the language
  variable system (see \"cc-langs.el\")."
-   (c-make-emacs-variables-local)
    (cond ((eq mode 'c-mode)    (c-init-language-vars c-mode))
        ((eq mode 'c++-mode)  (c-init-language-vars c++-mode))
        ((eq mode 'objc-mode) (c-init-language-vars objc-mode))
--- 168,173 ----
Index: cc-langs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-langs.el,v
retrieving revision 1.47
diff -c -r1.47 cc-langs.el
*** cc-langs.el 9 Apr 2007 10:51:29 -0000       1.47
--- cc-langs.el 16 Jul 2007 20:50:29 -0000
***************
*** 2898,2903 ****
--- 2898,2904 ----
         ;; that could be in the result from `cl-macroexpand-all'.
         (let ((c-buffer-is-cc-mode ',mode)
               current-var source-eval)
+          (c-make-emacs-variables-local)
           (condition-case err
  
               (if (eq c-version-sym ',c-version-sym)
***************
*** 2956,2961 ****
--- 2957,2963 ----
             (init (append (cdr c-emacs-variable-inits)
                           (cdr c-lang-variable-inits)))
             current-var)
+        (c-make-emacs-variables-local)
         (condition-case err
  
             (while init



> Cheers,
> -- 
>                                                     Jens Peter Secher.

-- 
Alan Mackenzie (Ittersbach, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]