[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r112214: Handle `parse-partial-sexp'
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r112214: Handle `parse-partial-sexp' landing inside a comment opener |
Date: |
Wed, 03 Apr 2013 17:50:39 +0000 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 112214
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Wed 2013-04-03 17:50:39 +0000
message:
Handle `parse-partial-sexp' landing inside a comment opener
(Bug#13244). Also adapt to the new values of element 7 of a parse
state.
* progmodes/cc-engine.el (c-state-pp-to-literal): New optional
parameter `not-in-delimiter'. Handle being inside comment opener.
(c-invalidate-state-cache-1): Reckon with an extra "invalid"
character in case we're typing a '*' after a '/'.
(c-literal-limits): Handle the awkward "not-in-delimiter" cond arm
instead by passing the parameter to c-state-pp-to-literal.
* progmodes/cc-fonts.el (c-font-lock-doc-comments): New handling
for elt. 7 of a parse state.
modified:
lisp/ChangeLog
lisp/progmodes/cc-engine.el
lisp/progmodes/cc-fonts.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-04-02 01:18:40 +0000
+++ b/lisp/ChangeLog 2013-04-03 17:50:39 +0000
@@ -1,3 +1,19 @@
+2013-04-03 Alan Mackenzie <address@hidden>
+
+ Handle `parse-partial-sexp' landing inside a comment opener
+ (Bug#13244). Also adapt to the new values of element 7 of a parse
+ state.
+
+ * progmodes/cc-engine.el (c-state-pp-to-literal): New optional
+ parameter `not-in-delimiter'. Handle being inside comment opener.
+ (c-invalidate-state-cache-1): Reckon with an extra "invalid"
+ character in case we're typing a '*' after a '/'.
+ (c-literal-limits): Handle the awkward "not-in-delimiter" cond arm
+ instead by passing the parameter to c-state-pp-to-literal.
+
+ * progmodes/cc-fonts.el (c-font-lock-doc-comments): New handling
+ for elt. 7 of a parse state.
+
2013-04-01 Paul Eggert <address@hidden>
Use UTF-8 for most files with non-ASCII characters (Bug#13936).
=== modified file 'lisp/progmodes/cc-engine.el'
--- a/lisp/progmodes/cc-engine.el 2013-03-05 17:13:01 +0000
+++ b/lisp/progmodes/cc-engine.el 2013-04-03 17:50:39 +0000
@@ -2180,32 +2180,45 @@
;; reduced by buffer changes, and increased by invocations of
;; `c-state-literal-at'. FIXME!!!
-(defsubst c-state-pp-to-literal (from to)
+(defsubst c-state-pp-to-literal (from to &optional not-in-delimiter)
;; Do a parse-partial-sexp from FROM to TO, returning either
;; (STATE TYPE (BEG . END)) if TO is in a literal; or
;; (STATE) otherwise,
;; where STATE is the parsing state at TO, TYPE is the type of the literal
;; (one of 'c, 'c++, 'string) and (BEG . END) is the boundaries of the
literal.
;;
+ ;; Unless NOT-IN-DELIMITER is non-nil, when TO is inside a two-character
+ ;; comment opener, this is recognized as being in a comment literal.
+ ;;
;; Only elements 3 (in a string), 4 (in a comment), 5 (following a quote),
;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of
;; STATE are valid.
(save-excursion
(let ((s (parse-partial-sexp from to))
- ty)
- (when (or (nth 3 s) (nth 4 s)) ; in a string or comment
+ ty co-st)
+ (cond
+ ((or (nth 3 s) (nth 4 s)) ; in a string or comment
(setq ty (cond
((nth 3 s) 'string)
- ((eq (nth 7 s) t) 'c++)
+ ((nth 7 s) 'c++)
(t 'c)))
(parse-partial-sexp (point) (point-max)
- nil ; TARGETDEPTH
- nil ; STOPBEFORE
- s ; OLDSTATE
- 'syntax-table)) ; stop at end of literal
- (if ty
- `(,s ,ty (,(nth 8 s) . ,(point)))
- `(,s)))))
+ nil ; TARGETDEPTH
+ nil ; STOPBEFORE
+ s ; OLDSTATE
+ 'syntax-table) ; stop at end of literal
+ `(,s ,ty (,(nth 8 s) . ,(point))))
+
+ ((and (not not-in-delimiter) ; inside a comment starter
+ (not (bobp))
+ (progn (backward-char)
+ (looking-at c-comment-start-regexp)))
+ (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)
+ co-st (point))
+ (forward-comment 1)
+ `(,s ,ty (,co-st . ,(point))))
+
+ (t `(,s))))))
(defun c-state-safe-place (here)
;; Return a buffer position before HERE which is "safe", i.e. outside any
@@ -3143,10 +3156,13 @@
;; This function is called from c-after-change.
;; The caches of non-literals:
- (if (< here c-state-nonlit-pos-cache-limit)
- (setq c-state-nonlit-pos-cache-limit here))
- (if (< here c-state-semi-nonlit-pos-cache-limit)
- (setq c-state-semi-nonlit-pos-cache-limit here))
+ ;; Note that we use "<=" for the possibility of the second char of a two-char
+ ;; comment opener being typed; this would invalidate any cache position at
+ ;; HERE.
+ (if (<= here c-state-nonlit-pos-cache-limit)
+ (setq c-state-nonlit-pos-cache-limit (1- here)))
+ (if (<= here c-state-semi-nonlit-pos-cache-limit)
+ (setq c-state-semi-nonlit-pos-cache-limit (1- here)))
;; `c-state-cache':
;; Case 1: if `here' is in a literal containing point-min, everything
@@ -4444,19 +4460,12 @@
(lim (or lim (c-state-semi-safe-place pos)))
(pp-to-lit (save-restriction
(widen)
- (c-state-pp-to-literal lim pos)))
+ (c-state-pp-to-literal lim pos not-in-delimiter)))
(state (car pp-to-lit))
(lit-limits (car (cddr pp-to-lit))))
(cond
(lit-limits)
- ((and (not not-in-delimiter)
- (not (elt state 5))
- (eq (char-before) ?/)
- (looking-at "[/*]")) ; FIXME!!! use c-line/block-comment-starter.
2008-09-28.
- ;; We're standing in a comment starter.
- (backward-char 1)
- (cons (point) (progn (c-forward-single-comment) (point))))
(near
(goto-char pos)
=== modified file 'lisp/progmodes/cc-fonts.el'
--- a/lisp/progmodes/cc-fonts.el 2013-01-11 23:08:55 +0000
+++ b/lisp/progmodes/cc-fonts.el 2013-04-03 17:50:39 +0000
@@ -2486,7 +2486,7 @@
(setq comment-beg nil))
(setq region-beg comment-beg))
- (if (eq (elt (parse-partial-sexp comment-beg (+ comment-beg 2)) 7) t)
+ (if (elt (parse-partial-sexp comment-beg (+ comment-beg 2)) 7)
;; Collect a sequence of doc style line comments.
(progn
(goto-char comment-beg)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r112214: Handle `parse-partial-sexp' landing inside a comment opener,
Alan Mackenzie <=