[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
regexp problem with 2 character comment starter
From: |
Bielawski, Richard G. |
Subject: |
regexp problem with 2 character comment starter |
Date: |
Wed, 23 Mar 2005 12:03:31 -0800 |
(re-search-forward "\\s<") won't find comments
that begin with a 2 character comment starter.
For example:
(modify-syntax-entry ?\{ "<" st)
(modify-syntax-entry ?\} ">" st)
(modify-syntax-entry ?\= "_ b12" st)
(modify-syntax-entry ?\n "> b" st)
^ <- with point here (re-search-forward "\\s<")
some text ==followed by comment
more text {different style comment}
The {dif... line will be found, not the ==foll... line.
I noticed it when the following function didn't always work.
Being generic, it has no way of knowing what comment
characters are defined for the current mode and currently
can't depend on the character syntax either.
(defun end-of-code-or-line ()
"Move to EOL. If there, to EOL sans comments."
(interactive)
(if (not (eolp))
(end-of-line)
(skip-syntax-backward " \t")
(let ((pt (point))
(lim (line-beginning-position)))
(when (re-search-backward "\\s<" lim t)
(setq lim (point))
(if (re-search-forward "\\s>" (1- pt) t)
(goto-char pt)
(goto-char lim) ; test here ->
(while (looking-back "\\s<")
(backward-char))
(skip-syntax-backward " \t"))))))
Richard Bielawski
612-667-5039
- regexp problem with 2 character comment starter,
Bielawski, Richard G. <=