unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Small gud.el patch
@ 2006-08-03 15:23 David Hansen
  2006-08-03 18:31 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: David Hansen @ 2006-08-03 15:23 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

Hello,

this patch fixes two problems:

1. Wrong coloring of the 'd' in 'end' (syntactic keywords
   gave the 'd' comment end syntax).

2. "end" after a "document" is now colored as a keyword.

David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gud.diff --]
[-- Type: text/x-patch, Size: 844 bytes --]

--- /home/dhansen/cvs-src/emacs/lisp/progmodes/gud.el	2006-07-20 23:23:10.000000000 +0200
+++ gud.el	2006-08-03 17:18:52.000000000 +0200
@@ -3175,12 +3175,12 @@
     ("\\$\\(\\w+\\)" (1 font-lock-variable-name-face))
     ("^\\s-*\\(\\w\\(\\w\\|\\s_\\)*\\)" (1 font-lock-keyword-face))))
 
-;; FIXME: The keyword "end" associated with "document"
-;; should have font-lock-keyword-face (currently font-lock-doc-face).
+(defun gdb-script-font-lock-end-of-document (limit)
+  (re-search-forward "\\(\n\\)end\\>" limit t))
+
 (defvar gdb-script-font-lock-syntactic-keywords
   '(("^document\\s-.*\\(\n\\)" (1 "< b"))
-    ;; It would be best to change the \n in front, but it's more difficult.
-    ("^en\\(d\\)\\>" (1 "> b"))))
+    (gdb-script-font-lock-end-of-document (1 "> b"))))
 
 (defun gdb-script-font-lock-syntactic-face (state)
   (cond

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Small gud.el patch
  2006-08-03 15:23 Small gud.el patch David Hansen
@ 2006-08-03 18:31 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2006-08-03 18:31 UTC (permalink / raw)


> 1. Wrong coloring of the 'd' in 'end' (syntactic keywords
>    gave the 'd' comment end syntax).

> 2. "end" after a "document" is now colored as a keyword.

IIRC an earlier version of the code did exactly what your patch does.
The problem is that the \n you modify belongs to the previous line, so
you're now dealing with a multiline keyword here.

This causes problems for example if you go and modify the line just before
the "end": the refontification of that line will remove the annotation on
the \n.

I've installed the patch below instead,


        Stefan


Index: lisp/progmodes/gud.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/gud.el,v
retrieving revision 1.114
diff -u -r1.114 gud.el
--- lisp/progmodes/gud.el	13 Jul 2006 21:57:05 -0000	1.114
+++ lisp/progmodes/gud.el	3 Aug 2006 18:29:22 -0000
@@ -3180,7 +3180,15 @@
 (defvar gdb-script-font-lock-syntactic-keywords
   '(("^document\\s-.*\\(\n\\)" (1 "< b"))
     ;; It would be best to change the \n in front, but it's more difficult.
-    ("^en\\(d\\)\\>" (1 "> b"))))
+    ("^end\\>"
+     (0 (progn
+          (unless (eq (match-beginning 0) (point-min))
+            (put-text-property (1- (match-beginning 0)) (match-beginning 0)
+                               'syntax-table (eval-when-compile
+                                               (string-to-syntax "> b")))
+            (put-text-property (1- (match-beginning 0)) (match-end 0)
+                               'font-lock-multiline t)
+            nil))))))
 
 (defun gdb-script-font-lock-syntactic-face (state)
   (cond

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

end of thread, other threads:[~2006-08-03 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-03 15:23 Small gud.el patch David Hansen
2006-08-03 18:31 ` 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).