emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/sm-c-mode a3efebd 09/12: * sm-c-mode.el: Fix some prob


From: Stefan Monnier
Subject: [elpa] externals/sm-c-mode a3efebd 09/12: * sm-c-mode.el: Fix some problems reported by Andrés Ramírez
Date: Sat, 28 Nov 2020 18:11:08 -0500 (EST)

branch: externals/sm-c-mode
commit a3efebd9e6c341892222ecf7f9b168decdee7954
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * sm-c-mode.el: Fix some problems reported by Andrés Ramírez
    
    (sm-c-smie-rules): Avoid inf-looping on "case foo: {".
    (sm-c--cpp-syntax-propertize): Treat trailing //...\n in CPP directive
    as being outside the directive.
---
 sm-c-mode.el | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sm-c-mode.el b/sm-c-mode.el
index deaf952..0731203 100644
--- a/sm-c-mode.el
+++ b/sm-c-mode.el
@@ -150,8 +150,20 @@ no difference."
                    (with-syntax-table sm-c--cpp-syntax-table
                      (nth 4 (parse-partial-sexp (1+ (nth 8 ppss)) (point)))))))
       (when found
-        (put-text-property (1- (point)) (point)
-                           'syntax-table (string-to-syntax "> c"))))))
+        (let* ((ppss-in
+                (save-excursion
+                  (parse-partial-sexp (1+ (nth 8 ppss)) (1- (point)))))
+               ;; Put the end before a closing //...\n comment so as to avoid
+               ;; a bug in back_comment.  The problem is that back_comment
+               ;; otherwise will see "// <...> <...> \n" and will consider the
+               ;; CPP pseudo-comments as nested within the //...\n comment.
+               (end (if (and (nth 4 ppss-in)        ;Inside a comment.
+                             (null (nth 7 ppss-in)) ;A style `a' comment.
+                             (memq (char-before (nth 8 ppss-in)) '(?\s ?\t)))
+                        (nth 8 ppss-in)
+                      (point))))
+          (put-text-property (1- end) end
+                             'syntax-table (string-to-syntax "> c")))))))
 
 ;;;; Indenting CPP directives.
 
@@ -661,6 +673,7 @@ if INNER is non-nil, it stops at the innermost one."
                             (equal ")" (car (smie-indent-backward-token))))
                    (up-list -1)
                    `(column . ,(sm-c--smie-virtual)))))
+              ((>= (point) pos) nil)
               (t `(column . ,(smie-indent-virtual))))))))
       ((smie-rule-hanging-p)
        (cond



reply via email to

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