]> git.donarmstrong.com Git - lilypond.git/commitdiff
new function: LilyPond-paren-set-mode
authorHeikki Junes <heikki.junes@hut.fi>
Thu, 10 Jul 2003 23:10:30 +0000 (23:10 +0000)
committerHeikki Junes <heikki.junes@hut.fi>
Thu, 10 Jul 2003 23:10:30 +0000 (23:10 +0000)
ChangeLog
lilypond-indent.el
lilypond-mode.el

index 1461e8f49246cfdf659513d61dd9c211c1d7dc64..80905e23a9594d82d3a5e3de8dcf85aadc93c8bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-07-11  Heikki Junes  <hjunes@cc.hut.fi>
+
+       * lilypond-indent.el (LilyPond-paren-set-mode): From XEmacs' paren.el:
+       Disable buffer-locally default paren hook and make a new one. 
+
+       * lilypond-mode.el: Turn off locally paren-mode, but turn on
+       locally LilyPond-paren-mode. Add todo for mouse double-click.
+
 2003-07-10  Heikki Junes  <hjunes@cc.hut.fi>
 
        * lilypond-indent.el (LilyPond-show-paren-mode): From Emacs' paren.el:
index e9e7b90c65177ae248729df6d5e3f1fb49e38ce2..1e36e993ae5990d9cb610b2c6c5fff53ad210562 100644 (file)
@@ -17,7 +17,7 @@
 ;;;    * in syntax-highlighting slurs are not always highlighted the right way
 ;;;      e.g. opening slurs are found found better in "#( ( ) ( ) )" than
 ;;;      opening slurs
-;;;    * XEmacs: should make Lilypond-paren-mode instead of using paren-mode
+;;;    * 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.")
@@ -811,6 +811,37 @@ in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
       (and show-paren-overlay-1
           (eq (overlay-buffer show-paren-overlay-1) (current-buffer))
           (delete-overlay show-paren-overlay-1))))
-;;; XEMACS' Lilypond-paren-mode definition
-(progn ; TODO
-))
+;;; XEMACS' Lilypond-paren-set-mode definition
+(defun LilyPond-paren-set-mode (arg &optional quiet)
+  "Cycles through possible values for `paren-mode', force off with negative arg.
+When called from lisp, a symbolic value for `paren-mode' can be passed directly.
+See also `paren-mode' and `paren-highlight'."
+  (interactive "P")
+  ;; kill off the competition, er, uh, eliminate redundancy...
+  (setq post-command-hook (delq 'show-paren-command-hook post-command-hook))
+  (setq pre-command-hook (delq 'blink-paren-pre-command pre-command-hook))
+  (setq post-command-hook (delq 'blink-paren-post-command post-command-hook))
+
+  (let* ((paren-modes '(blink-paren paren sexp))
+        (paren-next-modes (cons nil (append paren-modes (list nil)))))
+    (setq paren-mode (if (and (numberp arg) (< arg 0))
+                        nil            ; turn paren highlighting off
+                      (cond ((and arg (symbolp arg)) arg)
+                            ((and (numberp arg) (> arg 0))
+                             (nth (1- arg) paren-modes))
+                            ((numberp arg) nil)
+                            (t (car (cdr (memq paren-mode
+                                               paren-next-modes)))))
+                      )))
+  (cond (paren-mode
+        (add-hook 'post-command-hook 'LilyPond-paren-highlight)
+        (add-hook 'pre-command-hook 'paren-nuke-extent)
+        (setq blink-matching-paren nil))
+       ((not (local-variable-p 'paren-mode (current-buffer)))
+        (remove-hook 'post-command-hook 'LilyPond-paren-highlight)
+        (remove-hook 'pre-command-hook 'paren-nuke-extent)
+        (paren-nuke-extent)            ; overkill
+        (setq blink-matching-paren t)
+        ))
+  (or quiet (message "Paren mode is %s" (or paren-mode "OFF"))))
+)
index ec698235417f74b7581d7cadabfcaa4aa81646a9..892bd13f1cee936a2c124bd7ed592c2f26b1bcf4 100644 (file)
@@ -1002,7 +1002,7 @@ command."
             ["LilyPond Paren Mode" 
              (if (not (string-match "XEmacs\\|Lucid" emacs-version))
                  (LilyPond-show-paren-mode (not LilyPond-show-paren-mode))
-               (paren-set-mode (and (not paren-mode) 'paren)))
+               (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)]
@@ -1142,11 +1142,9 @@ LilyPond-xdvi-command\t\tcommand to display dvi files -- bit superfluous"
        (make-local-variable 'LilyPond-show-paren-mode)
        (LilyPond-show-paren-mode t))
     (progn 
-      (make-local-variable 'show-paren-mode)
-      (paren-set-mode 'paren)
-      ;;  don't redefine Xemacs functions. It breaks other modes.
-      ;;  should have an own idle-timer instead
-      ;; (defun paren-highlight () (LilyPond-paren-highlight)) ; for testing
+      (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
       ))
 
   ;; run the mode hook. LilyPond-mode-hook use is deprecated