[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mic-paren.el 3.10 available
From: |
Frank Fischer |
Subject: |
Re: mic-paren.el 3.10 available |
Date: |
Thu, 26 Jul 2012 06:24:45 +0000 (UTC) |
User-agent: |
slrn/0.9.9p1 (Linux) |
On 2012-07-25, address@hidden <address@hidden> wrote:
> Dear Mr. Nguyen,
>
> Thank you for releasing this updated version of mic-paren.el.
>
> As I use Viper, a Vim-emulation mode, I looked into the
> customization group mic-paren-matching, hoping to find a way to
> emulate the way Vim uses to highlight parentheses. I found nothing.
Evil [1], another vim emulation mode, does highlight matching
parentheses as vim does. This is achieved by advising
`show-paren-function'. I attached the advice below, maybe it helps
you.
(defadvice show-paren-function (around evil)
"Match parentheses in Normal state."
(if (if (memq 'not evil-highlight-closing-paren-at-point-states)
(memq evil-state evil-highlight-closing-paren-at-point-states)
(not (memq evil-state evil-highlight-closing-paren-at-point-states)))
ad-do-it
(let ((pos (point)) syntax narrow)
(setq pos
(catch 'end
(dotimes (var (1+ (* 2 evil-show-paren-range)))
(if (zerop (mod var 2))
(setq pos (+ pos var))
(setq pos (- pos var)))
(setq syntax (syntax-class (syntax-after pos)))
(cond
((eq syntax 4)
(setq narrow pos)
(throw 'end pos))
((eq syntax 5)
(throw 'end (1+ pos)))))))
(if pos
(save-excursion
(goto-char pos)
(save-restriction
(when narrow
(narrow-to-region narrow (point-max)))
ad-do-it))
;; prevent the preceding pair from being highlighted
(when (overlayp show-paren-overlay)
(delete-overlay show-paren-overlay))
(when (overlayp show-paren-overlay-1)
(delete-overlay show-paren-overlay-1))))))
Frank
[1] http://emacswiki.org/emacs/Evil