# vim:ft=diff: This is the chdir patch by Christoph Berg . * Homepage: http://www.df7cb.de/projects/mutt/chdir/ == END PATCH Index: mutt/PATCHES =================================================================== --- mutt/PATCHES.orig 2007-02-15 20:46:31.855875008 +0100 +++ mutt/PATCHES 2007-02-15 20:46:31.855875008 +0100 @@ -0,0 +1 @@ +patch-1.5.13.cb.chdir.1 Index: mutt/init.c =================================================================== --- mutt.orig/init.c 2006-12-12 14:15:03.000000000 +0100 +++ mutt/init.c 2007-02-15 20:46:18.950836872 +0100 @@ -2214,6 +2214,35 @@ static int parse_source (BUFFER *tmp, BU return (source_rc (path, err)); } +static int parse_cd (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) +{ + char path[_POSIX_PATH_MAX]; + + if (mutt_extract_token (tmp, s, 0) != 0) + { + snprintf (err->data, err->dsize, _("cd: error at %s"), s->dptr); + return (-1); + } + if (MoreArgs (s)) + { + strfcpy (err->data, _("cd: too many arguments"), err->dsize); + return (-1); + } + strfcpy (path, tmp->data, sizeof (path)); + mutt_expand_path (path, sizeof (path)); + if (!*path) { + char *home = getenv("HOME"); + if (home) + strfcpy (path, home, sizeof (path)); + } + if (chdir(path) != 0) { + snprintf (err->data, err->dsize, _("cd: %s"), strerror(errno)); + return (-1); + } + return (0); +} + + /* line command to execute token scratch buffer to be used by parser. caller should free Index: mutt/init.h =================================================================== --- mutt.orig/init.h 2006-12-12 14:15:03.000000000 +0100 +++ mutt/init.h 2007-02-15 20:46:18.951836720 +0100 @@ -3020,6 +3020,7 @@ static int parse_unalias (BUFFER *, BUFF static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *); +static int parse_cd (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_set (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_my_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_unmy_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *); @@ -3056,6 +3057,7 @@ struct command_t Commands[] = { { "auto_view", parse_list, UL &AutoViewList }, { "alternative_order", parse_list, UL &AlternativeOrderList}, { "bind", mutt_parse_bind, 0 }, + { "cd", parse_cd, 0 }, { "charset-hook", mutt_parse_hook, M_CHARSETHOOK }, #ifdef HAVE_COLOR { "color", mutt_parse_color, 0 }, Index: mutt/doc/manual.xml.head =================================================================== --- mutt.orig/doc/manual.xml.head 2007-02-15 20:51:41.226843472 +0100 +++ mutt/doc/manual.xml.head 2007-02-15 20:51:45.303223768 +0100 @@ -1701,6 +1701,25 @@ sequence. + +Changing the current working directory + + + +Usage: cd directory + + + + +The cd command changes Mutt's current working directory. +This affects commands and functions like source, +change-folder, and save-entry that use +relative paths. Using cd without directory changes to your +home directory. + + + + Defining aliases for character sets