unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Jens Peter Secher <jpsecher@gmail.com>
Cc: Vagn Johansen <gonz808@hotmail.com>,
	Richard Stallman <rms@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: New major mode using cc-mode => cc-mode intrudes unrelated modes
Date: Mon, 16 Jul 2007 23:42:32 +0100	[thread overview]
Message-ID: <20070716224232.GA14029@muc.de> (raw)
In-Reply-To: <87wsxpw62h.fsf@turing.ravneholm26.dk>

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  <acm@muc.de>

	* 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).

  parent reply	other threads:[~2007-07-16 22:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-27 19:28 New major mode using cc-mode => cc-mode intrudes unrelated modes Jens Peter Secher
2007-06-29 16:22 ` Vagn Johansen
2007-07-16 22:42 ` Alan Mackenzie [this message]
2007-07-17 15:05   ` Richard Stallman
2007-07-17 16:14   ` Jens Peter Secher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070716224232.GA14029@muc.de \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=gonz808@hotmail.com \
    --cc=jpsecher@gmail.com \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).