76 lines
1.9 KiB
EmacsLisp
76 lines
1.9 KiB
EmacsLisp
;;;; Hacks for Lilypond work
|
|
|
|
(require 'lilypond-mode)
|
|
(add-hook 'LilyPond-mode-hook 'subword-mode)
|
|
|
|
(defun cp-toggle-selective-display ()
|
|
(interactive)
|
|
(set-selective-display (if selective-display nil 1)))
|
|
|
|
(defun cp-backward-def ()
|
|
(interactive)
|
|
(re-search-backward "\\(^[a-zA-Z]\\|^}\\)")
|
|
(beginning-of-line))
|
|
|
|
(defun cp-forward-def ()
|
|
(interactive)
|
|
(forward-char)
|
|
(re-search-forward "\\(^[a-zA-Z]\\|^}\\)")
|
|
(beginning-of-line))
|
|
|
|
(defun cp-upper-level ()
|
|
(interactive)
|
|
(re-search-backward "{"))
|
|
|
|
(defun cp-lower-level ()
|
|
(interactive)
|
|
(if (equal (string (char-after)) "{")
|
|
(forward-char))
|
|
(if (not (re-search-forward "{"))
|
|
(message "At deepest level."))
|
|
(backward-char))
|
|
|
|
(cp-set-keys
|
|
:bindings
|
|
`((,(kbd "C-c C-i") 'LilyPond-info)
|
|
(,(kbd "M-]") 'cp-toggle-selective-display)))
|
|
|
|
(cp-set-keys
|
|
:keymap LilyPond-mode-map
|
|
:bindings
|
|
`((,(kbd "M-p") cp-backward-def)
|
|
(,(kbd "M-n") cp-forward-def)
|
|
(,(kbd "M-P") cp-upper-level)
|
|
(,(kbd "M-N") cp-lower-level)))
|
|
|
|
;; (defun cp-lilypond-enclose-<< ()
|
|
;; (interactive)
|
|
;; (if (equal (string (char-after)) "\\")
|
|
;; (progn (insert "<< ")
|
|
;; (search-forward "{")
|
|
;; (backward-char)
|
|
;; (forward-sexp))))
|
|
|
|
;; if at a \new ... block - enclose expression
|
|
;; otherwise, enclose current position and after the first bar check
|
|
;; found
|
|
;; if region is active, enclose beginning and end
|
|
|
|
;; (defun cp-lilypond-enclose-<< ()
|
|
;; (interactive)
|
|
;; (if (equal (thing-at-point 'sexp)
|
|
;; "\\new")
|
|
;; (progn ;; (insert "<< ")
|
|
;; (newline-and-indent)
|
|
;; (search-forward "{")
|
|
;; (backward-char)
|
|
;; (forward-list)
|
|
;; ;; (forward-sexp))
|
|
;; )
|
|
;; ;; (let ((point1 (point)))
|
|
;; ;; (next-line)
|
|
;; ;; (goto-char point1))
|
|
;; ))
|
|
;; (define-key LilyPond-mode-map (kbd "<<")
|
|
;; 'cp-lilypond-enclose-<<)
|