- (setq close-char (char-before (point)))
- (if (and blink-matching-paren
- (not (LilyPond-inside-string-or-comment-p))
- (save-excursion (re-search-backward
- (concat (mapconcat 'cdr (mapcar 'cdr LilyPond-parens-regexp-alist) "\\|") "\\|)") nil t)
- (eq oldpos (1- (match-end 0)))))
- (progn (backward-char 1)
- (LilyPond-blink-matching-open close-char)
- (forward-char 1)))))
+ ;; Refontify buffer if a block-comment-ender '%}' is inserted
+ (if (and (eq (char-before (point)) ?})
+ (eq (char-before (- (point) 1)) ?%))
+ (font-lock-fontify-buffer)
+ ;; Match paren if the cursor is not inside string or comment.
+ (if (and blink-matching-paren
+ (not (LilyPond-inside-string-or-comment-p))
+ (save-excursion (re-search-backward
+ (concat (mapconcat 'cdr (mapcar 'cdr LilyPond-parens-regexp-alist) "\\|") "\\|)") nil t)
+ (eq oldpos (1- (match-end 0)))))
+ (progn (backward-char 1)
+ (LilyPond-blink-matching-paren)
+ (forward-char 1))))))
+
+;;; REDEFINITIONS
+(defun aargh-this-breaks-other-emacs-modes-scan-sexps (pos dir)
+ "This function is redefined to be used in Emacs' show-paren-function and
+in XEmacs' paren-highlight."
+ (LilyPond-blink-matching-paren dir))
+
+;; Emacs and XEmacs have slightly different names for parenthesis highlighting.
+(if (not (string-match "XEmacs\\|Lucid" emacs-version))
+ (progn
+ (fset 'old-show-paren-function (symbol-function 'show-paren-function))
+ (defun show-paren-function ()
+ "Highlights the matching slur if cursor is moved before opening or
+after closing slur. In this redefinition strings and comments are skipped."
+ (if (not (LilyPond-inside-string-or-comment-p))
+ (old-show-paren-function))))
+ (progn
+ ;; NOTE: paren-set-mode must be set before paren-highlight is redefined
+ (paren-set-mode 'paren)
+ (fset 'old-paren-highlight (symbol-function 'paren-highlight))
+ (defun paren-highlight ()
+ "Highlights the matching slur if cursor is moved before opening or
+after closing slur. In this redefinition strings and comments are skipped."
+ (if (not (LilyPond-inside-string-or-comment-p))
+ (old-paren-highlight)))))