Changeset b950088


Ignore:
Timestamp:
Jun 29, 2002, 11:55:06 AM (22 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
855ebe7
Parents:
61d27fb
Message:
* Added --no-move option to delete command.
        In particular, delete-and-always-move-down may now
	be implemented with
	'( delete --no-move ; next --skip-deleted )'.
* Folded the nextmsg and prevmsg commands and functions together into
        one command which takes arguments.
	Added '--filter <name>' option (eg, for next_personal),
	'--skip-deleted' option, and
	'--last-if-none'/'--first-if-none' options.
	Help updated accordingly.
	In particular, the 'personal' view is now used
	for 'next personal'.
* Updated examples/owlconf.erik with the above.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r1aee7d9 rb950088  
    55        Added RCS Id strings to all files.
    66        'show keymaps' shows details of all keymaps after summary list.
     7        Added --no-move option to delete command.
     8                In particular, delete-and-always-move-down may now
     9                be implemented with
     10                '( delete --no-move ; next --skip-deleted )'.
     11        Folded the nextmsg and prevmsg commands and functions together into
     12                one command which takes arguments.
     13                Added '--filter <name>' option (eg, for next_personal),
     14                '--skip-deleted' option, and
     15                '--last-if-none'/'--first-if-none' options.
     16                Help updated accordingly. 
     17                In particular, the 'personal' view is now used
     18                for 'next personal'. 
     19        Updated examples/owlconf.erik with the above.
    720       
    8211.2.0-pre-erikdevel-17
  • commands.c

    r1aee7d9 rb950088  
    193193              "Scrolls up if <numlines> is negative, else scrolls down.\n"),
    194194
    195   OWLCMD_VOID("next", owl_command_next, OWL_CTX_INTERACTIVE,
    196               "move the pointer to the next message", "", ""),
     195  OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE,
     196              "move the pointer to the next message",
     197              "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]",
     198              "Moves the pointer to the next message in the current view.\n"
     199              "If --filter is specified, will only consider messages in\n"
     200              "the filter <name>.\n"
     201              "If --skip-deleted is specified, deleted messages will\n"
     202              "be skipped.\n"
     203              "If --last-if-none is specified, will stop at last message\n"
     204              "in the view if no other suitable messages are found.\n"),
    197205  OWLCMD_ALIAS("recv:next", "next"),
    198206
    199   OWLCMD_VOID("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
    200               "move the pointer to the previous message", "", ""),
     207  OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
     208              "move the pointer to the previous message",
     209              "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]",
     210              "Moves the pointer to the next message in the current view.\n"
     211              "If --filter is specified, will only consider messages in\n"
     212              "the filter <name>.\n"
     213              "If --skip-deleted is specified, deleted messages will\n"
     214              "be skipped.\n"
     215              "If --first-if-none is specified, will stop at first message\n"
     216              "in the view if no other suitable messages are found.\n"),
    201217  OWLCMD_ALIAS("recv:prev", "prev"),
    202218
    203   OWLCMD_VOID("next-notdel", owl_command_next_notdeleted, OWL_CTX_INTERACTIVE,
    204               "move the pointer to the next non-deleted message", "", ""),
    205   OWLCMD_ALIAS("recv:next-notdel", "next-notdel"),
    206 
    207   OWLCMD_VOID("prev-notdel", owl_command_prev_notdeleted, OWL_CTX_INTERACTIVE,
    208               "move the pointer to the previous non-deleted message", "", ""),
    209   OWLCMD_ALIAS("recv:prev-notdel", "prev-notdel"),
    210 
    211   OWLCMD_VOID("recv:next-personal", owl_function_next_personal,
    212               OWL_CTX_INTERACTIVE,
    213               "move the pointer to the next personal message", "", ""),
    214 
    215   OWLCMD_VOID("recv:prev-personal", owl_function_prev_personal,
    216               OWL_CTX_INTERACTIVE,
    217               "move the pointer to the previous personal message", "", ""),
     219  OWLCMD_ALIAS("recv:next-notdel", "recv:next --skip-deleted --last-if-none"),
     220  OWLCMD_ALIAS("next-notdel",      "recv:next --skip-deleted --last-if-none"),
     221
     222  OWLCMD_ALIAS("recv:prev-notdel", "recv:prev --skip-deleted --first-if-none"),
     223  OWLCMD_ALIAS("prev-notdel",      "recv:prev --skip-deleted --first-if-none"),
     224
     225  OWLCMD_ALIAS("recv:next-personal", "recv:next --filter personal"),
     226
     227  OWLCMD_ALIAS("recv:prev-personal", "recv:prev --filter personal"),
    218228
    219229  OWLCMD_VOID("first", owl_command_first, OWL_CTX_INTERACTIVE,
     
    417427  OWLCMD_ARGS("delete", owl_command_delete, OWL_CTX_INTERACTIVE,
    418428              "mark a message for deletion",
    419               "delete [ -id msgid ]\n"
     429              "delete [ -id msgid ] [ --no-move ]\n"
    420430              "delete view\n"
    421431              "delete trash",
     
    423433              "for deletion.  Otherwise the message with the given message\n"
    424434              "id is marked for deltion.\n"
     435              "If '--no-move' is specified, don't move after deletion.\n"
    425436              "If 'trash' is specified, deletes all trash/auto messages\n"
    426437              "in the current view.\n"
     
    431442  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
    432443              "unmark a message for deletion",
    433               "undelete [ -id msgid ]\n"
     444              "undelete [ -id msgid ] [ --no-move ]\n"
    434445              "undelete view",
    435446              "If no message id is specified the current message is\n"
    436447              "unmarked for deletion.  Otherwise the message with the\n"
    437448              "given message id is marked for undeltion.\n"
     449              "If '--no-move' is specified, don't move after deletion.\n"
    438450              "If 'view' is specified, undeletes all messages\n"
    439451              "in the current view.\n"),
     
    649661}
    650662
    651 void owl_command_next() {
    652   owl_function_nextmsg();
    653 }
    654 
    655 void owl_command_prev() {
    656   owl_function_prevmsg();
    657 }
    658 
    659 void owl_command_next_notdeleted() {
    660   owl_function_nextmsg_notdeleted();
    661 }
    662 
    663 void owl_command_prev_notdeleted() {
    664   owl_function_prevmsg_notdeleted();
     663char *owl_command_next(int argc, char **argv, char *buff) {
     664  char *filter=NULL;
     665  int skip_deleted=0, last_if_none=0;
     666  while (argc>1) {
     667    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
     668      skip_deleted=1;
     669      argc-=1; argv+=1;
     670    } else if (argc>=1 && !strcmp(argv[1], "--last-if-none")) {
     671      last_if_none=1;
     672      argc-=1; argv+=1;
     673    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
     674      filter = argv[2];
     675      argc-=2; argv+=2;
     676    } else {
     677      owl_function_makemsg("Invalid arguments to command 'next'.");
     678      return(NULL);
     679    }
     680  }
     681  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
     682  return(NULL);
     683}
     684
     685char *owl_command_prev(int argc, char **argv, char *buff) {
     686  char *filter=NULL;
     687  int skip_deleted=0, first_if_none=0;
     688  while (argc>1) {
     689    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
     690      skip_deleted=1;
     691      argc-=1; argv+=1;
     692    } else if (argc>=1 && !strcmp(argv[1], "--first-if-none")) {
     693      first_if_none=1;
     694      argc-=1; argv+=1;
     695    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
     696      filter = argv[2];
     697      argc-=2; argv+=2;
     698    } else {
     699      owl_function_makemsg("Invalid arguments to command 'prev'.");
     700      return(NULL);
     701    }
     702  }
     703  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
     704  return(NULL);
    665705}
    666706
     
    11701210
    11711211char *owl_command_delete(int argc, char **argv, char *buff) {
     1212  int move_after = 1;
     1213
     1214  if (!strcmp(argv[1], "--no-move")) {
     1215    move_after = 0;
     1216    argc--;
     1217    argv++;
     1218  }
     1219
    11721220  if (argc==1) {
    1173     owl_function_deletecur();
     1221    owl_function_deletecur(move_after);
    11741222    return NULL;
    11751223  }
     
    11951243
    11961244char *owl_command_undelete(int argc, char **argv, char *buff) {
     1245  int move_after = 1;
     1246
     1247  if (!strcmp(argv[1], "--no-move")) {
     1248    move_after = 0;
     1249    argc--;
     1250    argv++;
     1251  }
     1252
    11971253  if (argc==1) {
    1198     owl_function_undeletecur();
     1254    owl_function_undeletecur(move_after);
    11991255    return NULL;
    12001256  }
  • examples/owlconf.erik

    r7d4fbcd rb950088  
    11### The owlconf config file   -*- perl -*- 
    22###  $Id$
     3
     4### !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!!
     5### This is an example file intended to demonstrate how to use
     6### various features of owl.  Some of the key bindings, in particular,
     7### are more for examples than things you may actually want to use.
     8### Make sure to read through it first and understand it before just using it.
     9### Don't blame me if anything in here ends up vaporizing your dog.
     10### !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!! !!!!!WARNING!!!!!
     11
    312###
    413### This file is interpreted by the perl interpreter.
     
    7786    owl::command("alias zc zwrite -c");
    7887
     88    # Send zephyrs with "C-c C-c". 
     89    # Note that this will cause "C-c" to not work...
    7990    owl::command("bindkey editmulti \"C-c C-c\" command editmulti:done");
     91
     92    # Make "d" ignore current movement direction
     93    owl::command("bindkey recv d command ( delete --no-move ; next --skip-deleted )");
     94
     95    # Useful keys for reading and deleting by class/instance
    8096    owl::command("bindkey recv M-k command ( smartnarrow ; delete view )");
    8197    owl::command("bindkey recv M-l command ( expunge ; view all )");
    8298    owl::command("bindkey recv M-K command ( smartnarrow ; delete view ; expunge ; view all )");
     99
     100    # Make 'M-s' insert a <scritchscritchscritch> sequence with a random
     101    # number of scritches.
    83102    owl::command(q(bindkey edit M-s command perl owl::command("edit:insert-text <".("scritch"x int(1+rand(5))).">")));
    84103
  • functions.c

    r1aee7d9 rb950088  
    176176
    177177
     178/* If filter is non-null, looks for the next message matching
     179 * that filter.  If skip_deleted, skips any deleted messages.
     180 * If last_if_none, will stop at the last message in the view
     181 * if no matching messages are found.  */
     182void owl_function_nextmsg_full(char *filter, int skip_deleted, int last_if_none) {
     183  int curmsg, i, viewsize, found;
     184  owl_view *v;
     185  owl_filter *f = NULL;
     186  owl_message *m;
     187
     188  v=owl_global_get_current_view(&g);
     189
     190  if (filter) {
     191    f=owl_global_get_filter(&g, filter);
     192    if (!f) {
     193      owl_function_makemsg("No %s filter defined", filter);
     194      return;
     195    }
     196  }
     197
     198  curmsg=owl_global_get_curmsg(&g);
     199  viewsize=owl_view_get_size(v);
     200  found=0;
     201
     202  /* just check to make sure we're in bounds... */
     203  if (curmsg>viewsize-1) curmsg=viewsize-1;
     204  if (curmsg<0) curmsg=0;
     205
     206  for (i=curmsg+1; i<viewsize; i++) {
     207    m=owl_view_get_element(v, i);
     208    if (skip_deleted && owl_message_is_delete(m)) continue;
     209    if (f && !owl_filter_message_match(f, m)) continue;
     210    found = 1;
     211    break;
     212  }
     213
     214  if (i>owl_view_get_size(v)-1) i=owl_view_get_size(v)-1;
     215
     216  if (!found) {
     217    owl_function_makemsg("already at last%s message%s%s",
     218                         skip_deleted?" non-deleted":"",
     219                         filter?" in ":"", filter?filter:"");
     220    owl_function_beep();
     221  }
     222
     223  if (last_if_none || found) {
     224    owl_global_set_curmsg(&g, i);
     225    owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
     226    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     227    owl_global_set_direction_downwards(&g);
     228  }
     229}
     230
     231void owl_function_prevmsg_full(char *filter, int skip_deleted, int first_if_none) {
     232  int curmsg, i, viewsize, found;
     233  owl_view *v;
     234  owl_filter *f = NULL;
     235  owl_message *m;
     236
     237  v=owl_global_get_current_view(&g);
     238
     239  if (filter) {
     240    f=owl_global_get_filter(&g, filter);
     241    if (!f) {
     242      owl_function_makemsg("No %s filter defined", filter);
     243      return;
     244    }
     245  }
     246
     247  curmsg=owl_global_get_curmsg(&g);
     248  viewsize=owl_view_get_size(v);
     249  found=0;
     250
     251  /* just check to make sure we're in bounds... */
     252  if (curmsg>viewsize-1) curmsg=viewsize-1;
     253  if (curmsg<0) curmsg=0;
     254
     255  for (i=curmsg-1; i>=0; i--) {
     256    m=owl_view_get_element(v, i);
     257    if (skip_deleted && owl_message_is_delete(m)) continue;
     258    if (f && !owl_filter_message_match(f, m)) continue;
     259    found = 1;
     260    break;
     261  }
     262
     263  if (i<0) i=0;
     264
     265  if (!found) {
     266    owl_function_makemsg("already at first%s message%s%s",
     267                         skip_deleted?" non-deleted":"",
     268                         filter?" in ":"", filter?filter:"");
     269    owl_function_beep();
     270  }
     271
     272  if (first_if_none || found) {
     273    owl_global_set_curmsg(&g, i);
     274    owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS);
     275    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     276    owl_global_set_direction_upwards(&g);
     277  }
     278}
    178279
    179280void owl_function_nextmsg() {
    180   int curmsg;
    181   owl_view *v;
    182 
    183   v=owl_global_get_current_view(&g);
    184  
    185   curmsg=owl_global_get_curmsg(&g);
    186   curmsg++;
    187   if (curmsg>owl_view_get_size(v)-1) {
    188     curmsg=owl_view_get_size(v)-1;
    189     if (curmsg<0) curmsg=0;
    190     owl_function_beep();
    191     owl_function_makemsg("already at last message");
    192   }
    193   owl_global_set_curmsg(&g, curmsg);
    194   owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    195 
    196   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    197   owl_global_set_direction_downwards(&g);
     281  owl_function_nextmsg_full(NULL, 0, 1);
    198282}
    199283
    200284
    201285void owl_function_prevmsg() {
    202   int curmsg;
    203  
    204   curmsg=owl_global_get_curmsg(&g);
    205   curmsg--;
    206   if (curmsg<0) {
    207     curmsg=0;
    208     owl_function_beep();
    209     owl_function_makemsg("already at first message");
    210   }
    211   owl_global_set_curmsg(&g, curmsg);
    212   owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS);
    213   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    214   owl_global_set_direction_upwards(&g);
    215 }
    216 
     286  owl_function_prevmsg_full(NULL, 0, 1);
     287}
    217288
    218289void owl_function_nextmsg_notdeleted() {
    219   int curmsg;
    220   owl_message *m;
    221   owl_view *v;
    222 
    223   v=owl_global_get_current_view(&g);
    224 
    225   curmsg=owl_global_get_curmsg(&g);
    226   while (1) {
    227     curmsg++;
    228 
    229     /* if we're out of bounds get in bounds and stop */
    230     if (curmsg>owl_view_get_size(v)-1) {
    231       curmsg=owl_view_get_size(v)-1;
    232       if (curmsg<0) curmsg=0;
    233       owl_function_makemsg("already at last non-deleted message");
    234       break;
    235     }
    236 
    237     /* if this one is not deleted we can stop where we are */
    238     m=owl_view_get_element(v, curmsg);
    239     if (!owl_message_is_delete(m)) {
    240       break;
    241     }
    242   }
    243  
    244   owl_global_set_curmsg(&g, curmsg);
    245   owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    246   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    247   owl_global_set_direction_downwards(&g);
     290  owl_function_nextmsg_full(NULL, 1, 1);
    248291}
    249292
    250293
    251294void owl_function_prevmsg_notdeleted() {
    252   int curmsg;
    253   owl_message *m;
    254   owl_view *v;
    255 
    256   v=owl_global_get_current_view(&g);
    257 
    258   curmsg=owl_global_get_curmsg(&g);
    259   while(1) {
    260     curmsg--;
    261 
    262     /* if we're out of bounds get in bounds and stop */
    263     if (curmsg<0) {
    264       curmsg=0;
    265       owl_function_makemsg("already at first non-deleted message");
    266       break;
    267     }
    268 
    269     /* if this one is not deleted we can stop where we are */
    270     m=owl_view_get_element(v, curmsg);
    271     if (!owl_message_is_delete(m)) {
    272       break;
    273     }
    274   }
    275 
    276   owl_global_set_curmsg(&g, curmsg);
    277   owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS);
    278   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    279   owl_global_set_direction_upwards(&g);
    280 }
    281 
    282 
    283 void owl_function_deletecur() {
     295  owl_function_prevmsg_full(NULL, 1, 1);
     296}
     297
     298
     299void owl_function_nextmsg_personal() {
     300  owl_function_nextmsg_full("personal", 0, 0);
     301}
     302
     303void owl_function_prevmsg_personal() {
     304  owl_function_prevmsg_full("personal", 0, 0);
     305}
     306
     307
     308/* if move_after is 1, moves after the delete */
     309void owl_function_deletecur(int move_after) {
    284310  int curmsg;
    285311  owl_view *v;
     
    297323  owl_view_delete_element(v, curmsg);
    298324
    299   /* move the poiner in the appropriate direction to the next undeleted msg */
    300   if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) {
    301     owl_command_prev_notdeleted();
    302   } else {
    303     owl_command_next_notdeleted();
    304   }
    305 }
    306 
    307 
    308 void owl_function_undeletecur() {
     325  if (move_after) {
     326    /* move the poiner in the appropriate direction
     327     * to the next undeleted msg */
     328    if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) {
     329      owl_function_prevmsg_notdeleted();
     330    } else {
     331      owl_function_nextmsg_notdeleted();
     332    }
     333  }
     334}
     335
     336
     337void owl_function_undeletecur(int move_after) {
    309338  int curmsg;
    310339  owl_view *v;
     
    320349  owl_view_undelete_element(v, curmsg);
    321350
    322   if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) {
    323     if (curmsg>0) {
    324       owl_command_prev();
     351  if (move_after) {
     352    if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) {
     353      if (curmsg>0) {
     354        owl_function_prevmsg();
     355      } else {
     356        owl_function_nextmsg();
     357      }
    325358    } else {
    326       owl_command_next();
    327     }
    328   } else {
    329     owl_command_next();
     359      owl_function_nextmsg();
     360    }
    330361  }
    331362
     
    12591290  owl_function_makemsg(buff);
    12601291  owl_global_set_needrefresh(&g);
    1261 }
    1262 
    1263 void owl_function_next_personal() {
    1264   int i, j, curmsg, found;
    1265   owl_view *v;
    1266 
    1267   v=owl_global_get_current_view(&g);
    1268   j=owl_view_get_size(v);
    1269   curmsg=owl_global_get_curmsg(&g);
    1270   found=0;
    1271   for (i=curmsg+1; i<j; i++) {
    1272     if (owl_message_is_personal(owl_view_get_element(v, i))) {
    1273       owl_global_set_curmsg(&g, i);
    1274       owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    1275       owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    1276       owl_global_set_direction_downwards(&g);
    1277       found=1;
    1278       break;
    1279     }
    1280   }
    1281   if (!found) {
    1282     owl_function_makemsg("No next personal message found");
    1283   }
    1284 }
    1285 
    1286 void owl_function_prev_personal() {
    1287   int i, curmsg, found;
    1288   owl_view *v;
    1289 
    1290   v=owl_global_get_current_view(&g);
    1291   curmsg=owl_global_get_curmsg(&g);
    1292   found=0;
    1293   for (i=curmsg-1; i>=0; i--) {
    1294     if (owl_message_is_personal(owl_view_get_element(v, i))) {
    1295       owl_global_set_curmsg(&g, i);
    1296       owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS);
    1297       owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    1298       owl_global_set_direction_upwards(&g);
    1299       found=1;
    1300       break;
    1301     }
    1302   }
    1303   if (!found) {
    1304     owl_function_makemsg("No previous personal message found");
    1305   }
    13061292}
    13071293
Note: See TracChangeset for help on using the changeset viewer.