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: Thien-Thi Nguyen
Subject: Re: mic-paren.el 3.10 available
Date: Mon, 21 Jan 2013 13:53:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Here's a patch that "works for me".  Any problems w/ this approach?

--- mic-paren.el~
+++ mic-paren.el
@@ -1011,6 +1011,31 @@ (defun mic-paren-highlight ()
                                  right-prio))
                        (not fcq)))))

+           (comment-style
+            ()
+            (or (get major-mode 'mic-paren-comment-style)
+                (put major-mode 'mic-paren-comment-style
+                     ;; Tested (lightly) w/ SML, Modula-2, Pascal.
+                     (flet ((sub (str pos) (condition-case ()
+                                               (aref str (if (> 0 pos)
+                                                             (+ (length str) 
pos)
+                                                           pos))
+                                             (error 0))))
+                       (if (string= "()" (string (sub comment-start 0)
+                                                 (sub comment-end -1)))
+                           'sexp
+                         'normal)))))
+
+           (sexp-ish-comment-edge
+            (p mult)
+            (and (eq 'sexp (comment-style))
+                 (if (> 0 mult)
+                     (prog1 (nth 8 (syntax-ppss (1- p)))
+                       (forward-char 1))
+                   ;; hmmm
+                   (save-match-data
+                     (looking-at (regexp-quote comment-start))))))
+
            (find-other-paren
             (forwardp)
             (let ((mult (if forwardp 1 -1)))
@@ -1027,7 +1052,11 @@ (defun mic-paren-highlight ()
                                             (min lim (point-max))
                                           (point-max)))))
                   (condition-case ()
-                      (setq opos (scan-sexps (point) mult))
+                      (setq opos (let ((p (point)))
+                                   (if (not (sexp-ish-comment-edge p mult))
+                                       (scan-sexps p mult)
+                                     (forward-comment mult)
+                                     (point))))
                     (error nil))))
               ;; We must call matching-paren because `scan-sexps' doesn't
               ;; care about the kind of paren (e.g., matches '( and '}).

-- 
Thien-Thi Nguyen

reply via email to

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