[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-devel] Fun with syntax tables
From: |
Ralf Angeli |
Subject: |
[AUCTeX-devel] Fun with syntax tables |
Date: |
Thu, 21 Jul 2005 21:28:45 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
Suppose you have line like
foo \verb|bar| baz
in a LaTeX buffer. font-latex puts syntax properties (string quote
syntax) onto the | characters which then get picked up by
`font-lock-fontify-syntactically-region'. This happens with help of
`parse-partial-sexp'.
This is fine in LaTeX mode, but fails in documentation parts of docTeX
mode. There the line would look like this:
% foo \verb|bar| baz
That means with a comment starter at the front.
The problem is that with % as the comment start and \n as the comment
end `parse-partial-sexp' won't find the stuff marked with string quote
syntax inside of the comment. Here is an example:
(with-temp-buffer
(let ((my-syntax-table (make-syntax-table)))
(modify-syntax-entry ?% "<" my-syntax-table)
(modify-syntax-entry ?\n ">" my-syntax-table)
(with-syntax-table my-syntax-table
(insert "%foo |X| bar")
(goto-char (point-min))
(search-forward "|")
(put-text-property (1- (point)) (point) 'syntax-table '(7))
(search-forward "|")
(put-text-property (1- (point)) (point) 'syntax-table '(7))
(goto-char (point-min))
(set (make-local-variable 'parse-sexp-lookup-properties) t)
(let ((old-state (parse-partial-sexp (point-min) (point-max)
nil nil nil 'syntax-table)))
(parse-partial-sexp (point) (point-max)
nil nil old-state 'syntax-table))
(point))))
If you execute it, it should return 13 which is the end of the line.
If you remove the % character from the inserted string it will return
8 which is the position just after the second | character.
Can anybody tell me how to make the string quote stuff visible for
`parse-partial-sexp'?
--
Ralf
- [AUCTeX-devel] Fun with syntax tables,
Ralf Angeli <=