commit 8f1d0295bcf5ff5b2899831a5705051bca366c0e (HEAD, refs/remotes/origin/master) Author: Morgan Smith Date: Fri Aug 19 01:51:42 2022 +0200 Speed up image-dired-display-image * lisp/image-dired.el (image-dired-display-image): Open file literally so we don't run image-mode twice. (Bug#57281) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 93cce33c2b..9f12354111 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -1978,8 +1978,8 @@ based on `image-mode'." (cur-win (selected-window))) (when buf (kill-buffer buf)) - (when-let ((buf (find-file-other-window file))) - (display-buffer buf) + (when-let ((buf (find-file-noselect file nil t))) + (pop-to-buffer buf) (rename-buffer image-dired-display-image-buffer) (image-dired-display-image-mode) (select-window cur-win)))) commit 1a9175a0de98676ac9aa1dec8f3c5c585ce2a9cd Merge: b90192b50e e64d811b51 Author: Stefan Kangas Date: Fri Aug 19 06:30:21 2022 +0200 Merge from origin/emacs-28 e64d811b51 Improve image-mode-as-hex docstring commit b90192b50e59ff987ef2102c1538e94b7864b1fd Author: Po Lu Date: Fri Aug 19 10:06:29 2022 +0800 Fix more calls to XQueryPointer for MPX * src/xterm.c (x_dnd_begin_drag_and_drop): Set DND devices to -1 if XI2 is not supported on the given display. (x_query_pointer): Make wrapper around x_query_pointer_1. (x_query_pointer_1): Split off most of x_query_pointer to this function. Allow a specific client pointer to be specified. (x_dnd_update_tooltip_now, x_dnd_update_state): Use x_query_pointer_1 with the right device instead of XQueryPointer. diff --git a/src/xterm.c b/src/xterm.c index a329ca59d0..12c7b7d4dc 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12186,6 +12186,11 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, if (device) x_dnd_keyboard_device = device->attachment; } + else + { + x_dnd_pointer_device = -1; + x_dnd_keyboard_device = -1; + } #endif @@ -13401,18 +13406,17 @@ get_keysym_name (int keysym) return value; } -/* Like XQueryPointer, but always use the right client pointer - device. */ - -Bool -x_query_pointer (Display *dpy, Window w, Window *root_return, - Window *child_return, int *root_x_return, - int *root_y_return, int *win_x_return, - int *win_y_return, unsigned int *mask_return) +static Bool +x_query_pointer_1 (struct x_display_info *dpyinfo, + int client_pointer_device, Window w, + Window *root_return, Window *child_return, + int *root_x_return, int *root_y_return, + int *win_x_return, int *win_y_return, + unsigned int *mask_return) { Bool rc; + Display *dpy; #ifdef HAVE_XINPUT2 - struct x_display_info *dpyinfo; bool had_errors; XIModifierState modifiers; XIButtonState buttons; @@ -13421,9 +13425,10 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, unsigned int state; #endif + dpy = dpyinfo->display; + #ifdef HAVE_XINPUT2 - dpyinfo = x_display_info_for_display (dpy); - if (dpyinfo && dpyinfo->client_pointer_device != -1) + if (client_pointer_device != -1) { /* Catch errors caused by the device going away. This is not very expensive, since XIQueryPointer will sync anyway. */ @@ -13463,6 +13468,31 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, return rc; } +Bool +x_query_pointer (Display *dpy, Window w, Window *root_return, + Window *child_return, int *root_x_return, + int *root_y_return, int *win_x_return, + int *win_y_return, unsigned int *mask_return) +{ + struct x_display_info *dpyinfo; + + dpyinfo = x_display_info_for_display (dpy); + + if (!dpyinfo) + emacs_abort (); + +#ifdef HAVE_XINPUT2 + return x_query_pointer_1 (dpyinfo, dpyinfo->client_pointer_device, + w, root_return, child_return, root_x_return, + root_y_return, win_x_return, win_y_return, + mask_return); +#else + return x_query_pointer_1 (dpyinfo, -1, w, root_return, child_return, + root_x_return, root_y_return, win_x_return, + win_y_return, mask_return); +#endif +} + /* Mouse clicks and mouse movement. Rah. Formerly, we used PointerMotionHintMask (in standard_event_mask) @@ -16902,11 +16932,19 @@ x_dnd_update_tooltip_now (void) dpyinfo = FRAME_DISPLAY_INFO (x_dnd_frame); +#ifndef HAVE_XINPUT2 rc = XQueryPointer (dpyinfo->display, dpyinfo->root_window, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); +#else + rc = x_query_pointer_1 (dpyinfo, x_dnd_pointer_device, + dpyinfo->root_window, + &root, &child, &root_x, + &root_y, &win_x, &win_y, + &mask); +#endif if (rc) x_dnd_update_tooltip_position (root_x, root_y); @@ -16926,12 +16964,17 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp) xm_drop_start_message dsmsg; bool was_frame; - if (XQueryPointer (dpyinfo->display, - dpyinfo->root_window, - &dummy, &dummy_child, - &root_x, &root_y, - &dummy_x, &dummy_y, - &dummy_mask)) + if (x_query_pointer_1 (dpyinfo, +#ifdef HAVE_XINPUT2 + x_dnd_pointer_device, +#else + -1, +#endif + dpyinfo->root_window, + &dummy, &dummy_child, + &root_x, &root_y, + &dummy_x, &dummy_y, + &dummy_mask)) { target = x_dnd_get_target_window (dpyinfo, root_x, root_y, &target_proto, commit f1f2bbbc0880f1033feff69fa786d551875ec5e6 Author: Stefan Kangas Date: Thu Aug 18 23:47:47 2022 +0200 Improve obsoletion of image-transform-fit-to-{height,width} * lisp/image-mode.el (image-transform-fit-to-height) (image-transform-fit-to-width): Change obsoletion to refer to new command 'image-transform-fit-to-window'. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 9646d8e4c3..1f4ade6e02 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -1554,14 +1554,14 @@ The percentage is in relation to the original size of the image." (defun image-transform-fit-to-height () "Fit the current image to the height of the current window." - (declare (obsolete nil "29.1")) + (declare (obsolete image-transform-fit-to-window "29.1")) (interactive nil image-mode) (setq image-transform-resize 'fit-height) (image-toggle-display-image)) (defun image-transform-fit-to-width () "Fit the current image to the width of the current window." - (declare (obsolete nil "29.1")) + (declare (obsolete image-transform-fit-to-window "29.1")) (interactive nil image-mode) (setq image-transform-resize 'fit-width) (image-toggle-display-image)) commit 0bd96806ef1a0f0d2d3f48cdb1204b7e393ab036 Author: Andrea Corallo Date: Thu Aug 18 23:41:39 2022 +0200 * Rename `comp--typeof-builtin-types' * lisp/emacs-lisp/comp-cstr.el (comp--typeof-builtin-types): Rename. (comp-normalize-valset, comp-common-supertype-2): Update. diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 948a2c4f70..8cff06a383 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -37,9 +37,9 @@ (require 'cl-lib) -(defconst comp--typeof-types (mapcar (lambda (x) - (append x '(t))) - cl--typeof-types) +(defconst comp--typeof-builtin-types (mapcar (lambda (x) + (append x '(t))) + cl--typeof-types) ;; TODO can we just add t in `cl--typeof-types'? "Like `cl--typeof-types' but with t as common supertype.") @@ -230,7 +230,7 @@ Return them as multiple value." (cl-loop named outer with found = nil - for l in comp--typeof-types + for l in comp--typeof-builtin-types do (cl-loop for x in l for i from (length l) downto 0 @@ -273,7 +273,7 @@ Return them as multiple value." (cl-loop with types = (apply #'append typesets) with res = '() - for lane in comp--typeof-types + for lane in comp--typeof-builtin-types do (cl-loop with last = nil for x in lane commit 715f1ebea303459747765f2c5e08e9c41c97e65b Author: Andrea Corallo Date: Thu Aug 18 23:35:33 2022 +0200 * lisp/emacs-lisp/comp-cstr.el (comp--all-builtin-types): Remove diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 6451e34c42..948a2c4f70 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -43,10 +43,6 @@ ;; TODO can we just add t in `cl--typeof-types'? "Like `cl--typeof-types' but with t as common supertype.") -(defconst comp--all-builtin-types - (append cl--all-builtin-types '(t)) - "Likewise like `cl--all-builtin-types' but with t as common supertype.") - (cl-defstruct (comp-cstr (:constructor comp-type-to-cstr (type &aux (null (eq type 'null)) commit 869bef892b0211704ba438d37ba6914574835c7e Author: Arash Esbati Date: Thu Aug 18 22:55:18 2022 +0200 Adjust the environment name for the minted package * lisp/textmodes/reftex-vars.el (reftex-label-alist-builtin): Fix the name of the environment which can contain a \label macro. diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index f9f09825fa..ee94cc5d69 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -100,7 +100,7 @@ (("lstlisting" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting")))) (minted "The minted package" - (("minted" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting")))) + (("listing" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting")))) ;; The LaTeX core stuff (LaTeX "LaTeX default environments" commit e64d811b510a8579a97639d5c3018622eb43e4d5 (refs/remotes/origin/emacs-28) Author: Stefan Kangas Date: Thu Aug 18 20:13:34 2022 +0200 Improve image-mode-as-hex docstring * lisp/image-mode.el: Fix typos. (image-mode-as-hex): Doc fix; say that it uses 'hexl-mode' and reflow. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 383d1ac50b..726b76b2ba 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -742,11 +742,12 @@ displays an image file as text." (image-toggle-display-text)))) (defun image-mode-as-hex () - "Set a non-image mode as major mode in combination with image minor mode. + "Set `hexl-mode' as major mode in combination with image minor mode. A non-mage major mode found from `auto-mode-alist' or fundamental mode displays an image file as hex. `image-minor-mode' provides the key -\\\\[image-toggle-hex-display] to switch back to `image-mode' -to display an image file as the actual image. +\\\\[image-toggle-hex-display] to switch back to `image-mode' \ +to display an image file as +the actual image. You can use `image-mode-as-hex' in `auto-mode-alist' when you want to display an image file as hex initially. @@ -1161,14 +1162,14 @@ tar mode buffers." (when (buffer-live-p archive-superior-buffer) (push (cons 'archive archive-superior-buffer) buffers))) (t - ;; Find a dired buffer. + ;; Find a Dired buffer. (dolist (buffer (buffer-list)) (with-current-buffer buffer (when (and (derived-mode-p 'dired-mode) (equal (file-truename dir) (file-truename default-directory))) (push (cons 'dired (current-buffer)) buffers)))) - ;; If we can't find any buffers to navigate in, we open a dired + ;; If we can't find any buffers to navigate in, we open a Dired ;; buffer. (unless buffers (push (cons 'dired (find-file-noselect dir)) buffers) @@ -1180,14 +1181,14 @@ tar mode buffers." (defun image-mode--next-file (file n) "Go to the next image file in the parent buffer of FILE. -This is typically a dired buffer, but may also be a tar/archive buffer. +This is typically a Dired buffer, but may also be a tar/archive buffer. Return the next image file from that buffer. If N is negative, go to the previous file." (let ((regexp (image-file-name-regexp)) (buffers (image-mode--directory-buffers file)) next) (dolist (buffer buffers) - ;; We do this traversal for all the dired buffers open on this + ;; We do this traversal for all the Dired buffers open on this ;; directory. There probably is just one, but we want to move ;; point in all of them. (save-window-excursion @@ -1236,8 +1237,8 @@ replacing the current Image mode buffer." (message "Copied %s" buffer-file-name)) (defun image-mode-mark-file () - "Mark the current file in the appropriate dired buffer(s). -Any dired buffer that's opened to the current file's directory + "Mark the current file in the appropriate Dired buffer(s). +Any Dired buffer that's opened to the current file's directory will have the line where the image appears (if any) marked. If no such buffer exists, it will be opened." @@ -1247,8 +1248,8 @@ If no such buffer exists, it will be opened." (image-mode--mark-file buffer-file-name #'dired-mark "marked")) (defun image-mode-unmark-file () - "Unmark the current file in the appropriate dired buffer(s). -Any dired buffer that's opened to the current file's directory + "Unmark the current file in the appropriate Dired buffer(s). +Any Dired buffer that's opened to the current file's directory will remove the mark from the line where the image appears (if any). commit 7858ec980bf968b15703db520e18903e51bfb63f Author: Stefan Kangas Date: Thu Aug 18 19:58:39 2022 +0200 Do interactive mode tagging in image-mode.el * lisp/image-mode.el (image-forward-hscroll) (image-backward-hscroll, image-next-line, image-previous-line) (image-scroll-up, image-scroll-down, image-scroll-left) (image-scroll-right, image-bol, image-eol, image-bob, image-eob) (image-mode-fit-frame, image-kill-buffer, image-next-file) (image-previous-file, image-mode-copy-file-name-as-kill) (image-mode-mark-file, image-mode-unmark-file) (image-transform-set-percent, image-transform-set-scale) (image-transform-fit-to-height, image-transform-fit-to-width) (image-transform-fit-both, image-transform-fit-to-window) (image-transform-set-rotation, image-transform-set-smoothing) (image-transform-original, image-transform-reset): Add interactive tag for image-mode. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 20aa9588b3..9646d8e4c3 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -242,7 +242,7 @@ image." (defun image-forward-hscroll (&optional n) "Scroll image in current window to the left by N character widths. Stop if the right edge of the image is reached." - (interactive "p") + (interactive "p" image-mode) (cond ((= n 0) nil) ((< n 0) (image-set-window-hscroll (max 0 (+ (window-hscroll) n)))) @@ -257,13 +257,13 @@ Stop if the right edge of the image is reached." (defun image-backward-hscroll (&optional n) "Scroll image in current window to the right by N character widths. Stop if the left edge of the image is reached." - (interactive "p") + (interactive "p" image-mode) (image-forward-hscroll (- n))) (defun image-next-line (n) "Scroll image in current window upward by N lines. Stop if the bottom edge of the image is reached." - (interactive "p") + (interactive "p" image-mode) ;; Convert N to pixels. (setq n (* n (frame-char-height))) (cond ((= n 0) nil) @@ -280,7 +280,7 @@ Stop if the bottom edge of the image is reached." (defun image-previous-line (&optional n) "Scroll image in current window downward by N lines. Stop if the top edge of the image is reached." - (interactive "p") + (interactive "p" image-mode) (image-next-line (- n))) (defun image-scroll-up (&optional n) @@ -298,7 +298,7 @@ A negative N means scroll downward. If N is the atom `-', scroll downward by nearly full screen. When calling from a program, supply as argument a number, nil, or `-'." - (interactive "P") + (interactive "P" image-mode) (cond ((null n) (let* ((edges (window-inside-edges)) (win-height (- (nth 3 edges) (nth 1 edges)))) @@ -326,7 +326,7 @@ A negative N means scroll upward. If N is the atom `-', scroll upward by nearly full screen. When calling from a program, supply as argument a number, nil, or `-'." - (interactive "P") + (interactive "P" image-mode) (cond ((null n) (let* ((edges (window-inside-edges)) (win-height (- (nth 3 edges) (nth 1 edges)))) @@ -347,7 +347,7 @@ A near full screen is 2 columns less than a full screen. Negative ARG means scroll rightward. If ARG is the atom `-', scroll rightward by nearly full screen. When calling from a program, supply as argument a number, nil, or `-'." - (interactive "P") + (interactive "P" image-mode) (cond ((null n) (let* ((edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges)))) @@ -368,7 +368,7 @@ A near full screen is 2 less than a full screen. Negative ARG means scroll leftward. If ARG is the atom `-', scroll leftward by nearly full screen. When calling from a program, supply as argument a number, nil, or `-'." - (interactive "P") + (interactive "P" image-mode) (cond ((null n) (let* ((edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges)))) @@ -385,7 +385,7 @@ When calling from a program, supply as argument a number, nil, or `-'." "Scroll horizontally to the left edge of the image in the current window. With argument ARG not nil or 1, move forward ARG - 1 lines first, stopping if the top or bottom edge of the image is reached." - (interactive "p") + (interactive "p" image-mode) (and arg (/= (setq arg (prefix-numeric-value arg)) 1) (image-next-line (- arg 1))) @@ -395,7 +395,7 @@ stopping if the top or bottom edge of the image is reached." "Scroll horizontally to the right edge of the image in the current window. With argument ARG not nil or 1, move forward ARG - 1 lines first, stopping if the top or bottom edge of the image is reached." - (interactive "p") + (interactive "p" image-mode) (and arg (/= (setq arg (prefix-numeric-value arg)) 1) (image-next-line (- arg 1))) @@ -407,13 +407,13 @@ stopping if the top or bottom edge of the image is reached." (defun image-bob () "Scroll to the top-left corner of the image in the current window." - (interactive) + (interactive nil image-mode) (image-set-window-hscroll 0) (image-set-window-vscroll 0)) (defun image-eob () "Scroll to the bottom-right corner of the image in the current window." - (interactive) + (interactive nil image-mode) (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (pixel-edges (window-edges nil t t)) @@ -435,7 +435,7 @@ If called interactively, or if TOGGLE is non-nil, toggle between fitting FRAME to the current image and restoring the size and window configuration prior to the last `image-mode-fit-frame' call." - (interactive (list nil t)) + (interactive (list nil t) image-mode) (let* ((buffer (current-buffer)) (saved (frame-parameter frame 'image-mode-saved-params)) (window-configuration (current-window-configuration frame)) @@ -1014,7 +1014,7 @@ Otherwise, display the image by calling `image-mode'." (defun image-kill-buffer () "Kill the current buffer." - (interactive) + (interactive nil image-mode) (kill-buffer (current-buffer))) (defun image-after-revert-hook () @@ -1195,7 +1195,7 @@ current one, in cyclic alphabetical order. This command visits the specified file via `find-alternate-file', replacing the current Image mode buffer." - (interactive "p") + (interactive "p" image-mode) (unless (derived-mode-p 'image-mode) (error "The buffer is not in Image mode")) (unless buffer-file-name @@ -1292,12 +1292,12 @@ current one, in cyclic alphabetical order. This command visits the specified file via `find-alternate-file', replacing the current Image mode buffer." - (interactive "p") + (interactive "p" image-mode) (image-next-file (- n))) (defun image-mode-copy-file-name-as-kill () "Push the currently visited file name onto the kill ring." - (interactive) + (interactive nil image-mode) (unless buffer-file-name (error "The current buffer doesn't visit a file")) (kill-new buffer-file-name) @@ -1309,7 +1309,7 @@ Any dired buffer that's opened to the current file's directory will have the line where the image appears (if any) marked. If no such buffer exists, it will be opened." - (interactive) + (interactive nil image-mode) (unless buffer-file-name (error "Current buffer is not visiting a file")) (image-mode--mark-file buffer-file-name #'dired-mark "marked")) @@ -1321,7 +1321,7 @@ will remove the mark from the line where the image appears (if any). If no such buffer exists, it will be opened." - (interactive) + (interactive nil image-mode) (unless buffer-file-name (error "Current buffer is not visiting a file")) (image-mode--mark-file buffer-file-name #'dired-unmark "unmarked")) @@ -1539,7 +1539,8 @@ return value is suitable for appending to an image spec." "Prompt for a percentage, and resize the current image to that size. The percentage is in relation to the original size of the image." (interactive (list (read-number "Scale (% of original): " 100 - 'read-number-history))) + 'read-number-history)) + image-mode) (unless (cl-plusp scale) (error "Not a positive number: %s" scale)) (setq image-transform-resize (/ scale 100.0)) @@ -1547,59 +1548,60 @@ The percentage is in relation to the original size of the image." (defun image-transform-set-scale (scale) "Prompt for a number, and resize the current image by that amount." - (interactive "nScale: ") + (interactive "nScale: " image-mode) (setq image-transform-resize scale) (image-toggle-display-image)) (defun image-transform-fit-to-height () "Fit the current image to the height of the current window." (declare (obsolete nil "29.1")) - (interactive) + (interactive nil image-mode) (setq image-transform-resize 'fit-height) (image-toggle-display-image)) (defun image-transform-fit-to-width () "Fit the current image to the width of the current window." (declare (obsolete nil "29.1")) - (interactive) + (interactive nil image-mode) (setq image-transform-resize 'fit-width) (image-toggle-display-image)) (defun image-transform-fit-both () "Scale the current image down to fit in the current window." - (interactive) + (interactive nil image-mode) (setq image-transform-resize t) (image-toggle-display-image)) (defun image-transform-fit-to-window () "Fit the current image to the height and width of the current window." - (interactive) + (interactive nil image-mode) (setq image-transform-resize 'fit-window) (image-toggle-display-image)) (defun image-transform-set-rotation (rotation) "Prompt for an angle ROTATION, and rotate the image by that amount. ROTATION should be in degrees." - (interactive "nRotation angle (in degrees): ") + (interactive "nRotation angle (in degrees): " image-mode) (setq image-transform-rotation (float (mod rotation 360))) (image-toggle-display-image)) (defun image-transform-set-smoothing (smoothing) (interactive (list (completing-read "Smoothing: " - '("none" "smooth") nil t))) + '("none" "smooth") nil t)) + image-mode) (setq image--transform-smoothing smoothing) (image-toggle-display-image)) (defun image-transform-original () "Display the current image with the original (actual) size and rotation." - (interactive) + (interactive nil image-mode) (setq image-transform-resize nil image-transform-scale 1) (image-toggle-display-image)) (defun image-transform-reset () "Display the current image with the default (initial) size and rotation." - (interactive) + (interactive nil image-mode) (setq image-transform-resize image-auto-resize image-transform-rotation 0.0 image-transform-scale 1 commit 104cb5cbf5da4c07d5e4b3d26431eaa42e8ce33d Author: Stefan Kangas Date: Thu Aug 18 18:46:10 2022 +0200 Make toggling between image, hex and text more consistent * lisp/image-mode.el (image-toggle-hex-display, image-toggle-display): Ensure commands work correctly also in `hexl-mode'. (image-mode-to-text): (image-mode-as-hex, image-mode-as-text): Enable image-minor-mode also in hexl-mode, which adds the "C-c C-x" keybinding for easier toggling. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 0888e565a3..20aa9588b3 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -773,8 +773,6 @@ displays an image file as text." (major-mode-restore '(image-mode image-mode-as-text)) ;; Restore `image-type' after `kill-all-local-variables' in `normal-mode'. (setq image-type previous-image-type) - ;; Enable image minor mode with `C-c C-c'. - (image-minor-mode 1) (unless (image-get-display-property) ;; Show the image file as text. (image-toggle-display-text)))) @@ -794,8 +792,10 @@ on these modes." (interactive) (image-mode-to-text) (hexl-mode) - (message "%s" (substitute-command-keys - "Type \\[hexl-mode-exit] to view the image as an image"))) + (image-minor-mode 1) + (message (substitute-command-keys + "Type \\[image-toggle-display] or \ +\\[image-toggle-hex-display] to view the image as an image"))) (defun image-mode-as-text () "Set a non-image mode as major mode in combination with image minor mode. @@ -811,6 +811,7 @@ See commands `image-mode' and `image-minor-mode' for more information on these modes." (interactive) (image-mode-to-text) + (image-minor-mode 1) (message (substitute-command-keys "Type \\[image-toggle-display] to view the image as %s") (if (image-get-display-property) @@ -986,14 +987,17 @@ was inserted." (memq (intern (upcase (file-name-extension filename)) obarray) imagemagick-types-inhibit))))) +(declare-function hexl-mode-exit "hexl" (&optional arg)) + (defun image-toggle-hex-display () "Toggle between image and hex display." (interactive) - (if (image-get-display-property) - (image-mode-as-hex) - (if (eq major-mode 'fundamental-mode) - (image-mode-as-hex) - (image-mode)))) + (cond ((or (image-get-display-property) ; in `image-mode' + (eq major-mode 'fundamental-mode)) + (image-mode-as-hex)) + ((eq major-mode 'hexl-mode) + (hexl-mode-exit)) + (t (error "That command is invalid here")))) (defun image-toggle-display () "Toggle between image and text display. @@ -1002,11 +1006,11 @@ If the current buffer is displaying an image file as an image, call `image-mode-as-text' to switch to text or hex display. Otherwise, display the image by calling `image-mode'." (interactive) - (if (image-get-display-property) - (image-mode-as-text) - (if (eq major-mode 'hexl-mode) - (image-mode-as-text) - (image-mode)))) + (cond ((image-get-display-property) ; in `image-mode' + (image-mode-as-text)) + ((eq major-mode 'hexl-mode) + (hexl-mode-exit)) + ((image-mode)))) (defun image-kill-buffer () "Kill the current buffer." commit 054d1e80dc7cf3ba612ff704f312d0b8953416cf Author: Stefan Kangas Date: Thu Aug 18 18:06:56 2022 +0200 ; * lisp/image-mode.el (image-minor-mode): Reflow docstring. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 7892f0d5b9..0888e565a3 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -754,9 +754,9 @@ Key bindings: (define-minor-mode image-minor-mode "Toggle Image minor mode in this buffer. -Image minor mode provides the key \\\\[image-toggle-display], -to switch back to `image-mode' and display an image file as the -actual image." +Image minor mode provides the key \\\\[image-toggle-display], \ +to switch back to +`image-mode' and display an image file as the actual image." :lighter (:eval (if image-type (format " Image[%s]" image-type) " Image")) :group 'image :version "22.1" commit 0dc9c9a68f5a137fd71d7aca356d08fd52b16d52 Author: Stefan Kangas Date: Thu Oct 28 03:36:28 2021 +0200 New command image-transform-set-percent * lisp/image-mode.el (image-transform-set-percent): New command. (image-mode-map): Bind above new command to "s p". * doc/emacs/files.texi (Image Mode): Document it. diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 404978b315..5b3b15cd38 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -2273,12 +2273,14 @@ behavior by using the options @code{image-auto-resize} and @findex image-transform-set-scale @findex image-transform-reset To resize the image manually you can use the command -@code{image-transform-fit-to-window} bound to @kbd{s w} -that fits the image to both the window height and width. -To scale the image specifying a scale factor, use the command -@code{image-transform-set-scale} bound to @kbd{s s}. -To reset all transformations to the initial state, use -@code{image-transform-reset} bound to @kbd{s 0}. +@code{image-transform-fit-to-window} bound to @kbd{s w} that fits the +image to both the window height and width. To scale the image to a +percentage of its original size, use the command +@code{image-transform-set-percent} bound to @kbd{s p}. To scale +the image specifying a scale factor, use the command +@code{image-transform-set-scale} bound to @kbd{s s}. To reset all +transformations to the initial state, use @code{image-transform-reset} +bound to @kbd{s 0}. @findex image-next-file @findex image-previous-file diff --git a/etc/NEWS b/etc/NEWS index 4b3a48a820..511687a174 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1863,6 +1863,11 @@ this message for SVG and XPM. *** New commands: 'image-flip-horizontally' and 'image-flip-vertically'. These commands horizontally and vertically flip the image under point. ++++ +*** New command 'image-transform-set-percent'. +It allows setting the image size to a percentage of its original size, +and is bound to "s p" in Image mode. + ** Images +++ diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 726f2af2ad..7892f0d5b9 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -494,6 +494,7 @@ image as text, when opening such images in `image-mode'." "s h" #'image-transform-fit-to-height "s i" #'image-transform-fit-to-width "s b" #'image-transform-fit-both + "s p" #'image-transform-set-percent "s s" #'image-transform-set-scale "s r" #'image-transform-set-rotation "s m" #'image-transform-set-smoothing @@ -1530,6 +1531,16 @@ return value is suitable for appending to an image spec." (list :transform-smoothing (string= image--transform-smoothing "smooth"))))))) +(defun image-transform-set-percent (scale) + "Prompt for a percentage, and resize the current image to that size. +The percentage is in relation to the original size of the image." + (interactive (list (read-number "Scale (% of original): " 100 + 'read-number-history))) + (unless (cl-plusp scale) + (error "Not a positive number: %s" scale)) + (setq image-transform-resize (/ scale 100.0)) + (image-toggle-display-image)) + (defun image-transform-set-scale (scale) "Prompt for a number, and resize the current image by that amount." (interactive "nScale: ") commit 9f8e16d828bab7db3bdf67fabd5b3abfe3974e8e Author: Stefan Kangas Date: Thu Aug 18 17:23:03 2022 +0200 Prefer defvar-keymap in image-mode.el * lisp/image-mode.el (image-mode-map, image-minor-mode-map): Prefer defvar-keymap. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index a923db5b5f..726f2af2ad 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -480,156 +480,155 @@ image as text, when opening such images in `image-mode'." (defvar-local image-multi-frame nil "Non-nil if image for the current Image mode buffer has multiple frames.") -(defvar image-mode-map - (let ((map (make-sparse-keymap))) - - ;; Toggling keys - (define-key map "\C-c\C-c" 'image-toggle-display) - (define-key map "\C-c\C-x" 'image-toggle-hex-display) - - ;; Transformation keys - (define-key map "sf" 'image-mode-fit-frame) - (define-key map "sw" 'image-transform-fit-to-window) - (define-key map "sh" 'image-transform-fit-to-height) - (define-key map "si" 'image-transform-fit-to-width) - (define-key map "sb" 'image-transform-fit-both) - (define-key map "ss" 'image-transform-set-scale) - (define-key map "sr" 'image-transform-set-rotation) - (define-key map "sm" 'image-transform-set-smoothing) - (define-key map "so" 'image-transform-original) - (define-key map "s0" 'image-transform-reset) - - ;; Multi-frame keys - (define-key map (kbd "RET") 'image-toggle-animation) - (define-key map "F" 'image-goto-frame) - (define-key map "f" 'image-next-frame) - (define-key map "b" 'image-previous-frame) - (define-key map "a+" 'image-increase-speed) - (define-key map "a-" 'image-decrease-speed) - (define-key map "a0" 'image-reset-speed) - (define-key map "ar" 'image-reverse-speed) - - ;; File keys - (define-key map "n" 'image-next-file) - (define-key map "p" 'image-previous-file) - (define-key map "w" 'image-mode-copy-file-name-as-kill) - (define-key map "m" 'image-mode-mark-file) - (define-key map "u" 'image-mode-unmark-file) - - ;; Scrolling keys - (define-key map (kbd "SPC") 'image-scroll-up) - (define-key map (kbd "S-SPC") 'image-scroll-down) - (define-key map (kbd "DEL") 'image-scroll-down) - (define-key map [remap forward-char] 'image-forward-hscroll) - (define-key map [remap backward-char] 'image-backward-hscroll) - (define-key map [remap right-char] 'image-forward-hscroll) - (define-key map [remap left-char] 'image-backward-hscroll) - (define-key map [remap previous-line] 'image-previous-line) - (define-key map [remap next-line] 'image-next-line) - (define-key map [remap scroll-up] 'image-scroll-up) - (define-key map [remap scroll-down] 'image-scroll-down) - (define-key map [remap scroll-up-command] 'image-scroll-up) - (define-key map [remap scroll-down-command] 'image-scroll-down) - (define-key map [remap scroll-left] 'image-scroll-left) - (define-key map [remap scroll-right] 'image-scroll-right) - (define-key map [remap move-beginning-of-line] 'image-bol) - (define-key map [remap move-end-of-line] 'image-eol) - (define-key map [remap beginning-of-buffer] 'image-bob) - (define-key map [remap end-of-buffer] 'image-eob) - - (easy-menu-define image-mode-menu map "Menu for Image mode." - '("Image" - ["Show as Text" image-toggle-display :active t - :help "Show image as text"] +(defvar-keymap image-mode-map + :doc "Mode keymap for `image-mode'." + :parent (make-composed-keymap image-map special-mode-map) + + ;; Toggling keys + "C-c C-c" #'image-toggle-display + "C-c C-x" #'image-toggle-hex-display + + ;; Transformation keys + "s f" #'image-mode-fit-frame + "s w" #'image-transform-fit-to-window + "s h" #'image-transform-fit-to-height + "s i" #'image-transform-fit-to-width + "s b" #'image-transform-fit-both + "s s" #'image-transform-set-scale + "s r" #'image-transform-set-rotation + "s m" #'image-transform-set-smoothing + "s o" #'image-transform-original + "s 0" #'image-transform-reset + + ;; Multi-frame keys + "RET" #'image-toggle-animation + "F" #'image-goto-frame + "f" #'image-next-frame + "b" #'image-previous-frame + "a +" #'image-increase-speed + "a -" #'image-decrease-speed + "a 0" #'image-reset-speed + "a r" #'image-reverse-speed + + ;; File keys + "n" #'image-next-file + "p" #'image-previous-file + "w" #'image-mode-copy-file-name-as-kill + "m" #'image-mode-mark-file + "u" #'image-mode-unmark-file + + ;; Scrolling keys + "SPC" #'image-scroll-up + "S-SPC" #'image-scroll-down + "DEL" #'image-scroll-down + + ;; Remapped + " " #'image-forward-hscroll + " " #'image-backward-hscroll + " " #'image-forward-hscroll + " " #'image-backward-hscroll + " " #'image-previous-line + " " #'image-next-line + " " #'image-scroll-up + " " #'image-scroll-down + " " #'image-scroll-up + " " #'image-scroll-down + " " #'image-scroll-left + " " #'image-scroll-right + " " #'image-bol + " " #'image-eol + " " #'image-bob + " " #'image-eob) + +(easy-menu-define image-mode-menu image-mode-map + "Menu for Image mode." + '("Image" + ["Show as Text" image-toggle-display :active t + :help "Show image as text"] ["Show as Hex" image-toggle-hex-display :active t :help "Show image as hex"] - "--" - ["Fit Frame to Image" image-mode-fit-frame :active t - :help "Resize frame to match image"] - ["Fit Image to Window" image-transform-fit-to-window - :help "Resize image to match the window height and width"] - ["Fit Image to Window (Scale down only)" image-transform-fit-both - :help "Scale image down to match the window height and width"] - ["Zoom In" image-increase-size - :help "Enlarge the image"] - ["Zoom Out" image-decrease-size - :help "Shrink the image"] - ["Set Scale..." image-transform-set-scale - :help "Resize image by specified scale factor"] - ["Rotate Clockwise" image-rotate - :help "Rotate the image"] - ["Set Rotation..." image-transform-set-rotation - :help "Set rotation angle of the image"] - ["Set Smoothing..." image-transform-set-smoothing - :help "Toggle smoothing"] - ["Original Size" image-transform-original - :help "Reset image to actual size"] - ["Reset to Default Size" image-transform-reset - :help "Reset all image transformations to initial size"] - "--" - ["Show Thumbnails" - (lambda () - (interactive) - (image-dired default-directory)) - :active default-directory - :help "Show thumbnails for all images in this directory"] - ["Previous Image" image-previous-file :active buffer-file-name - :help "Move to previous image in this directory"] - ["Next Image" image-next-file :active buffer-file-name - :help "Move to next image in this directory"] - ["Copy File Name" image-mode-copy-file-name-as-kill - :active buffer-file-name - :help "Copy the current file name to the kill ring"] - "--" - ["Animate Image" image-toggle-animation :style toggle - :selected (let ((image (image-get-display-property))) - (and image (image-animate-timer image))) - :active image-multi-frame - :help "Toggle image animation"] - ["Loop Animation" - (lambda () (interactive) - (setq image-animate-loop (not image-animate-loop)) - ;; FIXME this is a hacky way to make it affect a currently - ;; animating image. - (when (let ((image (image-get-display-property))) - (and image (image-animate-timer image))) - (image-toggle-animation) - (image-toggle-animation))) - :style toggle :selected image-animate-loop - :active image-multi-frame - :help "Animate images once, or forever?"] - ["Reverse Animation" image-reverse-speed - :style toggle :selected (let ((image (image-get-display-property))) - (and image (< - (image-animate-get-speed image) - 0))) - :active image-multi-frame - :help "Reverse direction of this image's animation?"] - ["Speed Up Animation" image-increase-speed - :active image-multi-frame - :help "Speed up this image's animation"] - ["Slow Down Animation" image-decrease-speed - :active image-multi-frame - :help "Slow down this image's animation"] - ["Reset Animation Speed" image-reset-speed - :active image-multi-frame - :help "Reset the speed of this image's animation"] - ["Previous Frame" image-previous-frame :active image-multi-frame - :help "Show the previous frame of this image"] - ["Next Frame" image-next-frame :active image-multi-frame - :help "Show the next frame of this image"] - ["Goto Frame..." image-goto-frame :active image-multi-frame - :help "Show a specific frame of this image"] - )) - (make-composed-keymap (list map image-map) special-mode-map)) - "Mode keymap for `image-mode'.") - -(defvar image-minor-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-c\C-c" 'image-toggle-display) - (define-key map "\C-c\C-x" 'image-toggle-hex-display) - map) - "Mode keymap for `image-minor-mode'.") + "--" + ["Fit Frame to Image" image-mode-fit-frame :active t + :help "Resize frame to match image"] + ["Fit Image to Window" image-transform-fit-to-window + :help "Resize image to match the window height and width"] + ["Fit Image to Window (Scale down only)" image-transform-fit-both + :help "Scale image down to match the window height and width"] + ["Zoom In" image-increase-size + :help "Enlarge the image"] + ["Zoom Out" image-decrease-size + :help "Shrink the image"] + ["Set Scale..." image-transform-set-scale + :help "Resize image by specified scale factor"] + ["Rotate Clockwise" image-rotate + :help "Rotate the image"] + ["Set Rotation..." image-transform-set-rotation + :help "Set rotation angle of the image"] + ["Set Smoothing..." image-transform-set-smoothing + :help "Toggle smoothing"] + ["Original Size" image-transform-original + :help "Reset image to actual size"] + ["Reset to Default Size" image-transform-reset + :help "Reset all image transformations to initial size"] + "--" + ["Show Thumbnails" + (lambda () + (interactive) + (image-dired default-directory)) + :active default-directory + :help "Show thumbnails for all images in this directory"] + ["Previous Image" image-previous-file :active buffer-file-name + :help "Move to previous image in this directory"] + ["Next Image" image-next-file :active buffer-file-name + :help "Move to next image in this directory"] + ["Copy File Name" image-mode-copy-file-name-as-kill + :active buffer-file-name + :help "Copy the current file name to the kill ring"] + "--" + ["Animate Image" image-toggle-animation :style toggle + :selected (let ((image (image-get-display-property))) + (and image (image-animate-timer image))) + :active image-multi-frame + :help "Toggle image animation"] + ["Loop Animation" + (lambda () (interactive) + (setq image-animate-loop (not image-animate-loop)) + ;; FIXME this is a hacky way to make it affect a currently + ;; animating image. + (when (let ((image (image-get-display-property))) + (and image (image-animate-timer image))) + (image-toggle-animation) + (image-toggle-animation))) + :style toggle :selected image-animate-loop + :active image-multi-frame + :help "Animate images once, or forever?"] + ["Reverse Animation" image-reverse-speed + :style toggle :selected (let ((image (image-get-display-property))) + (and image (< + (image-animate-get-speed image) + 0))) + :active image-multi-frame + :help "Reverse direction of this image's animation?"] + ["Speed Up Animation" image-increase-speed + :active image-multi-frame + :help "Speed up this image's animation"] + ["Slow Down Animation" image-decrease-speed + :active image-multi-frame + :help "Slow down this image's animation"] + ["Reset Animation Speed" image-reset-speed + :active image-multi-frame + :help "Reset the speed of this image's animation"] + ["Previous Frame" image-previous-frame :active image-multi-frame + :help "Show the previous frame of this image"] + ["Next Frame" image-next-frame :active image-multi-frame + :help "Show the next frame of this image"] + ["Goto Frame..." image-goto-frame :active image-multi-frame + :help "Show a specific frame of this image"])) + +(defvar-keymap image-minor-mode-map + :doc "Mode keymap for `image-minor-mode'." + "C-c C-c" #'image-toggle-display + "C-c C-x" #'image-toggle-hex-display) (defvar bookmark-make-record-function) commit 0b43ed4dbca0b6472ab2ec91c22dd809dfd42801 Author: Stefan Kangas Date: Thu Aug 18 17:29:53 2022 +0200 ; * lisp/image-mode.el: Delete commented out image-transform-mode. This mode was added in 2010 but never implemented. It was subsequently commented out in 2012. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 76c076818f..a923db5b5f 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -1384,26 +1384,6 @@ If no such buffer exists, it will be opened." (image-toggle-display)))) -;; Not yet implemented. -;; (defvar image-transform-minor-mode-map -;; (let ((map (make-sparse-keymap))) -;; ;; (define-key map [(control ?+)] 'image-scale-in) -;; ;; (define-key map [(control ?-)] 'image-scale-out) -;; ;; (define-key map [(control ?=)] 'image-scale-none) -;; ;; (define-key map "c f h" 'image-scale-fit-height) -;; ;; (define-key map "c ]" 'image-rotate-right) -;; map) -;; "Minor mode keymap `image-transform-mode'.") -;; -;; (define-minor-mode image-transform-mode -;; "Minor mode for scaling and rotating images. -;; With a prefix argument ARG, enable the mode if ARG is positive, -;; and disable it otherwise. If called from Lisp, enable the mode -;; if ARG is omitted or nil. This minor mode requires Emacs to have -;; been compiled with ImageMagick support." -;; nil "image-transform" image-transform-minor-mode-map) - - (defsubst image-transform-width (width height) "Return the bounding box width of a rotated WIDTH x HEIGHT rectangle. The rotation angle is the value of `image-transform-rotation' in degrees." commit f97668c38fe4b503d14200baa4fe9627c2cbcb1b Merge: f98276f77b ef1e68f11d Author: Stefan Kangas Date: Thu Aug 18 19:21:32 2022 +0200 Merge from origin/emacs-28 ef1e68f11d * lisp/image-mode.el (image-mode-as-hex): Fix toggle instr... dc0fce3a7d ; lisp/image-mode.el: Fix typo. 254ba1d3e5 * lisp/image-mode.el: Improve commentary. ac43ac1af9 cl-reduce doc string improvement commit ef1e68f11d9c5a4c66fa3b28c116ed3038a56496 Author: Stefan Kangas Date: Thu Aug 18 18:41:18 2022 +0200 * lisp/image-mode.el (image-mode-as-hex): Fix toggle instructions. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 70f8746a3a..383d1ac50b 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -755,13 +755,9 @@ See commands `image-mode' and `image-minor-mode' for more information on these modes." (interactive) (image-mode-to-text) - ;; Turn on hexl-mode (hexl-mode) - (message "%s" (concat - (substitute-command-keys - "Type \\[image-toggle-hex-display] or \\[image-toggle-display] to view the image as ") - (if (image-get-display-property) - "hex" "an image or text") "."))) + (message "%s" (substitute-command-keys + "Type \\[hexl-mode-exit] to view the image as an image"))) (defun image-mode-as-text () "Set a non-image mode as major mode in combination with image minor mode. @@ -781,7 +777,7 @@ on these modes." (substitute-command-keys "Type \\[image-toggle-display] or \\[image-toggle-hex-display] to view the image as ") (if (image-get-display-property) - "text" "an image or hex") "."))) + "text" "an image or hex")))) (defun image-toggle-display-text () "Show the image file as text. commit f98276f77b4e2cbf37e4d24387d21b48e9fd6144 Author: Michael Albinus Date: Thu Aug 18 18:30:35 2022 +0200 Fix encoding problem in tramp-sh.el * lisp/net/tramp-sh.el (tramp-sh-handle-file-local-copy): Compute inline coding only if needed. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 4a9cf2e699..5075394d43 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3269,81 +3269,84 @@ implementation will be used." (defun tramp-sh-handle-file-local-copy (filename) "Like `file-local-copy' for Tramp files." (tramp-skeleton-file-local-copy filename - (if-let ((size (file-attribute-size (file-attributes filename))) - (rem-enc (tramp-get-inline-coding v "remote-encoding" size)) - (loc-dec (tramp-get-inline-coding v "local-decoding" size))) + (if-let ((size (file-attribute-size (file-attributes filename)))) + (let (rem-enc loc-dec) - (condition-case err - (cond - ;; Empty file. - ((zerop size)) - - ;; `copy-file' handles direct copy and out-of-band methods. - ((or (tramp-local-host-p v) - (tramp-method-out-of-band-p v size)) - (copy-file filename tmpfile 'ok-if-already-exists 'keep-time)) - - ;; Use inline encoding for file transfer. - (rem-enc - (with-tramp-progress-reporter - v 3 - (format-message - "Encoding remote file `%s' with `%s'" filename rem-enc) - (tramp-barf-unless-okay - v (format rem-enc (tramp-shell-quote-argument localname)) - "Encoding remote file failed")) - - ;; Check error. `rem-enc' could be a pipe, which doesn't - ;; flag the error in the first command. - (when (zerop (buffer-size (tramp-get-buffer v))) - (tramp-error v 'file-error' "Encoding remote file failed")) + (condition-case err + (cond + ;; Empty file. Nothing to copy. + ((zerop size)) + + ;; `copy-file' handles direct copy and out-of-band methods. + ((or (tramp-local-host-p v) + (tramp-method-out-of-band-p v size)) + (copy-file filename tmpfile 'ok-if-already-exists 'keep-time)) + + ;; Use inline encoding for file transfer. + ((and (setq rem-enc + (tramp-get-inline-coding v "remote-encoding" size)) + (setq loc-dec + (tramp-get-inline-coding v "local-decoding" size))) + (with-tramp-progress-reporter + v 3 + (format-message + "Encoding remote file `%s' with `%s'" filename rem-enc) + (tramp-barf-unless-okay + v (format rem-enc (tramp-shell-quote-argument localname)) + "Encoding remote file failed")) + + ;; Check error. `rem-enc' could be a pipe, which + ;; doesn't flag the error in the first command. + (when (zerop (buffer-size (tramp-get-buffer v))) + (tramp-error v 'file-error' "Encoding remote file failed")) + + (with-tramp-progress-reporter + v 3 (format-message + "Decoding local file `%s' with `%s'" tmpfile loc-dec) + (if (functionp loc-dec) + ;; If local decoding is a function, we call it. + ;; We must disable multibyte, because + ;; `uudecode-decode-region' doesn't handle it + ;; correctly. Unset `file-name-handler-alist'. + ;; Otherwise, epa-file gets confused. + (let (file-name-handler-alist + (coding-system-for-write 'binary) + (default-directory + tramp-compat-temporary-file-directory)) + (with-temp-file tmpfile + (set-buffer-multibyte nil) + (insert-buffer-substring (tramp-get-buffer v)) + (funcall loc-dec (point-min) (point-max)))) + + ;; If tramp-decoding-function is not defined for + ;; this method, we invoke tramp-decoding-command + ;; instead. + (let ((tmpfile2 (tramp-compat-make-temp-file filename))) + ;; Unset `file-name-handler-alist'. Otherwise, + ;; epa-file gets confused. + (let (file-name-handler-alist + (coding-system-for-write 'binary)) + (with-current-buffer (tramp-get-buffer v) + (write-region + (point-min) (point-max) tmpfile2 nil 'no-message))) + (unwind-protect + (tramp-call-local-coding-command + loc-dec tmpfile2 tmpfile) + (delete-file tmpfile2))))) + + ;; Set proper permissions. + (set-file-modes tmpfile (tramp-default-file-modes filename)) + ;; Set local user ownership. + (tramp-set-file-uid-gid tmpfile)) + + ;; Oops, I don't know what to do. + (t (tramp-error + v 'file-error "Wrong method specification for `%s'" method))) - (with-tramp-progress-reporter - v 3 (format-message - "Decoding local file `%s' with `%s'" tmpfile loc-dec) - (if (functionp loc-dec) - ;; If local decoding is a function, we call it. We - ;; must disable multibyte, because - ;; `uudecode-decode-region' doesn't handle it - ;; correctly. Unset `file-name-handler-alist'. - ;; Otherwise, epa-file gets confused. - (let (file-name-handler-alist - (coding-system-for-write 'binary) - (default-directory - tramp-compat-temporary-file-directory)) - (with-temp-file tmpfile - (set-buffer-multibyte nil) - (insert-buffer-substring (tramp-get-buffer v)) - (funcall loc-dec (point-min) (point-max)))) - - ;; If tramp-decoding-function is not defined for this - ;; method, we invoke tramp-decoding-command instead. - (let ((tmpfile2 (tramp-compat-make-temp-file filename))) - ;; Unset `file-name-handler-alist'. Otherwise, - ;; epa-file gets confused. - (let (file-name-handler-alist - (coding-system-for-write 'binary)) - (with-current-buffer (tramp-get-buffer v) - (write-region - (point-min) (point-max) tmpfile2 nil 'no-message))) - (unwind-protect - (tramp-call-local-coding-command - loc-dec tmpfile2 tmpfile) - (delete-file tmpfile2))))) - - ;; Set proper permissions. - (set-file-modes tmpfile (tramp-default-file-modes filename)) - ;; Set local user ownership. - (tramp-set-file-uid-gid tmpfile)) - - ;; Oops, I don't know what to do. - (t (tramp-error - v 'file-error "Wrong method specification for `%s'" method))) - - ;; Error handling. - ((error quit) - (delete-file tmpfile) - (signal (car err) (cdr err)))) + ;; Error handling. + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err))))) ;; Impossible to copy. Trigger `file-missing' error. (setq tmpfile nil)))) commit ca7c278e32d43160c18f2ef8e324bf3b9be5c687 Author: Stefan Monnier Date: Thu Aug 18 12:28:26 2022 -0400 * doc/misc/cl.texi (Macro Bindings): Fix bug#57263 Update `cl-symbol-macrolet` according to the change in response to bug#26073. diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index 07c19e37ce..a7548bb1f8 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi @@ -1381,19 +1381,10 @@ bar A @code{setq} of a symbol macro is treated the same as a @code{setf}. I.e., @code{(setq foo 4)} in the above would be equivalent to -@code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) 4)}. - -Likewise, a @code{let} or @code{let*} binding a symbol macro is -treated like a @code{cl-letf} or @code{cl-letf*}. This differs from true -Common Lisp, where the rules of lexical scoping cause a @code{let} -binding to shadow a @code{symbol-macrolet} binding. In this package, -such shadowing does not occur, even when @code{lexical-binding} is -@c See https://debbugs.gnu.org/12119 -@code{t}. (This behavior predates the addition of lexical binding to -Emacs Lisp, and may change in future to respect @code{lexical-binding}.) -At present in this package, only @code{lexical-let} and -@code{lexical-let*} will shadow a symbol macro. @xref{Obsolete -Lexical Binding}. +@code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) +4)}. A @code{let} (or @code{let*}, @code{lambda}, ...) binding of +the same symbol will locally shadow the symbol macro as is the case in +Common Lisp. There is no analogue of @code{defmacro} for symbol macros; all symbol macros are local. A typical use of @code{cl-symbol-macrolet} is in the commit dc0fce3a7d94ce837420ced27d163ae889cbec89 Author: Stefan Kangas Date: Thu Aug 18 17:50:13 2022 +0200 ; lisp/image-mode.el: Fix typo. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 41a87a1a3f..70f8746a3a 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -24,9 +24,9 @@ ;;; Commentary: ;; Defines `image-mode', a major mode for visiting image files. Displaying -;; images only works only if Emacs was built with support for -;; displaying such images. See Info node `(emacs) Image Mode' for -;; more information. +;; images only works if Emacs was built with support for displaying +;; such images. See Info node `(emacs) Image Mode' for more +;; information. ;; ;; There is support for switching between viewing the text of the ;; file, the hex of the file and viewing the file as an image. commit 254ba1d3e5c4499ef56d0452803a7c1011d7712f Author: Stefan Kangas Date: Thu Aug 18 17:36:54 2022 +0200 * lisp/image-mode.el: Improve commentary. diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 1eb7cd58c3..41a87a1a3f 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -23,10 +23,14 @@ ;;; Commentary: -;; Defines a major mode for visiting image files -;; that allows conversion between viewing the text of the file, -;; hex of the file and viewing the file as an image. Viewing the image -;; works by putting a `display' text-property on the +;; Defines `image-mode', a major mode for visiting image files. Displaying +;; images only works only if Emacs was built with support for +;; displaying such images. See Info node `(emacs) Image Mode' for +;; more information. +;; +;; There is support for switching between viewing the text of the +;; file, the hex of the file and viewing the file as an image. +;; Viewing the image works by putting a `display' text-property on the ;; image data, with the image-data still present underneath; if the ;; resulting buffer file is saved to another name it will correctly save ;; the image data to the new file. commit 1ad0d607404ab0527f5095a64a8dcc9c2bea6411 Author: Mattias Engdegård Date: Thu Aug 18 17:25:41 2022 +0200 Fix string-to-syntax signature in comp-known-type-specifiers * lisp/emacs-lisp/comp.el (comp-known-type-specifiers): `string-to-syntax` can return nil. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 869781bea1..304ea8cc6c 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -520,7 +520,7 @@ Useful to hook into pass checkers.") (string-to-char (function (string) fixnum)) (string-to-multibyte (function (string) string)) (string-to-number (function (string &optional integer) number)) - (string-to-syntax (function (string) cons)) + (string-to-syntax (function (string) (or cons null))) (string< (function ((or string symbol) (or string symbol)) boolean)) (string= (function ((or string symbol) (or string symbol)) boolean)) (stringp (function (t) boolean)) commit 67ec99418079dc6443b73b60840dc281ba2a68ae Author: Andrea Corallo Date: Thu Aug 18 17:09:36 2022 +0200 * lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Fix some type diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 5ee10fcbca..869781bea1 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -304,7 +304,7 @@ Useful to hook into pass checkers.") (bool-vector-subsetp (function (bool-vector bool-vector) boolean)) (boundp (function (symbol) boolean)) (buffer-end (function ((or number marker)) integer)) - (buffer-file-name (function (&optional buffer) string)) + (buffer-file-name (function (&optional buffer) (or string null))) (buffer-list (function (&optional frame) list)) (buffer-local-variables (function (&optional buffer) list)) (buffer-modified-p (function (&optional buffer) boolean)) @@ -321,8 +321,8 @@ Useful to hook into pass checkers.") (cdr (function (list) t)) (cdr-safe (function (t) t)) (ceiling (function (number &optional number) integer)) - (char-after (function (&optional (or marker integer)) fixnum)) - (char-before (function (&optional (or marker integer)) fixnum)) + (char-after (function (&optional (or marker integer)) (or fixnum null))) + (char-before (function (&optional (or marker integer)) (or fixnum null))) (char-equal (function (integer integer) boolean)) (char-or-string-p (function (t) boolean)) (char-to-string (function (fixnum) string)) @@ -344,8 +344,8 @@ Useful to hook into pass checkers.") (current-buffer (function () buffer)) (current-global-map (function () cons)) (current-indentation (function () integer)) - (current-local-map (function () cons)) - (current-minor-mode-maps (function () cons)) + (current-local-map (function () (or cons null))) + (current-minor-mode-maps (function () (or cons null))) (current-time (function () cons)) (current-time-string (function (&optional string boolean) string)) (current-time-zone (function (&optional string boolean) cons)) @@ -400,8 +400,8 @@ Useful to hook into pass checkers.") (get-buffer (function ((or buffer string)) (or buffer null))) (get-buffer-window (function (&optional (or buffer string) (or symbol (integer 0 0))) (or null window))) (get-file-buffer (function (string) (or null buffer))) - (get-largest-window (function (&optional t t t) window)) - (get-lru-window (function (&optional t t t) window)) + (get-largest-window (function (&optional t t t) (or window null))) + (get-lru-window (function (&optional t t t) (or window null))) (getenv (function (string &optional frame) (or null string))) (gethash (function (t hash-table &optional t) t)) (hash-table-count (function (hash-table) integer)) @@ -450,7 +450,7 @@ Useful to hook into pass checkers.") (make-symbol (function (string) symbol)) (mark (function (&optional t) (or integer null))) (mark-marker (function () marker)) - (marker-buffer (function (marker) buffer)) + (marker-buffer (function (marker) (or buffer null))) (markerp (function (t) boolean)) (max (function ((or number marker) &rest (or number marker)) number)) (max-char (function () fixnum)) @@ -459,7 +459,7 @@ Useful to hook into pass checkers.") (memq (function (t list) list)) (memql (function (t list) list)) (min (function ((or number marker) &rest (or number marker)) number)) - (minibuffer-selected-window (function () window)) + (minibuffer-selected-window (function () (or window null))) (minibuffer-window (function (&optional frame) window)) (mod (function ((or number marker) (or number marker)) (or (integer 0 *) (float 0 *)))) (mouse-movement-p (function (t) boolean)) @@ -487,7 +487,7 @@ Useful to hook into pass checkers.") (previous-window (function (&optional window t t) window)) (prin1-to-string (function (t &optional t t) string)) (processp (function (t) boolean)) - (proper-list-p (function (t) integer)) + (proper-list-p (function (t) boolean)) (propertize (function (string &rest t) string)) (radians-to-degrees (function (number) float)) (rassoc (function (t list) list)) commit 9361c833182e47607099f7ffb5dc68a53de26792 Author: Mattias Engdegård Date: Thu Aug 18 12:33:40 2022 +0200 More non-nil-returning functions in source optimisation This change was partially generated and mechanically cross-validated with function type information from comp-known-type-specifiers in comp.el. * lisp/emacs-lisp/byte-opt.el (byte-compile-trueconstp): Extend list of functions and fix a typo (logxor). diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index bbe8135f04..1751669445 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -753,22 +753,41 @@ for speeding up processing.") ((memq head ;; FIXME: Replace this list with a function property? '( length safe-length cons lambda - string make-string format concat + string unibyte-string make-string concat + format format-message substring substring-no-properties string-replace replace-regexp-in-string symbol-name make-symbol + compare-strings mapconcat vector make-vector vconcat make-record record regexp-quote regexp-opt buffer-string buffer-substring buffer-substring-no-properties current-buffer buffer-size - point point-min point-max + point point-min point-max buffer-end count-lines following-char preceding-char max-char - + - * / % 1+ 1- min max abs - logand logior lorxor lognot ash + region-beginning region-end + line-beginning-position line-end-position + + - * / % 1+ 1- min max abs mod expt logb + logand logior logxor lognot ash logcount + floor ceiling round truncate + sqrt sin cos tan asin acos atan exp log copysign + ffloor fceiling fround ftruncate float + ldexp frexp number-to-string string-to-number - int-to-string char-to-string prin1-to-string + int-to-string char-to-string + prin1-to-string read-from-string byte-to-string string-to-vector string-to-char + capitalize upcase downcase + propertize + string-as-multibyte string-as-unibyte + string-to-multibyte string-to-unibyte + string-make-multibyte string-make-unibyte + make-hash-table hash-table-count + unibyte-char-to-multibyte multibyte-char-to-unibyte + sxhash sxhash-equal sxhash-eq sxhash-eql + sxhash-equal-including-properties + make-marker copy-marker point-marker mark-marker always)) t) ((eq head 'if) commit f33a429a53ea2647199804f12e16c65768d526d5 Author: Mattias Engdegård Date: Thu Aug 18 12:08:24 2022 +0200 Copy-edit doc strings and comments wrt bignum and fixnum Don't say that a value is a fixnum if small enough and a bignum otherwise, because that is now how Lisp integers always work, and we generally don't expose the fixnum/bignum difference to the user unless really necessary. * src/charset.c (Fencode_char): * src/editfns.c (Fuser_uid, Fuser_real_uid, Fgroup_gid) (Fgroup_real_gid, Femacs_pid): * src/font.c (Ffont_variation_glyphs): * src/process.c (Fprocess_id): Edit doc strings. * src/pgtkselect.c: * src/xselect.c: Edit comments. diff --git a/src/charset.c b/src/charset.c index 9edbd4c8c8..bb59262fe9 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1852,9 +1852,8 @@ although this usage is obsolescent. */) DEFUN ("encode-char", Fencode_char, Sencode_char, 2, 2, 0, doc: /* Encode the character CH into a code-point of CHARSET. -Return the encoded code-point, a fixnum if its value is small enough, -otherwise a bignum. -Return nil if CHARSET doesn't support CH. */) +Return the encoded code-point as an integer, +or nil if CHARSET doesn't support CH. */) (Lisp_Object ch, Lisp_Object charset) { int c, id; diff --git a/src/editfns.c b/src/editfns.c index 07f5c0bbef..4fb82485ab 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -1172,8 +1172,7 @@ This ignores the environment variables LOGNAME and USER, so it differs from } DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0, - doc: /* Return the effective uid of Emacs. -Value is a fixnum, if it's small enough, otherwise a bignum. */) + doc: /* Return the effective uid of Emacs, as an integer. */) (void) { uid_t euid = geteuid (); @@ -1181,8 +1180,7 @@ Value is a fixnum, if it's small enough, otherwise a bignum. */) } DEFUN ("user-real-uid", Fuser_real_uid, Suser_real_uid, 0, 0, 0, - doc: /* Return the real uid of Emacs. -Value is a fixnum, if it's small enough, otherwise a bignum. */) + doc: /* Return the real uid of Emacs, as an integer. */) (void) { uid_t uid = getuid (); @@ -1208,8 +1206,7 @@ Return nil if a group with such GID does not exists or is not known. */) } DEFUN ("group-gid", Fgroup_gid, Sgroup_gid, 0, 0, 0, - doc: /* Return the effective gid of Emacs. -Value is a fixnum, if it's small enough, otherwise a bignum. */) + doc: /* Return the effective gid of Emacs, as an integer. */) (void) { gid_t egid = getegid (); @@ -1217,8 +1214,7 @@ Value is a fixnum, if it's small enough, otherwise a bignum. */) } DEFUN ("group-real-gid", Fgroup_real_gid, Sgroup_real_gid, 0, 0, 0, - doc: /* Return the real gid of Emacs. -Value is a fixnum, if it's small enough, otherwise a bignum. */) + doc: /* Return the real gid of Emacs, as an integer. */) (void) { gid_t gid = getgid (); @@ -1306,8 +1302,7 @@ DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0, } DEFUN ("emacs-pid", Femacs_pid, Semacs_pid, 0, 0, 0, - doc: /* Return the process ID of Emacs, as a number. -Value is a fixnum, if it's small enough, otherwise a bignum. */) + doc: /* Return the process ID of Emacs, as an integer. */) (void) { pid_t pid = getpid (); diff --git a/src/font.c b/src/font.c index 3846cfc107..8acedb9bf8 100644 --- a/src/font.c +++ b/src/font.c @@ -4691,8 +4691,7 @@ Each element of the value is a cons (VARIATION-SELECTOR . GLYPH-ID), where VARIATION-SELECTOR is a character code of variation selector (#xFE00..#xFE0F or #xE0100..#xE01EF). - GLYPH-ID is a glyph code of the corresponding variation glyph, -a fixnum, if it's small enough, otherwise a bignum. */) + GLYPH-ID is a glyph code of the corresponding variation glyph, an integer. */) (Lisp_Object font_object, Lisp_Object character) { unsigned variations[256]; @@ -4729,8 +4728,7 @@ a fixnum, if it's small enough, otherwise a bignum. */) that apply to POSITION. POSITION may be nil, in which case, FONT-SPEC is the font for displaying the character CH with the default face. GLYPH-CODE is the glyph code in the font to use for - the character, it is a fixnum, if it is small enough, otherwise a - bignum. + the character, as an integer. For a text terminal, return a nonnegative integer glyph code for the character, or a negative integer if the character is not diff --git a/src/pgtkselect.c b/src/pgtkselect.c index e0230003b3..212bbd56aa 100644 --- a/src/pgtkselect.c +++ b/src/pgtkselect.c @@ -1248,8 +1248,7 @@ pgtk_get_window_property_as_lisp_data (struct pgtk_display_info *dpyinfo, ATOM 32 > 1 Vector of Symbols * 16 1 Integer * 16 > 1 Vector of Integers - * 32 1 if small enough: fixnum - otherwise: bignum + * 32 1 Integer * 32 > 1 Vector of the above When converting an object to C, it may be of the form (SYMBOL diff --git a/src/process.c b/src/process.c index 23479c0619..697249a461 100644 --- a/src/process.c +++ b/src/process.c @@ -1209,8 +1209,8 @@ If PROCESS has not yet exited or died, return 0. */) DEFUN ("process-id", Fprocess_id, Sprocess_id, 1, 1, 0, doc: /* Return the process id of PROCESS. -This is the pid of the external process which PROCESS uses or talks to. -It is a fixnum if the value is small enough, otherwise a bignum. +This is the pid of the external process which PROCESS uses or talks to, +an integer. For a network, serial, and pipe connections, this value is nil. */) (register Lisp_Object process) { diff --git a/src/xselect.c b/src/xselect.c index d6e6d0c30b..bab0400540 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -1754,8 +1754,7 @@ x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, ATOM 32 > 1 Vector of Symbols * 16 1 Integer * 16 > 1 Vector of Integers - * 32 1 if small enough: fixnum - otherwise: bignum + * 32 1 Integer * 32 > 1 Vector of the above When converting an object to C, it may be of the form (SYMBOL . ) commit e75822fba6ee5f1cced6b87305fc0f444803feb7 Author: Eli Zaretskii Date: Thu Aug 18 16:30:32 2022 +0300 ; Fix a typo in autoload.el * lisp/obsolete/autoload.el (update-directory-autoloads): Fix obsolescence version. (Bug#57276) diff --git a/lisp/obsolete/autoload.el b/lisp/obsolete/autoload.el index 4df8f0ce6c..680df739e0 100644 --- a/lisp/obsolete/autoload.el +++ b/lisp/obsolete/autoload.el @@ -713,7 +713,7 @@ autoload definitions. When called from Lisp, use the existing value of `generated-autoload-file'. If any Lisp file binds `generated-autoload-file' as a file-local variable, write its autoloads into the specified file instead." - (declare (obsolete loaddefs-generate "28.1")) + (declare (obsolete loaddefs-generate "29.1")) (interactive "DUpdate autoloads from directory: ") (make-directory-autoloads dirs commit b9c6c0fb7bf396aa7ef0c53778211544d0c3499f Author: kobarity Date: Thu Aug 18 15:16:08 2022 +0200 Fix Python indentation of block continuation * lisp/progmodes/python.el (python-indent--calculate-indentation): Fix indentation of :after-backslash-block-continuation. * test/lisp/progmodes/python-tests.el (python-indent-after-backslash-6): New test (bug#57262). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e135039199..9a2d17abb4 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1238,8 +1238,14 @@ possibilities can be narrowed to specific indentation points." ;; Add one indentation level. (goto-char start) (+ (current-indentation) python-indent-offset)) + (`(:after-backslash-block-continuation . ,start) + (goto-char start) + (let ((column (current-column))) + (if (= column (+ (current-indentation) python-indent-offset)) + ;; Add one level to avoid same indent as next logical line. + (+ column python-indent-offset) + column))) (`(,(or :inside-paren - :after-backslash-block-continuation :after-backslash-dotted-continuation) . ,start) ;; Use the column given by the context. (goto-char start) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 875c92573e..0904dfc963 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -1250,6 +1250,25 @@ def delete_all_things(): :after-backslash-dotted-continuation)) (should (= (python-indent-calculate-indentation) 16)))) +(ert-deftest python-indent-after-backslash-6 () + "Backslash continuation from for block." + (python-tests-with-temp-buffer + " +for long_variable_name \\ + in (1, 2): + print(long_variable_name) +" + (python-tests-look-at "for long_variable_name \\") + (should (eq (car (python-indent-context)) :no-indent)) + (should (= (python-indent-calculate-indentation) 0)) + (python-tests-look-at "in (1, 2):") + (should (eq (car (python-indent-context)) + :after-backslash-block-continuation)) + (should (= (python-indent-calculate-indentation) 8)) + (python-tests-look-at "print(long_variable_name)") + (should (eq (car (python-indent-context)) :after-block-start)) + (should (= (python-indent-calculate-indentation) 4)))) + (ert-deftest python-indent-block-enders-1 () "Test de-indentation for pass keyword." (python-tests-with-temp-buffer commit 74e830768dc412b7041e01882efb1a697278d462 Author: Lars Ingebrigtsen Date: Thu Aug 18 15:12:55 2022 +0200 Make GEN message from loaddefs-generate nicer * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Shorten the informational GEN file relative to the stated directory (bug#57265). This makes the message nicer for ELPA packages. diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 8413373e5d..e13b92bab8 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -645,7 +645,8 @@ instead of just updating them with the new/changed autoloads." (unless (equal (buffer-hash) hash) (write-region (point-min) (point-max) loaddefs-file nil 'silent) (byte-compile-info - (file-relative-name loaddefs-file lisp-directory) t "GEN")))))))) + (file-relative-name loaddefs-file (car (ensure-list dir))) + t "GEN")))))))) (defun loaddefs-generate--print-form (def) "Print DEF in a format that makes sense for version control." commit ac43ac1af9dac42d30fbee044defee6e2641ebfc Author: Colin Woodbury Date: Thu Aug 18 15:06:56 2022 +0200 cl-reduce doc string improvement * lisp/emacs-lisp/cl-seq.el (cl-reduce): Explain what happens when using :from-end (bug#57273). diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el index 64ae05bf2a..60e204eaf5 100644 --- a/lisp/emacs-lisp/cl-seq.el +++ b/lisp/emacs-lisp/cl-seq.el @@ -139,6 +139,10 @@ only case where FUNCTION is called with fewer than two arguments. If SEQ contains exactly one element and no :INITIAL-VALUE is specified, then return that element and FUNCTION is not called. +If :FROM-END is non-nil, the reduction occurs from the back of +the SEQ moving forward, and the order of arguments to the +FUNCTION is also reversed. + \n(fn FUNCTION SEQ [KEYWORD VALUE]...)" (cl--parsing-keywords (:from-end (:start 0) :end :initial-value :key) () (or (listp cl-seq) (setq cl-seq (append cl-seq nil))) commit 6d38ff1b9e41b1f37bf4a0c64cddfcac64e4c4e7 Author: Gerd Möllmann Date: Thu Aug 18 14:44:11 2022 +0200 Rebuild the Emacs executable if loaddefs.el has changed * Makefile.in (src-depending-on-lisp): Ensure that we check whether we need to rebuild the Emacs executable if loaddefs.el has been updated. diff --git a/Makefile.in b/Makefile.in index bf0f52b514..78103f897f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -358,10 +358,17 @@ endif gsettings_SCHEMAS = etc/org.gnu.emacs.defaults.gschema.xml -all: ${SUBDIR} info $(gsettings_SCHEMAS:.xml=.valid) +all: ${SUBDIR} info $(gsettings_SCHEMAS:.xml=.valid) src-depending-on-lisp .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 epaths-force-ns-self-contained etc-emacsver +# Changes in lisp may require us to reconsider the build in src. For +# example, if loaddefs.{el,elc} were built in lisp, we need a new +# .pdmp containing the new autoloads. +.PHONY: src-depending-on-lisp +src-depending-on-lisp: lisp + ${MAKE} -C src + # If configure were to just generate emacsver.tex from emacsver.tex.in # in the normal way, the timestamp of emacsver.tex would always be # newer than that of the pdf files, which are prebuilt in release tarfiles. commit 335bf5f55a02eaa8c6cbc60d7fdc6865a8000b61 Author: Stefan Kangas Date: Thu Aug 18 13:36:46 2022 +0200 Improve update-directory-autoloads deprecation message * lisp/obsolete/autoload.el (update-directory-autoloads): Improve deprecation message. (Bug#57276) diff --git a/lisp/obsolete/autoload.el b/lisp/obsolete/autoload.el index a30f8271a3..4df8f0ce6c 100644 --- a/lisp/obsolete/autoload.el +++ b/lisp/obsolete/autoload.el @@ -713,7 +713,7 @@ autoload definitions. When called from Lisp, use the existing value of `generated-autoload-file'. If any Lisp file binds `generated-autoload-file' as a file-local variable, write its autoloads into the specified file instead." - (declare (obsolete make-directory-autoloads "28.1")) + (declare (obsolete loaddefs-generate "28.1")) (interactive "DUpdate autoloads from directory: ") (make-directory-autoloads dirs commit dae4fc3adf8f673187f9eb323af157f9056c3645 Author: Stefan Kangas Date: Thu Aug 18 13:17:11 2022 +0200 Improve cryptic syntax switch message in re-builder * lisp/emacs-lisp/re-builder.el (reb-restart-font-lock): Move message from here... * lisp/emacs-lisp/re-builder.el (reb-change-syntax): ...to here. Change it to be less cryptic. diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el index 46b429ce6f..4b5363d8f6 100644 --- a/lisp/emacs-lisp/re-builder.el +++ b/lisp/emacs-lisp/re-builder.el @@ -497,7 +497,8 @@ Optional argument SYNTAX must be specified if called non-interactively." (setq reb-re-syntax syntax) (when buffer (with-current-buffer buffer - (reb-initialize-buffer)))) + (reb-initialize-buffer)) + (message "Switched syntax to `%s'" reb-re-syntax))) (error "Invalid syntax: %s" syntax))) @@ -819,7 +820,6 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions." (defun reb-restart-font-lock () "Restart `font-lock-mode' to fit current regexp format." - (message "reb-restart-font-lock re-re-syntax=%s" reb-re-syntax) (with-current-buffer (get-buffer reb-buffer) (let ((font-lock-is-on font-lock-mode)) (font-lock-mode -1) commit 842c641c57b6cc6ffa82ca6a74df655d8369e9e1 Author: Andrea Corallo Date: Wed Aug 17 22:47:05 2022 +0200 * lisp/loadup.el: Always fix-up all loaded compilation units diff --git a/lisp/loadup.el b/lisp/loadup.el index 17e82cc0c4..634a331436 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -478,17 +478,12 @@ lost after dumping"))) ;; installed or if the source directory got moved. This is set to be ;; a pair in the form of: ;; (rel-filename-from-install-bin . rel-filename-from-local-bin). - (let ((h (make-hash-table :test #'eq)) - (bin-dest-dir (cadr (member "--bin-dest" command-line-args))) + (let ((bin-dest-dir (cadr (member "--bin-dest" command-line-args))) (eln-dest-dir (cadr (member "--eln-dest" command-line-args)))) (when (and bin-dest-dir eln-dest-dir) (setq eln-dest-dir (concat eln-dest-dir "native-lisp/" comp-native-version-dir "/")) - (mapatoms (lambda (s) - (let ((f (symbol-function s))) - (when (subr-native-elisp-p f) - (puthash (subr-native-comp-unit f) nil h))))) - (maphash (lambda (cu _) + (maphash (lambda (_ cu) (let* ((file (native-comp-unit-file cu)) (preloaded (equal (substring (file-name-directory file) -10 -1) @@ -508,7 +503,7 @@ lost after dumping"))) bin-dest-dir) ;; Relative filename from the built uninstalled binary. (file-relative-name file invocation-directory))))) - h)))) + comp-loaded-comp-units-h)))) (when (hash-table-p purify-flag) (let ((strings 0) commit aea05a5dec90c36fa12e0622234a12fbf0a403f3 Author: Andrea Corallo Date: Wed Aug 17 22:29:33 2022 +0200 * Expose `comp-loaded-comp-units-h' * src/comp.c : remove 'all_loaded_comp_units_h'. (syms_of_comp): Define `comp-loaded-comp-units-h'. (register_native_comp_unit, Fnative_elisp_load): Use it. diff --git a/src/comp.c b/src/comp.c index 21d2ee5300..70e7d5a8bb 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5017,8 +5017,6 @@ helper_GET_SYMBOL_WITH_POSITION (Lisp_Object a) /* `native-comp-eln-load-path' clean-up support code. */ -static Lisp_Object all_loaded_comp_units_h; - #ifdef WINDOWSNT static Lisp_Object return_nil (Lisp_Object arg) @@ -5060,11 +5058,12 @@ eln_load_path_final_clean_up (void) } /* This function puts the compilation unit in the - `all_loaded_comp_units_h` hashmap. */ + `Vcomp_loaded_comp_units_h` hashmap. */ static void register_native_comp_unit (Lisp_Object comp_u) { - Fputhash (XNATIVE_COMP_UNIT (comp_u)->file, comp_u, all_loaded_comp_units_h); + Fputhash ( + XNATIVE_COMP_UNIT (comp_u)->file, comp_u, Vcomp_loaded_comp_units_h); } @@ -5552,7 +5551,7 @@ LATE_LOAD has to be non-nil when loading for deferred compilation. */) struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit (); Lisp_Object encoded_filename = ENCODE_FILE (filename); - if (!NILP (Fgethash (filename, all_loaded_comp_units_h, Qnil)) + if (!NILP (Fgethash (filename, Vcomp_loaded_comp_units_h, Qnil)) && !file_in_eln_sys_dir (filename) && !NILP (Ffile_writable_p (filename))) { @@ -5754,10 +5753,6 @@ compiled one. */); staticpro (&loadsearch_re_list); loadsearch_re_list = Qnil; - staticpro (&all_loaded_comp_units_h); - all_loaded_comp_units_h = - CALLN (Fmake_hash_table, QCweakness, Qkey_and_value, QCtest, Qequal); - DEFVAR_LISP ("comp-ctxt", Vcomp_ctxt, doc: /* The compiler context. */); Vcomp_ctxt = Qnil; @@ -5817,6 +5812,12 @@ For internal use. */); doc: /* When non-nil assume the file being compiled to be preloaded. */); + DEFVAR_LISP ("comp-loaded-comp-units-h", Vcomp_loaded_comp_units_h, + doc: /* Hash table recording all loaded compilation units. +file -> CU. */); + Vcomp_loaded_comp_units_h = + CALLN (Fmake_hash_table, QCweakness, Qvalue, QCtest, Qequal); + Fprovide (intern_c_string ("native-compile"), Qnil); #endif /* #ifdef HAVE_NATIVE_COMP */