Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; (find-planner "2004.04.14") (defvar music-G-clef " <s> ----/\\------- | / ----/-------- / | ------------- | /|\\ -----|------- \\ |/ ------------- \\/ </s> ") (defun forward-line-keep-column (arg) (interactive "p") (let ((column (current-column)) (indent-tabs-mode nil)) (forward-line arg) (move-to-column column t))) (defmacro with-music-vars (&rest body) `(let* (s-tag (s (save-excursion (search-backward "\n<s>") (setq s-tag (+ (point) 1)) (forward-line 2) (beginning-of-line) (point))) after-e-tag (e (save-excursion (search-forward "\n</s>") (setq after-e-tag (save-excursion (forward-line 1) (beginning-of-line) (point))) (beginning-of-line) (point))) (nlines (count-lines s e)) (bol (save-excursion (beginning-of-line) (point))) (thisline (count-lines s bol)) (column (current-column)) (indent-tabs-mode nil)) . ,body)) (defun music-background-char () (let ((char (save-excursion (beginning-of-line) (char-after)))) (if (eq char ?\n) 32 char))) (defun music-insert (char) (interactive "c") (with-music-vars (save-excursion (dotimes (i nlines) (save-excursion (forward-line-keep-column (- i thisline)) (insert-and-inherit (if (= i thisline) char (music-background-char)))))) (forward-char 1))) (defun music-self-insert-command (n) (interactive "p") (if overwrite-mode (self-insert-command n) (dotimes (i n) (music-insert last-command-char)))) ;; (defun music-delete-char ...) (defvar music-keymap (make-keymap)) (defun music-keymap-build () (let ((i 32)) (while (<= i 126) (define-key music-keymap (format "%c" i) 'music-self-insert-command) (setq i (+ i 1))))) (music-keymap-build) (defun music-mode-local (arg) (interactive "p") (if (> arg 0) (with-music-vars (set-text-properties s-tag s `(face bold)) (set-text-properties s e `(keymap ,music-keymap)) (set-text-properties e after-e-tag `(face bold)) (untabify s e)) (with-music-vars (set-text-properties s-tag after-e-tag nil))))