changeset 18818:0728f7b6b1a2

edit.m: Don't append default '.m' extension if an extension already exists. edit.m: Don't append default '.m' extension to a newly created file if an extension already exists.
author Rik <rik@octave.org>
date Tue, 27 May 2014 13:53:39 -0700
parents 5556ddfb841b
children 1f170b211be3
files scripts/miscellaneous/edit.m
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/edit.m	Sun May 25 13:13:17 2014 -0700
+++ b/scripts/miscellaneous/edit.m	Tue May 27 13:53:39 2014 -0700
@@ -340,12 +340,19 @@
     ## If in gui-mode, create it before or editor would prompt again.
     fileandpath = file;
     idx = rindex (file, ".");
-    name = file(1:idx-1);
-    ext = file(idx+1:end);
+    if (idx)
+      name = file(1:idx-1);
+      ext = file(idx+1:end);
+    else
+      name = file;
+      ext = "";
+    endif
     if (! any (strcmp (ext, {"cc", "m"})))
       ## Some unknown file.  Create and open it or just open it.
-      ## Add .m file extension per default
-      fileandpath = [fileandpath ".m"];
+      keyboard;
+      if (isempty (ext))
+        fileandpath = [fileandpath ".m"];  # Add .m extension per default
+      endif
       if (isguirunning ())
         ## Write the initial file (if there is anything to write)
         ## Give user the opportunity to change the file extension