+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
;; * 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)) '( ?\] ))
;;; 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.")
(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"
(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))
["(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]
(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))