all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Need help with some changes in c-mode
@ 2007-02-17  6:34 nemshilov
  2007-02-19 19:34 ` Glenn Morris
  0 siblings, 1 reply; 8+ messages in thread
From: nemshilov @ 2007-02-17  6:34 UTC (permalink / raw)
  To: help-gnu-emacs

Hello there,

I'm trying to create a custom mode based on the c-mode and there are a
pair of questions which I cannot figure out by myself.

First, I need to be able to use strings like that

var_a = <<<EOL
some string inside of it
EOL;

I with to have all the text between "<<<EOL\n" and "\nEOL;" to be
marked as a string. I do mean that it should be colorized as a string
and behave as a multi-line string. And "EOL" is just an identifier,
it's not necessarily "EOL", it's anything like that "[a-zA-Z]+". And
if it's possible I would like to have the "<<<EOL" and "EOL" markers
to be marked somehow diffrent of the string by itself. Say as a
constant or keyword, I'll choose something later, just I need a hint
there.

The second stuff, I wish to have strings like "#....\n" as single-line
comments. I've allready added it like a comment, but there's a
problem, when I'm typing down something like " # =Synopsis ", I've got
problems with indentation case the "="-symbol handles as some kind of
operation by the c-mode. How can I switch it off?

That's it, Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Need help with some changes in c-mode
  2007-02-17  6:34 Need help with some changes in c-mode nemshilov
@ 2007-02-19 19:34 ` Glenn Morris
  2007-02-20  4:03   ` nemshilov
  0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2007-02-19 19:34 UTC (permalink / raw)
  To: help-gnu-emacs

nemshilov@gmail.com wrote:

> I'm trying to create a custom mode based on the c-mode and there are
> a pair of questions which I cannot figure out by myself.
>
> First, I need to be able to use strings like that
>
> var_a = <<<EOL
> some string inside of it
> EOL;
>
> I with to have all the text between "<<<EOL\n" and "\nEOL;" to be
> marked as a string.
[...]
> The second stuff, I wish to have strings like "#....\n" as single-line
> comments.

>From the information presented, it sounds like you might be better off
basing your mode on sh-mode. Have at look at how sh-script.el handles
here documents (which is what your first construct is, save for an
extra "<"). Look for "heredocs" in the code.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Need help with some changes in c-mode
  2007-02-19 19:34 ` Glenn Morris
@ 2007-02-20  4:03   ` nemshilov
  2007-02-20 15:50     ` Robert Thorpe
  0 siblings, 1 reply; 8+ messages in thread
From: nemshilov @ 2007-02-20  4:03 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 20, 1:34 am, Glenn Morris <rgm+n...@stanford.edu> wrote:
> nemshi...@gmail.com wrote:
> From the information presented, it sounds like you might be better off
> basing your mode on sh-mode. Have at look at how sh-script.el handles
> here documents (which is what your first construct is, save for an
> extra "<"). Look for "heredocs" in the code.
Actually not. This is for php-mode (I know, I know... ) I'm trying to
create more correct mode than the existing one.

Think php is more close to c-mode by semantic than to shell. Generally
there's everything except this two problems.

I've a glue how solve the first issue with the strings, but how solve
the problem with comments?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Need help with some changes in c-mode
  2007-02-20  4:03   ` nemshilov
@ 2007-02-20 15:50     ` Robert Thorpe
  2007-02-21  3:19       ` MadRabbit
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Thorpe @ 2007-02-20 15:50 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 20, 4:03 am, nemshi...@gmail.com wrote:
> On Feb 20, 1:34 am, Glenn Morris <rgm+n...@stanford.edu> wrote:> nemshi...@gmail.com wrote:
> > From the information presented, it sounds like you might be better off
> > basing your mode on sh-mode. Have at look at how sh-script.el handles
> > here documents (which is what your first construct is, save for an
> > extra "<"). Look for "heredocs" in the code.
>
> Actually not. This is for php-mode (I know, I know... ) I'm trying to
> create more correct mode than the existing one.
>
> Think php is more close to c-mode by semantic than to shell. Generally
> there's everything except this two problems.
>
> I've a glue how solve the first issue with the strings, but how solve
> the problem with comments?

Probably the best way would be to derive a derived mode from c-mode
for php.  You can then add to that mode some of the code from sh-
script mode to handle heredocs.  Handling heredocs isn't that simple
unfortunately.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Need help with some changes in c-mode
  2007-02-20 15:50     ` Robert Thorpe
@ 2007-02-21  3:19       ` MadRabbit
  2007-02-21 10:25         ` Robert Thorpe
  0 siblings, 1 reply; 8+ messages in thread
From: MadRabbit @ 2007-02-21  3:19 UTC (permalink / raw)
  To: help-gnu-emacs

> Probably the best way would be to derive a derived mode from c-mode
> for php.  You can then add to that mode some of the code from sh-
> script mode to handle heredocs.  Handling heredocs isn't that simple
> unfortunately.

That's exactly what I do. There's a php-mode which derived from c-
mode. Most of problems are already solved. I need help with this one.
Can anyone give a piece of code?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Need help with some changes in c-mode
  2007-02-21  3:19       ` MadRabbit
@ 2007-02-21 10:25         ` Robert Thorpe
  2007-02-21 13:33           ` MadRabbit
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Thorpe @ 2007-02-21 10:25 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 21, 3:19 am, "MadRabbit" <nemshi...@gmail.com> wrote:
> > Probably the best way would be to derive a derived mode from c-mode
> > for php.  You can then add to that mode some of the code from sh-
> > script mode to handle heredocs.  Handling heredocs isn't that simple
> > unfortunately.
>
> That's exactly what I do. There's a php-mode which derived from c-
> mode. Most of problems are already solved. I need help with this one.
> Can anyone give a piece of code?

See line ~821 in sh-script.el in the distribution of GNU Emacs 21 to
see how sh-mode deals with this problem.
The solution should be quite transferable to PHP.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Need help with some changes in c-mode
  2007-02-21 10:25         ` Robert Thorpe
@ 2007-02-21 13:33           ` MadRabbit
  2007-02-21 17:34             ` Robert Thorpe
  0 siblings, 1 reply; 8+ messages in thread
From: MadRabbit @ 2007-02-21 13:33 UTC (permalink / raw)
  To: help-gnu-emacs

> > That's exactly what I do. There's a php-mode which derived from c-
> > mode. Most of problems are already solved. I need help with this one.
> > Can anyone give a piece of code?
>
> See line ~821 in sh-script.el in the distribution of GNU Emacs 21 to
> see how sh-mode deals with this problem.
> The solution should be quite transferable to PHP.

The problem is a bit differ. I've already defined font-locks and
there's no problem with colorizing #comments. The problem in it's
behavior.

When you're typing something like
--------------
# correct usual comment
$bla = "bla bla bla";
--------------
All are ok, but if you input something like "= - '%" in that comment.
The next line will be understood as a part of sentence which started
inside the comment. Like that
------------
# $a =
.........."bla bla bla";
------------
The second line will have an indentation and behave like a part of "$a
= " sentence which started in the comment. I guess this is case c-mode
handles text inside #-comments and I don't know how to switch it off.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Need help with some changes in c-mode
  2007-02-21 13:33           ` MadRabbit
@ 2007-02-21 17:34             ` Robert Thorpe
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Thorpe @ 2007-02-21 17:34 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 21, 1:33 pm, "MadRabbit" <nemshi...@gmail.com> wrote:
> > > That's exactly what I do. There's a php-mode which derived from c-
> > > mode. Most of problems are already solved. I need help with this one.
> > > Can anyone give a piece of code?
>
> > See line ~821 in sh-script.el in the distribution of GNU Emacs 21 to
> > see how sh-mode deals with this problem.
> > The solution should be quite transferable to PHP.
>
> The problem is a bit differ. I've already defined font-locks and
> there's no problem with colorizing #comments. The problem in it's
> behavior.
>
> When you're typing something like
> --------------
> # correct usual comment
> $bla = "bla bla bla";
> --------------
> All are ok, but if you input something like "= - '%" in that comment.
> The next line will be understood as a part of sentence which started
> inside the comment. Like that
> ------------
> # $a =
> .........."bla bla bla";
> ------------
> The second line will have an indentation and behave like a part of "$a
> = " sentence which started in the comment. I guess this is case c-mode
> handles text inside #-comments and I don't know how to switch it off.

I don't know how to solve that.
Read the CC-mode docs and the CC-mode source.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-02-21 17:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-17  6:34 Need help with some changes in c-mode nemshilov
2007-02-19 19:34 ` Glenn Morris
2007-02-20  4:03   ` nemshilov
2007-02-20 15:50     ` Robert Thorpe
2007-02-21  3:19       ` MadRabbit
2007-02-21 10:25         ` Robert Thorpe
2007-02-21 13:33           ` MadRabbit
2007-02-21 17:34             ` Robert Thorpe

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.