2 This is the chdir patch by Christoph Berg <cb@df7cb.de>.
4 * Homepage: http://www.df7cb.de/projects/mutt/chdir/
8 ===================================================================
9 --- mutt/PATCHES.orig 2007-02-15 20:46:31.855875008 +0100
10 +++ mutt/PATCHES 2007-02-15 20:46:31.855875008 +0100
12 +patch-1.5.13.cb.chdir.1
14 ===================================================================
15 --- mutt.orig/init.c 2006-12-12 14:15:03.000000000 +0100
16 +++ mutt/init.c 2007-02-15 20:46:18.950836872 +0100
17 @@ -2214,6 +2214,35 @@ static int parse_source (BUFFER *tmp, BU
18 return (source_rc (path, err));
21 +static int parse_cd (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
23 + char path[_POSIX_PATH_MAX];
25 + if (mutt_extract_token (tmp, s, 0) != 0)
27 + snprintf (err->data, err->dsize, _("cd: error at %s"), s->dptr);
32 + strfcpy (err->data, _("cd: too many arguments"), err->dsize);
35 + strfcpy (path, tmp->data, sizeof (path));
36 + mutt_expand_path (path, sizeof (path));
38 + char *home = getenv("HOME");
40 + strfcpy (path, home, sizeof (path));
42 + if (chdir(path) != 0) {
43 + snprintf (err->data, err->dsize, _("cd: %s"), strerror(errno));
50 /* line command to execute
52 token scratch buffer to be used by parser. caller should free
54 ===================================================================
55 --- mutt.orig/init.h 2006-12-12 14:15:03.000000000 +0100
56 +++ mutt/init.h 2007-02-15 20:46:18.951836720 +0100
57 @@ -3020,6 +3020,7 @@ static int parse_unalias (BUFFER *, BUFF
58 static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
59 static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
60 static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *);
61 +static int parse_cd (BUFFER *, BUFFER *, unsigned long, BUFFER *);
62 static int parse_set (BUFFER *, BUFFER *, unsigned long, BUFFER *);
63 static int parse_my_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *);
64 static int parse_unmy_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *);
65 @@ -3056,6 +3057,7 @@ struct command_t Commands[] = {
66 { "auto_view", parse_list, UL &AutoViewList },
67 { "alternative_order", parse_list, UL &AlternativeOrderList},
68 { "bind", mutt_parse_bind, 0 },
69 + { "cd", parse_cd, 0 },
70 { "charset-hook", mutt_parse_hook, M_CHARSETHOOK },
72 { "color", mutt_parse_color, 0 },
73 Index: mutt/doc/manual.xml.head
74 ===================================================================
75 --- mutt.orig/doc/manual.xml.head 2007-02-15 20:51:41.226843472 +0100
76 +++ mutt/doc/manual.xml.head 2007-02-15 20:51:45.303223768 +0100
77 @@ -1701,6 +1701,25 @@ sequence.
82 +<title>Changing the current working directory</title>
86 +Usage: <literal>cd</literal> <emphasis>directory</emphasis>
91 +The <literal>cd</literal> command changes Mutt's current working directory.
92 +This affects commands and functions like <literal>source</literal>,
93 +<literal>change-folder</literal>, and <literal>save-entry</literal> that use
94 +relative paths. Using <literal>cd</literal> without directory changes to your
100 <sect1 id="charset-hook">
101 <title>Defining aliases for character sets </title>