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

index 9609ad4d0272a8fe9c3f1873b14855f3458bba2f..1461e8f49246cfdf659513d61dd9c211c1d7dc64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-07-10  Heikki Junes  <hjunes@cc.hut.fi>
+
+       * lilypond-indent.el (LilyPond-show-paren-mode): From Emacs' paren.el:
+       Disable buffer-locally default paren idle timer and make a new one. 
+
+       * lilypond-mode.el: Turn off locally show-paren-mode, but turn on
+       locally LilyPond-show-paren-mode. Add to menu a toggle for
+       LilyPond-show-paren-function.
+
 2003-07-08  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * input/template/jazz-combo.ly (drumNotes): 1.7 fixes 
index 0ba6240fd4d03503b73b9602828553ac89336603..e9e7b90c65177ae248729df6d5e3f1fb49e38ce2 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
-;;;    * should make Lilypond-show-paren-mode instead of using show-paren-mode
+;;;    * XEmacs: should make Lilypond-paren-mode instead of using paren-mode
 
 (defcustom LilyPond-indent-level 4
   "*Indentation of lilypond statements with respect to containing block.")
@@ -574,7 +574,7 @@ in XEmacs' paren-highlight."
 ;; Find the place to show, if there is one,
 ;; and show it until input arrives.
 (defun LilyPond-show-paren-function ()
-  (if show-paren-mode
+  (if LilyPond-show-paren-mode
       (let (pos dir mismatch face (oldpos (point)))
        (cond ((eq (char-syntax (preceding-char)) ?\))
               (setq dir -1))
@@ -769,3 +769,48 @@ and the following faces:
                                            nil
                                            paren-blink-interval))))))
        ))))
+
+(if (not (string-match "XEmacs\\|Lucid" emacs-version))
+;;; EMACS' Lilypond-show-paren-mode definition
+(define-minor-mode LilyPond-show-paren-mode
+  "Toggle Show Paren mode.
+With prefix ARG, turn Show Paren mode on if and only if ARG is positive.
+Returns the new status of Show Paren mode (non-nil means on).
+
+When Show Paren mode is enabled, any matching parenthesis is highlighted
+in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
+  :global t :group 'LilyPond-paren-showing
+    ;; Turn off the usual paren-matching method
+    ;; when this one is turned on.
+    (if (local-variable-p 'LilyPond-show-paren-mode)
+       (make-local-variable 'blink-matching-paren-on-screen)
+      (kill-local-variable 'blink-matching-paren-on-screen))
+    (setq blink-matching-paren-on-screen (not LilyPond-show-paren-mode))
+    ;; Now enable or disable the mechanism.
+    ;; First get rid of the old idle timer.
+    (if show-paren-idle-timer
+       (cancel-timer show-paren-idle-timer))
+    (if (boundp 'LilyPond-show-paren-idle-timer)
+       (cancel-timer LilyPond-show-paren-idle-timer))
+    (setq LilyPond-show-paren-idle-timer nil)
+    ;; If show-paren-mode is enabled in some buffer now,
+    ;; set up a new timer.
+    (when (memq t (mapcar (lambda (buffer)
+                           (or (with-current-buffer buffer
+                                 show-paren-mode)
+                               (with-current-buffer buffer
+                                 LilyPond-show-paren-mode)))
+                         (buffer-list)))
+      (setq LilyPond-show-paren-idle-timer (run-with-idle-timer
+                                           show-paren-delay t
+                                           'LilyPond-show-paren-function)))
+    (unless show-paren-mode
+      (and show-paren-overlay
+          (eq (overlay-buffer show-paren-overlay) (current-buffer))
+          (delete-overlay show-paren-overlay))
+      (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
+))
index 44ea6075bba6704f7b2b3783795dee4a9b4cea3b..ec698235417f74b7581d7cadabfcaa4aa81646a9 100644 (file)
@@ -22,7 +22,7 @@
 (require 'easymenu)
 (require 'compile)
 
-(defconst LilyPond-version "1.7.21"
+(defconst LilyPond-version "1.7.24"
   "`LilyPond-mode' version number.")
 
 (defconst LilyPond-help-address "bug-lilypond@gnu.org"
@@ -999,6 +999,13 @@ 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))
+               (paren-set-mode (and (not paren-mode) 'paren)))
+             :style toggle :selected 
+             (if (not (string-match "XEmacs\\|Lucid" emacs-version))
+                 LilyPond-show-paren-mode paren-mode)]
             ))
          '(("Info"
             ["LilyPond" LilyPond-info t]
@@ -1111,29 +1118,6 @@ LilyPond-xdvi-command\t\tcommand to display dvi files -- bit superfluous"
   (setq local-abbrev-table LilyPond-mode-abbrev-table)
   (use-local-map LilyPond-mode-map)
 
-  ;; In Emacs blink-...-on-screen needs to be declared.
-  (if (not (string-match "XEmacs\\|Lucid" emacs-version))
-      (progn
-       (make-local-variable 'show-paren-mode)
-       (setq show-paren-mode t))
-    (paren-set-mode 'paren))
-
-  (if (not (string-match "XEmacs\\|Lucid" emacs-version))
-      (progn
-       ;; (make-local-variable 'show-paren-function) ; possible?
-       ;; (setq show-paren-function 'LilyPond-show-paren-function) ; possible?
-       ;;  don't redefine emacs functions. It breaks other modes.
-       ;;  should have an own idle-timer instead
-       ;; (defun show-paren-function () (LilyPond-show-paren-function)) ; for testing
-       )
-    (progn
-      ;; (make-local-variable 'paren-highlight) ; possible?
-      ;; (setq paren-highlight 'LilyPond-paren-highlight) ; possible?
-      ;;  don't redefine Xemacs functions. It breaks other modes.
-      ;;  should have an own idle-timer instead
-      ;; (defun paren-highlight () (LilyPond-paren-highlight)) ; for testing
-      ))
-
   ;; In XEmacs imenu was synched up with: FSF 20.4
   (make-local-variable 'imenu-generic-expression)
   (setq imenu-generic-expression LilyPond-imenu-generic-expression)
@@ -1150,6 +1134,21 @@ 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))
+      (progn
+       (make-local-variable 'show-paren-mode)
+       (show-paren-mode nil)
+       (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
+      ))
+
   ;; run the mode hook. LilyPond-mode-hook use is deprecated
   (run-hooks 'LilyPond-mode-hook))