Mercurial > emacs
view nt/runemacs.c @ 42490:0715d86d229c
Extensive changes to support multiple xscheme buffers:
(run-scheme): Break up into new functions to facilitate starting
processes in other buffers.
(xscheme-start, xscheme-read-command-line): New functions.
(start-scheme, select-scheme)
(default-xscheme-runlight)
(global-set-scheme-interaction-buffer)
(local-set-scheme-interaction-buffer)
(local-clear-scheme-interaction-buffer)
(exit-scheme-interaction-mode)
(verify-xscheme-buffer): New functions.
(xscheme-process-name, xscheme-buffer-name)
(xscheme-runlight): New internal vars.
(default-xscheme-runlight): New const.
(xscheme-start-process): Add args for the process/buffer names.
(reset-scheme): Pass process/buffer names.
(scheme-interaction-mode): Initialize new local vars.
(reset-scheme, xscheme-send-string-2, xscheme-process-running-p)
(xscheme-select-process-buffer, xscheme-process-buffer)
(xscheme-send-region, xscheme-send-char, xscheme-send-interrupt)
(xscheme-goto-output-point, xscheme-write-message-1): Use new
var xscheme-process-name.
(xscheme-start-process): Initialize xscheme-process-name and
xscheme-buffer-name in the process buffer. Pass buffer name to
xscheme-modeline-initialize.
(xscheme-modeline-initialize): Add argument to specify buffer name
for mode-line vars.
(xscheme-process-sentinel): Make sure sentinel is run in the
process buffer so it sees its local vars.
(xscheme-process-filter-initialize, xscheme-set-runlight): More
elaborate logic to handle multiple-buffer mode lines.
(xscheme-enter-input-wait): Re-enable control-G handler upon
entering input wait.
(scheme-interaction-mode): Add arg to preserve local vars.
(xscheme-enter-interaction-mode)
(xscheme-enter-debugger-mode): Preserve local vars.
(xscheme-start-process): Clobber local vars.
(scheme-interaction-mode-commands): Allow end user to add commands
to scheme-interaction-mode keymap.
(scheme-interaction-mode-commands-alist): New variable.
(xscheme-send-string): Don't use insert-before-markers.
Implement a per-buffer kill ring:
(xscheme-insert-expression)
(xscheme-rotate-yank-pointer, xscheme-yank)
(xscheme-yank-pop, xscheme-yank-push): New functions.
(xscheme-expressions-ring)
(xscheme-expressions-ring-yank-pointer)
(xscheme-expressions-ring-max): New variables.
(xscheme-send-string-1): Call xscheme-insert-expression to save
expression in ring.
(xscheme-yank-previous-send): Now an alias for xscheme-yank.
(xscheme-previous-send): Deleted variable.
(xscheme-send-string-2, xscheme-send-char, xscheme-send-proceed,
xscheme-send-control-g-interrupt): Use process-send-string rather
than send-string.
(xscheme-send-region): Insert a newline after an expression that
is submitted in the interaction buffer, for consistency with
recent changes to Edwin.
(xscheme-delete-output): New function mimics comint-delete-output.
(xscheme-last-input-end): New internal variable.
(xscheme-process-filter-output): Update xscheme-last-input-end.
(xscheme-send-control-g-interrupt): Make sure that
xscheme-control-g-disabled-p is looked up in the right buffer.
(xscheme-enable-control-g): Clear C-g message if visible.
(xscheme-control-g-message-string): New internal var.
(xscheme-send-control-g-interrupt): Use new var.
(xscheme-send-control-g-interrupt, xscheme-send-interrupt): Delay
after sending interrupt in order to work around race condition.
(xscheme-send-control-g-interrupt, xscheme-send-interrupt)
(xscheme-send-char): Use xscheme-send-char rather than send-string
to send single char.
(xscheme-process-filter, xscheme-process-filter-alist): Add
support for evaluating expressions outside of the call-excursion.
(xscheme-process-filter:string-action-noexcursion): New func.
(xscheme-write-value): Change output string to match that used by Edwin.
(xscheme-coerce-prompt): Don't write a space after a command
prompt. The PROMPT-FOR-COMMAND- procedures will take care of this
for us.
(reset-scheme): Delete process after killing it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 02 Jan 2002 23:50:46 +0000 |
parents | b2e0c0638bf2 |
children | 695cf19ef79e d7ddb3e565de |
line wrap: on
line source
/* Simple program to start Emacs with its console window hidden. This program is provided purely for convenience, since most users will use Emacs in windowing (GUI) mode, and will not want to have an extra console window lying around. */ /* You may want to define this if you want to be able to install updated emacs binaries even when other users are using the current version. The problem with some file servers (notably Novell) is that an open file cannot be overwritten, deleted, or even renamed. So if someone is running emacs.exe already, you cannot install a newer version. By defining CHOOSE_NEWEST_EXE, you can name your new emacs.exe something else which matches "emacs*.exe", and runemacs will automatically select the newest emacs executeable in the bin directory. (So you'll probably be able to delete the old version some hours/days later). */ /* #define CHOOSE_NEWEST_EXE */ #include <windows.h> #include <string.h> #include <malloc.h> int WINAPI WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow) { STARTUPINFO start; SECURITY_ATTRIBUTES sec_attrs; SECURITY_DESCRIPTOR sec_desc; PROCESS_INFORMATION child; int wait_for_child = FALSE; DWORD priority_class = NORMAL_PRIORITY_CLASS; DWORD ret_code = 0; char *new_cmdline; char *p; char modname[MAX_PATH]; if (!GetModuleFileName (NULL, modname, MAX_PATH)) goto error; if ((p = strrchr (modname, '\\')) == NULL) goto error; *p = 0; new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 3); /* Quote executable name in case of spaces in the path. */ *new_cmdline = '"'; strcpy (new_cmdline + 1, modname); #ifdef CHOOSE_NEWEST_EXE { /* Silly hack to allow new versions to be installed on server even when current version is in use. */ char * best_name = alloca (MAX_PATH + 1); FILETIME best_time = {0,0}; WIN32_FIND_DATA wfd; HANDLE fh; p = new_cmdline + strlen (new_cmdline); strcpy (p, "\\emacs*.exe\" "); fh = FindFirstFile (new_cmdline, &wfd); if (fh == INVALID_HANDLE_VALUE) goto error; do { if (wfd.ftLastWriteTime.dwHighDateTime > best_time.dwHighDateTime || (wfd.ftLastWriteTime.dwHighDateTime == best_time.dwHighDateTime && wfd.ftLastWriteTime.dwLowDateTime > best_time.dwLowDateTime)) { best_time = wfd.ftLastWriteTime; strcpy (best_name, wfd.cFileName); } } while (FindNextFile (fh, &wfd)); FindClose (fh); *p++ = '\\'; strcpy (p, best_name); strcat (p, " "); } #else strcat (new_cmdline, "\\emacs.exe\" "); #endif /* Append original arguments if any; first look for arguments we recognise (-wait, -high, and -low), and apply them ourselves. */ while (cmdline[0] == '-' || cmdline[0] == '/') { if (strncmp (cmdline+1, "wait", 4) == 0) { wait_for_child = TRUE; cmdline += 5; } else if (strncmp (cmdline+1, "high", 4) == 0) { priority_class = HIGH_PRIORITY_CLASS; cmdline += 5; } else if (strncmp (cmdline+1, "low", 3) == 0) { priority_class = IDLE_PRIORITY_CLASS; cmdline += 4; } else break; } strcat (new_cmdline, cmdline); /* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin". */ if ((p = strrchr (modname, '\\')) && stricmp (p, "\\bin") == 0) { *p = 0; for (p = modname; *p; p++) if (*p == '\\') *p = '/'; SetEnvironmentVariable ("emacs_dir", modname); } memset (&start, 0, sizeof (start)); start.cb = sizeof (start); start.dwFlags = STARTF_USESHOWWINDOW; start.wShowWindow = SW_HIDE; sec_attrs.nLength = sizeof (sec_attrs); sec_attrs.lpSecurityDescriptor = NULL; sec_attrs.bInheritHandle = FALSE; if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, priority_class, GetEnvironmentStrings (), NULL, &start, &child)) { if (wait_for_child) { WaitForSingleObject (child.hProcess, INFINITE); GetExitCodeProcess (child.hProcess, &ret_code); } CloseHandle (child.hThread); CloseHandle (child.hProcess); } else goto error; return (int) ret_code; error: MessageBox (NULL, "Could not start Emacs.", "Error", MB_ICONSTOP); return 1; }