From: Heikki Junes Date: Thu, 10 Jul 2003 23:10:30 +0000 (+0000) Subject: new function: LilyPond-paren-set-mode X-Git-Tag: release/1.7.26~46 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f60e85b804b78b19132e09df4fc91846febea77e;p=lilypond.git new function: LilyPond-paren-set-mode --- diff --git a/ChangeLog b/ChangeLog index 1461e8f492..80905e23a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-07-11 Heikki Junes + + * 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 * lilypond-indent.el (LilyPond-show-paren-mode): From Emacs' paren.el: diff --git a/lilypond-indent.el b/lilypond-indent.el index e9e7b90c65..1e36e993ae 100644 --- a/lilypond-indent.el +++ b/lilypond-indent.el @@ -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")))) +) diff --git a/lilypond-mode.el b/lilypond-mode.el index ec69823541..892bd13f1c 100644 --- a/lilypond-mode.el +++ b/lilypond-mode.el @@ -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