Index: functions.c
===================================================================
--- functions.c	(revision 67b959cc0ae9cbf49b8d9bcdf3fdbcb1f50b2509)
+++ functions.c	(revision a16d7e5b1281bf21e0fe52b6d9946fd58893da28)
@@ -127,5 +127,5 @@
 
   text=""
-    "barnowl version " OWL_VERSION_STRING "\n"
+    "BarnOwl version " OWL_VERSION_STRING "\n"
     "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n"
     "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
@@ -144,6 +144,6 @@
     "\n"
     "   * Redistributions in any form must be accompanied by information on\n"
-    "     how to obtain complete source code for the Owl software and any\n"
-    "     accompanying software that uses the Owl software. The source code\n"
+    "     how to obtain complete source code for the BarnOwl software and any\n"
+    "     accompanying software that uses the BarnOwl software. The source code\n"
     "     must either be included in the distribution or be available for no\n"
     "     more than the cost of distribution plus a nominal fee, and must be\n"
@@ -662,34 +662,4 @@
 }
 
-void owl_function_delete_and_expunge_message(int n)
-{
-  owl_messagelist *ml = owl_global_get_msglist(&g);
-  owl_view *v = owl_global_get_current_view(&g);
-  int lastmsgid = owl_function_get_curmsg_id(v);
-
-  /* delete and expunge the message */
-  owl_messagelist_delete_and_expunge_element(ml, n);
-
-  owl_function_redisplay_to_nearest(lastmsgid, v);
-}
-
-void owl_function_delete_and_expunge_cur(bool exclaim_success)
-{
-  int curmsg;
-  const owl_view *v = owl_global_get_current_view(&g);
-
-  /* bail if there's no current message */
-  if (owl_view_get_size(v) < 1) {
-    owl_function_error("No current message to delete");
-    return;
-  }
-
-  /* delete the current message */
-  curmsg = owl_global_get_curmsg(&g);
-  owl_function_delete_and_expunge_message(curmsg);
-  if (exclaim_success)
-    owl_function_makemsg("Message deleted and expunged");
-}
-
 /* if move_after is 1, moves after the delete */
 void owl_function_deletecur(int move_after)
@@ -751,60 +721,38 @@
 }
 
-/* returns the current message id, if it exists.  Otherwise returns
- * -1 if we are past the end of the message list, and 0 otherwise. */
-int owl_function_get_curmsg_id(const owl_view *v)
-{
-  int curmsg = owl_global_get_curmsg(&g);
-  const owl_message *m = owl_view_get_element(v, curmsg);
-  if (m)
-    return owl_message_get_id(m);
-  if (curmsg > 0) /* past the end of the message list (probably) */
-    return -1;
-  return 0;
-}
-
-/* redisplays the view to the nearest message to the id given.
- * if msgid < 0, redisplay to past the end of the message list */
-void owl_function_redisplay_to_nearest(int msgid, owl_view *v)
+void owl_function_expunge(void)
 {
   int curmsg;
+  const owl_message *m;
+  owl_messagelist *ml;
+  owl_view *v;
+  int lastmsgid=0;
+
+  curmsg=owl_global_get_curmsg(&g);
+  v=owl_global_get_current_view(&g);
+  ml=owl_global_get_msglist(&g);
+
+  m=owl_view_get_element(v, curmsg);
+  if (m) lastmsgid = owl_message_get_id(m);
+
+  /* expunge the message list */
+  owl_messagelist_expunge(ml);
+
   /* update all views (we only have one right now) */
   owl_view_recalculate(v);
 
-  /* find where the new position should be */
-  if (msgid < 0) {
-    /* If already at the end, blank the screen and move curmsg
-     * past the end of the messages. */
-    curmsg = owl_view_get_size(v);
-    owl_global_set_topmsg(&g, curmsg);
-    owl_global_set_curmsg(&g, curmsg);
-  } else {
-    curmsg = owl_view_get_nearest_to_msgid(v, msgid);
-    if (curmsg > owl_view_get_size(v) - 1)
-      curmsg = owl_view_get_size(v) - 1;
-    if (curmsg < 0)
-      curmsg = 0;
-    owl_global_set_curmsg(&g, curmsg);
-    owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
-  }
+  /* find where the new position should be
+     (as close as possible to where we last where) */
+  curmsg = owl_view_get_nearest_to_msgid(v, lastmsgid);
+  if (curmsg>owl_view_get_size(v)-1) curmsg = owl_view_get_size(v)-1;
+  if (curmsg<0) curmsg = 0;
+  owl_global_set_curmsg(&g, curmsg);
+  owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
   /* if there are no messages set the direction to down in case we
-   * delete everything upwards */
+     delete everything upwards */
   owl_global_set_direction_downwards(&g);
-
-  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
-}
-
-void owl_function_expunge(void)
-{
-  owl_messagelist *ml = owl_global_get_msglist(&g);
-  owl_view *v = owl_global_get_current_view(&g);
-  int lastmsgid = owl_function_get_curmsg_id(v);
-
-  /* expunge the message list */
-  owl_messagelist_expunge(ml);
-
-  owl_function_redisplay_to_nearest(lastmsgid, v);
   
   owl_function_makemsg("Messages expunged");
+  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
 }
 
@@ -1024,5 +972,5 @@
   }
 
-  owl_function_debugmsg("Quitting Owl");
+  owl_function_debugmsg("Quitting BarnOwl");
   owl_select_quit_loop();
 }
@@ -1357,6 +1305,6 @@
 {
   owl_function_popless_text(
-    "This is barnowl version " OWL_VERSION_STRING ".\n\n"
-    "barnowl is a fork of the Owl zephyr client, written and\n"
+    "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
+    "BarnOwl is a fork of the Owl zephyr client, written and\n"
     "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
     "Massachusetts Institute of Technology. \n"
@@ -1367,5 +1315,5 @@
     "The name 'owl' was chosen in reference to the owls in the\n"
     "Harry Potter novels, who are tasked with carrying messages\n"
-    "between Witches and Wizards. The name 'barnowl' was chosen\n"
+    "between Witches and Wizards. The name 'BarnOwl' was chosen\n"
     "because we feel our owls should live closer to our ponies.\n"
     "\n"
@@ -1491,5 +1439,5 @@
   }
 
-  owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
+  owl_fmtext_append_bold(&fm, "\nBarnOwl Message Attributes:\n");
   owl_message_attributes_tofmtext(m, &attrfm);
   owl_fmtext_append_fmtext(&fm, &attrfm);
@@ -1624,4 +1572,5 @@
 void owl_function_printallvars(void)
 {
+  const owl_variable *v;
   const char *name;
   char *var;
@@ -1637,8 +1586,11 @@
     if (name && name[0]!='_') {
       g_string_append_printf(str, "\n%-20s = ", name);
-      var = owl_variable_get_tostring(owl_global_get_vardict(&g), name);
+      v = owl_variable_get_var(owl_global_get_vardict(&g), name);
+      var = owl_variable_get_tostring(v);
       if (var) {
-	g_string_append(str, var);
-	g_free(var);
+        g_string_append(str, var);
+        g_free(var);
+      } else {
+        g_string_append(str, "<null>");
       }
     }
@@ -1653,4 +1605,5 @@
 void owl_function_show_variables(void)
 {
+  const owl_variable *v;
   GPtrArray *varnames;
   owl_fmtext fm;  
@@ -1665,5 +1618,6 @@
     varname = varnames->pdata[i];
     if (varname && varname[0]!='_') {
-      owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
+      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
+      owl_variable_describe(v, &fm);
     }
   }
@@ -1675,23 +1629,15 @@
 void owl_function_show_variable(const char *name)
 {
+  const owl_variable *v;
   owl_fmtext fm;  
 
   owl_fmtext_init_null(&fm);
-  owl_variable_get_help(owl_global_get_vardict(&g), name, &fm);
+  v = owl_variable_get_var(owl_global_get_vardict(&g), name);
+  if (v)
+    owl_variable_get_help(v, &fm);
+  else
+    owl_fmtext_append_normal(&fm, "No such variable...\n");
   owl_function_popless_fmtext(&fm);
   owl_fmtext_cleanup(&fm);
-}
-
-void owl_function_delete_and_expunge_by_id(int id, bool exclaim_success)
-{
-  const owl_messagelist *ml = owl_global_get_msglist(&g);
-  int msg = owl_messagelist_get_index_by_id(ml, id);
-  if (msg < 0) {
-    owl_function_error("No message with id %d: unable to delete", id);
-  } else {
-    owl_function_delete_and_expunge_message(msg);
-    if (exclaim_success)
-      owl_function_makemsg("Message deleted and expunged");
-  }
 }
 
