Index: ChangeLog
===================================================================
--- ChangeLog	(revision 9bd2c178df9e3d3332b6643c78796fbd069738f3)
+++ ChangeLog	(revision 5eeea3bf29b5ab1d821dbd35697404c06eb5eed8)
@@ -16,5 +16,14 @@
 	Switched "C-x C-x" to only "startcommand quit"
 	'getsubs' prints closer to the order you sub in.
-	
+	Modified the behavior of last so that "> >" will clear the screen.
+	The new behavior of last is:
+	      Moves the pointer to the last message in the view.
+	      If we are already at the last message in the view,
+	      blanks the screen and moves just past the end of the view
+	      so that new messages will appear starting at the top
+	      of the screen.
+	Fixed a typo in the help for smartzpunt.
+	Fixed functions to handle curmsg being past the end of the view.
+
 1.2.1
         New framework for command handling.
Index: commands.c
===================================================================
--- commands.c	(revision 1fd0b25bc362ef6deee5d05e4558ce154f8c6f5c)
+++ commands.c	(revision 5eeea3bf29b5ab1d821dbd35697404c06eb5eed8)
@@ -155,5 +155,5 @@
   OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE,
 	      "creates a zpunt based on the current message",
-	      "smartnarrow [-i | --instance]",
+	      "smartzpunt [-i | --instance]",
 	      "Starts a zpunt command based on the current message's class\n"
 	      "(and instance if -i is specified).\n"),
@@ -248,5 +248,10 @@
 
   OWLCMD_VOID("last", owl_command_last, OWL_CTX_INTERACTIVE,
-	      "move the pointer to the last message", "", ""),
+	      "move the pointer to the last message", "", 
+	      "Moves the pointer to the last message in the view.\n"
+	      "If we are already at the last message in the view,\n"
+	      "blanks the screen and moves just past the end of the view\n"
+	      "so that new messages will appear starting at the top\n"
+	      "of the screen.\n"),
   OWLCMD_ALIAS("recv:last", "last"),
 
Index: functions.c
===================================================================
--- functions.c	(revision 9bd2c178df9e3d3332b6643c78796fbd069738f3)
+++ functions.c	(revision 5eeea3bf29b5ab1d821dbd35697404c06eb5eed8)
@@ -375,4 +375,8 @@
   v=owl_global_get_current_view(&g);
   ml=owl_global_get_msglist(&g);
+
+  /* just check to make sure we're in bounds... */
+  if (curmsg>owl_view_get_size(v)-1) curmsg=owl_view_get_size(v)-1;
+  if (curmsg<0) curmsg=0;
 
   /* first try to move to an undeleted message in the view*/
@@ -389,5 +393,4 @@
 
     /* if we weren't successful try to find one backwards */
-    curmsg=owl_global_get_curmsg(&g);
     if (owl_message_is_delete(owl_view_get_element(v, curmsg))) {
       for (i=curmsg; i>0; i--) {
@@ -431,13 +434,20 @@
 
 void owl_function_lastmsg_noredisplay() {
-  int curmsg;
+  int oldcurmsg, curmsg;
   owl_view *v;
 
   v=owl_global_get_current_view(&g);
-  
-  curmsg=owl_view_get_size(v)-1;
+  oldcurmsg=owl_global_get_curmsg(&g);
+  curmsg=owl_view_get_size(v)-1;  
   if (curmsg<0) curmsg=0;
   owl_global_set_curmsg(&g, curmsg);
-  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
+  if (oldcurmsg < curmsg) {
+    owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
+  } else if (curmsg<owl_view_get_size(v)) {
+    /* If already at the end, blank the screen and move curmsg
+     * past the end of the messages. */
+    owl_global_set_topmsg(&g, curmsg+1);
+    owl_global_set_curmsg(&g, curmsg+1);
+  } 
   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
   owl_global_set_direction_downwards(&g);
@@ -631,10 +641,11 @@
   v=owl_global_get_current_view(&g);
   
-  if (owl_view_get_size(v)==0) {
+  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
+
+  if (!m || owl_view_get_size(v)==0) {
     owl_function_makemsg("No current message selected");
     return;
   }
 
-  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
   text=owl_message_get_text(m);
 
@@ -1056,10 +1067,11 @@
   v=owl_global_get_current_view(&g);
   
-  if (owl_view_get_size(v)==0) {
+  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
+
+  if (!m || owl_view_get_size(v)==0) {
     owl_function_makemsg("No message selected\n");
     return;
   }
 
-  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
   if (!owl_message_is_zephyr(m)) {
     sprintf(buff,   "Owl Message Id: %i\n", owl_message_get_id(m));
@@ -1158,10 +1170,11 @@
   pw=owl_global_get_popwin(&g);
 
-  if (owl_view_get_size(v)==0) {
+  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
+
+  if (!m || owl_view_get_size(v)==0) {
     owl_function_makemsg("No current message");
     return;
   }
 
-  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
   owl_function_popless_fmtext(owl_message_get_fmtext(m));
 }
@@ -1177,7 +1190,7 @@
   offset=owl_global_get_curmsg_vert_offset(&g);
   v=owl_global_get_current_view(&g);
-  if (owl_view_get_size(v)==0) return;
   curmsg=owl_global_get_curmsg(&g);
   m=owl_view_get_element(v, curmsg);
+  if (!m || owl_view_get_size(v)==0) return;
   lines=owl_message_get_numlines(m);
 
@@ -1479,4 +1492,9 @@
     
     m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g));
+    if (!m) {
+      owl_function_makemsg("No message selected");
+      return;
+    }
+
 
     /* first check if we catch the reply-lockout filter */
@@ -1986,5 +2004,5 @@
   m=owl_view_get_element(v, owl_global_get_curmsg(&g));
 
-  if (owl_view_get_size(v)==0) {
+  if (!m || owl_view_get_size(v)==0) {
     owl_function_makemsg("No message selected\n");
     return NULL;
@@ -2033,5 +2051,5 @@
   m=owl_view_get_element(v, owl_global_get_curmsg(&g));
 
-  if (owl_view_get_size(v)==0) {
+  if (!m || owl_view_get_size(v)==0) {
     owl_function_makemsg("No message selected\n");
     return;
Index: mainwin.c
===================================================================
--- mainwin.c	(revision f2e36b55e049ea4bedc8dfa6b96f20072e4edaa1)
+++ mainwin.c	(revision 5eeea3bf29b5ab1d821dbd35697404c06eb5eed8)
@@ -10,5 +10,5 @@
 void owl_mainwin_redisplay(owl_mainwin *mw) {
   owl_message *m;
-  int i, j, p, q, lines, isfull;
+  int i, p, q, lines, isfull, viewsize;
   int x, y, savey, recwinlines, start;
   int topmsg, curmsg, color;
@@ -27,8 +27,12 @@
   recwinlines=owl_global_get_recwin_lines(&g);
   topmsg=owl_global_get_topmsg(&g);
+  viewsize=owl_view_get_size(v);
 
-  /* if there are no messages, just draw a blank screen */
-  if (owl_view_get_size(v)==0) {
-    owl_global_set_topmsg(&g, 0);
+  /* if there are no messages or if topmsg is past the end of the messages,
+   * just draw a blank screen */
+  if (viewsize==0 || topmsg>=viewsize) {
+    if (viewsize==0) {
+      owl_global_set_topmsg(&g, 0);
+    }
     mw->curtruncated=0;
     mw->lastdisplayed=-1;
@@ -42,6 +46,6 @@
   mw->curtruncated=0;
   mw->lasttruncated=0;
-  j=owl_view_get_size(v);
-  for (i=topmsg; i<j; i++) {
+
+  for (i=topmsg; i<viewsize; i++) {
     if (isfull) break;
     m=owl_view_get_element(v, i);
