/* * copy-filename: Copies the filename surrounding point to a new kill * buffer. Useful if immediately followed by find-file or find-file-other- * window. Note that the filename pattern includes characters which are * legal in DOS filenames but that you might not expect, such as parenthesis. * If you never use some of these characters in filenames, simplify the * pattern to make it more suitable. (E.g., it won't properly copy a * "normal" filename surrounded by parenthesis.) * * find-file-other-window: Does a find-file, but in another window. * If only 1 window is on the screen, splits it. * * Given to all Epsilon users by David S. Bakin. Do with these what you * will, but don't blame me if anything goes wrong. * March 8, 1990. */ #include "eel.h" char file_pattern[60] = "([a-zA-Z]:)*(-|^:|[!@#$%&(){}~`a-zA-Z0-9_/\\.])+"; /* adapted from [tags.e]pluck_tag: */ command copy_filename() { int here; iter = 0; here = point--; re_search(1, file_pattern); re_search(-1, file_pattern); prev_cmd = 0; do_save_only(point, matchstart); /* in [kill.e] */ this_cmd = 0; point = here; } /* Does a find file, but in another window. Splits the only window if necessary. */ command find_file_other_window() { char fname[FNAMELEN]; /* From (file.e)find_file: */ iter = 0; get_file_dir(fname, "Find file (other window): ", filename); /* Make sure a valid filename was entered: */ if (fname[0] == '\0' || strcmp(filename, fname) == 0) return; /* Now move to another window or split the windows: */ if (number_of_windows() == 1) { window_split(); window_number = 1; } else { int nw = window_number + 1; if (nw == number_of_windows()) nw = 0; window_number = nw; } /* Move to the file's buffer or read the file: */ find_it (fname, !has_arg); }