Subject: bug#8169: 23.2; wrong fontification in gdb-script

From: Stefan Monnier <[email-masked]>
Date: Thu, 03 Mar 2011 23:49:10 -0500

>>>>> "Tom" == Tom Tromey <[email-masked]> writes:

> Visit a file named .gdbinit and enter:

> define something
>   echo hi
>   # a comment
> end

> Notice that "end" is incorrect given the comment face.

> This happens due to some logic in gdb-script-syntax-propertize-function.
> It overrides the comment-end syntax on the newline.  But, this is
> only really ok if the newline is actually part of a "document" command.

Good point.  The patch below fixes this case, I think.

        Stefan "can't commit right now"

=== modified file 'lisp/progmodes/gud.el'
--- lisp/progmodes/gud.el	2011-01-25 20:26:05 +0000
+++ lisp/progmodes/gud.el	2011-03-04 04:47:29 +0000
@@ -3128,7 +3128,9 @@
    ("^document\\s-.*\\(\n\\)" (1 "< b"))
    ("^end\\(\\>\\)"
     (1 (ignore
-        (unless (eq (match-beginning 0) (point-min))
+        (when (and (> (match-beginning 0) (point-min))
+                   (eq 1 (nth 7 (save-excursion
+                                  (syntax-ppss (1- (match-beginning 0)))))))
           ;; We change the \n in front, which is more difficult, but results
           ;; in better highlighting.  If the doc is empty, the single \n is
           ;; both the beginning and the end of the docstring, which can't be