commit e5ef4c660c191223912b15ebfa3b61a058221992 (HEAD, refs/remotes/origin/master) Author: Michael Albinus Date: Mon Jan 21 09:48:55 2019 +0100 Use `inhibit-read-only' in Tramp * lisp/net/tramp.el (tramp-process-actions, tramp-accept-process-output) (tramp-send-string): * lisp/net/tramp-adb.el (tramp-adb-handle-make-process) (tramp-adb-send-command-and-check, tramp-adb-wait-for-output): * lisp/net/tramp-sh.el (tramp-sh-handle-make-process) (tramp-wait-for-output, tramp-send-command-and-check): * lisp/net/tramp-smb.el (tramp-smb-wait-for-output): Use `inhibit-read-only'. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 0a357e1ae2..73774dbc44 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -1091,7 +1091,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ;; otherwise we might be interrupted by ;; `verify-visited-file-modtime'. (let ((buffer-undo-list t) - (buffer-read-only nil) + (inhibit-read-only t) (mark (point))) (clear-visited-file-modtime) (narrow-to-region (point-max) (point-max)) @@ -1242,7 +1242,7 @@ the exit status is not equal 0, and t otherwise." (skip-chars-forward "^ ") (prog1 (zerop (read (current-buffer))) - (let (buffer-read-only) + (let ((inhibit-read-only t)) (delete-region (match-beginning 0) (point-max)))))) (defun tramp-adb-barf-unless-okay (vec command fmt &rest args) @@ -1260,7 +1260,7 @@ FMT and ARGS are passed to `error'." (if (tramp-wait-for-regexp proc timeout (tramp-get-connection-property proc "prompt" tramp-adb-prompt)) - (let (buffer-read-only) + (let ((inhibit-read-only t)) (goto-char (point-min)) ;; ADB terminal sends "^H" sequences. (when (re-search-forward "<\b+" (point-at-eol) t) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 5c9c568545..4fa8b3fa3f 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2906,7 +2906,7 @@ the result will be a local, non-Tramp, file name." ;; otherwise we might be interrupted by ;; `verify-visited-file-modtime'. (let ((buffer-undo-list t) - (buffer-read-only nil) + (inhibit-read-only t) (mark (point-max))) (clear-visited-file-modtime) (narrow-to-region (point-max) (point-max)) @@ -5081,7 +5081,7 @@ function waits for output unless NOOUTPUT is set." (regexp1 (format "\\(^\\|\000\\)%s" regexp)) (found (tramp-wait-for-regexp proc timeout regexp1))) (if found - (let (buffer-read-only) + (let ((inhibit-read-only t)) ;; A simple-minded busybox has sent " ^H" sequences. ;; Delete them. (goto-char (point-min)) @@ -5128,7 +5128,7 @@ DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null." (skip-chars-forward "^ ") (prog1 (zerop (read (current-buffer))) - (let (buffer-read-only) + (let ((inhibit-read-only t)) (delete-region (match-beginning 0) (point-max)))))) (defun tramp-barf-unless-okay (vec command fmt &rest args) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 8198930abc..08f2f30747 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -2029,7 +2029,7 @@ If ARGUMENT is non-nil, use it as argument for Removes smb prompt. Returns nil if an error message has appeared." (with-current-buffer (tramp-get-connection-buffer vec) (let ((p (get-buffer-process (current-buffer))) - buffer-read-only) + (inhibit-read-only t)) ;; Read pending output. (while (tramp-accept-process-output p 0.1)) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3b235095d3..a65094f811 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4074,7 +4074,7 @@ connection buffer." (t "Login failed"))))) (when (numberp pos) (with-current-buffer (tramp-get-connection-buffer vec) - (let (buffer-read-only) (delete-region pos (point)))))))) + (let ((inhibit-read-only t)) (delete-region pos (point)))))))) ;;; Utility functions: @@ -4083,7 +4083,8 @@ connection buffer." This is needed in order to hide `last-coding-system-used', which is set for process communication also." (with-current-buffer (process-buffer proc) - (let (buffer-read-only last-coding-system-used + (let ((inhibit-read-only t) + last-coding-system-used ;; We do not want to run timers. timer-list timer-idle-list result) @@ -4186,7 +4187,7 @@ the remote host use line-endings as defined in the variable (with-current-buffer (tramp-get-connection-buffer vec) ;; Clean up the buffer. We cannot call `erase-buffer' because ;; narrowing might be in effect. - (let (buffer-read-only) (delete-region (point-min) (point-max))) + (let ((inhibit-read-only t)) (delete-region (point-min) (point-max))) ;; Replace "\n" by `tramp-rsh-end-of-line'. (setq string (mapconcat commit 5961e4fa427822fa441f4fcf53041043dd6741e1 Author: Michael Albinus Date: Sun Jan 20 18:56:26 2019 +0100 Use POSIX "df" in Tramp, if available * lisp/net/tramp-sh.el (tramp-get-remote-df): Support also POSIX.1 "df". (tramp-sh-handle-file-system-info): Adapt accordingly. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 022ecb3d79..5c9c568545 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3817,22 +3817,26 @@ file-notify events." (tramp-message v 5 "file system info: %s" localname) (tramp-send-command v (format - "%s --block-size=1 --output=size,used,avail %s" + "%s %s" (tramp-get-remote-df v) (tramp-shell-quote-argument localname))) (with-current-buffer (tramp-get-connection-buffer v) (goto-char (point-min)) (forward-line) (when (looking-at (eval-when-compile - (concat "[[:space:]]*\\([[:digit:]]+\\)" + (concat "\\(?:^/[^[:space:]]*[[:space:]]\\)?" + "[[:space:]]*\\([[:digit:]]+\\)" "[[:space:]]+\\([[:digit:]]+\\)" "[[:space:]]+\\([[:digit:]]+\\)"))) - (list (string-to-number (match-string 1)) - ;; The second value is the used size. We need the - ;; free size. - (- (string-to-number (match-string 1)) - (string-to-number (match-string 2))) - (string-to-number (match-string 3))))))))) + (mapcar + (lambda (d) + (* d (tramp-get-connection-property v "df-blocksize" 0))) + (list (string-to-number (match-string 1)) + ;; The second value is the used size. We need the + ;; free size. + (- (string-to-number (match-string 1)) + (string-to-number (match-string 2))) + (string-to-number (match-string 3)))))))))) ;;; Internal Functions: @@ -5578,12 +5582,24 @@ This command is returned only if `delete-by-moving-to-trash' is non-nil." "Determine remote `df' command." (with-tramp-connection-property vec "df" (tramp-message vec 5 "Finding a suitable `df' command") - (let ((result (tramp-find-executable vec "df" (tramp-get-remote-path vec)))) - (and - result - (tramp-send-command-and-check - vec (format "%s --block-size=1 --output=size,used,avail /" result)) - result)))) + (let ((df (tramp-find-executable vec "df" (tramp-get-remote-path vec))) + result) + (when df + (cond + ;; coreutils. + ((tramp-send-command-and-check + vec + (format + "%s /" + (setq result + (format "%s --block-size=1 --output=size,used,avail" df)))) + (tramp-set-connection-property vec "df-blocksize" 1) + result) + ;; POSIX.1 + ((tramp-send-command-and-check + vec (format "%s /" (setq result (format "%s -k" df)))) + (tramp-set-connection-property vec "df-blocksize" 1024) + result)))))) (defun tramp-get-remote-gio-monitor (vec) "Determine remote `gio-monitor' command." commit 67b1053dcd958d21a964dc09c2ba9666e11240b2 Author: Eli Zaretskii Date: Sun Jan 20 17:59:12 2019 +0200 Support native image resizing on MS-Windows * src/w32term.c (x_draw_image_foreground): Scale the image if the requested dimensions are different from the bitmap dimensions. * src/image.c (Fimage_scaling_p): Return t when HAVE_NTGUI. (x_set_image_size) [HAVE_NTGUI]: Record the scaled dimensions in the image struct. * src/dispextern.h (HAVE_NATIVE_SCALING): Define when HAVE_NTGUI as well. * etc/NEWS: Update the announcement of native image scaling. diff --git a/etc/NEWS b/etc/NEWS index 9d91a30a58..21187474a2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1505,8 +1505,12 @@ buffer's 'default-directory' and invoke that file name handler to make the process. That way 'make-process' can start remote processes. +++ -** Emacs now supports resizing images without ImageMagick on X window -systems where the XRender extension is available, and on the NS port. +** Emacs now supports resizing (scaling) of images without ImageMagick. +All modern systems are supported by this feature. (On GNU and Unix +systems, the XRender extension to X11 is required for this to be +available; the configure script will test for it and, if found, enable +scaling.) + The new function 'image-scaling-p' can be used to test whether any given frame supports resizing. diff --git a/src/dispextern.h b/src/dispextern.h index 9cea3218c1..894753669d 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2938,7 +2938,7 @@ struct redisplay_interface #ifdef HAVE_WINDOW_SYSTEM -# if defined HAVE_XRENDER || defined HAVE_NS +# if defined HAVE_XRENDER || defined HAVE_NS || defined HAVE_NTGUI # define HAVE_NATIVE_SCALING # endif diff --git a/src/image.c b/src/image.c index bcc61dfccd..2014860581 100644 --- a/src/image.c +++ b/src/image.c @@ -1900,6 +1900,12 @@ x_set_image_size (struct frame *f, struct image *img) img->height = height; } # endif +# ifdef HAVE_NTGUI + /* Under HAVE_NTGUI, we will scale the image on the fly, when we + draw it. See w32term.c:x_draw_image_foreground. */ + img->width = width; + img->height = height; +# endif #endif } @@ -9915,7 +9921,7 @@ DEFUN ("image-scaling-p", Fimage_scaling_p, Simage_scaling_p, 0, 1, 0, Return t if FRAME supports native scaling, nil otherwise. */) (Lisp_Object frame) { -#ifdef HAVE_NS +#if defined (HAVE_NS) || defined (HAVE_NTGUI) return Qt; #elif defined (HAVE_X_WINDOWS) && defined (HAVE_XRENDER) int event_basep, error_basep; diff --git a/src/w32term.c b/src/w32term.c index d13763d7db..6fc8612419 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1874,9 +1874,24 @@ x_draw_image_foreground (struct glyph_string *s) HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground); HBRUSH orig_brush = SelectObject (s->hdc, fg_brush); HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap); + LONG orig_width, orig_height; + DIBSECTION dib; SetBkColor (compat_hdc, RGB (255, 255, 255)); SetTextColor (s->hdc, RGB (0, 0, 0)); x_set_glyph_string_clipping (s); + /* Extract the original dimensions of the bitmap. */ + if (GetObject (s->img->pixmap, sizeof (dib), &dib) > 0) + { + BITMAP bmp = dib.dsBm; + orig_width = bmp.bmWidth; + orig_height = bmp.bmHeight; + } + else + { + DebPrint (("x_draw_image_foreground: GetObject failed!\n")); + orig_width = s->slice.width; + orig_height = s->slice.height; + } if (s->img->mask) { @@ -1885,14 +1900,36 @@ x_draw_image_foreground (struct glyph_string *s) SetTextColor (s->hdc, RGB (255, 255, 255)); SetBkColor (s->hdc, RGB (0, 0, 0)); - - BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, - compat_hdc, s->slice.x, s->slice.y, SRCINVERT); - BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, - mask_dc, s->slice.x, s->slice.y, SRCAND); - BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, - compat_hdc, s->slice.x, s->slice.y, SRCINVERT); - + if (s->slice.width == orig_width && s->slice.height == orig_height) + { + BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, + compat_hdc, s->slice.x, s->slice.y, SRCINVERT); + BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, + mask_dc, s->slice.x, s->slice.y, SRCAND); + BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, + compat_hdc, s->slice.x, s->slice.y, SRCINVERT); + } + else + { + int pmode = 0; + /* HALFTONE produces better results, especially when + scaling to a larger size, but Windows 9X doesn't + support HALFTONE. */ + if (os_subtype == OS_NT + && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0) + SetBrushOrgEx (s->hdc, 0, 0, NULL); + StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, + compat_hdc, s->slice.x, s->slice.y, + orig_width, orig_height, SRCINVERT); + StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, + mask_dc, s->slice.x, s->slice.y, + orig_width, orig_height, SRCAND); + StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, + compat_hdc, s->slice.x, s->slice.y, + orig_width, orig_height, SRCINVERT); + if (pmode) + SetStretchBltMode (s->hdc, pmode); + } SelectObject (mask_dc, mask_orig_obj); DeleteDC (mask_dc); } @@ -1900,9 +1937,22 @@ x_draw_image_foreground (struct glyph_string *s) { SetTextColor (s->hdc, s->gc->foreground); SetBkColor (s->hdc, s->gc->background); - - BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, - compat_hdc, s->slice.x, s->slice.y, SRCCOPY); + if (s->slice.width == orig_width && s->slice.height == orig_height) + BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, + compat_hdc, s->slice.x, s->slice.y, SRCCOPY); + else + { + int pmode = 0; + /* Windows 9X doesn't support HALFTONE. */ + if (os_subtype == OS_NT + && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0) + SetBrushOrgEx (s->hdc, 0, 0, NULL); + StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, + compat_hdc, s->slice.x, s->slice.y, + orig_width, orig_height, SRCCOPY); + if (pmode) + SetStretchBltMode (s->hdc, pmode); + } /* When the image has a mask, we can expect that at least part of a mouse highlight or a block cursor will @@ -2031,6 +2081,10 @@ w32_draw_image_foreground_1 (struct glyph_string *s, HBITMAP pixmap) if (s->slice.y == 0) y += s->img->vmargin; + /* FIXME (maybe): The below doesn't support image scaling. But it + seems to never be called, because the conditions for its call in + x_draw_image_glyph_string are never fulfilled (they will be if + the #ifdef'ed away part of that function is ever activated). */ if (s->img->pixmap) { HDC compat_hdc = CreateCompatibleDC (hdc);