Changeset 8a5b5a1


Ignore:
Timestamp:
Apr 2, 2010, 10:40:39 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
e2cbbbe
Parents:
66e409c
git-author:
Nelson Elhage <nelhage@mit.edu> (04/02/10 21:02:30)
git-committer:
Nelson Elhage <nelhage@mit.edu> (04/02/10 22:40:39)
Message:
Add option to smartnarrow to temporarily invert narrow-related.

Bind this to M-n and M-M.

Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
[nelhage@mit.edu: Rename modnarrow → narrow-related]
Signed-off-by: Nelson Elhage <nelhage@mit.edu>
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r66e409c r8a5b5a1  
     1#include <getopt.h>
    12#include <stdio.h>
    23#include <stdlib.h>
     
    592593  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
    593594              "view only messages similar to the current message",
    594               "smartnarrow [-i | --instance]",
     595              "smartnarrow [-i | --instance]  [-r | --relatde]",
    595596              "If the curmsg is a personal message narrow\n"
    596597              "   to the conversation with that user.\n"
     
    600601              "    to the class.\n"
    601602              "If the curmsg is a class message and '-i' is specified\n"
    602               "    then narrow to the class and instance.\n"),
     603              "    then narrow to the class and instance.\n"
     604              "If '-r' or '--related' is specified, behave as though the\n"
     605              "    'narrow-related' variable was inverted."),
    603606
    604607  OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE,
     
    12381241      argc-=2; argv+=2;
    12391242    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
    1240       filter = owl_function_smartfilter(0);
     1243      filter = owl_function_smartfilter(0, 0);
    12411244      argc-=2; argv+=2;
    12421245    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
    1243       filter = owl_function_smartfilter(1);
     1246      filter = owl_function_smartfilter(1, 0);
    12441247      argc-=2; argv+=2;
    12451248    } else {
     
    12681271      argc-=2; argv+=2;
    12691272    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
    1270       filter = owl_function_smartfilter(0);
     1273      filter = owl_function_smartfilter(0, 0);
    12711274      argc-=2; argv+=2;
    12721275    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
    1273       filter = owl_function_smartfilter(1);
     1276      filter = owl_function_smartfilter(1, 0);
    12741277      argc-=2; argv+=2; 
    12751278   } else {
     
    12871290  char *filtname = NULL;
    12881291
    1289   if (argc == 1) {
    1290     filtname = owl_function_smartfilter(0);
    1291   } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
    1292     filtname = owl_function_smartfilter(1);
    1293   } else {
    1294     owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
    1295   }
     1292  char opt;
     1293  int instance = 0, related = 0, i;
     1294  char **tmp_argv = owl_malloc(sizeof(char *) * argc);
     1295
     1296  for (i = 0; i < argc; i++)
     1297    tmp_argv[i] = owl_strdup(argv[i]);
     1298
     1299  static struct option options[] = {
     1300    {"instance", 0, 0, 'i'},
     1301    {"related",  0, 0, 'r'},
     1302    {NULL,       0, 0, 0}};
     1303  while ((opt = getopt_long(argc, tmp_argv, "ir", options, NULL)) != -1) {
     1304    switch (opt) {
     1305      case 'i':
     1306        instance = 1;
     1307        break;
     1308      case 'r':
     1309        related = 1;
     1310        break;
     1311      default:
     1312        owl_function_makemsg("Wrong number of arguments for %s (%c)", argv[0], opt);
     1313        goto done;
     1314    }
     1315  }
     1316
     1317  for (i = 0; i < argc; i++)
     1318    owl_free(tmp_argv[i]);
     1319  owl_free(tmp_argv);
     1320
     1321  filtname = owl_function_smartfilter(instance, related);
     1322
    12961323  if (filtname) {
    12971324    owl_function_change_currentview_filter(filtname);
    12981325    owl_free(filtname);
    12991326  }
     1327
     1328done:
     1329  optind = 0; /* reset getopt */
    13001330  return NULL;
    13011331}
     
    13061336
    13071337  if (argc == 1) {
    1308     filtname = owl_function_smartfilter(0);
     1338    filtname = owl_function_smartfilter(0, 0);
    13091339  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
    1310     filtname = owl_function_smartfilter(1);
     1340    filtname = owl_function_smartfilter(1, 0);
    13111341  } else {
    13121342    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
  • functions.c

    r66e409c r8a5b5a1  
    25112511 *    name to the AIM conversation with that user
    25122512 */
    2513 char *owl_function_smartfilter(int type)
     2513char *owl_function_smartfilter(int type, int invert_related)
    25142514{
    25152515  const owl_view *v;
     
    25172517  char *zperson, *filtname=NULL;
    25182518  const char *argv[2];
    2519   int related = owl_global_is_narrow_related(&g);
    2520  
     2519  int related = owl_global_is_narrow_related(&g) ^ invert_related;
     2520
    25212521  v=owl_global_get_current_view(&g);
    25222522  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
  • keys.c

    r8830df47 r8a5b5a1  
    246246  BIND_CMD("M-n", "smartnarrow",      "narrow to a view based on the current message");
    247247  BIND_CMD("M-N", "smartnarrow -i",   "narrow to a view based on the current message, and consider instance pair");
     248  BIND_CMD("M-m", "smartnarrow -r",   "like M-n but with 'narrow-related' temporarily flipped.");
     249  BIND_CMD("M-M", "smartnarrow -ri",  "like M-N but with 'narrow-related' temporarily flipped.");
    248250  BIND_CMD("M-p", "view personal", "");
    249251 
Note: See TracChangeset for help on using the changeset viewer.