]> git.donarmstrong.com Git - lilypond.git/commitdiff
(un)comment lines in region independently.
authorHeikki Junes <heikki.junes@hut.fi>
Mon, 16 Jun 2003 21:58:25 +0000 (21:58 +0000)
committerHeikki Junes <heikki.junes@hut.fi>
Mon, 16 Jun 2003 21:58:25 +0000 (21:58 +0000)
ChangeLog
lilypond-indent.el
lilypond-mode.el

index 6d01475926ef840065a70fd09a3e6b7cbc22c1ff..a4a9fdcc6277fd0b6e3c9a3c70b452760f49d208 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-06-17  Heikki Junes  <hjunes@cc.hut.fi>
+
+       * lilypond-mode.el (LilyPond-un-comment-region): removed.
+       Use one command for both commenting and uncommenting.
+
+       * lilypond-indent.el (LilyPond-comment-region): new function,
+       (un)comments each line separately.
+       
 2003-06-16  Heikki Junes  <hjunes@cc.hut.fi>
 
        * lilypond-mode.el: Set show-paren-mode local; minor-mode
@@ -9,7 +17,7 @@
        XEmacs' paren-highlight and make minimal changes;
        add comments about locality. 
        Fix matching first open-paren-char in '<< .. >>'.
-       
+
 2003-06-16  Graham Percival  <gperlist@shaw.ca>
 
        * input/test/g*: added texidoc index.
index cdf7cb9771452d87832867adfcd69ff11d35bfa7..814ffce0bb0cb5218dee4061c0f779794cceafec 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."
index 26df4e5ad774c1e9805adc927247f67d2394c6a8..9fbe6dad1a96ed02010bd0ffb69dc83516506c8d 100644 (file)
@@ -513,12 +513,6 @@ Must be the car of an entry in `LilyPond-command-alist'."
   (LilyPond-command (LilyPond-command-menu "ViewPS") 'LilyPond-master-file)
 )
 
-;;; Refer to syntax-table (in lilypond-font-lock.el) for comment characters.
-(defun LilyPond-un-comment-region (start end level)
-  "Remove up to LEVEL comment characters from each line in the region."
-  (interactive "*r\np") 
-  (comment-region start end (- level)))
-
 ;; FIXME, this is broken
 (defun LilyPond-region-file (begin end)
   (let (
@@ -686,8 +680,7 @@ command."
   (define-key LilyPond-mode-map "\C-ci" 'LilyPond-quick-note-insert)
   (define-key LilyPond-mode-map "\C-cn" 'LilyPond-insert-tag-notes)
   (define-key LilyPond-mode-map "\C-cs" 'LilyPond-insert-tag-score)
-  (define-key LilyPond-mode-map "\C-c:" 'LilyPond-un-comment-region)
-  (define-key LilyPond-mode-map "\C-c;" 'comment-region)
+  (define-key LilyPond-mode-map "\C-c;" 'LilyPond-comment-region)
   (define-key LilyPond-mode-map ")" 'LilyPond-electric-close-paren)
   (define-key LilyPond-mode-map ">" 'LilyPond-electric-close-paren)
   (define-key LilyPond-mode-map "}" 'LilyPond-electric-close-paren)
@@ -999,8 +992,7 @@ command."
             ["Autocompletion"   LilyPond-autocompletion t]
             ))
          '(("Miscellaneous"
-            ["Uncomment Region" LilyPond-un-comment-region t]
-            ["Comment Region" comment-region t]
+            ["(Un)comment Region" LilyPond-comment-region t]
             ["Refontify buffer" font-lock-fontify-buffer t]
             ))
          '(("Info"