]> git.donarmstrong.com Git - lilypond.git/blobdiff - lilypond-indent.el
release commit
[lilypond.git] / lilypond-indent.el
index cdf7cb9771452d87832867adfcd69ff11d35bfa7..50db7bb3433585674d7e03ccc634e190cec71613 100644 (file)
@@ -3,6 +3,7 @@
 ;;; 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>
@@ -51,6 +52,28 @@ Compares with other text in same context.")
 (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.
@@ -129,7 +152,6 @@ Returns nil if line starts inside a string"
                   (current-indentation)))))))))
 
 
-
 (defun LilyPond-indent-line ()
   "Indent current line as lilypond code.
 Return the amount the indentation changed by."
@@ -552,8 +574,12 @@ in XEmacs' paren-highlight."
 ;;; 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)) ?\))
@@ -658,8 +684,10 @@ in XEmacs' paren-highlight."
 ;;; 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: