commit 3b93549597f187989e5508b638f297d0244e5cc6 (HEAD, refs/remotes/origin/master) Author: Juri Linkov Date: Tue Jun 9 02:34:53 2020 +0300 * lisp/simple.el (shell-command-on-region): Handle nil replace on rectangles. When 'region-noncontiguous-p' is non-nil (rectangular region) but 'replace' is nil, pop up the shell output buffer (bug#41440). When 'replace' is non-nil, trim the trailing newline. diff --git a/lisp/simple.el b/lisp/simple.el index 247769e7ab..0fe8a1025c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3978,7 +3978,7 @@ interactively, this is t." exit-status) ;; Unless a single contiguous chunk is selected, operate on multiple chunks. (if region-noncontiguous-p - (let ((input (concat (funcall region-extract-function 'delete) "\n")) + (let ((input (concat (funcall region-extract-function (when replace 'delete)) "\n")) output) (with-temp-buffer (insert input) @@ -3986,9 +3986,24 @@ interactively, this is t." shell-file-name t t nil shell-command-switch command) - (setq output (split-string (buffer-string) "\n"))) - (goto-char start) - (funcall region-insert-function output)) + (setq output (split-string (buffer-substring + (point-min) + ;; Trim the trailing newline. + (if (eq (char-before (point-max)) ?\n) + (1- (point-max)) + (point-max))) + "\n"))) + (cond + (replace + (goto-char start) + (funcall region-insert-function output)) + (t + (let ((buffer (get-buffer-create + (or output-buffer "*Shell Command Output*")))) + (with-current-buffer buffer + (erase-buffer) + (funcall region-insert-function output)) + (display-message-or-buffer buffer))))) (if (or replace (and output-buffer (not (or (bufferp output-buffer) (stringp output-buffer))))) commit 64e25cde324b2e270acf82958abb59018e67f841 Author: Mattias EngdegÄrd Date: Mon Jun 8 13:06:51 2020 +0200 More robust NS hex colour string parsing Invalid arguments to color-values, such as "#abcdefg" or "#1234", or valid ones like "#111222333", should not yield nonsense values. * src/nsterm.m (ns_get_color): Only accept "#RGB" strings with 1-4 digits per components, equal number of digits each, and no trailing characters. Parse 12-bit colours correctly. diff --git a/src/nsterm.m b/src/nsterm.m index 1953138954..3dc7e1db7c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2399,20 +2399,23 @@ so some key presses (TAB) are swallowed by the system. */ scaling = (snprintf (hex, sizeof hex, "%s", name + 4) - 2) / 3; else if (name[0] == '#') /* An old X11 format; convert to newer */ { - int len = (strlen(name) - 1); - int start = (len % 3 == 0) ? 1 : len / 4 + 1; - int i; - scaling = strlen(name+start) / 3; - for (i = 0; i < 3; i++) - sprintf (hex + i * (scaling + 1), "%.*s/", scaling, - name + start + i * scaling); - hex[3 * (scaling + 1) - 1] = '\0'; + int len = 0; + while (isxdigit (name[len + 1])) + len++; + if (name[len + 1] == '\0' && len >= 1 && len <= 12 && len % 3 == 0) + { + scaling = len / 3; + for (int i = 0; i < 3; i++) + sprintf (hex + i * (scaling + 1), "%.*s/", scaling, + name + 1 + i * scaling); + hex[3 * (scaling + 1) - 1] = '\0'; + } } if (hex[0]) { unsigned int rr, gg, bb; - float fscale = scaling == 4 ? 65535.0 : (scaling == 2 ? 255.0 : 15.0); + float fscale = (1 << (scaling * 4)) - 1; if (sscanf (hex, "%x/%x/%x", &rr, &gg, &bb)) { r = rr / fscale;