diff --git a/ChangeLog b/ChangeLog
index 5c0260f43879719cada82e1b37d70ae45f4c0b9d..cf015979ea93806a812bf3c7f44180385dd85418 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@ CVS code -
 	  new code in read_line and write_file.  New cmdline flag
 	  (-D --dos) to automatically write the file in DOS format,
 	  regardless of the original format.
+	- Mac file writing supported too.  Flag -M, --mac.  No toggle
+	  as of yet.
 - nano.c:
   main()
 	- Added vars oldcurrent and oldcurrent_x to check whether cursor
diff --git a/Makefile.in b/Makefile.in
index ec5298e56d354f71328413908e776cb3ebbf3f4d..57b35c99a28ad9c09249f3db6bfe0a2a008cb94d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -155,7 +155,7 @@ all: all-redirect
 .SUFFIXES:
 .SUFFIXES: .S .c .dvi .info .o .ps .s .texi .texinfo .txi
 $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
+	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
 
 Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
 	cd $(top_builddir) \
@@ -164,7 +164,7 @@ Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
 $(ACLOCAL_M4):  configure.in 
 	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 
-config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES)
 	$(SHELL) ./config.status --recheck
 $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
 	cd $(srcdir) && $(AUTOCONF)
@@ -324,7 +324,7 @@ uninstall-info:
 	else ii=; fi; \
 	list='$(INFO_DEPS)'; \
 	for file in $$list; do \
-	  test -z "$ii" \
+	  test -z "$$ii" \
 	    || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
 	done
 	@$(NORMAL_UNINSTALL)
@@ -531,7 +531,7 @@ distdir: $(DISTFILES)
 	@for file in $(DISTFILES); do \
 	  d=$(srcdir); \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
 	  else \
 	    test -f $(distdir)/$$file \
 	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
diff --git a/aclocal.m4 b/aclocal.m4
index 5ffb977343b5bf2b494e9f3d4cfcd15e2cf574ea..a9a9d423899a211759ee78c095b4d8ac3416e34a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-dnl aclocal.m4 generated automatically by aclocal 1.4
+dnl aclocal.m4 generated automatically by aclocal 1.4-p4
 
 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
diff --git a/config.h.in b/config.h.in
index 02ba1537cee5270db11b3f348f51d9db07b6e346..7fcb8da22dbb99fcf7454829ffd99851f4240d61 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,4 +1,4 @@
-/* config.h.in.  Generated automatically from configure.in by autoheader 2.13.  */
+/* config.h.in.  Generated automatically from configure.in by autoheader.  */
 
 /* Define if using alloca.c.  */
 #undef C_ALLOCA
diff --git a/files.c b/files.c
index 6f08a1005288415b317e192ddc6f1dee59a79c24..d31fcdc5f10eb5f560488a69144ddfe7ffe04218 100644
--- a/files.c
+++ b/files.c
@@ -184,7 +184,11 @@ int read_file(int fd, char *filename, int quiet)
     /* Read the entire file into file struct */
     while ((size = read_byte(fd, filename, input)) > 0) {
 	linetemp = 0;
-	if (input[0] == '\n') {
+	if (input[0] == '\n'
+#ifndef NANO_SMALL
+	    || (ISSET(MAC_FILE) && input[0] == '\r')
+#endif
+	) {
 	    fileptr = read_line(buf, fileptr, &line1ins);
 	    num_lines++;
 	    buf[0] = 0;
@@ -1125,10 +1129,12 @@ int write_file(char *name, int tmp, int append, int nonamechange)
 #endif
 	}
 #ifndef NANO_SMALL
-	if (ISSET(DOS_FILE))
+	if (ISSET(DOS_FILE) || ISSET(MAC_FILE))
 	    write(fd, "\r", 1);
+
+	if (!ISSET(MAC_FILE))
 #endif
-	write(fd, "\n", 1);
+	    write(fd, "\n", 1);
 
 	fileptr = fileptr->next;
 	lineswritten++;
@@ -1151,13 +1157,17 @@ int write_file(char *name, int tmp, int append, int nonamechange)
 		    return -1;
 		}
 	    }
+
+	    if (!ISSET(MAC_FILE))
 #endif
-	    size = write(fd, "\n", 1);
-	    lineswritten++;
-	    if (size == -1) {
-		statusbar(_("Could not open file for writing: %s"),
+	    {
+		size = write(fd, "\n", 1);
+		lineswritten++;
+		if (size == -1) {
+		    statusbar(_("Could not open file for writing: %s"),
 			  strerror(errno));
-		return -1;
+		    return -1;
+		}
 	    }
 	}
     }
diff --git a/nano.c b/nano.c
index efd9c034933b00c976eb56d0bf79f0aa4aefb2d3..cb8a8aa229a605d2152a823e05ef90fa324a5bc4 100644
--- a/nano.c
+++ b/nano.c
@@ -412,6 +412,11 @@ void usage(void)
 	(_
 	 (" -F 		--multibuffer		Enable multiple file buffers\n"));
 #endif
+#ifndef NANO_SMALL
+    printf
+	(_
+	 (" -M 		--mac			Write file in Mac format\n"));
+#endif
 #ifdef HAVE_REGEX_H
     printf(_
 	   (" -R		--regexp		Use regular expressions for search\n"));
@@ -476,6 +481,9 @@ void usage(void)
 #endif
 #ifdef ENABLE_MULTIBUFFER
     printf(_(" -F 		Enable multiple file buffers\n"));
+#endif
+#ifndef NANO_SMALL
+    printf(_(" -M 		Write file in Mac format\n"));
 #endif
     printf(_(" -T [num]	Set width of a tab to num\n"));
     printf(_(" -R		Use regular expressions for search\n"));
@@ -2416,6 +2424,7 @@ int main(int argc, char *argv[])
 #ifndef NANO_SMALL
 	{"cut", 0, 0, 'k'},
 	{"dos", 0, 0, 'D'},
+	{"mac", 0, 0, 'M'},
 	{"autoindent", 0, 0, 'i'},
 #endif
 	{"tempfile", 0, 0, 't'},
@@ -2458,11 +2467,11 @@ int main(int argc, char *argv[])
 #endif /* ENABLE_NANORC */
 
 #ifdef HAVE_GETOPT_LONG
-    while ((optchr = getopt_long(argc, argv, "h?DFRT:Vabcefgijklmo:pr:s:tvwxz",
+    while ((optchr = getopt_long(argc, argv, "h?DFMRT:Vabcefgijklmo:pr:s:tvwxz",
 				 long_options, &option_index)) != EOF) {
 #else
     while ((optchr =
-	    getopt(argc, argv, "h?DFRT:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
+	    getopt(argc, argv, "h?DFMRT:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
 #endif
 
 	switch (optchr) {
@@ -2477,7 +2486,11 @@ int main(int argc, char *argv[])
 	    SET(MULTIBUFFER);
 	    break;
 #endif
-
+#ifndef NANO_SMALL
+	case 'M':
+	    SET(MAC_FILE);
+	    break;
+#endif
 	case 'T':
 	    tabsize = atoi(optarg);
 	    if (tabsize <= 0) {
diff --git a/nano.h b/nano.h
index b007450c7deabd2b79504db6ae4fa8fdd746c548..1f8702930c418f4382a5eabd77b5894243d68f88 100644
--- a/nano.h
+++ b/nano.h
@@ -141,6 +141,7 @@ typedef struct rcoption {
 #define MULTIBUFFER		(1<<19)
 #define CLEAR_BACKUPSTRING	(1<<20)
 #define DOS_FILE		(1<<21)
+#define MAC_FILE		(1<<22)
 
 /* Control key sequences, changing these would be very very bad */