gnu-emacs-sources
[Top][All Lists]
Advanced

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

Re: mic-paren.el 3.10 available


From: Leo Liu
Subject: Re: mic-paren.el 3.10 available
Date: Fri, 18 Jan 2013 00:32:20 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.92 (OS X 10.8.2)

On 2013-01-17 22:58 +0800, Stefan Monnier wrote:
> But this leads to other bugs (try it with a comment like (* foo"bar *)
> for example).
>
> I think the only way to do it right begins by checking whether (1-
> (point)) is within a comment.

Syntax at pos (+ (point) +1/-1) still says not a comment.

How about something like this?

diff --git a/mic-paren.el b/mic-paren.el
index 25b72496..a3c202a4 100644
--- a/mic-paren.el
+++ b/mic-paren.el
@@ -1006,6 +1006,15 @@ (defun mic-paren-highlight ()
                                  right-prio))
                        (not fcq)))))
 
+           ;; helper for find-other-paren
+           (comment-edge
+            (m)
+            (let ((pt (point)) res)
+              (save-excursion (when (forward-comment m)
+                                (setq res (point))
+                                (forward-comment (- m))
+                                (and (eq pt (point)) res)))))
+
            (find-other-paren
             (forwardp)
             (let ((mult (if forwardp 1 -1)))
@@ -1022,7 +1031,8 @@ (defun mic-paren-highlight ()
                                             (min lim (point-max))
                                           (point-max)))))
                   (condition-case ()
-                      (setq opos (scan-sexps (point) mult))
+                      (setq opos (or (comment-edge mult)
+                                     (scan-sexps (point) mult)))
                     (error nil))))
               ;; We must call matching-paren because `scan-sexps' doesn't
               ;; care about the kind of paren (e.g., matches '( and '}).



reply via email to

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