]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add support for Info inside Emacs.
authorHeikki Junes <heikki.junes@hut.fi>
Mon, 25 Nov 2002 15:04:58 +0000 (15:04 +0000)
committerHeikki Junes <heikki.junes@hut.fi>
Mon, 25 Nov 2002 15:04:58 +0000 (15:04 +0000)
ChangeLog
lilypond-mode.el

index 77265a0462967ba6873a70a793c785298b0be45d..c31cbe40a51daa294448fb206ec35795d4081401 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-11-25  Heikki Junes <hjunes@cc.hut.fi>
+
+       * lilypond-mode.el: Add support for Info inside Emacs.
+
 2002-11-24  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * buildscripts/make-font-dir.py: 
index ba8e03569d4be7af7f35cb62f329568bef27ce17..bd2c3ed2da8dbb099db950c540bc7e0709d80bb8 100644 (file)
@@ -588,6 +588,7 @@ command."
   (define-key LilyPond-mode-map ">" 'LilyPond-electric-close-paren)
   (define-key LilyPond-mode-map "}" 'LilyPond-electric-close-paren)
   (define-key LilyPond-mode-map [S-iso-lefttab] 'LilyPond-autocompletion)
+  (define-key LilyPond-mode-map "\C-c\t" 'LilyPond-info-index-search)
   )
 
 ;;; Menu Support
@@ -689,52 +690,83 @@ command."
             (message "Remember to add all other details as well.") (sit-for 5 0 1)))
     )))
 
+(defun LilyPond-pre-word-search ()
+  "Fetch the alphabetic characters and \\ in front of the cursor."
+  (interactive)
+  (let ((pre "")
+       (prelen 0)
+       (ch (char-before (- (point) 0))))
+    (while (and ch (or (and (>= ch 65) (<= ch 90)) ; not bolp, A-Z
+                      (and (>= ch 97) (<= ch 122)) ; a-z
+                      (= ch 92))) ; \\
+      (setq pre (concat (char-to-string ch) pre))
+      (setq prelen (+ prelen 1))
+      (setq ch (char-before (- (point) prelen))))
+    pre))
+
+(defun LilyPond-post-word-search ()
+  "Fetch the alphabetic characters behind the cursor."
+  (interactive)
+  (let ((post "")
+       (postlen 0)
+       (ch (char-after (+ (point) 0))))
+    (while (and ch (or (and (>= ch 65) (<= ch 90)) ; not eolp, A-Z
+                      (and (>= ch 97) (<= ch 122)))) ; a-z
+      (setq post (concat post (char-to-string ch)))
+      (setq postlen (+ postlen 1))
+      (setq ch (char-after (+ (point) postlen))))
+    post))
+
 (defun LilyPond-autocompletion ()
   "Show completions in mini-buffer for the given word."
   (interactive)
-
-  ; search the begin of word: add [A-Za-z\\] until bolp/non-alpha
-  (setq pre "")
-  (setq prelen 0)
-  (setq ch (char-before (- (point) prelen)))
-  (while (and ch (or (and (>= ch 65) (<= ch 90)) ; bolp, A-Z
-                    (and (>= ch 97) (<= ch 122)) ; a-z
-                    (= ch 92))) ; \\
-    (setq pre (concat (char-to-string ch) pre))
-    (setq prelen (+ prelen 1))
-    (setq ch (char-before (- (point) prelen))))
-
-  ; search the end of word: add [A-Za-z] until eolp/non-alpha
-  (setq post "")
-  (setq postlen 0)
-  (setq ch (char-after (+ (point) postlen)))
-  (while (and ch (or (and (>= ch 65) (<= ch 90)) ; eolp, A-Z
-                    (and (>= ch 97) (<= ch 122)))) ; a-z
-    (setq post (concat post (char-to-string ch)))
-    (setq postlen (+ postlen 1))
-    (setq ch (char-after (+ (point) postlen))))
-  
+  (let ((pre (LilyPond-pre-word-search))
+       (post (LilyPond-post-word-search))
+       (compsstr ""))
   ; insert try-completion and show all-completions
-  (if (> prelen 0)
-      (progn
-       (setq trycomp (try-completion pre (LilyPond-add-dictionary-word ())))
-       (if (char-or-string-p trycomp)
-           (if (string-equal (concat pre post) trycomp)
-               (goto-char (+ (point) postlen))
-             (progn
-               (delete-region (point) (+ (point) postlen))
-               (insert (substring trycomp prelen nil))))
-         (progn
-           (delete-region (point) (+ (point) postlen))
-           (font-lock-fontify-buffer))) ; only inserting fontifies
+    (if (> (length pre) 0)
+       (progn
+         (setq trycomp (try-completion pre (LilyPond-add-dictionary-word ())))
+         (if (char-or-string-p trycomp)
+             (if (string-equal (concat pre post) trycomp)
+                 (goto-char (+ (point) (length post)))
+               (progn
+                 (delete-region (point) (+ (point) (length post)))
+                 (insert (substring trycomp (length pre) nil))))
+           (progn
+             (delete-region (point) (+ (point) (length post)))
+             (font-lock-fontify-buffer))) ; only inserting fontifies
        
-       (setq compsstr "")
        (setq complist (all-completions pre (LilyPond-add-dictionary-word ())))
        (while (> (length complist) 0)
          (setq compsstr (concat compsstr "\"" (car complist) "\" "))
          (setq complist (cdr complist)))
        (message compsstr) 
-       (sit-for 0 100 1))))
+       (sit-for 0 100 1)))))
+
+(defun LilyPond-info ()
+  "Launch Info for lilypond."
+  (interactive)
+  (info "lilypond"))
+  
+(defun LilyPond-music-glossary-info ()
+  "Launch Info for music-glossary."
+  (interactive)
+  (info "music-glossary"))
+(defun LilyPond-internals-info ()
+  "Launch Info for lilypond-internals."
+  (interactive)
+  (info "lilypond-internals"))
+  
+(defun LilyPond-info-index-search ()
+  "Inside Emacs, launch `info lilypond --index-search word-under-cursor'"
+  (interactive)
+  (let ((str (concat (LilyPond-pre-word-search) (LilyPond-post-word-search))))
+    (if (and (> (length str) 0) 
+            (string-equal (substring str 0 1) "\\"))
+       (setq str (substring str 1 nil)))
+    (LilyPond-info)
+    (Info-index str)))
 
 (defun LilyPond-insert-string (pre)
   "Insert text to the buffer."
@@ -854,6 +886,12 @@ command."
             ["Comment Region" comment-region t]
             ["Refontify buffer" font-lock-fontify-buffer t]
             ))
+         '(("Info"
+            ["LilyPond" LilyPond-info t]
+            ["LilyPond index-search" LilyPond-info-index-search t]
+            ["Music Glossary" LilyPond-music-glossary-info t]
+            ["LilyPond internals" LilyPond-internals-info t]
+            ))
          ))
 
 (defconst LilyPond-imenu-generic-re "^\\([a-zA-Z]+\\) *="