Index: gui.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/gui.lisp,v
retrieving revision 1.168
diff -u -r1.168 gui.lisp
--- gui.lisp	1 Aug 2005 21:53:38 -0000	1.168
+++ gui.lisp	4 Aug 2005 08:58:57 -0000
@@ -130,15 +130,6 @@
 
 (defvar *kill-ring* (make-instance 'kill-ring :max-size 7))
 
-(defun meta-digit (gesture)
-  (position gesture
-	    '((#\0 :meta) (#\1 :meta) (#\2 :meta) (#\3 :meta) (#\4 :meta)
-	      (#\5 :meta) (#\6 :meta) (#\7 :meta) (#\8 :meta) (#\9 :meta))
-	    :test #'event-matches-gesture-name-p))
-
-(defun substitute-numeric-argument-p (command numargp)
-  (substitute numargp *numeric-argument-p* command :test #'eq))
-
 (defmethod execute-frame-command :around ((frame climacs) command)
   (handler-case
       (with-undo ((buffer (current-window)))
@@ -435,9 +426,9 @@
          (begin-mark (clone-mark point))
          (end-mark (clone-mark point)))
     (unless (eql (object-before begin-mark) #\Newline)
-      (beginning-of-paragraph begin-mark syntax))
+      (backward-paragraph begin-mark syntax))
     (unless (eql (object-after end-mark) #\Newline)
-      (end-of-paragraph end-mark syntax))
+      (forward-paragraph end-mark syntax))
     (do-buffer-region (object offset buffer
                        (offset begin-mark) (offset end-mark))
       (when (eql object #\Newline)
@@ -882,14 +873,14 @@
   (insert-sequence (point (current-window)) (kill-ring-yank *kill-ring*)))
 
 ;; Destructively cut a given buffer region into the kill-ring
-(define-named-command com-cut-out ()
+(define-named-command com-kill-region ()
   (let ((pane (current-window)))
     (kill-ring-standard-push
      *kill-ring* (region-to-sequence (mark pane) (point pane)))
     (delete-region (mark pane) (point pane))))
 
 ;; Non destructively copies in buffer region to the kill ring
-(define-named-command com-copy-out ()
+(define-named-command com-copy-region ()
   (let ((pane (current-window)))
     (kill-ring-standard-push *kill-ring* (region-to-sequence (point pane) (mark pane)))))
 
@@ -1168,17 +1159,17 @@
 						(setf (offset dabbrev-expansion-mark) offset))))
 		      (move))))))))
 	   
-(define-named-command com-beginning-of-paragraph ()
+(define-named-command com-backward-paragraph ()
   (let* ((pane (current-window))
 	 (point (point pane))
 	 (syntax (syntax (buffer pane))))
-    (beginning-of-paragraph point syntax)))
+    (backward-paragraph point syntax)))
 
-(define-named-command com-end-of-paragraph ()
+(define-named-command com-forward-paragraph ()
   (let* ((pane (current-window))
 	 (point (point pane))
 	 (syntax (syntax (buffer pane))))
-    (end-of-paragraph point syntax)))
+    (forward-paragraph point syntax)))
 
 (define-named-command com-mark-paragraph ((count 'integer :prompt "Number of paragraphs"))
   (let* ((pane (current-window))
@@ -1187,8 +1178,20 @@
 	 (syntax (syntax (buffer pane))))
     (unless (eq (previous-command pane) 'com-mark-paragraph)
       (setf (offset mark) (offset point))
-      (beginning-of-paragraph point syntax))
-    (dotimes (i count) (end-of-paragraph mark syntax))))
+      (backward-paragraph point syntax))
+    (dotimes (i count) (forward-paragraph mark syntax))))
+
+(define-named-command com-backward-sentence ()
+  (let* ((pane (current-window))
+	 (point (point pane))
+	 (syntax (syntax (buffer pane))))
+    (backward-sentence point syntax)))
+
+(define-named-command com-forward-sentence ()
+  (let* ((pane (current-window))
+	 (point (point pane))
+	 (syntax (syntax (buffer pane))))
+    (forward-sentence point syntax)))
 
 (define-named-command com-eval-expression ((insertp 'boolean :prompt "Insert?"))
   (let* ((*package* (find-package :climacs-gui))
@@ -1250,6 +1253,28 @@
 	 (syntax (syntax (buffer pane))))
     (eval-defun point syntax)))
 
+(define-named-command com-beginning-of-definition ()
+  (let* ((pane (current-window))
+	 (point (point pane))
+	 (syntax (syntax (buffer pane))))
+    (beginning-of-definition point syntax)))
+
+(define-named-command com-end-of-definition ()
+  (let* ((pane (current-window))
+	 (point (point pane))
+	 (syntax (syntax (buffer pane))))
+    (end-of-definition point syntax)))
+
+(define-named-command com-mark-definition ()
+  (let* ((pane (current-window))
+	 (point (point pane))
+	 (mark (mark pane))
+	 (syntax (syntax (buffer pane))))
+    (unless (eq (previous-command pane) 'com-mark-definition)
+      (beginning-of-definition point syntax)
+      (setf (offset mark) (offset point)))
+    (end-of-definition mark syntax)))
+
 (define-named-command com-package ()
   (let* ((pane (current-window))
 	 (syntax (syntax (buffer pane)))
@@ -1319,9 +1344,9 @@
 (global-set-key '(#\t :control) 'com-transpose-objects)
 (global-set-key '(#\Space :control) 'com-set-mark)
 (global-set-key '(#\y :control) 'com-yank)
-(global-set-key '(#\w :control) 'com-cut-out)
-(global-set-key '(#\e :meta) `(com-forward-expression ,*numeric-argument-marker*))
-(global-set-key '(#\a :meta) `(com-backward-expression ,*numeric-argument-marker*))
+(global-set-key '(#\w :control) 'com-kill-region)
+(global-set-key '(#\e :meta) 'com-forward-sentence)
+(global-set-key '(#\a :meta) 'com-backward-sentence)
 (global-set-key '(#\@ :meta :control :shift) `(com-mark-expression ,*numeric-argument-marker*))
 (global-set-key '(#\f :meta) `(com-forward-word ,*numeric-argument-marker*))
 (global-set-key '(#\b :meta) `(com-backward-word ,*numeric-argument-marker*))
@@ -1331,7 +1356,7 @@
 (global-set-key '(#\c :meta) 'com-capitalize-word)
 (global-set-key '(#\y :meta) 'com-rotate-yank) 
 (global-set-key '(#\z :meta) 'com-zap-to-character)
-(global-set-key '(#\w :meta) 'com-copy-out)
+(global-set-key '(#\w :meta) 'com-copy-region)
 (global-set-key '(#\v :control) 'com-page-down)
 (global-set-key '(#\v :meta) 'com-page-up)
 (global-set-key '(#\< :shift :meta) 'com-beginning-of-buffer)
@@ -1343,8 +1368,8 @@
 (global-set-key '(#\Backspace :meta) `(com-backward-delete-word ,*numeric-argument-marker*))
 (global-set-key '(#\@ :meta :shift) `(com-mark-word ,*numeric-argument-marker*))
 (global-set-key '(#\/ :meta) 'com-dabbrev-expand)
-(global-set-key '(#\a :control :meta) 'com-beginning-of-paragraph)
-(global-set-key '(#\e :control :meta) 'com-end-of-paragraph)
+(global-set-key '(#\{ :meta :shift) 'com-backward-paragraph)
+(global-set-key '(#\} :meta :shift) 'com-forward-paragraph)
 (global-set-key '(#\h :meta) `(com-mark-paragraph ,*numeric-argument-marker*))
 (global-set-key '(#\s :control) 'com-isearch-mode-forward)
 (global-set-key '(#\r :control) 'com-isearch-mode-backward)
@@ -1371,8 +1396,10 @@
 
 (global-set-key '(#\b :control :meta) `(com-backward-expression ,*numeric-argument-marker*))
 (global-set-key '(#\f :control :meta) `(com-forward-expression ,*numeric-argument-marker*))
-(global-set-key '(#\x :control :meta) '(com-eval-defun))
-
+(global-set-key '(#\x :control :meta) 'com-eval-defun)
+(global-set-key '(#\a :control :meta) 'com-beginning-of-definition)
+(global-set-key '(#\e :control :meta) 'com-end-of-definition)
+(global-set-key '(#\h :control :meta) 'com-mark-definition)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; 
 ;;; C-x command table
@@ -1396,7 +1423,7 @@
 (c-x-set-key '(#\h) 'com-mark-whole-buffer)
 (c-x-set-key '(#\i) 'com-insert-file)
 (c-x-set-key '(#\k) 'com-kill-buffer)
-(c-x-set-key '(#\l :control) 'com-load-file)
+;; (c-x-set-key '(#\l :control) 'com-load-file)
 (c-x-set-key '(#\o) 'com-other-window)
 (c-x-set-key '(#\r) 'com-redo)
 (c-x-set-key '(#\u) 'com-undo)
Index: lisp-syntax.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/lisp-syntax.lisp,v
retrieving revision 1.18
diff -u -r1.18 lisp-syntax.lisp
--- lisp-syntax.lisp	28 Jul 2005 20:36:36 -0000	1.18
+++ lisp-syntax.lisp	4 Aug 2005 08:58:59 -0000
@@ -850,7 +850,8 @@
 
 ;;;;;;;;;;;;;;;; pathname
 
-;;; FIXME: #P _must_ be followed by a string
+;;; NB: #P need not be followed by a string,
+;;;  as it could be followed by a #. construct instead (or some other reader macro)
 
 ;;; parse trees
 (defclass pathname-form (form) ())
@@ -1309,3 +1310,27 @@
 							(end-offset form))
 				       'string)))))))
 
+(defmethod beginning-of-definition (mark (syntax lisp-syntax))
+  (with-slots (stack-top) syntax
+    (loop for form in (children stack-top)
+	  with last-toplevel-list = nil
+	  when (and (typep form 'list-form)
+		    (mark< mark (end-offset form)))
+          do (if (mark< (start-offset form) mark)
+		 (setf (offset mark) (start-offset form))
+		 (when last-toplevel-list form
+		       (setf (offset mark) (start-offset last-toplevel-list))))
+	     (return t)
+	  when (typep form 'list-form)
+	  do (setf last-toplevel-list form)
+	  finally (when last-toplevel-list form
+		       (setf (offset mark) (start-offset last-toplevel-list))))))
+
+(defmethod end-of-definition (mark (syntax lisp-syntax))
+  (with-slots (stack-top) syntax
+    (loop for form in (children stack-top)
+	  when (and (typep form 'list-form)
+		    (mark< mark (end-offset form)))
+	  do (setf (offset mark) (end-offset form))
+	     (loop-finish))))
+
@@ -1495,6 +1551,9 @@
 (defmethod indent-form ((syntax lisp-syntax) (tree token-form) path)
   (values tree 0))
 
+(defmethod indent-form ((syntax lisp-syntax) (tree error-symbol) path)
+  (values tree nil))
+
 (defmethod indent-binding ((syntax lisp-syntax) tree path)
   (if (null (cdr path))
       ;; top level
@@ -1673,6 +1732,8 @@
     (let ((path (compute-path syntax (offset mark))))
       (multiple-value-bind (tree offset)
 	  (indent-form syntax stack-top path)
-	(setf (offset mark) (start-offset tree))
-	(+ (real-column-number mark tab-width)
-	   offset)))))
+	(cond ((null offset) 0)
+	      (t
+	       (setf (offset mark) (start-offset tree))
+	       (+ (real-column-number mark tab-width)
+		  offset)))))))
Index: packages.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/packages.lisp,v
retrieving revision 1.71
diff -u -r1.71 packages.lisp
--- packages.lisp	28 Jul 2005 20:36:36 -0000	1.71
+++ packages.lisp	4 Aug 2005 08:59:00 -0000
@@ -107,8 +107,10 @@
            #:syntax-line-indentation
 	   #:forward-expression #:backward-expression
 	   #:eval-defun
+	   #:beginning-of-definition #:end-of-definition
 	   #:redisplay-pane-with-syntax
-	   #:beginning-of-paragraph #:end-of-paragraph))
+	   #:backward-paragraph #:forward-paragraph
+	   #:backward-sentence #:forward-sentence))
 
 (defpackage :climacs-kill-ring
   (:use :clim-lisp :flexichain)
Index: syntax.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/syntax.lisp,v
retrieving revision 1.53
diff -u -r1.53 syntax.lisp
--- syntax.lisp	4 Jul 2005 13:55:56 -0000	1.53
+++ syntax.lisp	4 Aug 2005 08:59:00 -0000
@@ -55,6 +55,18 @@
 
 (defgeneric eval-defun (mark syntax))
 
+(defgeneric beginning-of-definition (mark syntax))
+
+(defgeneric end-of-definition (mark syntax))
+
+(defgeneric backward-paragraph (mark syntax))
+
+(defgeneric forward-paragraph (mark syntax))
+
+(defgeneric backward-sentence (mark syntax))
+
+(defgeneric forward-sentence (mark syntax))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; Syntax completion
@@ -154,6 +166,24 @@
   (error 'no-such-operation))
 
 (defmethod eval-defun (mark syntax)
+  (error 'no-such-operation))
+
+(defmethod beginning-of-definition (mark syntax)
+  (error 'no-such-operation))
+
+(defmethod end-of-definition (mark syntax)
+  (error 'no-such-operation))
+
+(defmethod backward-paragraph (mark syntax)
+  (error 'no-such-operation))
+
+(defmethod forward-paragraph (mark syntax)
+  (error 'no-such-operation))
+
+(defmethod backward-sentence (mark syntax)
+  (error 'no-such-operation))
+
+(defmethod forward-sentence (mark syntax)
   (error 'no-such-operation))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Index: text-syntax.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/text-syntax.lisp,v
retrieving revision 1.8
diff -u -r1.8 text-syntax.lisp
--- text-syntax.lisp	20 Jul 2005 09:41:06 -0000	1.8
+++ text-syntax.lisp	4 Aug 2005 08:59:01 -0000
@@ -148,11 +148,7 @@
 			 (incf pos1))
 			(t nil))))))))
 
-
-
-(defgeneric beginning-of-paragraph (mark text-syntax))
-
-(defmethod beginning-of-paragraph (mark (syntax text-syntax))
+(defmethod backward-paragraph (mark (syntax text-syntax))
   (with-slots (paragraphs) syntax
      (let ((pos1 (index-of-mark-after-offset paragraphs (offset mark))))
        (when (> pos1 0)
@@ -161,9 +157,7 @@
 		   (offset (element* paragraphs (- pos1 2)))
 		   (offset (element* paragraphs (1- pos1)))))))))
 
-(defgeneric end-of-paragraph (mark text-syntax))
-
-(defmethod end-of-paragraph (mark (syntax text-syntax))
+(defmethod forward-paragraph (mark (syntax text-syntax))
   (with-slots (paragraphs) syntax
     (let ((pos1 (index-of-mark-after-offset
                  paragraphs
@@ -176,18 +170,14 @@
 		   (offset (element* paragraphs (1+ pos1)))
 		   (offset (element* paragraphs pos1))))))))
 
-
- (defgeneric backward-expression (mark text-syntax))
-
- (defmethod backward-expression (mark (syntax text-syntax))
+ (defmethod backward-sentence (mark (syntax text-syntax))
    (with-slots (sentence-beginnings) syntax
       (let ((pos1 (index-of-mark-after-offset sentence-beginnings (offset mark))))
         (when (> pos1 0)
  	 (setf (offset mark)
  		   (offset (element* sentence-beginnings (1- pos1))))))))
- (defgeneric forward-expression (mark text-syntax))
 
- (defmethod forward-expression (mark (syntax text-syntax))
+ (defmethod forward-sentence (mark (syntax text-syntax))
    (with-slots (sentence-endings) syntax
      (let ((pos1 (index-of-mark-after-offset
                   sentence-endings
