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

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

[nongnu] elpa/tuareg 4a18078 1/2: show-paren-mode: Suppress bogus mismat


From: ELPA Syncer
Subject: [nongnu] elpa/tuareg 4a18078 1/2: show-paren-mode: Suppress bogus mismatched parentheses for comment
Date: Fri, 3 Sep 2021 19:57:43 -0400 (EDT)

branch: elpa/tuareg
commit 4a180787dbdd17e73bf40d1c53fa6e38f8f5573e
Author: Christophe Troestler <Christophe.Troestler@umons.ac.be>
Commit: Christophe Troestler <Christophe.Troestler@umons.ac.be>

    show-paren-mode: Suppress bogus mismatched parentheses for comment
    
    See https://github.com/ocaml/tuareg/pull/270#issuecomment-912846738
---
 tuareg.el | 46 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/tuareg.el b/tuareg.el
index cad2b29..6e8494c 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -3065,18 +3065,41 @@ expansion at run-time, if the run-time version of Emacs 
does know this macro."
     (if (equal "->" (nth 2 (smie-forward-sexp "-dlpd-")))
         (smie-indent-forward-token))))
 
-(defun tuareg--blink-matching-check (start end)
+(defun tuareg--point-before-comment-p ()
+  "Return non-nil if a comment follows the point."
   (let ((pt (point)))
-    (if (and (> pt (+ (point-min) 3))
-             (eq (char-before) ?\))
-             (eq (char-before (1- pt)) ?*)
-             (save-excursion
-               (and (forward-comment -1)
-                    (forward-comment 1)
-                    (eq (point) pt))))
-        ;; Immediately after a comment-ending "*)" -- no mismatch error.
-        nil
-      (smie-blink-matching-check start end))))
+    (and (< (+ pt 2) (point-max))
+         (eq (char-after) ?\()
+         (eq (char-after (1+ pt)) ?*)
+         (save-excursion
+           (and (forward-comment 1)
+                (forward-comment -1)
+                (eq (point) pt))))))
+
+(defun tuareg--point-after-comment-p ()
+  "Return non-nil if a comment precedes the point."
+  (let ((pt (point)))
+    (and (> pt (+ (point-min) 3))
+         (eq (char-before) ?\))
+         (eq (char-before (1- pt)) ?*)
+         (save-excursion
+           (and (forward-comment -1)
+                (forward-comment 1)
+                (eq (point) pt))))))
+
+(defun tuareg--blink-matching-check (start end)
+  (if (tuareg--point-after-comment-p)
+      ;; Immediately after a comment-ending "*)" -- no mismatch error.
+      nil
+    (smie-blink-matching-check start end)))
+
+(defvar show-paren-data-function); Silence the byte-compiler
+(declare-function show-paren--default "paren" ())
+
+(defun tuareg--show-paren ()
+  (if (or (tuareg--point-before-comment-p) (tuareg--point-after-comment-p))
+      nil
+    (show-paren--default)))
 
 (defun tuareg--common-mode-setup ()
   (setq-local syntax-propertize-function #'tuareg-syntax-propertize)
@@ -3095,6 +3118,7 @@ expansion at run-time, if the run-time version of Emacs 
does know this macro."
   (add-hook 'smie-indent-functions #'tuareg-smie--args nil t)
   (add-hook 'smie-indent-functions #'tuareg-smie--inside-string nil t)
   (setq-local add-log-current-defun-function #'tuareg-current-fun-name)
+  (setq-local show-paren-data-function #'tuareg--show-paren)
   (setq prettify-symbols-alist
         (if tuareg-prettify-symbols-full
             (append tuareg-prettify-symbols-basic-alist



reply via email to

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