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