]> git.donarmstrong.com Git - lilypond.git/commitdiff
apply context dependent syntax tables.
authorHeikki Junes <heikki.junes@hut.fi>
Sun, 20 Jul 2003 20:55:42 +0000 (20:55 +0000)
committerHeikki Junes <heikki.junes@hut.fi>
Sun, 20 Jul 2003 20:55:42 +0000 (20:55 +0000)
ChangeLog
lilypond-font-lock.el
lilypond-indent.el
lilypond-mode.el

index 94fb28e75e1f724137d65c0047abf17577991629..961acf3961f5f810f33178e8760eb72e41a5577e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-07-20  Heikki Junes  <hjunes@cc.hut.fi>
+
+       * lilypond-font-lock.el: do not try to match two-char slurs \( \[.
+
+       * lilypond-mode.el: add a buffer-local post-command-hook to set
+       context dependent syntax-table after each cursor event. Remove old
+       stuff. XEmacs: turn on parenthesis highlighting in LilyPond-mode.
+
+       * lilypond-indent.el: update comments.
+
 2003-07-20  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * VERSION (PACKAGE_NAME): release 1.7.27
index 8dc3eb79edd23d96a2a541ec0a2affd290ccf829..98fc4adef8ac8a94971569f2759775e228f236a2 100644 (file)
@@ -6,12 +6,13 @@
 ;;  * Emacs-mode: new keywords, reserved words, identifiers, notenames, 
 ;;    some dynamics and brackets are font-lock-keywords
 ;;  * File lilypond.words gives keywords, identifiers and reserved words
+;;  * context-dependent syntax-tables
 ;; Author: 1997: Han-Wen Nienhuys
 ;; Author: 1995-1996 Barry A. Warsaw
 ;;         1992-1994 Tim Peters
 ;; Created:       Feb 1992
-;; Version:       1.7.20
-;; Last Modified: 9JUN2003
+;; Version:       1.7.25
+;; Last Modified: 20JUL2003
 ;; Keywords: lilypond languages music notation
 
 ;; This software is provided as-is, without express or implied
   "Syntax table used in `LilyPond-mode' buffers.")
 
 (defun LilyPond-mode-set-syntax-table (&optional not-punct)
-  "Change syntax table which can be customized according to a context."
-  (interactive)
+  "Change syntax table according to the argument `not-punct' which contains characters which are given a context dependent non-punctuation syntax: parentheses may be set to parenthesis syntax and characters `-', `^' and `_' may be set to escape syntax."
   (if (not not-punct) (setq not-punct '()))
   (setq LilyPond-mode-syntax-table (make-syntax-table))
   (let ((defaults        
          '(
            ;; NOTE: Emacs knows only "13"-style (used), XEmacs knows also "1b3b", etc.
-           ( ?\%  .  "< 13" ) ; comment starter, 1st char in block-comments
+           ( ?\% . "< 13" )   ; comment starter, 1st char in block-comments
            ( ?\n . ">")       ; newline: comment ender
            ( ?\r . ">")       ; formfeed: comment ender
            ( ?\\ . "\\" )     ; escape characters (as '\n' in strings)
     (set-syntax-table LilyPond-mode-syntax-table)))
 
 (defun LilyPond-mode-context-set-syntax-table ()
-  "Change syntax table which can be customized according to a context."
-  ;; make a syntax table without parentheses
+  "Change syntax table according to current context."
   (interactive)
-  ;; default map sets parentheses to punctuation characters
+  ;; default syntax table sets parentheses to punctuation characters
   (LilyPond-mode-set-syntax-table) 
-  ;; find the context
+  ;; find current context
   (setq context (parse-partial-sexp (point-min) (point)))
   (cond ((nth 3 context)) ; inside string
        ((nth 4 context)) ; inside a comment
+       ((eq (char-syntax (char-before (point))) ?\\)) ; found escape-char
        ((memq (char-before (point)) '( ?\) ))
         (LilyPond-mode-set-syntax-table '( ?\( ?\) )))
        ((memq (char-before (point)) '( ?\] ))
index a8313ff6163032e2714867c3f70d2e159e1e4b1b..4626646d06a7139dd40c96cb843cdf71dc8ceae9 100644 (file)
@@ -1,8 +1,7 @@
 ;;; lilypond-indent.el --- Auto-indentation for lilypond code
 ;;;
 ;;; Heikki Junes <hjunes@cc.hut.fi>
-;;; * introduce Lilypond-show-paren-function for Emacs and 
-;;;             Lilypond-paren-highlight for XEmacs
+;;; * ond-char paren matching is handled by context dependent syntax tables
 ;;; * match two-char slurs '\( ... \)' and '\[ ... \]' separately.
 ;;; * adopt Emacs' f90-comment-region
 
 ;;; TODO:
 ;;;    * currently, in bracket matching one may need a non-bracket 
 ;;;      chararacter between the bracket characters, like ( ( ) )
-;;;    * in syntax-highlighting slurs are not always highlighted the right way
-;;;      e.g. opening slurs are found found better in "#( ( ) ( ) )" than
-;;;      opening slurs
-;;;    * Mouse double-clicks should use LilyPond-scan-sexps for slur matching.
 
 (defcustom LilyPond-indent-level 4
   "*Indentation of lilypond statements with respect to containing block.")
index e06325f8b730dee7d38e4bc5f4252d04435552d9..19c5ad9b1338dd56ebc8bfce0b1a966f8fd69a5a 100644 (file)
@@ -22,7 +22,7 @@
 (require 'easymenu)
 (require 'compile)
 
-(defconst LilyPond-version "1.7.24"
+(defconst LilyPond-version "1.7.25"
   "`LilyPond-mode' version number.")
 
 (defconst LilyPond-help-address "bug-lilypond@gnu.org"
@@ -689,7 +689,6 @@ command."
   (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)
-  (define-key LilyPond-mode-map "\C-c\C-x" 'LilyPond-mode-context-set-syntax-table) ; try it
   (if (string-match "XEmacs\\|Lucid" emacs-version)
       (define-key LilyPond-mode-map [iso-left-tab] 'LilyPond-autocompletion)
     (define-key LilyPond-mode-map [iso-lefttab] 'LilyPond-autocompletion))
@@ -1000,13 +999,6 @@ command."
             ["(Un)comment Region" LilyPond-comment-region t]
             ["Refontify buffer" font-lock-fontify-buffer t]
             ["Add index menu" LilyPond-add-imenu-menu]
-            ["LilyPond Paren Mode" 
-             (if (not (string-match "XEmacs\\|Lucid" emacs-version))
-                 (LilyPond-show-paren-mode (not LilyPond-show-paren-mode))
-               (LilyPond-paren-set-mode (if (not paren-mode) 'paren -1)))
-             :style toggle :selected 
-             (if (not (string-match "XEmacs\\|Lucid" emacs-version))
-                 LilyPond-show-paren-mode paren-mode)]
             ))
          '(("Info"
             ["LilyPond" LilyPond-info t]
@@ -1135,21 +1127,16 @@ LilyPond-xdvi-command\t\tcommand to display dvi files -- bit superfluous"
       (setq zmacs-regions nil)
     (setq mark-even-if-inactive t))
 
-  ;; In Emacs blink-...-on-screen needs to be declared.
-  (if (not (string-match "XEmacs\\|Lucid" emacs-version))
+  ;; Context dependent syntax tables in Lilypond-mode
+  (make-local-hook 'post-command-hook) ; XEmacs requires
+  (add-hook 'post-command-hook 'LilyPond-mode-context-set-syntax-table nil t)
+
+  ;; Turn on paren-mode buffer-locally, i.e., in LilyPond-mode
+  (if (string-match "XEmacs\\|Lucid" emacs-version)
       (progn
-;; Commented-out: there may be several idle-timers
-;;     (make-local-variable 'show-paren-mode)
-;;     (show-paren-mode nil)
-;;     (make-local-variable 'LilyPond-show-paren-mode)
-;;     (LilyPond-show-paren-mode t)
-       )
-    (progn
-;; Commented-out: show-paren-command-hook should not be deleted from post-command-hook
-;;     (make-local-variable 'paren-mode) ; used in LilyPond-paren-set-mode
-;;     (paren-set-mode -1)               ; disable default hook
-;;     (LilyPond-paren-set-mode 'paren)  ; define buffer-local hook
-      ))
+       (make-local-variable 'paren-mode)
+       (paren-set-mode 'paren)
+       ))
 
   ;; run the mode hook. LilyPond-mode-hook use is deprecated
   (run-hooks 'LilyPond-mode-hook))