# HG changeset patch # User Mike Miller # Date 1334753783 14400 # Node ID 6ecd26bc382c2b2e1be8539328c6a9b832dd1263 # Parent e993cbc4b08f3c35e3a4579f09469a6a714fc7d2 edit.m: Create an m-file from a new name with no path and no extension * edit.m: Append a .m to any new file with no path and no extension. diff --git a/scripts/miscellaneous/edit.m b/scripts/miscellaneous/edit.m --- a/scripts/miscellaneous/edit.m +++ b/scripts/miscellaneous/edit.m @@ -305,12 +305,17 @@ endif ## If the new file includes a path, take it as given. Otherwise, create - ## the file in HOME and edit it. + ## the file in HOME and edit it. If the file has neither path nor + ## extension, it is the name of a new function, create it as an m-file. idx = rindex (file, filesep); if (idx != 0) fileandpath = file; file = fileandpath(idx+1:end); else + idx = rindex (file, "."); + if (idx == 0) + file = strcat (file, ".m"); + endif fileandpath = fullfile (FUNCTION.HOME, file); endif