From eca7da109248c40963c285417b878a8abcd84049 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 7 Feb 2015 11:04:52 +0200 Subject: [PATCH 1/5] Complete the remaining documentation updates for 24.5 doc/lispref/processes.texi (Synchronous Processes): Update documentation of call-process-shell-command and process-file-shell-command. etc/NEWS: Mark the entry for changed calling sequence of call-process-shell-command and process-file-shell-command as documented. --- doc/lispref/ChangeLog | 5 +++++ doc/lispref/processes.texi | 16 ++++++++++------ etc/NEWS | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 911e698ad49..be2bb3e79ed 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2015-02-07 Eli Zaretskii + + * processes.texi (Synchronous Processes): Update documentation of + call-process-shell-command and process-file-shell-command. + 2015-01-24 Eli Zaretskii * searching.texi (Regexp Search): Add a cross-reference to "Syntax diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 621e8a1bfba..cbc9ce4696c 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -503,17 +503,21 @@ inputinput@point{} @c It actually uses shell-command-switch, but no need to mention that here. @end defun -@defun call-process-shell-command command &optional infile destination display &rest args +@defun call-process-shell-command command &optional infile destination display This function executes the shell command @var{command} synchronously. -The final arguments @var{args} are additional arguments to add at the -end of @var{command}. The other arguments are handled as in -@code{call-process}. +The arguments are handled as in @code{call-process}. An old calling +convention allowed to pass any number of additional arguments after +@var{display}, which were concatenated to @var{command}; this is still +supported, but strongly discouraged. @end defun -@defun process-file-shell-command command &optional infile destination display &rest args +@defun process-file-shell-command command &optional infile destination display This function is like @code{call-process-shell-command}, but uses @code{process-file} internally. Depending on @code{default-directory}, -@var{command} can be executed also on remote hosts. +@var{command} can be executed also on remote hosts. An old calling +convention allowed to pass any number of additional arguments after +@var{display}, which were concatenated to @var{command}; this is still +supported, but strongly discouraged. @end defun @defun shell-command-to-string command diff --git a/etc/NEWS b/etc/NEWS index ae0d402a3d5..c25f663ae62 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -33,11 +33,13 @@ otherwise leave it unmarked. * Changes in Specialized Modes and Packages in Emacs 24.5 ++++ ** `call-process-shell-command' and `process-file-shell-command' don't take "&rest args" any more. ** Obsolete packages +--- *** cc-compat.el --- From 20c817d3657ec67792edafd75f34d829144e8590 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 8 Feb 2015 18:17:40 +0200 Subject: [PATCH 2/5] Fix handling of frame color parameters in TTY sessions (Bug#19802) src/xfaces.c (map_tty_color): Use assoc_no_quit instead of assq_no_quit to fetch color definition by its string name. lisp/frame.el (frame-notice-user-settings): Refresh the value of frame parameters after calling tty-handle-reverse-video. Call face-set-after-frame-default with the actual parameters, to avoid resetting colors back to unspecified. (set-background-color, set-foreground-color): Pass the selected color to face-set-after-frame-default. --- lisp/ChangeLog | 9 +++++++++ lisp/frame.el | 14 +++++++++++--- src/ChangeLog | 6 ++++++ src/xfaces.c | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 17b3d112432..79e3378b2e8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2015-02-08 Eli Zaretskii + + * frame.el (frame-notice-user-settings): Refresh the value of + frame parameters after calling tty-handle-reverse-video. Call + face-set-after-frame-default with the actual parameters, to avoid + resetting colors back to unspecified. + (set-background-color, set-foreground-color): Pass the selected + color to face-set-after-frame-default. (Bug#19802) + 2015-02-06 Wolfgang Jenkner * net/network-stream.el (network-stream-open-tls): Respect the diff --git a/lisp/frame.el b/lisp/frame.el index c77df558da8..eea5c24a82d 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -251,6 +251,10 @@ there (in decreasing order of priority)." (let ((newparms (frame-parameters)) (frame (selected-frame))) (tty-handle-reverse-video frame newparms) + ;; tty-handle-reverse-video might change the frame's + ;; color parameters, and we need to use the updated + ;; value below. + (setq newparms (frame-parameters)) ;; If we changed the background color, we need to update ;; the background-mode parameter, and maybe some faces, ;; too. @@ -258,7 +262,7 @@ there (in decreasing order of priority)." (unless (or (assq 'background-mode initial-frame-alist) (assq 'background-mode default-frame-alist)) (frame-set-background-mode frame)) - (face-set-after-frame-default frame)))))) + (face-set-after-frame-default frame newparms)))))) ;; If the initial frame is still around, apply initial-frame-alist ;; and default-frame-alist to it. @@ -1185,7 +1189,9 @@ To get the frame's current background color, use `frame-parameters'." (modify-frame-parameters (selected-frame) (list (cons 'background-color color-name))) (or window-system - (face-set-after-frame-default (selected-frame)))) + (face-set-after-frame-default (selected-frame) + (list + (cons 'background-color color-name))))) (defun set-foreground-color (color-name) "Set the foreground color of the selected frame to COLOR-NAME. @@ -1195,7 +1201,9 @@ To get the frame's current foreground color, use `frame-parameters'." (modify-frame-parameters (selected-frame) (list (cons 'foreground-color color-name))) (or window-system - (face-set-after-frame-default (selected-frame)))) + (face-set-after-frame-default (selected-frame) + (list + (cons 'foreground-color color-name))))) (defun set-cursor-color (color-name) "Set the text cursor color of the selected frame to COLOR-NAME. diff --git a/src/ChangeLog b/src/ChangeLog index 135f28fb20f..7a7fd23d43d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2015-02-08 Eli Zaretskii + + * xfaces.c (map_tty_color): Use assoc_no_quit instead of + assq_no_quit to fetch color definition by its string name. + (Bug#19802) + 2015-02-05 Eli Zaretskii * xdisp.c (move_it_in_display_line_to): Handle the case where the diff --git a/src/xfaces.c b/src/xfaces.c index 44c72aa4944..29c91f7169f 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -5793,7 +5793,7 @@ map_tty_color (struct frame *f, struct face *face, if (STRINGP (color) && SCHARS (color) && CONSP (Vtty_defined_color_alist) - && (def = assq_no_quit (color, call1 (Qtty_color_alist, frame)), + && (def = assoc_no_quit (color, call1 (Qtty_color_alist, frame)), CONSP (def))) { /* Associations in tty-defined-color-alist are of the form From a7b1c2f88f06bbeda16117c0aa1caffac1b4ebe1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 8 Feb 2015 20:09:19 +0200 Subject: [PATCH 3/5] Don't lose frame's background color when setting foreground (Bug#19802) lisp/frame.el ((set-background-color, set-foreground-color): Pass the other color, if defined, to face-set-after-frame-default. --- lisp/ChangeLog | 4 ++-- lisp/frame.el | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 79e3378b2e8..728b9833c9f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -4,8 +4,8 @@ frame parameters after calling tty-handle-reverse-video. Call face-set-after-frame-default with the actual parameters, to avoid resetting colors back to unspecified. - (set-background-color, set-foreground-color): Pass the selected - color to face-set-after-frame-default. (Bug#19802) + (set-background-color, set-foreground-color): Pass the foreground + and background colors to face-set-after-frame-default. (Bug#19802) 2015-02-06 Wolfgang Jenkner diff --git a/lisp/frame.el b/lisp/frame.el index eea5c24a82d..1a584fa0e2c 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1191,7 +1191,13 @@ To get the frame's current background color, use `frame-parameters'." (or window-system (face-set-after-frame-default (selected-frame) (list - (cons 'background-color color-name))))) + (cons 'background-color color-name) + ;; Pass the foreground-color as + ;; well, if defined, to avoid + ;; losing it when faces are reset + ;; to their defaults. + (assq 'foreground-color + (frame-parameters)))))) (defun set-foreground-color (color-name) "Set the foreground color of the selected frame to COLOR-NAME. @@ -1203,7 +1209,13 @@ To get the frame's current foreground color, use `frame-parameters'." (or window-system (face-set-after-frame-default (selected-frame) (list - (cons 'foreground-color color-name))))) + (cons 'foreground-color color-name) + ;; Pass the background-color as + ;; well, if defined, to avoid + ;; losing it when faces are reset + ;; to their defaults. + (assq 'background-color + (frame-parameters)))))) (defun set-cursor-color (color-name) "Set the text cursor color of the selected frame to COLOR-NAME. From 87fc99fee17ef1df4c22db15ec783a7735d3fc6b Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 10 Feb 2015 02:38:09 +0200 Subject: [PATCH 4/5] Better support for the case of typing RET on the prompt in comint. * lisp/comint.el (comint-get-old-input-default): Go to the field end when comint-use-prompt-regexp is nil. (comint-line-beginning-position): Check if point is already on the prompt before searching for the prompt when comint-use-prompt-regexp is non-nil. Fixes: debbugs:19710 --- lisp/ChangeLog | 10 ++++++++++ lisp/comint.el | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 728b9833c9f..ea428b1de15 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2015-02-10 Juri Linkov + + Better support for the case of typing RET on the prompt in comint. + + * comint.el (comint-get-old-input-default): Go to the field end + when comint-use-prompt-regexp is nil. + (comint-line-beginning-position): Check if point is already + on the prompt before searching for the prompt when + comint-use-prompt-regexp is non-nil. (Bug#19710) + 2015-02-08 Eli Zaretskii * frame.el (frame-notice-user-settings): Refresh the value of diff --git a/lisp/comint.el b/lisp/comint.el index 419938ea684..c81551acd5f 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2215,7 +2215,10 @@ the current line with any initial string matching the regexp (null (get-char-property (setq bof (field-beginning)) 'field))) (field-string-no-properties bof) (comint-bol) - (buffer-substring-no-properties (point) (line-end-position))))) + (buffer-substring-no-properties (point) + (if comint-use-prompt-regexp + (line-end-position) + (field-end)))))) (defun comint-copy-old-input () "Insert after prompt old input at point as new input to be edited. @@ -2263,8 +2266,9 @@ a buffer local variable." (if comint-use-prompt-regexp ;; Use comint-prompt-regexp (save-excursion - (re-search-backward comint-prompt-regexp nil t) (beginning-of-line) + (unless (looking-at comint-prompt-regexp) + (re-search-backward comint-prompt-regexp nil t)) (comint-skip-prompt) (point)) ;; Use input fields. Note that, unlike the behavior of From 4b0b27d0018f040bda6a2ec885fa54c666d9c083 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 10 Feb 2015 18:26:23 +0200 Subject: [PATCH 5/5] Fix invocation of commands whose file name includes extension (Bug#19817) nt/cmdproxy.c (get_next_token): Don't make backslashes disappear without a trace when they are not followed by a quote. (search_dir): Support searching programs whose file name already has an arbitrary extension. (main): When passing a command line to the shell, use cmd.exe rules for quoting command-line tail. --- nt/ChangeLog | 9 +++++++ nt/cmdproxy.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/nt/ChangeLog b/nt/ChangeLog index cac8e054068..d1f953f9ac5 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,12 @@ +2015-02-10 Eli Zaretskii + + * cmdproxy.c (get_next_token): Don't make backslashes disappear + without a trace when they are not followed by a quote. + (search_dir): Support searching programs whose file name already + has an arbitrary extension. (Bug#19817) + (main): When passing a command line to the shell, use cmd.exe + rules for quoting command-line tail. + 2014-11-17 Oscar Fuentes * inc/ms-w32.h: Define MINGW_W64. diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c index 7dbb529a6c9..ce5815291df 100644 --- a/nt/cmdproxy.c +++ b/nt/cmdproxy.c @@ -135,7 +135,10 @@ skip_nonspace (const char *str) return str; } -int escape_char = '\\'; +/* This value is never changed by the code. We keep the code that + supports also the value of '"', but let's allow the compiler to + optimize it out, until someone actually uses that. */ +const int escape_char = '\\'; /* Get next token from input, advancing pointer. */ int @@ -196,11 +199,31 @@ get_next_token (char * buf, const char ** pSrc) /* End of string, but no ending quote found. We might want to flag this as an error, but for now will consider the end as the end of the token. */ + if (escape_char == '\\') + { + /* Output literal backslashes. Note that if the + token ends with an unpaired backslash, we eat it + up here. But since this case invokes undefined + behavior anyway, it's okay. */ + while (escape_char_run > 1) + { + *o++ = escape_char; + escape_char_run -= 2; + } + } *o = '\0'; break; } else { + if (escape_char == '\\') + { + /* Output literal backslashes. Note that we don't + treat a backslash as an escape character here, + since it doesn't preceed a quote. */ + for ( ; escape_char_run > 0; escape_char_run--) + *o++ = escape_char; + } *o++ = *p++; } } @@ -229,13 +252,44 @@ search_dir (const char *dir, const char *exec, int bufsize, char *buffer) int n_exts = sizeof (exts) / sizeof (char *); char *dummy; int i, rc; + const char *pext = strrchr (exec, '\\'); + + /* Does EXEC already include an extension? */ + if (!pext) + pext = exec; + pext = strchr (pext, '.'); /* Search the directory for the program. */ - for (i = 0; i < n_exts; i++) + if (pext) { - rc = SearchPath (dir, exec, exts[i], bufsize, buffer, &dummy); + /* SearchPath will not append an extension if the file already + has an extension, so we must append it ourselves. */ + char exec_ext[MAX_PATH], *p; + + p = strcpy (exec_ext, exec) + strlen (exec); + + /* Search first without any extension; if found, we are done. */ + rc = SearchPath (dir, exec_ext, NULL, bufsize, buffer, &dummy); if (rc > 0) return rc; + + /* Try the known extensions. */ + for (i = 0; i < n_exts; i++) + { + strcpy (p, exts[i]); + rc = SearchPath (dir, exec_ext, NULL, bufsize, buffer, &dummy); + if (rc > 0) + return rc; + } + } + else + { + for (i = 0; i < n_exts; i++) + { + rc = SearchPath (dir, exec, exts[i], bufsize, buffer, &dummy); + if (rc > 0) + return rc; + } } return 0; @@ -769,7 +823,7 @@ main (int argc, char ** argv) quotes, since they are illegal in path names). */ remlen = maxlen = - strlen (progname) + extra_arg_space + strlen (cmdline) + 16; + strlen (progname) + extra_arg_space + strlen (cmdline) + 16 + 2; buf = p = alloca (maxlen + 1); /* Quote progname in case it contains spaces. */ @@ -784,10 +838,16 @@ main (int argc, char ** argv) remlen = maxlen - (p - buf); } + /* Now that we know we will be invoking the shell, quote the + command line after the "/c" switch as the shell expects: + a single pair of quotes enclosing the entire command + tail, no matter whether quotes are used in the command + line, and how many of them are there. See the output of + "cmd /?" for how cmd.exe treats quotes. */ if (run_command_dot_com) - _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline); + _snprintf (p, remlen, " /e:%d /c \"%s\"", envsize, cmdline); else - _snprintf (p, remlen, " /c %s", cmdline); + _snprintf (p, remlen, " /c \"%s\"", cmdline); cmdline = buf; } else