Index: buffer.lisp
===================================================================
RCS file: /project/gsharp/cvsroot/gsharp/buffer.lisp,v
retrieving revision 1.27
diff -u -r1.27 buffer.lisp
--- buffer.lisp	20 Nov 2005 19:17:22 -0000	1.27
+++ buffer.lisp	28 Nov 2005 11:19:28 -0000
@@ -76,10 +76,11 @@
 (defclass fiveline-staff (staff)
   ((print-character :allocation :class :initform #\=)
    (clef :accessor clef :initarg :clef :initform (make-clef :treble))
-   (keysig :accessor keysig :initarg :keysig
-	   :initform (make-array 7 :initial-element :natural))))
+   (keysig :accessor keysig :initarg :keysig 
+           :initform (make-array 7 :initial-element :natural))
+   (key-signatures :accessor key-signatures :initform nil)))
 	   
-(defun make-fiveline-staff (&rest args &key name clef keysig)
+(defun make-fiveline-staff (&rest args &key name clef)
   (declare (ignore name clef keysig))
   (apply #'make-instance 'fiveline-staff args))
 
@@ -209,48 +210,88 @@
 ;;; currently does not belong to any bar. 
 (defgeneric bar (element))
 
+(defclass element (gsharp-object)
+  ((bar :initform nil :initarg :bar :accessor bar)
+   (xoffset :initform 0 :initarg :xoffset :accessor xoffset)))
+
+(defmethod print-object :after ((element element) stream)
+  (format stream ":xoffset ~W " (xoffset element)))
+
+(defmethod duration ((element element))
+  1/8)
+
+(defmethod rbeams ((element element)) 0)
+(defmethod lbeams ((element element)) 0)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
+;;; Key Signature
+
+(defclass key-signature (element)
+  ((print-character :allocation :class :initform #\#)
+   (staff :initarg :staff :reader staff)
+   (keysig :accessor %%keysig :initarg :keysig
+           :initform (make-array 7 :initial-element :natural))))
+
+(defun make-keysig (staff &rest args &key keysig)
+  (declare (type (or null (simple-vector 7)) keysig))
+  (apply #'make-instance 'key-signature :staff staff args))
+
+(defmethod print-object :after ((keysig key-signature) stream)
+  (format stream ":staff ~W :keysig ~W " (staff keysig) (keysig keysig)))
+
+(defun read-key-signature-v3 (stream char n)
+  (declare (ignore char n))
+  (apply #'make-instance 'key-signature (read-delimited-list #\] stream t)))
+
+(set-dispatch-macro-character #\[ #\#
+  #'read-key-signature-v3
+  *gsharp-readtable-v3*)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
+;;; Rhythmic Element
+
 ;;; Return the notehead of the element.  With setf, set the notehead
 ;;; of the element. 
-(defgeneric notehead (element))
-(defgeneric (setf notehead) (notehead element))
+(defgeneric notehead (rhythmic-element))
+(defgeneric (setf notehead) (notehead rhythmic-element))
 
 ;;; Return the number of right beams of the element.  With setf, set
 ;;; the number of right beams of the element.
-(defgeneric rbeams (element))
-(defgeneric (setf rbeams) (rbeams element))
+(defgeneric rbeams (rhythmic-element))
+(defgeneric (setf rbeams) (rbeams rhythmic-element))
 
 ;;; Return the number of left beams of the element.  With setf, set
 ;;; the number of left beams of the element.
-(defgeneric lbeams (element))
-(defgeneric (setf lbeams) (lbeams element))
+(defgeneric lbeams (rhythmic-element))
+(defgeneric (setf lbeams) (lbeams rhythmic-element))
 
 ;;; Return the number of dots of the element.  With setf, set the
 ;;; number of dots of the element. 
-(defgeneric dots (element))
-(defgeneric (setf dots) (dots element))
+(defgeneric dots (rhythmic-element))
+(defgeneric (setf dots) (dots rhythmic-element))
 
-(defclass element (gsharp-object)
-  ((bar :initform nil :initarg :bar :accessor bar)
-   (notehead :initform :whole :initarg :notehead :accessor notehead)
+(defclass rhythmic-element (element)
+  ((notehead :initform :whole :initarg :notehead :accessor notehead)
    (rbeams :initform 0 :initarg :rbeams :accessor rbeams)
    (lbeams :initform 0 :initarg :lbeams :accessor lbeams)
-   (dots :initform 0 :initarg :dots :accessor dots)
-   (xoffset :initform 0 :initarg :xoffset :accessor xoffset)))
+   (dots :initform 0 :initarg :dots :accessor dots)))
    
-(defmethod print-object :after ((e element) stream)
+(defmethod print-object :after ((e rhythmic-element) stream)
   (with-slots (notehead rbeams lbeams dots xoffset) e
     (format stream
-	    ":notehead ~W :rbeams ~W :lbeams ~W :dots ~W :xoffset ~W "
+	    ":notehead ~W :rbeams ~W :lbeams ~W :dots ~W "
 	    notehead rbeams lbeams dots xoffset)))
 
-(defmethod undotted-duration ((element element))
+(defmethod undotted-duration ((element rhythmic-element))
   (ecase (notehead element)
     (:whole 1)
     (:half 1/2)
     (:filled (/ (expt 2 (+ 2 (max (rbeams element)
 				  (lbeams element))))))))
 
-(defmethod duration ((element element))
+(defmethod duration ((element rhythmic-element))
   (let ((duration (undotted-duration element)))
     (do ((dot-duration (/ duration 2) (/ dot-duration 2))
 	 (nb-dots (dots element) (1- nb-dots)))
@@ -262,7 +303,7 @@
 ;;;
 ;;; Melody element
 
-(defclass melody-element (element) ())
+(defclass melody-element (rhythmic-element) ())
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
@@ -409,7 +450,7 @@
 ;;;
 ;;; Lyrics element
 
-(defclass lyrics-element (element)
+(defclass lyrics-element (rhythmic-element)
   ((print-character :allocation :class :initform #\A)
    (staff :initarg :staff :reader staff)
    (text :initarg :text
Index: cursor.lisp
===================================================================
RCS file: /project/gsharp/cvsroot/gsharp/cursor.lisp,v
retrieving revision 1.2
diff -u -r1.2 cursor.lisp
--- cursor.lisp	23 Jul 2004 16:51:16 -0000	1.2
+++ cursor.lisp	28 Nov 2005 11:19:28 -0000
@@ -166,6 +166,12 @@
 	(when (> (pos cursor) position)
 	  (incf (pos cursor)))))
 
+(defmethod add-element :after 
+    ((keysig gsharp-buffer::key-signature) bar position)
+  (setf (gsharp-buffer::key-signatures (staff keysig))
+        ;; FIXME: unordered
+        (cons keysig (gsharp-buffer::key-signatures (staff keysig)))))
+
 (defmethod remove-element :before ((element element))
   (let ((elemno (number element)))
     (loop for cursor in (cursors (bar element)) do
Index: drawing.lisp
===================================================================
RCS file: /project/gsharp/cvsroot/gsharp/drawing.lisp,v
retrieving revision 1.35
diff -u -r1.35 drawing.lisp
--- drawing.lisp	28 Nov 2005 04:25:34 -0000	1.35
+++ drawing.lisp	28 Nov 2005 11:19:29 -0000
@@ -207,6 +207,9 @@
 		   (incf yy 90))))
 	 buffer)))))
 
+(define-added-mixin xelement () element
+  ((final-absolute-xoffset :accessor final-absolute-element-xoffset)))
+
 (define-added-mixin velement () melody-element
   (;; the position, in staff steps, of the end of the stem
    ;; that is not attached to a note, independent of the
@@ -220,11 +223,10 @@
    (top-note-staff-yoffset :accessor top-note-staff-yoffset)
    ;; the yoffset of the staff that contains the bottom note of
    ;; the element
-   (bot-note-staff-yoffset :accessor bot-note-staff-yoffset)
-   (final-absolute-xoffset :accessor final-absolute-element-xoffset)))
+   (bot-note-staff-yoffset :accessor bot-note-staff-yoffset)))
 
 (define-added-mixin welement () lyrics-element
-  ((final-absolute-xoffset :accessor final-absolute-element-xoffset)))
+  ())
 
 ;;; Compute and store several important pieces of information
 ;;; about an element:
@@ -322,6 +324,11 @@
 	  notes))
 
 (defun draw-beam-group (pane elements)
+  (let ((e (car elements)))
+    (when (typep e 'gsharp-buffer::key-signature)
+      (assert (null (cdr elements)))
+      (return-from draw-beam-group
+        (draw-element pane e (final-absolute-element-xoffset e)))))
   (mapc #'compute-top-bot-yoffset elements)
   (if (null (cdr elements))
       (let ((element (car elements)))
@@ -516,3 +523,65 @@
     (with-text-family (pane :serif)
       (draw-text* pane (map 'string 'code-char (text element))
                   x 0 :align-x :center))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
+;;; Key signature element
+
+(define-added-mixin dkey-signature () gsharp-buffer::key-signature
+  ((measure-bar-number :accessor measure-bar-number :initform nil)
+   (temporal-offset :accessor temporal-offset :initform nil)))
+
+#+nil
+(defmethod recompute-key-signature-positions ((buffer buffer)) ; RBUFFER?
+  (let ((staves (staves buffer)))))
+
+(defmethod draw-element (pane (keysig gsharp-buffer::key-signature) x &optional flags)
+  (let ((staff (staff keysig))
+        (old-keysig (keysig keysig)))
+    (score-pane:with-vertical-score-position (pane (staff-yoffset staff))
+      (let ((yoffset (ecase (name (clef staff))
+                       (:bass (- (lineno (clef staff)) 4))
+                       (:treble (+ (lineno (clef staff)) 2))
+                       (:c (- (lineno (clef staff))) 1))))
+        (loop with advance = 0
+              for pitch in '(6 2 5 1 4 0 3)
+              for line in '(0 3 -1 2 -2 1 -3)
+              when (and (eq (aref old-keysig pitch) :flat)
+                        (not (eq (aref (gsharp-buffer::%%keysig keysig) pitch) 
+                                 :flat)))
+              do (score-pane:draw-accidental 
+                  pane :natural (+ x advance) (+ line yoffset))
+              and do (incf advance (score-pane:staff-step 2))
+              finally (incf x (if (= advance 0) 0 (+ advance (score-pane:staff-step 2))))))
+      (let ((yoffset (ecase (name (clef staff))
+                       (:bass (lineno (clef staff)))
+                       (:treble (+ (lineno (clef staff)) 6))
+                       (:c (+ (lineno (clef staff))) 3))))
+        (loop with advance = 0
+              for pitch in '(3 0 4 1 5 2 6)
+              for line in '(0 -3 1 -2 -5 -1 -4)
+              when (and (eq (aref old-keysig pitch) :sharp)
+                        (not (eq (aref (gsharp-buffer::%%keysig keysig) pitch) :sharp)))
+              do (score-pane:draw-accidental pane :natural (+ x advance) (+ line yoffset))
+              and do (incf advance (score-pane:staff-step 2))
+              finally (incf x (if (= advance 0) 0 (+ advance (score-pane:staff-step 2))))))
+
+      (let ((yoffset (ecase (name (clef staff))
+                       (:bass (- (lineno (clef staff)) 4))
+                       (:treble (+ (lineno (clef staff)) 2))
+                       (:c (- (lineno (clef staff))) 1))))
+        (loop for pitch in '(6 2 5 1 4 0 3)
+              for line in '(0 3 -1 2 -2 1 -3)
+              for x from x by (score-pane:staff-step 2)
+              while (eq (aref (gsharp-buffer::%%keysig keysig) pitch) :flat)
+              do (score-pane:draw-accidental pane :flat x (+ line yoffset))))
+      (let ((yoffset (ecase (name (clef staff))
+                       (:bass (lineno (clef staff)))
+                       (:treble (+ (lineno (clef staff)) 6))
+                       (:c (+ (lineno (clef staff))) 3))))
+        (loop for pitch in '(3 0 4 1 5 2 6)
+              for line in '(0 -3 1 -2 -5 -1 -4)
+              for x from x by (score-pane:staff-step 2.5)
+              while (eq (aref (gsharp-buffer::%%keysig keysig) pitch) :sharp)
+              do (score-pane:draw-accidental pane :sharp x (+ line yoffset)))))))
\ No newline at end of file
Index: gui.lisp
===================================================================
RCS file: /project/gsharp/cvsroot/gsharp/gui.lisp,v
retrieving revision 1.45
diff -u -r1.45 gui.lisp
--- gui.lisp	26 Nov 2005 21:30:13 -0000	1.45
+++ gui.lisp	28 Nov 2005 11:19:29 -0000
@@ -136,6 +136,8 @@
 
 (defmethod display-score ((frame gsharp) pane)
   (let* ((buffer (buffer frame)))
+    #+nil
+    (gsharp-drawing::recompute-key-signature-positions buffer)
     (recompute-measures buffer)
     (score-pane:with-score-pane pane
       (flet ((draw-cursor (x) (draw-the-cursor pane x)))
@@ -580,7 +582,8 @@
 	 (staff (car (staves (layer (slice (bar cluster))))))
 	 (note (make-note pitch staff
 		 :head (notehead state)
-		 :accidentals (aref (keysig staff) (mod pitch 7))
+		 :accidentals (aref (keysig (cursor *application-frame*)) 
+                                    (mod pitch 7))
 		 :dots (dots state))))
     (setf *current-cluster* cluster
 	  *current-note* note)
@@ -825,6 +828,94 @@
       (unless *current-note*
         (com-erase-element)))))
 
+(defun insert-keysig ()
+  (let* ((state (input-state *application-frame*))
+	 (cursor (cursor *application-frame*))
+         (staff (car (staves (layer (cursor *application-frame*)))))
+	 (keysig (if (keysig cursor)
+                     (gsharp-buffer::make-keysig staff :keysig (copy-seq (keysig cursor)))
+                     (gsharp-buffer::make-keysig staff))))
+    ;; FIXME: should only invalidate elements temporally after the
+    ;; cursor.
+    (loop for segment in (segments (buffer *application-frame*))
+	  do (loop for layer in (layers segment)
+		   do (when (member staff (staves layer))
+			(invalidate-slice-using-staff (head layer) staff)
+			(invalidate-slice-using-staff (body layer) staff)
+			(invalidate-slice-using-staff (tail layer) staff))))
+    (insert-element keysig cursor)
+    (forward-element cursor)
+    keysig))
+
+(define-gsharp-command com-insert-keysig ()
+  (insert-keysig))
+
+(defmethod remove-element :before ((keysig gsharp-buffer::key-signature))
+  (let ((staff (staff keysig)))
+    (setf (gsharp-buffer::key-signatures staff)
+          (remove keysig (gsharp-buffer::key-signatures staff)))
+    (loop for segment in (segments (buffer *application-frame*))
+	  do (loop for layer in (layers segment)
+		   do (when (member staff (staves layer))
+			(invalidate-slice-using-staff (head layer) staff)
+			(invalidate-slice-using-staff (body layer) staff)
+			(invalidate-slice-using-staff (tail layer) staff))))))
+
+(defun %keysig (staff key-signatures bar bars element-or-nil)
+  ;; common case
+  (when (null key-signatures)
+    (return-from %keysig (keysig staff)))
+  ;; earlier in the same bar?
+  (let ((k nil))
+    (dolist (e (elements bar) (when k (return-from %keysig (gsharp-buffer::%%keysig k))))
+      (when (eq e element-or-nil)
+        (if k (return-from %keysig (gsharp-buffer::%%keysig k)) (return nil)))
+      (when (and (typep e 'gsharp-buffer::key-signature)
+                 (eq (staff e) staff))
+        (setq k e))))
+  ;; must be an earlier bar.
+  (let ((bars (nreverse (loop for b in bars until (eq b bar) collect b))))
+    (dolist (b bars (keysig staff))
+      (when (find b key-signatures :key #'bar)
+        (dolist (e (reverse (elements b)) (error "inconsistency"))
+          (when (and (typep e 'gsharp-buffer::key-signature)
+                     (eq (staff e) staff))
+            (return-from %keysig (gsharp-buffer::%%keysig e))))))))
+
+(defmethod keysig ((cursor gsharp-cursor))
+  ;; FIXME: not just a cursor but _the_ cursor (i.e. in a given staff)
+  (assert (eq cursor (cursor *application-frame*)))
+  (let* ((staff (car (staves (layer cursor))))
+         (key-signatures (gsharp-buffer::key-signatures staff))
+         (bar (bar cursor))
+         (slice (slice bar))
+         (bars (bars slice))
+         (element-or-nil (cursor-element cursor)))
+    (%keysig staff key-signatures bar bars element-or-nil)))
+
+(defmethod keysig ((note note))
+  (let* ((staff (staff note))
+         (key-signatures (gsharp-buffer::key-signatures staff))
+         (bar (bar (cluster note)))
+         (slice (slice bar))
+         (bars (bars slice))
+         (element-or-nil (cluster note)))
+    (%keysig staff key-signatures bar bars element-or-nil)))
+
+(defmethod keysig ((cluster cluster))
+  (error "Called ~S (a staff-scope operation) on an element with no ~
+          associated staff: ~S" 
+         'keysig cluster))
+
+(defmethod keysig ((element element))
+  (let* ((staff (staff element))
+         (key-signatures (gsharp-buffer::key-signatures staff))
+         (bar (bar element))
+         (slice (slice bar))
+         (bars (bars slice))
+         (element-or-nil element))
+    (%keysig staff key-signatures bar bars element-or-nil)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; motion by element
@@ -1096,52 +1187,52 @@
 		 do (mark-modified element))))
 
 (define-gsharp-command com-more-sharps ()
-  (let ((staff (car (staves (layer (cursor *application-frame*))))))
+  (let ((staff (car (staves (layer (cursor *application-frame*)))))
+        (keysig (keysig (cursor *application-frame*))))
     (loop for segment in (segments (buffer *application-frame*))
 	  do (loop for layer in (layers segment)
 		   do (when (member staff (staves layer))
 			(invalidate-slice-using-staff (head layer) staff)
 			(invalidate-slice-using-staff (body layer) staff)
 			(invalidate-slice-using-staff (tail layer) staff))))
-    (let ((keysig (keysig staff)))
-      (cond ((eq (aref keysig 3) :flat) (setf (aref keysig 3) :natural))
-	    ((eq (aref keysig 0) :flat) (setf (aref keysig 0) :natural))
-	    ((eq (aref keysig 4) :flat) (setf (aref keysig 4) :natural))
-	    ((eq (aref keysig 1) :flat) (setf (aref keysig 1) :natural))
-	    ((eq (aref keysig 5) :flat) (setf (aref keysig 5) :natural))
-	    ((eq (aref keysig 2) :flat) (setf (aref keysig 2) :natural))
-	    ((eq (aref keysig 6) :flat) (setf (aref keysig 6) :natural))
-	    ((eq (aref keysig 3) :natural) (setf (aref keysig 3) :sharp))
-	    ((eq (aref keysig 0) :natural) (setf (aref keysig 0) :sharp))
-	    ((eq (aref keysig 4) :natural) (setf (aref keysig 4) :sharp))
-	    ((eq (aref keysig 1) :natural) (setf (aref keysig 1) :sharp))
-	    ((eq (aref keysig 5) :natural) (setf (aref keysig 5) :sharp))
-	    ((eq (aref keysig 2) :natural) (setf (aref keysig 2) :sharp))
-	    ((eq (aref keysig 6) :natural) (setf (aref keysig 6) :sharp))))))
+    (cond ((eq (aref keysig 3) :flat) (setf (aref keysig 3) :natural))
+          ((eq (aref keysig 0) :flat) (setf (aref keysig 0) :natural))
+          ((eq (aref keysig 4) :flat) (setf (aref keysig 4) :natural))
+          ((eq (aref keysig 1) :flat) (setf (aref keysig 1) :natural))
+          ((eq (aref keysig 5) :flat) (setf (aref keysig 5) :natural))
+          ((eq (aref keysig 2) :flat) (setf (aref keysig 2) :natural))
+          ((eq (aref keysig 6) :flat) (setf (aref keysig 6) :natural))
+          ((eq (aref keysig 3) :natural) (setf (aref keysig 3) :sharp))
+          ((eq (aref keysig 0) :natural) (setf (aref keysig 0) :sharp))
+          ((eq (aref keysig 4) :natural) (setf (aref keysig 4) :sharp))
+          ((eq (aref keysig 1) :natural) (setf (aref keysig 1) :sharp))
+          ((eq (aref keysig 5) :natural) (setf (aref keysig 5) :sharp))
+          ((eq (aref keysig 2) :natural) (setf (aref keysig 2) :sharp))
+          ((eq (aref keysig 6) :natural) (setf (aref keysig 6) :sharp)))))
 
 (define-gsharp-command com-more-flats ()
-  (let ((staff (car (staves (layer (cursor *application-frame*))))))
+  (let ((staff (car (staves (layer (cursor *application-frame*)))))
+        (keysig (keysig (cursor *application-frame*))))
     (loop for segment in (segments (buffer *application-frame*))
 	  do (loop for layer in (layers segment)
 		   do (when (member staff (staves layer))
 			(invalidate-slice-using-staff (head layer) staff)
 			(invalidate-slice-using-staff (body layer) staff)
 			(invalidate-slice-using-staff (tail layer) staff))))
-    (let ((keysig (keysig staff)))
-      (cond ((eq (aref keysig 6) :sharp) (setf (aref keysig 6) :natural))
-	    ((eq (aref keysig 2) :sharp) (setf (aref keysig 2) :natural))
-	    ((eq (aref keysig 5) :sharp) (setf (aref keysig 5) :natural))
-	    ((eq (aref keysig 1) :sharp) (setf (aref keysig 1) :natural))
-	    ((eq (aref keysig 4) :sharp) (setf (aref keysig 4) :natural))
-	    ((eq (aref keysig 0) :sharp) (setf (aref keysig 0) :natural))
-	    ((eq (aref keysig 3) :sharp) (setf (aref keysig 3) :natural))
-	    ((eq (aref keysig 6) :natural) (setf (aref keysig 6) :flat))
-	    ((eq (aref keysig 2) :natural) (setf (aref keysig 2) :flat))
-	    ((eq (aref keysig 5) :natural) (setf (aref keysig 5) :flat))
-	    ((eq (aref keysig 1) :natural) (setf (aref keysig 1) :flat))
-	    ((eq (aref keysig 4) :natural) (setf (aref keysig 4) :flat))
-	    ((eq (aref keysig 0) :natural) (setf (aref keysig 0) :flat))
-	    ((eq (aref keysig 3) :natural) (setf (aref keysig 3) :flat))))))
+    (cond ((eq (aref keysig 6) :sharp) (setf (aref keysig 6) :natural))
+          ((eq (aref keysig 2) :sharp) (setf (aref keysig 2) :natural))
+          ((eq (aref keysig 5) :sharp) (setf (aref keysig 5) :natural))
+          ((eq (aref keysig 1) :sharp) (setf (aref keysig 1) :natural))
+          ((eq (aref keysig 4) :sharp) (setf (aref keysig 4) :natural))
+          ((eq (aref keysig 0) :sharp) (setf (aref keysig 0) :natural))
+          ((eq (aref keysig 3) :sharp) (setf (aref keysig 3) :natural))
+          ((eq (aref keysig 6) :natural) (setf (aref keysig 6) :flat))
+          ((eq (aref keysig 2) :natural) (setf (aref keysig 2) :flat))
+          ((eq (aref keysig 5) :natural) (setf (aref keysig 5) :flat))
+          ((eq (aref keysig 1) :natural) (setf (aref keysig 1) :flat))
+          ((eq (aref keysig 4) :natural) (setf (aref keysig 4) :flat))
+          ((eq (aref keysig 0) :natural) (setf (aref keysig 0) :flat))
+          ((eq (aref keysig 3) :natural) (setf (aref keysig 3) :flat)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
Index: measure.lisp
===================================================================
RCS file: /project/gsharp/cvsroot/gsharp/measure.lisp,v
retrieving revision 1.16
diff -u -r1.16 measure.lisp
--- measure.lisp	28 Nov 2005 04:25:34 -0000	1.16
+++ measure.lisp	28 Nov 2005 11:19:29 -0000
@@ -186,7 +186,7 @@
   (loop for note in group do
 	(setf (final-accidental note)
 	      (if (eq (accidentals note)
-		      (aref (keysig (staff note)) (mod (pitch note) 7)))
+		      (aref (keysig note) (mod (pitch note) 7)))
 		  nil
 		  (accidentals note)))))
 
@@ -621,12 +621,12 @@
 ;;; compute some important parameters of a bar
 (defgeneric compute-bar-parameters (bar))
 
-(defmethod compute-bar-parameter (bar)
+(defmethod compute-bar-parameters (bar)
   nil)
 
 (defmethod compute-bar-parameters ((bar melody-bar))
   (loop for group in (beam-groups (elements bar))
-	do (compute-beam-group-parameters group)))	
+	do (compute-beam-group-parameters group)))
 
 ;;; From a list of simultaneous bars (and some other stuff), create a
 ;;; measure.  The `other stuff' is the spacing style, which is neded
Index: modes.lisp
===================================================================
RCS file: /project/gsharp/cvsroot/gsharp/modes.lisp,v
retrieving revision 1.7
diff -u -r1.7 modes.lisp
--- modes.lisp	28 Oct 2005 17:20:30 -0000	1.7
+++ modes.lisp	28 Nov 2005 11:19:29 -0000
@@ -37,6 +37,7 @@
 (set-key 'com-add-note-g 'melody-table '(#\G))
 (set-key 'com-add-note-a 'melody-table '(#\A))
 (set-key 'com-add-note-b 'melody-table '(#\B))
+(set-key 'com-insert-keysig 'melody-table '(#\K))
 (set-key 'com-current-increment 'melody-table '((#\p)))
 (set-key 'com-current-decrement 'melody-table '((#\n)))
 (set-key 'com-istate-more-dots 'melody-table '((#\i) (#\.)))
