From: Heikki Junes Date: Sun, 20 Jul 2003 20:55:42 +0000 (+0000) Subject: apply context dependent syntax tables. X-Git-Tag: release/1.7.30~141 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ac47fe89a2c1bfb7aeaa3285c3d6d56474cca57d;p=lilypond.git apply context dependent syntax tables. --- diff --git a/ChangeLog b/ChangeLog index 94fb28e75e..961acf3961 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-07-20 Heikki Junes + + * 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 * VERSION (PACKAGE_NAME): release 1.7.27 diff --git a/lilypond-font-lock.el b/lilypond-font-lock.el index 8dc3eb79ed..98fc4adef8 100644 --- a/lilypond-font-lock.el +++ b/lilypond-font-lock.el @@ -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 @@ -125,14 +126,13 @@ "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) @@ -169,15 +169,15 @@ (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)) '( ?\] )) diff --git a/lilypond-indent.el b/lilypond-indent.el index a8313ff616..4626646d06 100644 --- a/lilypond-indent.el +++ b/lilypond-indent.el @@ -1,8 +1,7 @@ ;;; lilypond-indent.el --- Auto-indentation for lilypond code ;;; ;;; Heikki Junes -;;; * 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 @@ -14,10 +13,6 @@ ;;; 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.") diff --git a/lilypond-mode.el b/lilypond-mode.el index e06325f8b7..19c5ad9b13 100644 --- a/lilypond-mode.el +++ b/lilypond-mode.el @@ -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))