Created
December 5, 2013 14:31
-
-
Save kurohuku/7805989 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) | |
(defvar popup-matching-paren-open-parens "([{\"") | |
(defvar popup-matching-paren-close-parens ")]}\"") | |
(defun popup-matching-paren (&optional lines) | |
"popup 1+`lines'*2 lines" | |
(interactive) | |
(unless lines | |
(setq lines 0)) | |
(cond | |
((find (char-before) popup-matching-paren-close-parens) | |
(popup-matching-paren-backward lines)) | |
((find (char-after) popup-matching-paren-open-parens) | |
(popup-matching-paren-forward lines)))) | |
(defun popup-matching-paren-forward (lines) | |
(let ((text (save-excursion | |
(forward-sexp) | |
(unless (and (<= (window-start) (point)) | |
(< (point) (window-end))) | |
(popup-matching-paren-get-lines lines))))) | |
(when text | |
(popup-tip text)))) | |
(defun popup-matching-paren-backward (lines) | |
(let ((text (save-excursion | |
(backward-sexp) | |
(unless (and (<= (window-start) (point)) | |
(< (point) (window-end))) | |
(popup-matching-paren-get-lines lines))))) | |
(when text | |
(popup-tip text)))) | |
(defun popup-matching-paren-get-lines (lines) | |
(let ((beg (save-excursion (previous-line lines) (line-beginning-position))) | |
(end (save-excursion (next-line lines) (line-end-position)))) | |
(buffer-substring beg end))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment