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