emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/tex-mode.el


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/tex-mode.el
Date: Tue, 04 Oct 2005 16:45:58 -0400

Index: emacs/lisp/textmodes/tex-mode.el
diff -c emacs/lisp/textmodes/tex-mode.el:1.175 
emacs/lisp/textmodes/tex-mode.el:1.176
*** emacs/lisp/textmodes/tex-mode.el:1.175      Mon Sep 26 09:47:11 2005
--- emacs/lisp/textmodes/tex-mode.el    Tue Oct  4 20:45:58 2005
***************
*** 631,637 ****
        (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<"))
        ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b")
        ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b")
!       ("\\\\verb\\**\\(address@hidden)" 1 "\""))))
  
  (defun tex-font-lock-unfontify-region (beg end)
    (font-lock-default-unfontify-region beg end)
--- 631,640 ----
        (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<"))
        ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b")
        ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b")
!       ("\\\\verb\\**\\(address@hidden)"
!        ;; Do it last, because it uses syntax-ppss which needs the
!        ;; syntax-table properties of previous entries.
!        1 (tex-font-lock-verb (match-end 1))))))
  
  (defun tex-font-lock-unfontify-region (beg end)
    (font-lock-default-unfontify-region beg end)
***************
*** 670,691 ****
  (put 'tex-verbatim-face 'face-alias 'tex-verbatim)
  (defvar tex-verbatim-face 'tex-verbatim)
  
  ;; Use string syntax but math face for $...$.
  (defun tex-font-lock-syntactic-face-function (state)
    (let ((char (nth 3 state)))
      (cond
       ((not char) font-lock-comment-face)
       ((eq char ?$) tex-math-face)
!      (t
!       (when (char-valid-p char)
!       ;; This is a \verb?...? construct.  Let's find the end and mark it.
!       (save-excursion
!         (skip-chars-forward (string ?^ char)) ;; Use `end' ?
!         (when (eq (char-syntax (preceding-char)) ?/)
!           (put-text-property (1- (point)) (point) 'syntax-table '(1)))
!         (unless (eobp)
!           (put-text-property (point) (1+ (point)) 'syntax-table '(7)))))
!       tex-verbatim-face))))
  
  
  (defun tex-define-common-keys (keymap)
--- 673,710 ----
  (put 'tex-verbatim-face 'face-alias 'tex-verbatim)
  (defvar tex-verbatim-face 'tex-verbatim)
  
+ (defun tex-font-lock-verb (end)
+   "Place syntax-table properties on the \verb construct.
+ END is the position of the first delimiter after \verb."
+   (unless (nth 8 (syntax-ppss end))
+     ;; Do nothing if the \verb construct is itself inside a comment or
+     ;; verbatim env.
+     (save-excursion
+       ;; Let's find the end and mark it.
+       ;; We used to do it inside tex-font-lock-syntactic-face-function, but
+       ;; this leads to funny effects when jumping to the end of the buffer,
+       ;; because font-lock applies font-lock-syntactic-keywords to the whole
+       ;; preceding text but font-lock-syntactic-face-function only to the
+       ;; actually displayed text.
+       (goto-char end)
+       (let ((char (char-before)))
+         (skip-chars-forward (string ?^ char)) ;; Use `end' ?
+         (when (eq (char-syntax (preceding-char)) ?/)
+           (put-text-property (1- (point)) (point) 'syntax-table '(1)))
+         (unless (eobp)
+           (put-text-property (point) (1+ (point)) 'syntax-table '(7))
+           ;; Cause the rest of the buffer to be re-fontified.
+           ;; (remove-text-properties (1+ (point)) (point-max) '(fontified))
+           )))
+     "\""))
+ 
  ;; Use string syntax but math face for $...$.
  (defun tex-font-lock-syntactic-face-function (state)
    (let ((char (nth 3 state)))
      (cond
       ((not char) font-lock-comment-face)
       ((eq char ?$) tex-math-face)
!      (t tex-verbatim-face))))
  
  
  (defun tex-define-common-keys (keymap)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]