4 source/macro.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 3 files changed, 70 insertions(+)
8 diff --quilt old/source/macro.c new/source/macro.c
10 +++ new/source/macro.c
11 @@ -925,10 +925,76 @@ int ReadMacroFile(WindowInfo *window, co
17 +void LoadDotNMFiles(WindowInfo *window)
19 + const char *mode = LanguageModeName(window->languageMode);
21 + char *tok, *pos, *last;
23 + size_t filenamelen = strlen(".nm");
24 + char *filename = NULL;
25 + char *filename2 = NULL;
28 + /* for '.<mode>.nm' files */
29 + filenamelen += strlen(mode) + 1;
32 + /* a buffer for the file name (".nm" and ".<mode>.nm") */
33 + filename = malloc(filenamelen + 1);
37 + /* filename2 points to the ".nm" of the filenmae */
38 + filename2 = filename;
40 + filename2 = filename + strlen(mode) + 1;
41 + snprintf(filename, filenamelen + 1, ".%s.nm", mode);
43 + strcpy(filename, ".nm");
46 + /* a carbon copy for the strtok function */
47 + path = strdup(window->path);
49 + goto out_free_filename;
51 + /* good upperbound for longest file, plus one '/' */
52 + file = malloc(strlen(path) + filenamelen + 2);
59 + last += sprintf(last, "%s/", tok);
62 + strcpy(last, filename2);
63 + ReadMacroFile(window, file, False);
65 + /* ".<mode>.nm", overwrite ".nm" */
67 + strcpy(last, filename);
68 + ReadMacroFile(window, file, False);
71 + tok = strtok_r(*tok ? NULL : path, "/", &pos);
84 ** Parse and execute a macro string including macro definitions. Report
85 ** parsing errors in a dialog posted over window->shell.
87 int ReadMacroString(WindowInfo *window, char *string, const char *errIn)
88 diff --quilt old/source/macro.h new/source/macro.h
89 --- old/source/macro.h
90 +++ new/source/macro.h
91 @@ -65,10 +65,11 @@ void ResumeMacroExecution(WindowInfo *wi
92 void AbortMacroCommand(WindowInfo *window);
93 int MacroWindowCloseActions(WindowInfo *window);
94 void RepeatDialog(WindowInfo *window);
95 void RepeatMacro(WindowInfo *window, const char *command, int how);
96 int ReadMacroFile(WindowInfo *window, const char *fileName, int warnNotExist);
97 +void LoadDotNMFiles(WindowInfo *window);
98 int ReadMacroString(WindowInfo *window, char *string, const char *errIn);
99 int CheckMacroString(Widget dialogParent, char *string, const char *errIn,
101 char *GetReplayMacro(void);
102 void ReadMacroInitFile(WindowInfo *window);
103 diff --quilt old/source/file.c new/source/file.c
104 --- old/source/file.c
105 +++ new/source/file.c
106 @@ -264,10 +264,13 @@ WindowInfo *EditExistingFile(WindowInfo
107 strcat(fullname, name);
108 if(GetPrefAlwaysCheckRelTagsSpecs())
109 AddRelTagsFile(GetPrefTagFile(), path, TAG);
110 AddToPrevOpenMenu(fullname);
112 + /* autoload .nm files from parent directories */
113 + LoadDotNMFiles(window);
115 /* file_open_hook() */
116 MacroApplyHook(window, "post_open_hook", 0, NULL, NULL);