From: Heikki Junes Date: Wed, 11 Jun 2003 21:39:41 +0000 (+0000) Subject: fix matching ')' after '('. X-Git-Tag: release/1.7.21~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3d04794b24abfd23528564bc63383662759aba80;p=lilypond.git fix matching ')' after '('. --- diff --git a/ChangeLog b/ChangeLog index 1e8298061e..f79a5f7845 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-06-12 Heikki Junes + + * lilypond-indent.el: Fix: match concurrent one-char opening and + closing slurs: '()', etc. Add comments. + 2003-06-10 Graham Percival * input/test/beam-abbrev.ly input/test/default-neutral-dir.ly diff --git a/lilypond-indent.el b/lilypond-indent.el index 2556fde035..49c6b205cd 100644 --- a/lilypond-indent.el +++ b/lilypond-indent.el @@ -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)