Changeset 7360fab for functions.c


Ignore:
Timestamp:
Jun 29, 2002, 1:21:36 PM (19 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, 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"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.