From: Heikki Junes <heikki.junes@hut.fi>
Date: Sun, 24 Nov 2002 00:08:09 +0000 (+0000)
Subject: LilyPond-autocompletion fixes.
X-Git-Tag: release/1.7.9~26
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0002a82b202ad3c8df6dbc23752a181081224f77;p=lilypond.git

LilyPond-autocompletion fixes.
---

diff --git a/ChangeLog b/ChangeLog
index 82cb3d8c10..8afd46ce4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-11-23  Heikki Junes <hjunes@cc.hut.fi>
+
+	* lilypond-mode.el (LilyPond-autocompletion): invoked with
+	[S-iso-lefttab], fixes at bol and eol, descriptive variable names.
+
+	* lilypond-words.el: add two (Everybody can add/remove words now!).
+
 2002-11-23  Jan Nieuwenhuizen  <janneke@gnu.org>
 
 	* scripts/ly2dvi.py: Add paper sizes.
diff --git a/lilypond-mode.el b/lilypond-mode.el
index 9f8ef06e0b..ba8e03569d 100644
--- a/lilypond-mode.el
+++ b/lilypond-mode.el
@@ -587,7 +587,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 "}" 'LilyPond-electric-close-paren)
-  (define-key LilyPond-mode-map [(shift control c)] 'LilyPond-autocompletion)
+  (define-key LilyPond-mode-map [S-iso-lefttab] 'LilyPond-autocompletion)
   )
 
 ;;; Menu Support
@@ -693,48 +693,47 @@ command."
   "Show completions in mini-buffer for the given word."
   (interactive)
 
-  ; search the begin of word
-  (setq beg "")
-  (setq i 0)
-  (setq ch (char-before (- (point) i)))
-  (while (or (and (>= ch 65) (<= ch 90)) 
-	     (and (>= ch 97) (<= ch 122)) 
-	     (= ch 92)) ; add [A-Za-z\\] until non-alpha
-    (setq beg (concat (char-to-string ch) beg))
-    (setq i (+ i 1))
-    (setq ch (char-before (- (point) i)))
-   )
-
-  ; search the end of word
-  (setq end "")
-  (setq j 0)
-  (setq ch (char-after (+ (point) j)))
-  (while (or (and (>= ch 65) (<= ch 90)) 
-	     (and (>= ch 97) (<= ch 122))) ; add [A-Z,a-z] until non-alpha
-    (setq end (concat end (char-to-string ch)))
-    (setq j (+ j 1))
-    (setq ch (char-after (+ (point) j))))
+  ; 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))))
   
   ; insert try-completion and show all-completions
-  (if (> i 0)
+  (if (> prelen 0)
       (progn
-	(setq tryc (try-completion beg (LilyPond-add-dictionary-word ())))
-	(if (char-or-string-p tryc)
-	    (if (string-equal (concat beg end) tryc)
-		(goto-char (+ (point) (length end)))
+	(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) (length end)))
-		(insert (substring tryc (length beg) nil))))
+		(delete-region (point) (+ (point) postlen))
+		(insert (substring trycomp prelen nil))))
 	  (progn
-	    (delete-region (point) (+ (point) (length end)))
-	    (font-lock-fontify-buffer)))
+	    (delete-region (point) (+ (point) postlen))
+	    (font-lock-fontify-buffer))) ; only inserting fontifies
 	
-	(setq others "")
-	(setq co (all-completions beg (LilyPond-add-dictionary-word ())))
-	(while (> (length co) 0)
-	  (setq others (concat others "\"" (car co) "\" "))
-	  (setq co (cdr co)))
-	(message others) 
+	(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))))
 
 (defun LilyPond-insert-string (pre)
diff --git a/lilypond.words b/lilypond.words
index 6f1adf0524..7369889381 100644
--- a/lilypond.words
+++ b/lilypond.words
@@ -142,6 +142,7 @@ InnerChoirStaff
 \\keys
 \\keysignature
 \\lag
+\\legato
 \\legniGroup
 \\lheel
 \\linebreak
@@ -230,6 +231,7 @@ PianoStaff
 \\PianoStaffContext
 \\pitch
 \\pitchnames
+\\portato
 \\pp
 \\pper
 \\ppp