all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Trouble with quotes in comments for mode derived from sql-mode
@ 2006-01-19 14:20 colin.florendo
  2006-01-19 21:21 ` albrns
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: colin.florendo @ 2006-01-19 14:20 UTC (permalink / raw)


Hello,

I've written a very simple derived mode 'isq' mode which adds c++ style
comments
to sql-mode. The problem am having is unbalanced quotes in comments
mess up string
highlighting. I've seen similar problems in this group but haven't
found a solution.

Here's my derived mode:

(define-derived-mode isq-mode sql-mode "ISQ" "Major mode to edit Sybase
ISQ files."
  (setq indent-tabs-mode nil)
  (setq comment-start "// ")
)

(font-lock-add-keywords 'isq-mode '(("\\(--.*\\|//.*\\)$" (0
'font-lock-comment-face t))))
(add-to-list 'auto-mode-alist '(".isq\\'" . isq-mode))

I'm not sure if this is a shortcoming of sql-mode itself or if I'm
missing something.
Any help would be appreciated.

I'm using gnu emacs 21.1.1 on solaris 2.8

-Colin

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

* Re: Trouble with quotes in comments for mode derived from sql-mode
  2006-01-19 14:20 Trouble with quotes in comments for mode derived from sql-mode colin.florendo
@ 2006-01-19 21:21 ` albrns
  2006-01-20  9:55 ` Andreas Röhler
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: albrns @ 2006-01-19 21:21 UTC (permalink / raw)


hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

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

* Re: Trouble with quotes in comments for mode derived from sql-mode
  2006-01-19 14:20 Trouble with quotes in comments for mode derived from sql-mode colin.florendo
  2006-01-19 21:21 ` albrns
@ 2006-01-20  9:55 ` Andreas Röhler
  2006-01-24 15:03   ` colin.florendo
  2006-01-20 10:42 ` Tim X
  2006-01-20 15:05 ` David Hansen
  3 siblings, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2006-01-20  9:55 UTC (permalink / raw)


colin.florendo@sybase.com wrote:

> Hello,
> 
> I've written a very simple derived mode 'isq' mode which adds c++ style
> comments
> to sql-mode. The problem am having is unbalanced quotes in comments
> mess up string
> highlighting. I've seen similar problems in this group but haven't
> found a solution.
> 
> Here's my derived mode:
> 
> (define-derived-mode isq-mode sql-mode "ISQ" "Major mode to edit Sybase
> ISQ files."
>   (setq indent-tabs-mode nil)
>   (setq comment-start "// ")
> )
> 
> (font-lock-add-keywords 'isq-mode '(("\\(--.*\\|//.*\\)$" (0
> 'font-lock-comment-face t))))
> (add-to-list 'auto-mode-alist '(".isq\\'" . isq-mode))
> 
> I'm not sure if this is a shortcoming of sql-mode itself or if I'm
> missing something.
> Any help would be appreciated.
> 
> I'm using gnu emacs 21.1.1 on solaris 2.8
> 
> -Colin

Please load the latest newcomment.el and tell, if the problem persists.

I just digged a little bit into, to adapt some things: not to depend 

on transient-mark-mode, continuation if some key is pressed, fix evolving spaces and so on.

As I didn't work with sql-mode, some questions:

Your comment-start seems the same as in c++-mode. Is the problem also there?

Are you sure you need "// " instead of "--" or other - not so special - chars?

Maybe send some examples with email, so I may look at it.


Andreas Roehler

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

* Re: Trouble with quotes in comments for mode derived from sql-mode
  2006-01-19 14:20 Trouble with quotes in comments for mode derived from sql-mode colin.florendo
  2006-01-19 21:21 ` albrns
  2006-01-20  9:55 ` Andreas Röhler
@ 2006-01-20 10:42 ` Tim X
  2006-01-20 15:05 ` David Hansen
  3 siblings, 0 replies; 7+ messages in thread
From: Tim X @ 2006-01-20 10:42 UTC (permalink / raw)


"colin.florendo@sybase.com" <colin.florendo@sybase.com> writes:

> Hello,
> 
> I've written a very simple derived mode 'isq' mode which adds c++ style
> comments
> to sql-mode. The problem am having is unbalanced quotes in comments
> mess up string
> highlighting. I've seen similar problems in this group but haven't
> found a solution.
> 
> Here's my derived mode:
> 
> (define-derived-mode isq-mode sql-mode "ISQ" "Major mode to edit Sybase
> ISQ files."
>   (setq indent-tabs-mode nil)
>   (setq comment-start "// ")
> )
> 
> (font-lock-add-keywords 'isq-mode '(("\\(--.*\\|//.*\\)$" (0
> 'font-lock-comment-face t))))
> (add-to-list 'auto-mode-alist '(".isq\\'" . isq-mode))
> 
> I'm not sure if this is a shortcoming of sql-mode itself or if I'm
> missing something.
> Any help would be appreciated.
> 
> I'm using gnu emacs 21.1.1 on solaris 2.8
> 

This may not be of any use, but I use to use plsql-mode
(http://www.emacswiki.org/) which is also derived from sql mode. The
point is that plsql mode uses comments which start with -- (not that
much differenct from //). So, maybe this might give you some
hints. Therre were some bugs in plsql-mode which I contacted the
maintainer about (including patches), but never got a reply. However,
aside from the bugs, it worked quite will and I used it a lot back
when I was working with Oracle on a daily basis.



Tim

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!

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

* Re: Trouble with quotes in comments for mode derived from sql-mode
  2006-01-19 14:20 Trouble with quotes in comments for mode derived from sql-mode colin.florendo
                   ` (2 preceding siblings ...)
  2006-01-20 10:42 ` Tim X
@ 2006-01-20 15:05 ` David Hansen
  3 siblings, 0 replies; 7+ messages in thread
From: David Hansen @ 2006-01-20 15:05 UTC (permalink / raw)


On 19 Jan 2006 06:20:41 -0800 colin wrote:

> Hello,
>
> I've written a very simple derived mode 'isq' mode which
> adds c++ style comments to sql-mode. The problem am having
> is unbalanced quotes in comments mess up string
> highlighting. I've seen similar problems in this group but
> haven't found a solution.
>
> Here's my derived mode:
>
> (define-derived-mode isq-mode sql-mode "ISQ" "Major mode to edit Sybase
> ISQ files."
>   (setq indent-tabs-mode nil)
>   (setq comment-start "// ")
> )

You have to modify the syntax table otherwise the syntax
parser will treat quotes within "comments" as the start of a
string.

> (font-lock-add-keywords 'isq-mode '(("\\(--.*\\|//.*\\)$" (0
> 'font-lock-comment-face t))))

And then you don't need this anymore as the syntax pass of
font-lock already highlights strings and comments.

David

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

* Re: Trouble with quotes in comments for mode derived from sql-mode
  2006-01-20  9:55 ` Andreas Röhler
@ 2006-01-24 15:03   ` colin.florendo
  2006-01-25  4:53     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: colin.florendo @ 2006-01-24 15:03 UTC (permalink / raw)


Hi,

The file format I'm using supports both sql "--" and c++ "//" comments.
sql-mode provides the "--" comment, and handles quotes in this comment
style correctly.
I added the "//" comment style through the derived mode, but the c++
comment style does not handle the quotes correctly. I will try the
latest newcomment.el, but I suspect I'll need to modify the syntax
table as suggested by David Hansen below.

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

* Re: Trouble with quotes in comments for mode derived from sql-mode
  2006-01-24 15:03   ` colin.florendo
@ 2006-01-25  4:53     ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2006-01-25  4:53 UTC (permalink / raw)


> The file format I'm using supports both sql "--" and c++ "//" comments.
> sql-mode provides the "--" comment, and handles quotes in this comment
> style correctly.
> I added the "//" comment style through the derived mode, but the c++
> comment style does not handle the quotes correctly. I will try the
> latest newcomment.el, but I suspect I'll need to modify the syntax
> table as suggested by David Hansen below.

Of course, you'll have to create a new syntax-table (probably inheriting
from the other one).

But you'll probably also discover at some point that Emacs's syntax-tables
can't correctly handle -- and // at the same time.  I.e. if you tell it
that -- and // both start comments, then Emacs will then mistakenly also
consider -/ and /- to be comment starters :-(

One way out is to use font-lock-syntactic-keywords, but it's not as robust.


        Stefan

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

end of thread, other threads:[~2006-01-25  4:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-19 14:20 Trouble with quotes in comments for mode derived from sql-mode colin.florendo
2006-01-19 21:21 ` albrns
2006-01-20  9:55 ` Andreas Röhler
2006-01-24 15:03   ` colin.florendo
2006-01-25  4:53     ` Stefan Monnier
2006-01-20 10:42 ` Tim X
2006-01-20 15:05 ` David Hansen

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.