]> git.donarmstrong.com Git - lilypond.git/commitdiff
fix matching ')' after '('.
authorhjunes <hjunes>
Wed, 11 Jun 2003 21:39:41 +0000 (21:39 +0000)
committerhjunes <hjunes>
Wed, 11 Jun 2003 21:39:41 +0000 (21:39 +0000)
ChangeLog
lilypond-indent.el

index 1e8298061ee179c0728549ae86fefa27f0e4b054..f79a5f78455bb2688e4aebf28de4fee557d74e70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-06-12  Heikki Junes  <hjunes@cc.hut.fi>
+
+       * lilypond-indent.el: Fix: match concurrent one-char opening and 
+       closing slurs: '()', etc. Add comments.
+
 2003-06-10  Graham Percival  <gperlist@shaw.ca>
 
    * input/test/beam-abbrev.ly input/test/default-neutral-dir.ly
index 2556fde035e9a1e1df89be1ecd30d295872a3a84..49c6b205cd1ca722b1aa8b930373c9ba6fb7587d 100644 (file)
@@ -339,33 +339,50 @@ slur-paren-p defaults to nil.
                 (setq paren-regexp (concat (car paren-regexp) "\\|" (cdr paren-regexp))))
        (setq paren-regexp (concat (mapconcat 'car (mapcar 'cdr regexp-alist) "\\|") "\\|"
                                   (mapconcat 'cdr (mapcar 'cdr regexp-alist) "\\|")))))
+    ;; match concurrent one-char opening and closing slurs
     (if (and (eq dir 1)
-            (memq (char-after oldpos) '(?[ ?{ ?\()))
-       (forward-char 1))
+            (not (sequencep bracket-type))
+            (eq (char-syntax (char-after oldpos)) ?\())
+       ;; anyway do not count open slur, since already level = -1
+        (progn (forward-char 1)
+              (if (eq (following-char) 
+                      (LilyPond-matching-paren (char-after oldpos)))
+                  ;; matching char found, go after it and set level = 0
+                  (progn (forward-char 1)
+                         (setq level 0)))))
+    ;; browse the code until matching slur is found, or report mismatch
     (while (and (if (not (eq dir 1)) 
                    (> level 0) 
                  (< level 0))
+               ;; dir tells whether to search backward or forward
                (if (not (eq dir 1))
                    (re-search-backward paren-regexp nil t)
                  (re-search-forward paren-regexp nil t))
+               ;; note: in case of two-char bracket only latter is compared
                (setq match (char-before (match-end 0))))
 ;;;      (message "%d" level) (sit-for 0 300)
-      (if (not (save-excursion (goto-char (match-end 0)) 
+      (if (not (save-excursion (goto-char (match-end 0))
+                              ;; skip over strings and comments
                               (LilyPond-inside-string-or-comment-p)))
          (if (memq match '(?} ?> ?] ?\)))
+             ;; count closing brackets
              (progn (setq level (1+ level))
-                    ;; single '>' was not matched .. need to correct
+                    ;; slurs may be close to each other, e.g.,
+                    ;; a single '>' was not matched .. need to be corrected
                     (if (and (eq dir 1) (eq (char-after (match-end 0)) match))
                         (if (/= level 0)
                             (progn
                               (setq level (1+ level))
                               (forward-char 1))))
 ;;;                 (message "%d %c" level match) (sit-for 0 300)
+                    ;; hmm..
                     (if (and (= match ?>) 
                              (looking-at ".\\s-+>\\|\\({\\|}\\|<\\|>\\|(\\|)\\|[][]\\)>"))
                         (forward-char 1)))
+           ;; count opening brackets
            (progn (setq level (1- level))
 ;;;               (message "%d %c" level match) (sit-for 0 300)
+                  ;; hmm..
                   (if (and (= match ?<)
                            (looking-at ".\\s-+<\\|\\({\\|}\\|<\\|>\\|(\\|)\\|[][]\\)<"))
                       (forward-char 1))))))
@@ -373,8 +390,11 @@ slur-paren-p defaults to nil.
     (if (not (eq dir 1))
        (progn
          (if (sequencep bracket-type)
+             ;; match the latter char in two-char brackets
              (if (looking-at "..[][)(]") (forward-char 1)))
+         ;; if the following char is not already a slur
          (if (and (not (looking-at "[)(]"))
+                  ;; match the slur which follows
                   (looking-at ".[][><)(]")) (forward-char 1)))
       (backward-char 1))
     (if (= level 0)