emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 6a9d967: Widen in certain low level CC Mode functio


From: Alan Mackenzie
Subject: [Emacs-diffs] master 6a9d967: Widen in certain low level CC Mode functions. This fixes bug #24148.
Date: Thu, 4 Aug 2016 21:12:41 +0000 (UTC)

branch: master
commit 6a9d967048f489bea8c716eb7b5be2c582b480bb
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    Widen in certain low level CC Mode functions.  This fixes bug #24148.
    
    * lisp/progmodes/cc-engine (c-state-semi-pp-to-literal)
    (c-state-full-pp-to-literal): Widen around the functionality.
    (c-parse-ps-state-below): Correct the order of save-excursion and
    save-restriction.
---
 lisp/progmodes/cc-engine.el |  122 ++++++++++++++++++++++---------------------
 1 file changed, 63 insertions(+), 59 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index dbcd071..e22b98d 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2313,30 +2313,32 @@ comment at the start of cc-engine.el for more info."
   ;; newer Emacsen only, the syntax of a position after a potential first char
   ;; of a two char construct) of STATE are valid.
   (save-excursion
-    (save-match-data
-      (let* ((base-and-state (c-parse-ps-state-below here))
-            (base (car base-and-state))
-            (s (cdr base-and-state))
-            (s (parse-partial-sexp base here nil nil s))
-            ty)
-       (cond
-        ((or (nth 3 s) (nth 4 s))      ; in a string or comment
-         (setq ty (cond
-                   ((nth 3 s) 'string)
-                   ((nth 7 s) 'c++)
-                   (t 'c)))
-         (list s ty (nth 8 s)))
-
-        ((and (not not-in-delimiter)   ; inside a comment starter
-              (not (bobp))
-              (progn (backward-char)
-                     (and (not (and (memq 'category-properties 
c-emacs-features)
-                                    (looking-at "\\s!")))
-                          (looking-at c-comment-start-regexp))))
-         (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++))
-         (list s ty (point)))
-
-        (t (list s)))))))
+    (save-restriction
+      (widen)
+      (save-match-data
+       (let* ((base-and-state (c-parse-ps-state-below here))
+              (base (car base-and-state))
+              (s (cdr base-and-state))
+              (s (parse-partial-sexp base here nil nil s))
+              ty)
+         (cond
+          ((or (nth 3 s) (nth 4 s))    ; in a string or comment
+           (setq ty (cond
+                     ((nth 3 s) 'string)
+                     ((nth 7 s) 'c++)
+                     (t 'c)))
+           (list s ty (nth 8 s)))
+
+          ((and (not not-in-delimiter) ; inside a comment starter
+                (not (bobp))
+                (progn (backward-char)
+                       (and (not (and (memq 'category-properties 
c-emacs-features)
+                                      (looking-at "\\s!")))
+                            (looking-at c-comment-start-regexp))))
+           (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++))
+           (list s ty (point)))
+
+          (t (list s))))))))
 
 (defun c-state-full-pp-to-literal (here &optional not-in-delimiter)
   ;; This function will supersede c-state-pp-to-literal.
@@ -2357,38 +2359,40 @@ comment at the start of cc-engine.el for more info."
   ;; newer Emacsen only, the syntax of a position after a potential first char
   ;; of a two char construct) of STATE are valid.
   (save-excursion
-    (save-match-data
-      (let* ((base-and-state (c-parse-ps-state-below here))
-            (base (car base-and-state))
-            (s (cdr base-and-state))
-            (s (parse-partial-sexp base here nil nil s))
-            ty start)
-       (cond
-        ((or (nth 3 s) (nth 4 s))      ; in a string or comment
-         (setq ty (cond
-                   ((nth 3 s) 'string)
-                   ((nth 7 s) 'c++)
-                   (t 'c)))
-         (setq start (nth 8 s))
-         (parse-partial-sexp here (point-max)
-                             nil                             ; TARGETDEPTH
-                             nil                             ; STOPBEFORE
-                             s                               ; OLDSTATE
-                             'syntax-table) ; stop at end of literal
-         (list s ty (cons start (point))))
-
-        ((and (not not-in-delimiter)   ; inside a comment starter
-              (not (bobp))
-              (progn (backward-char)
-                     (and (not (and (memq 'category-properties 
c-emacs-features)
-                                    (looking-at "\\s!")))
-                          (looking-at c-comment-start-regexp))))
-         (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)
-               start (point))
-         (forward-comment 1)
-         (list s ty (cons start (point))))
-
-        (t (list s)))))))
+    (save-restriction
+      (widen)
+      (save-match-data
+       (let* ((base-and-state (c-parse-ps-state-below here))
+              (base (car base-and-state))
+              (s (cdr base-and-state))
+              (s (parse-partial-sexp base here nil nil s))
+              ty start)
+         (cond
+          ((or (nth 3 s) (nth 4 s))    ; in a string or comment
+           (setq ty (cond
+                     ((nth 3 s) 'string)
+                     ((nth 7 s) 'c++)
+                     (t 'c)))
+           (setq start (nth 8 s))
+           (parse-partial-sexp here (point-max)
+                               nil          ; TARGETDEPTH
+                               nil          ; STOPBEFORE
+                               s            ; OLDSTATE
+                               'syntax-table) ; stop at end of literal
+           (list s ty (cons start (point))))
+
+          ((and (not not-in-delimiter) ; inside a comment starter
+                (not (bobp))
+                (progn (backward-char)
+                       (and (not (and (memq 'category-properties 
c-emacs-features)
+                                      (looking-at "\\s!")))
+                            (looking-at c-comment-start-regexp))))
+           (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)
+                 start (point))
+           (forward-comment 1)
+           (list s ty (cons start (point))))
+
+          (t (list s))))))))
 
 (defsubst c-state-pp-to-literal (from to &optional not-in-delimiter)
   ;; Do a parse-partial-sexp from FROM to TO, returning either
@@ -2492,9 +2496,9 @@ comment at the start of cc-engine.el for more info."
   ;; STATE are those concerning comments and strings; STATE is the state of a
   ;; null `parse-partial-sexp' scan when CACHE-POS is not in a comment or
   ;; string.
-  (save-restriction
-    (widen)
-    (save-excursion
+  (save-excursion
+    (save-restriction
+      (widen)
       (let ((c c-state-semi-nonlit-pos-cache)
            elt state pos npos high-elt)
        ;; Trim the cache to take account of buffer changes.



reply via email to

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