;;; Heikki Junes <hjunes@cc.hut.fi>
;;; * redefine Emacs' show-paren-function and XEmacs' paren-highlight
;;; * match two-char slurs '\( ... \)' and '\[ ... \]' separately.
+;;; * adopt Emacs' f90-comment-region
;;; Chris Jackson <chris@fluffhouse.org.uk>
;;; some code is taken from ESS (Emacs Speaks Statistics) S-mode by A.J.Rossini <rossini@biostat.washington.edu>
(defcustom LilyPond-fancy-comments t
"*Non-nil means distiguish between %, %%, and %%% for indentation.")
+(defcustom LilyPond-comment-region "%%$"
+ "*String inserted by \\[LilyPond-comment-region]\
+ at start of each line in region.")
+
+(defun LilyPond-comment-region (beg-region end-region)
+ "Comment/uncomment every line in the region.
+Insert LilyPond-comment-region at the beginning of every line in the region
+or, if already present, remove it."
+ (interactive "*r")
+ (let ((end (make-marker)))
+ (set-marker end end-region)
+ (goto-char beg-region)
+ (beginning-of-line)
+ (if (looking-at (regexp-quote LilyPond-comment-region))
+ (delete-region (point) (match-end 0))
+ (insert LilyPond-comment-region))
+ (while (and (zerop (forward-line 1))
+ (< (point) (marker-position end)))
+ (if (looking-at (regexp-quote LilyPond-comment-region))
+ (delete-region (point) (match-end 0))
+ (insert LilyPond-comment-region)))
+ (set-marker end nil)))
(defun LilyPond-calculate-indent ()
"Return appropriate indentation for current line as lilypond code.
(current-indentation)))))))))
-
(defun LilyPond-indent-line ()
"Indent current line as lilypond code.
Return the amount the indentation changed by."
;;; From Emacs' paren.el, with minimal changes (see "LilyPond"-lines)
;; Find the place to show, if there is one,
;; and show it until input arrives.
-(defun show-paren-function ()
-;;(defun LilyPond-show-paren-function () ; make show-paren-function local ??
+; (defun show-paren-function ()
+
+
+;; don't redefine emacs functions. It breaks other modes.
+
+(defun LilyPond-show-paren-function () ; make show-paren-function local ??
(if show-paren-mode
(let (pos dir mismatch face (oldpos (point)))
(cond ((eq (char-syntax (preceding-char)) ?\))
;;; From XEmacs' paren.el, with minimal changes (see "LilyPond"-lines)
;; Find the place to show, if there is one,
;; and show it until input arrives.
-(defun paren-highlight ()
-;;(defun LilyPond-paren-highlight () ; make paren-highlight local ??
+(if (string-match "XEmacs\\|Lucid" emacs-version)
+ (paren-set-mode 'paren)) ; works if this is set here (, right place?)
+;(defun paren-highlight ()
+(defun LilyPond-paren-highlight () ; make paren-highlight local ??
"This highlights matching parentheses.
See the variables: