Changeset 7360fab


Ignore:
Timestamp:
Jun 29, 2002, 1:21:36 PM (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:
d36f2cb
Parents:
855ebe7
Message:
	Made owl_function_fast*filt return a string and not do the
	        narrowing, to make it more general.
	Added a smartfilter command that creates a filter
	        based on the current message and returns the name
		of the filter.
	Added --smart-filter and --smart-filter-instance options
	        to the next and prev commands.
	Added M-C-n and M-C-p keybindings to "move to next message
	        matching current" and "move to previous message
		matching current"
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r855ebe7 r7360fab  
    1919        Updated examples/owlconf.erik with the above.
    2020        Fixed the annoying pagedown sometimes-not-working bug.
     21        Made owl_function_fast*filt return a string and not do the
     22                narrowing, to make it more general.
     23        Added a smartfilter command that creates a filter
     24                based on the current message and returns the name
     25                of the filter.
     26        Added --smart-filter and --smart-filter-instance options
     27                to the next and prev commands.
     28        Added M-C-n and M-C-p keybindings to "move to next message
     29                matching current" and "move to previous message
     30                matching current"
    2131       
    22321.2.0-pre-erikdevel-17
  • commands.c

    rb950088 r7360fab  
    195195  OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE,
    196196              "move the pointer to the next message",
    197               "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]",
     197              "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]\n"
     198              "          [ --smart-filter | --smart-filter-instance ]",
    198199              "Moves the pointer to the next message in the current view.\n"
    199200              "If --filter is specified, will only consider messages in\n"
    200201              "the filter <name>.\n"
     202              "If --smart-filter or --smart-filter-instance is specified,\n"
     203              "goes to the next message that is similar to the current message.\n"
    201204              "If --skip-deleted is specified, deleted messages will\n"
    202205              "be skipped.\n"
     
    207210  OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
    208211              "move the pointer to the previous message",
    209               "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]",
     212              "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]\n"
     213              "          [ --smart-filter | --smart-filter-instance ]",
    210214              "Moves the pointer to the next message in the current view.\n"
    211215              "If --filter is specified, will only consider messages in\n"
    212216              "the filter <name>.\n"
     217              "If --smart-filter or --smart-filter-instance is specified,\n"
     218              "goes to the previous message that is similar to the current message.\n"
    213219              "If --skip-deleted is specified, deleted messages will\n"
    214220              "be skipped.\n"
     
    366372  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
    367373              "view only messages similar to the current message",
    368               "smartnarrow [-i]",
     374              "smartnarrow [-i | --instance]",
    369375              "If the curmsg is a personal message narrow\n"
    370376              "   to the converstaion with that user.\n"
     
    375381              "If the curmsg is a class message and '-i' is specied\n"
    376382              "    then narrow to the class, instance\n"),
     383
     384  OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE,
     385              "returns the name of a filter based on the current message",
     386              "smartfilter [-i | --instance]",
     387              "If the curmsg is a personal message, the filter is\n"
     388              "   the converstaion with that user.\n"
     389              "If the curmsg is a class message, instance foo, recip *\n"
     390              "   message, the filter is the class, inst.\n"
     391              "If the curmsg is a class message, the filter is that class.\n"
     392              "If the curmsg is a class message and '-i' is specied\n"
     393              "    the filter is that <class,instance> pair\n"),
    377394
    378395  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
     
    672689      argc-=1; argv+=1;
    673690    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
    674       filter = argv[2];
     691      filter = owl_strdup(argv[2]);
     692      argc-=2; argv+=2;
     693    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
     694      filter = owl_function_smartfilter(0);
     695      argc-=2; argv+=2;
     696    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
     697      filter = owl_function_smartfilter(1);
    675698      argc-=2; argv+=2;
    676699    } else {
     
    680703  }
    681704  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
     705  if (filter) owl_free(filter);
    682706  return(NULL);
    683707}
     
    694718      argc-=1; argv+=1;
    695719    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
    696       filter = argv[2];
     720      filter = owl_strdup(argv[2]);
    697721      argc-=2; argv+=2;
    698     } else {
     722    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
     723      filter = owl_function_smartfilter(0);
     724      argc-=2; argv+=2;
     725    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
     726      filter = owl_function_smartfilter(1);
     727      argc-=2; argv+=2; 
     728   } else {
    699729      owl_function_makemsg("Invalid arguments to command 'prev'.");
    700730      return(NULL);
     
    702732  }
    703733  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
     734  if (filter) owl_free(filter);
    704735  return(NULL);
    705736}
    706737
    707738char *owl_command_smartnarrow(int argc, char **argv, char *buff) {
     739  char *filtname = NULL;
     740
    708741  if (argc == 1) {
    709     owl_function_smartnarrow(0);
    710   } else if (argc == 2 && !strcmp(argv[1], "-i")) {
    711     owl_function_smartnarrow(1);
     742    filtname = owl_function_smartfilter(0);
     743  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
     744    filtname = owl_function_smartfilter(1);
    712745  } else {
    713746    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
    714747  }
    715   return NULL;
     748  if (filtname) {
     749    owl_function_change_view(filtname);
     750    owl_free(filtname);
     751  }
     752  return NULL;
     753}
     754
     755char *owl_command_smartfilter(int argc, char **argv, char *buff) {
     756  char *filtname = NULL;
     757
     758  if (argc == 1) {
     759    filtname = owl_function_smartfilter(0);
     760  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
     761    filtname = owl_function_smartfilter(1);
     762  } else {
     763    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
     764  }
     765  return filtname;
    716766}
    717767
     
    11831233
    11841234char *owl_command_viewclass(int argc, char **argv, char *buff) {
     1235  char *filtname;
    11851236  if (argc!=2) {
    11861237    owl_function_makemsg("Wrong number of arguments to viewclass command");
    11871238    return NULL;
    11881239  }
    1189   owl_function_fastclassinstfilt(argv[1], NULL);
     1240  filtname = owl_function_fastclassinstfilt(argv[1], NULL);
     1241  owl_function_change_view(filtname);
     1242  owl_free(filtname);
    11901243  return NULL;
    11911244}
    11921245
    11931246char *owl_command_viewuser(int argc, char **argv, char *buff) {
     1247  char *filtname;
    11941248  if (argc!=2) {
    11951249    owl_function_makemsg("Wrong number of arguments to viewuser command");
    11961250    return NULL;
    11971251  }
    1198   owl_function_fastuserfilt(argv[1]);
     1252  filtname = owl_function_fastuserfilt(argv[1]);
     1253  owl_function_change_view(filtname);
     1254  owl_free(filtname);
    11991255  return NULL;
    12001256}
     
    12331289  }
    12341290
    1235   if (argc==3 && !strcmp(argv[1], "-id")) {
     1291  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
    12361292    owl_function_delete_by_id(atoi(argv[2]), 1);
    12371293    return NULL;
     
    12611317  }
    12621318
    1263   if (argc==3 && !strcmp(argv[1], "-id")) {
     1319  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
    12641320    owl_function_delete_by_id(atoi(argv[2]), 0);
    12651321    return NULL;
  • functions.c

    r855ebe7 r7360fab  
    16831683}
    16841684
    1685 void owl_function_fastclassinstfilt(char *class, char *instance) {
    1686   /* narrow to the current class, instance.  If instance is null then
    1687      just narrow to the current class */
     1685char *owl_function_fastclassinstfilt(char *class, char *instance) {
     1686  /* creates a filter for a class, instance if one doesn't exist.
     1687   * If instance is null then apply for all messgaes in the class.
     1688   * returns the name of the filter, which the caller must free.*/
    16881689  owl_list *fl;
    16891690  owl_filter *f;
     
    17061707  /* if it already exists then go with it.  This lets users override */
    17071708  if (owl_global_get_filter(&g, filtname)) {
    1708     owl_function_change_view(filtname);
    1709     owl_free(filtname);
    1710     return;
     1709    return filtname;
    17111710  }
    17121711
     
    17241723  owl_global_add_filter(&g, f);
    17251724
    1726   /* set the current view to use it */
    1727   owl_function_change_view(filtname);
    1728 
    17291725  owl_free(argbuff);
    1730   owl_free(filtname);
    1731 }
    1732 
    1733 void owl_function_fastuserfilt(char *user) {
     1726  return filtname;
     1727}
     1728
     1729char *owl_function_fastuserfilt(char *user) {
    17341730  owl_filter *f;
    17351731  char *argbuff, *longuser, *shortuser, *filtname;
     
    17451741  /* if it already exists then go with it.  This lets users override */
    17461742  if (owl_global_get_filter(&g, filtname)) {
    1747     owl_function_change_view(filtname);
    1748     owl_free(filtname);
    1749     return;
     1743    return filtname;
    17501744  }
    17511745
     
    17631757  owl_global_add_filter(&g, f);
    17641758
    1765   /* set the current view to use it */
    1766   owl_function_change_view(filtname);
    1767 
    17681759  /* free stuff */
    17691760  owl_free(argbuff);
    1770   owl_free(filtname);
    17711761  owl_free(longuser);
    17721762  owl_free(shortuser);
    1773    
     1763
     1764  return filtname;
    17741765}
    17751766
     
    17951786}
    17961787
    1797 void owl_function_smartnarrow(int type) {
    1798   /* if the curmsg is a personal message narrow
     1788char *owl_function_smartfilter(int type) {
     1789  /* Returns the name of a filter, or null.  The caller
     1790   * must free this name.  */
     1791  /* if the curmsg is a personal message return a filter name
    17991792   *    to the converstaion with that user.
    18001793   * If the curmsg is a class message, instance foo, recip *
    1801    *    message, narrow to the class, inst.
    1802    * If the curmsg is a class message and type==0 then narrow
    1803    *    to the class
    1804    * If the curmsg is a class message and type==1 then narrow
    1805    *    to the class, instance
     1794   *    message, return a filter name to the class, inst.
     1795   * If the curmsg is a class message and type==0 then
     1796   *    return a filter name for just the class.
     1797   * If the curmsg is a class message and type==1 then
     1798   *    return a filter name for the class and instance.
    18061799   */
    18071800  owl_view *v;
    18081801  owl_message *m;
    1809   char *sender;
     1802  char *sender, *filtname=NULL;
    18101803 
    18111804  v=owl_global_get_current_view(&g);
     
    18141807  if (owl_view_get_size(v)==0) {
    18151808    owl_function_makemsg("No message selected\n");
    1816     return;
     1809    return NULL;
    18171810  }
    18181811
     
    18201813  if (owl_message_is_admin(m)) {
    18211814    owl_function_makemsg("Narrowing on an admin message has not been implemented yet.  Check back soon.");
    1822     return;
     1815    return NULL;
    18231816  }
    18241817
     
    18271820    if (owl_message_is_zephyr(m)) {
    18281821      sender=pretty_sender(owl_message_get_sender(m));
    1829       owl_function_fastuserfilt(sender);
    1830       free(sender);
    1831     }
    1832     return;
     1822      filtname = owl_function_fastuserfilt(sender);
     1823      owl_free(sender);
     1824      return filtname;
     1825    }
     1826    return NULL;
    18331827  }
    18341828
     
    18361830  if (!strcasecmp(owl_message_get_class(m), "message") &&
    18371831      !owl_message_is_personal(m)) {
    1838     owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
    1839     return;
     1832    filtname = owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     1833    return filtname;
    18401834  }
    18411835
    18421836  /* otherwise narrow to the class */
    18431837  if (type==0) {
    1844     owl_function_fastclassinstfilt(owl_message_get_class(m), NULL);
     1838    filtname = owl_function_fastclassinstfilt(owl_message_get_class(m), NULL);
    18451839  } else if (type==1) {
    1846     owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
    1847   }
     1840    filtname = owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     1841  }
     1842  return filtname;
    18481843}
    18491844
  • keys.c

    r1aee7d9 r7360fab  
    200200  BIND_CMD("DOWN",   "recv:next",      "");
    201201  BIND_CMD("C-n",    "recv:next",      "");
     202  BIND_CMD("M-C-n",  "recv:next --smart-filter", "move to next message matching the current one");
    202203  BIND_CMD("UP",     "recv:prev",      "");
    203204  BIND_CMD("n",      "recv:next-notdel", "");
    204205  BIND_CMD("p",      "recv:prev-notdel", "");
    205206  BIND_CMD("C-p",    "recv:prev",        "");
     207  BIND_CMD("M-C-p",  "recv:prev --smart-filter", "move to previous message matching the current one");
    206208  BIND_CMD("P",      "recv:next-personal", "");
    207209  BIND_CMD("M-P",    "recv:prev-personal", "");
Note: See TracChangeset for help on using the changeset viewer.