unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14434: 24.3; lisp mode's comment start seems bad
@ 2013-05-22  4:26 Leo Liu
  2013-05-22  6:15 ` Andreas Röhler
  2013-05-22 21:32 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Leo Liu @ 2013-05-22  4:26 UTC (permalink / raw)
  To: 14434

After fixing bug#14303, we can observe the following bug:

1. Emacs -q
2. insert in a emacs lisp mode buffer:
   (
     ;;
   )
3. Move point to be end of ;;
4. M-j

You should see:

   (
     ;;
     ;
   )

This seems to be due to bad comment-start-skip. Is the following fix correct?

--- lisp/emacs-lisp/lisp-mode.el.gz
+++ #<buffer lisp-mode.el.gz>
@@ -219,7 +219,7 @@
   (make-local-variable 'comment-start-skip)
   ;; Look within the line for a ; following an even number of backslashes
   ;; after either a non-backslash or the line beginning.
-  (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
+  (setq comment-start-skip "\\(\\(^\\|[^\\\\\n;]\\)\\(\\\\\\\\\\)*\\);+ *")
   (make-local-variable 'font-lock-comment-start-skip)
   ;; Font lock mode uses this only when it KNOWS a comment is starting.
   (setq font-lock-comment-start-skip ";+ *")

Diff finished.  Wed May 22 12:24:18 2013





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

* bug#14434: 24.3; lisp mode's comment start seems bad
  2013-05-22  4:26 bug#14434: 24.3; lisp mode's comment start seems bad Leo Liu
@ 2013-05-22  6:15 ` Andreas Röhler
  2013-05-22 21:32 ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Röhler @ 2013-05-22  6:15 UTC (permalink / raw)
  To: 14434

Am 22.05.2013 06:26, schrieb Leo Liu:
> After fixing bug#14303, we can observe the following bug:
>
> 1. Emacs -q
> 2. insert in a emacs lisp mode buffer:
>     (
>       ;;
>     )
> 3. Move point to be end of ;;
> 4. M-j
>
> You should see:
>
>     (
>       ;;
>       ;
>     )
>
> This seems to be due to bad comment-start-skip. Is the following fix correct?
>
> --- lisp/emacs-lisp/lisp-mode.el.gz
> +++ #<buffer lisp-mode.el.gz>
> @@ -219,7 +219,7 @@
>     (make-local-variable 'comment-start-skip)
>     ;; Look within the line for a ; following an even number of backslashes
>     ;; after either a non-backslash or the line beginning.
> -  (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
> +  (setq comment-start-skip "\\(\\(^\\|[^\\\\\n;]\\)\\(\\\\\\\\\\)*\\);+ *")
>     (make-local-variable 'font-lock-comment-start-skip)
>     ;; Font lock mode uses this only when it KNOWS a comment is starting.
>     (setq font-lock-comment-start-skip ";+ *")
>
> Diff finished.  Wed May 22 12:24:18 2013
>
>
>
>

Maybe it would be worth to re-consider that comment-start-skip.
What about to drop it?

All we need is the position of comment start and it's end. What to do with code before resp. after, let the modes decide.

AFAIU you can't check for an even number of backslashes with a regexp, never.
So that will remain buggy.

Cheers,

andreas






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

* bug#14434: 24.3; lisp mode's comment start seems bad
  2013-05-22  4:26 bug#14434: 24.3; lisp mode's comment start seems bad Leo Liu
  2013-05-22  6:15 ` Andreas Röhler
@ 2013-05-22 21:32 ` Stefan Monnier
  2013-06-07 12:04   ` Leo Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-05-22 21:32 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14434

> After fixing bug#14303, we can observe the following bug:
> 1. Emacs -q
> 2. insert in a emacs lisp mode buffer:
>    (
>      ;;
>    )
> 3. Move point to be end of ;;
> 4. M-j

> You should see:

>    (
>      ;;
>      ;
>    )

> This seems to be due to bad comment-start-skip.

That's one way to see it.  Another is that it's a regression introduced
by the fix to bug#14303.  It probably affects more than
emacs-lisp-mode.  So it'd be better to fix it by improving your fix to
bug#14303.  E.g. after the new while loop which finds the comment start, do
a looking-at to make sure the match-data extends as far as possible.

Tho maybe, we should take a new look at bug#14303 to see why it failed,
since after all the old comment-search-backward did already pay
attention to comment-use-global-state (via comment-search-forward), so
maybe bug#14303 was really due to a bug in comment-search-forward.


        Stefan





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

* bug#14434: 24.3; lisp mode's comment start seems bad
  2013-05-22 21:32 ` Stefan Monnier
@ 2013-06-07 12:04   ` Leo Liu
  2013-06-07 16:05     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Liu @ 2013-06-07 12:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14434-done

On 2013-05-23 05:32 +0800, Stefan Monnier wrote:
> That's one way to see it.  Another is that it's a regression introduced
> by the fix to bug#14303.  It probably affects more than
> emacs-lisp-mode.  So it'd be better to fix it by improving your fix to
> bug#14303.  E.g. after the new while loop which finds the comment start, do
> a looking-at to make sure the match-data extends as far as possible.
>
> Tho maybe, we should take a new look at bug#14303 to see why it failed,
> since after all the old comment-search-backward did already pay
> attention to comment-use-global-state (via comment-search-forward), so
> maybe bug#14303 was really due to a bug in comment-search-forward.

Thanks, Stefan, for the hints.

The fix for bug#14303 seems bad so I have reverted it and instead set
comment-use-global-state to t in octave-mode.

Leo





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

* bug#14434: 24.3; lisp mode's comment start seems bad
  2013-06-07 12:04   ` Leo Liu
@ 2013-06-07 16:05     ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2013-06-07 16:05 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14434-done

> The fix for bug#14303 seems bad so I have reverted it and instead set
> comment-use-global-state to t in octave-mode.

Great, thank you,


        Stefan





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

end of thread, other threads:[~2013-06-07 16:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-22  4:26 bug#14434: 24.3; lisp mode's comment start seems bad Leo Liu
2013-05-22  6:15 ` Andreas Röhler
2013-05-22 21:32 ` Stefan Monnier
2013-06-07 12:04   ` Leo Liu
2013-06-07 16:05     ` Stefan Monnier

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