commit 0a53e5f751244d84d766b45380a58df37c06ae3d (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Tue Oct 4 08:34:59 2022 +0300 ; * etc/NEWS: Improve wording. diff --git a/etc/NEWS b/etc/NEWS index 8a27b91e30..2b87641358 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -639,8 +639,9 @@ If non-nil, this option allows scrolling a window while dragging text around without a scroll wheel. +++ -*** 'mouse-drag-copy-region' can now be 'non-empty' (the Lisp symbol). -This inhibits putting empty strings onto the kill ring. +*** The value of 'mouse-drag-copy-region' can now be the symbol 'non-empty'. +This prevents mouse drag gestures from putting empty strings onto the +kill ring. +++ ** New user options 'dnd-indicate-insertion-point' and 'dnd-scroll-margin'. commit 2d87750004e793b7d1803df0365526944970fcd3 Author: Stefan Kangas Date: Tue Oct 4 07:32:04 2022 +0200 * etc/NEWS: Clarify confusing Image-Dired entry. (Bug#58279) diff --git a/etc/NEWS b/etc/NEWS index f21acaf207..8a27b91e30 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2306,9 +2306,8 @@ the thumbnail file. +++ *** Some commands and user options are now obsolete. -Since Image-Dired no longer converts images in the background before -displaying them, some commands and user options that are no longer -needed are now obsolete: +Since 'image-dired-display-image-mode' is now based on 'image-mode', +some commands and user options are no longer needed and are now obsolete: 'image-dired-cmd-create-temp-image-options', 'image-dired-cmd-create-temp-image-program', 'image-dired-display-current-image-full', commit 3583f6184d738f1760b9c5467edafd5095f5d3e2 Author: Po Lu Date: Tue Oct 4 09:25:06 2022 +0800 Fix deiconification handling on FVWM and possibly other window managers I can't believe we weren't doing this before. * src/xterm.c (x_handle_wm_state): New function. (handle_one_xevent): Handle window state changes in WM_STATE messages, and use them for signalling deiconification. (bug#58164) diff --git a/src/xterm.c b/src/xterm.c index 42335f0de0..f3bfae457b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -17701,6 +17701,53 @@ x_coords_from_dnd_message (struct x_display_info *dpyinfo, return false; } +static void +x_handle_wm_state (struct frame *f, struct input_event *ie) +{ + Atom type; + int format; + unsigned long nitems, bytes_after; + unsigned char *data; + unsigned long *state; + + data = NULL; + + if (XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), + FRAME_DISPLAY_INFO (f)->Xatom_wm_state, 0, 2, + False, AnyPropertyType, &type, &format, &nitems, + &bytes_after, &data) != Success) + return; + + if (!data || nitems != 2 || format != 32) + { + if (data) + XFree (data); + + return; + } + + state = (unsigned long *) data; + + if (state[0] == NormalState && FRAME_ICONIFIED_P (f)) + { + /* The frame has been deiconified. It has not been withdrawn + and is now visible. */ + SET_FRAME_VISIBLE (f, 1); + SET_FRAME_ICONIFIED (f, false); + f->output_data.x->has_been_visible = true; + + ie->kind = DEICONIFY_EVENT; + XSETFRAME (ie->frame_or_window, f); + } + + /* state[0] can also be WithdrawnState, meaning that the window has + been withdrawn and is no longer iconified. However, Emacs sets + the correct flags upon withdrawing the window, so there is no + need to do anything here. */ + + XFree (data); +} + /* Handles the XEvent EVENT on display DPYINFO. *FINISH is X_EVENT_GOTO_OUT if caller should stop reading events. @@ -18489,6 +18536,19 @@ handle_one_xevent (struct x_display_info *dpyinfo, } } + if (f && event->xproperty.atom == dpyinfo->Xatom_wm_state + && !FRAME_X_EMBEDDED_P (f) && !FRAME_PARENT_FRAME (f)) + /* Handle WM_STATE. We use this to clear the iconified flag + on a frame if it is set. + + GTK builds ignore deiconifying frames on FocusIn or Expose + by default, and cannot wait for the window manager to + remove _NET_WM_STATE_HIDDEN, as it is ambiguous when not + set. Handling UnmapNotify also checks for + _NET_WM_STATE_HIDDEN, and thus suffers from the same + problem. */ + x_handle_wm_state (f, &inev.ie); + if (f && FRAME_X_OUTPUT (f)->alpha_identical_p && (event->xproperty.atom == dpyinfo->Xatom_net_wm_window_opacity)) commit 200658eb77ba23ed1aa557f89f256dbaf86936e0 Author: Stefan Kangas Date: Tue Oct 4 02:15:51 2022 +0200 ; * lisp/proced.el (proced-mode): Manually reflow docstring. diff --git a/lisp/proced.el b/lisp/proced.el index 0f0937cac8..a774f2dd1e 100644 --- a/lisp/proced.el +++ b/lisp/proced.el @@ -642,22 +642,27 @@ type \\\\[proced-mark] to mark a process for later commands. Type \\[proced-send-signal] to send signals to marked processes. Type \\[proced-renice] to renice marked processes. -The initial content of a listing is defined by the variable `proced-filter' -and the variable `proced-format'. -The variable `proced-filter' specifies which system processes are displayed. -The variable `proced-format' specifies which attributes are displayed for -each process. Type \\[proced-filter-interactive] and \\[proced-format-interactive] -to change the values of `proced-filter' and `proced-format'. -The current value of the variable `proced-filter' is indicated in the -mode line. +The initial content of a listing is defined by the variable +`proced-filter' and the variable `proced-format'. + +The variable `proced-filter' specifies which system processes are +displayed. + +The variable `proced-format' specifies which attributes are +displayed for each process. + +Type \\[proced-filter-interactive] and \\[proced-format-interactive] to \ +change the values of `proced-filter' and +`proced-format'. The current value of the variable +`proced-filter' is indicated in the mode line. The sort order of Proced listings is defined by the variable `proced-sort'. -Type \\[proced-sort-interactive] or click on a header in the header line -to change the sort scheme. The current sort scheme is indicated in the -mode line, using \"+\" or \"-\" for ascending or descending sort order. +Type \\[proced-sort-interactive] or click on a header in the header \ +line to change the sort scheme. +The current sort scheme is indicated in the mode line, using +\"+\" or \"-\" for ascending or descending sort order. -Type \\[proced-toggle-tree] to toggle whether the listing is -displayed as process tree. +Type \\[proced-toggle-tree] to toggle whether the listing is displayed as process tree. Type \\[proced-toggle-auto-update] to automatically update the process list. The time interval for updates can be configured @@ -666,11 +671,11 @@ via `proced-auto-update-interval'. An existing Proced listing can be refined by typing \\[proced-refine]. Refining an existing listing does not update the variable `proced-filter'. -The attribute-specific rules for formatting, filtering, sorting, and refining -are defined in `proced-grammar-alist'. +The attribute-specific rules for formatting, filtering, sorting, +and refining are defined in `proced-grammar-alist'. -After displaying or updating a Proced buffer, Proced runs the normal hook -`proced-post-display-hook'. +After displaying or updating a Proced buffer, Proced runs the +normal hook `proced-post-display-hook'. \\{proced-mode-map}" :interactive nil commit 43eaa05ff2265ae33f71b73670a8a150a7a716ae Author: Jim Porter Date: Sun Oct 2 18:19:56 2022 -0700 ; Fix logic of $HOME adjustment for 'ert-remote-temporary-file-directory' * lisp/emacs-lisp/ert-x.el (ert-remote-temporary-file-directory): Only adjust $HOME when it doesn't exist (bug#58265). diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index bfd796586d..a891f068a7 100644 --- a/lisp/emacs-lisp/ert-x.el +++ b/lisp/emacs-lisp/ert-x.el @@ -568,7 +568,7 @@ The same keyword arguments are supported as in `("\\`mock\\'" nil ,(system-name))) ;; Emacs's Makefile sets $HOME to a nonexistent value. Needed ;; in batch mode only, therefore. - (unless (and (null noninteractive) (file-directory-p "~/")) + (when (and noninteractive (not (file-directory-p "~/"))) (setenv "HOME" temporary-file-directory)) (format "/mock::%s" temporary-file-directory)))) "Temporary directory for remote file tests.") commit 6a5169e747623541fc21429ef066d6de1eea7d8b Merge: b41d21eaa1 992611b10a Author: Stefan Kangas Date: Tue Oct 4 00:07:22 2022 +0200 Merge from origin/emacs-28 992611b10a Fix documentation of 'TAB' in cc-mode 08e485a2a5 Fix 'org-export-dispatch' command name in manual e5a49f44ff * src/emacs.c (load_pdump): Fix use of xpalloc. 7ff5207624 Avoid assertion violation in 'xpalloc' # Conflicts: # src/emacs.c commit b41d21eaa1d371318963080aa381f1173a5db866 Author: Stefan Kangas Date: Mon Oct 3 23:06:15 2022 +0200 ; * etc/NEWS: Minor copy editing. diff --git a/etc/NEWS b/etc/NEWS index 05e05afc8e..f21acaf207 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -484,7 +484,7 @@ This variable lets you remap the default modes (e.g. 'perl-mode' or 'LaTeX-mode') without having to use 'defalias', which can have undesirable side effects. This applies to all modes specified via 'auto-mode-alist', file-local -variables, etc... +variables, etc. --- ** Emacs now supports Unicode Standard version 15.0. @@ -529,10 +529,6 @@ increase and decrease the font size globally. Additionally, the user option 'global-text-scale-adjust-resizes-frames' controls whether the frames are resized when the font size is changed. -+++ -** New function 'file-name-parent-directory'. -Get the parent directory of a file. - ** New config variable 'syntax-wholeline-max' to reduce the cost of long lines. This variable is used by some operations (mostly syntax-propertization and font-locking) to treat lines longer than this variable as if they @@ -643,7 +639,7 @@ If non-nil, this option allows scrolling a window while dragging text around without a scroll wheel. +++ -*** 'mouse-drag-copy-region' can now be 'non-empty'. +*** 'mouse-drag-copy-region' can now be 'non-empty' (the Lisp symbol). This inhibits putting empty strings onto the kill ring. +++ @@ -677,7 +673,9 @@ yes/no question before executing. The new function 'command-query' is a convenient method of making commands disabled in this way. --- -** 'count-lines' will now report buffer totals if given a prefix. +** 'count-words' will now report buffer totals if given a prefix. +Without a prefix, it will only report the word count for the narrowed +part of the buffer. +++ ** 'count-words' will now report sentence count when used interactively. @@ -722,11 +720,6 @@ This value stands for the value of the corresponding attribute of the 'default' face. It can be used to reset attribute values produced by inheriting from other faces. -+++ -** New function 'buffer-text-pixel-size'. -This is similar to 'window-text-pixel-size', but can be used when the -buffer isn't displayed. - +++ ** New X resource: "borderThickness". This controls the thickness of the external borders of the menu bars @@ -3602,6 +3595,10 @@ a valid key sequence according to 'key-valid-p'. ** New function 'file-name-split'. This returns a list of all the components of a file name. ++++ +** New function 'file-name-parent-directory'. +This returns the parent directory of a file name. + +++ ** New macro 'with-undo-amalgamate'. It records a particular sequence of operations as a single undo step. @@ -3804,6 +3801,11 @@ It no longer depends on edmacro.el and cl-lib.el. This function returns t if point is on a valid image, and nil otherwise. ++++ +** New function 'buffer-text-pixel-size'. +This is similar to 'window-text-pixel-size', but can be used when the +buffer isn't displayed. + +++ ** New function 'string-pixel-width'. This returns the width of a string in pixels. This can be useful when commit b374952b5117990e84a9d51da78ad94b2c82ecbb Author: Juri Linkov Date: Mon Oct 3 22:54:16 2022 +0300 * lisp/repeat.el (repeat-exit-key): Replace type 'key-sequence' with 'key'. (repeat-post-hook, repeat-echo-message-string): Add backward-compatibility code for repeat-exit-key to keep support for 'key-sequence' type (bug#55986). diff --git a/lisp/repeat.el b/lisp/repeat.el index df6b8140a6..d773e44067 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -344,7 +344,7 @@ recently executed command not bound to an input event\"." "Key that stops the modal repeating of keys in sequence. For example, you can set it to like `isearch-exit'." :type '(choice (const :tag "No special key to exit repeating sequence" nil) - (key-sequence :tag "Key that exits repeating sequence")) + (key :tag "Kbd keys that exit repeating sequence")) :group 'repeat :version "28.1") @@ -475,7 +475,10 @@ See `describe-repeat-maps' for a list of all repeatable commands." ;; Adding an exit key (when repeat-exit-key - (define-key map repeat-exit-key 'ignore)) + (define-key map (if (key-valid-p repeat-exit-key) + (kbd repeat-exit-key) + repeat-exit-key) + 'ignore)) (when (and repeat-keep-prefix (not prefix-arg)) (setq prefix-arg current-prefix-arg)) @@ -526,7 +529,9 @@ This function can be used to force exit of repetition while it's active." (if repeat-exit-key (substitute-command-keys (format ", or exit with \\`%s'" - (key-description repeat-exit-key))) + (if (key-valid-p repeat-exit-key) + repeat-exit-key + (key-description repeat-exit-key)))) "")))) (defun repeat-echo-message (keymap) commit b67dc85e2200307a43b5ef40e18b53f0437ca26c Author: Juri Linkov Date: Mon Oct 3 22:51:33 2022 +0300 * lisp/repeat.el (repeat-exit): New command. (repeat-exit-function): New variable. (repeat-post-hook): Set repeat-exit-function. Call repeat-exit from run-with-idle-timer. Also use repeat--exit. (repeat--exit): New internal function. diff --git a/lisp/repeat.el b/lisp/repeat.el index 2181bc0e2a..df6b8140a6 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -359,6 +359,9 @@ This property can override the value of this variable." :group 'repeat :version "28.1") +(defvar repeat-exit-function nil + "Function that exits the repeating sequence.") + (defvar repeat-exit-timer nil "Timer activated after the last key typed in the repeating key sequence.") @@ -479,29 +482,36 @@ See `describe-repeat-maps' for a list of all repeatable commands." (setq repeat-in-progress t) (let ((exitfun (set-transient-map map))) - - (when repeat-exit-timer - (cancel-timer repeat-exit-timer) - (setq repeat-exit-timer nil)) + (repeat--exit) + (setq repeat-exit-function exitfun) (let* ((prop (repeat--command-property 'repeat-exit-timeout)) (timeout (unless (eq prop 'no) (or prop repeat-exit-timeout)))) (when timeout (setq repeat-exit-timer - (run-with-idle-timer - timeout nil - (lambda () - (setq repeat-in-progress nil) - (funcall exitfun) - (funcall repeat-echo-function nil)))))))))))) + (run-with-idle-timer timeout nil #'repeat-exit)))))))))) (setq repeat-map nil) (setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command)) (when (and was-in-progress (not repeat-in-progress)) - (when repeat-exit-timer - (cancel-timer repeat-exit-timer) - (setq repeat-exit-timer nil)) - (funcall repeat-echo-function nil)))) + (repeat-exit)))) + +(defun repeat-exit () + "Exit the repeating sequence. +This function can be used to force exit of repetition while it's active." + (interactive) + (setq repeat-in-progress nil) + (repeat--exit) + (funcall repeat-echo-function nil)) + +(defun repeat--exit () + "Internal function to clean up previously set exit function and timer." + (when repeat-exit-timer + (cancel-timer repeat-exit-timer) + (setq repeat-exit-timer nil)) + (when repeat-exit-function + (funcall repeat-exit-function) + (setq repeat-exit-function nil))) (defun repeat-echo-message-string (keymap) "Return a string with a list of repeating keys." commit d9d164f0033d0af76f005e2560d15e9e606f85fd Author: Stefan Monnier Date: Mon Oct 3 15:03:57 2022 -0400 * lisp/textmodes/tex-mode.el (tex--redirect-to-submode): Fix last change diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 5c2dbdfe5c..6dc2865dd9 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -1032,7 +1032,7 @@ says which mode to use." ;; `tex--guess-mode' really tries to guess the *type* of file, ;; so we still need to consult `major-mode-remap-alist' ;; to see which mode to use for that type. - (funcall (alist-get mode major-mode-remap-alist mode))))))) + (alist-get mode major-mode-remap-alist mode)))))) ;; The following three autoloaded aliases appear to conflict with ;; AUCTeX. We keep those confusing aliases for those users who may commit 129fcb3d38b60f15c70f72851ddc3abeff39efe6 Author: Lars Ingebrigtsen Date: Mon Oct 3 21:40:27 2022 +0200 Improve messaging in ecomplete-remove * lisp/ecomplete.el (ecomplete-remove): Make messaging better. diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el index 6e40eb7456..6ff67d46d2 100644 --- a/lisp/ecomplete.el +++ b/lisp/ecomplete.el @@ -314,12 +314,17 @@ non-nil and there is only a single completion option available." (elems (seq-filter (lambda (elem) (string-match-p match (car elem))) data))) - (when (yes-or-no-p (format "Delete %s matching ecomplete entries? " - (length elems))) - (dolist (elem elems) - (ecomplete--remove-item type (car elem))) - (ecomplete-save) - (message "Deleted entries")))) + (if (length= elems 0) + (message "No matching entries for %s" match) + (when (yes-or-no-p (format "Delete %s matching ecomplete %s? " + (length elems) + (if (length= elems 1) + "entry" + "entries"))) + (dolist (elem elems) + (ecomplete--remove-item type (car elem))) + (ecomplete-save) + (message "Deleted entries"))))) (provide 'ecomplete) commit 8ef8da13f6bc287dc301c78d74d12adb406bc67d Author: Lars Ingebrigtsen Date: Mon Oct 3 21:35:43 2022 +0200 Fix typo in last help-fns--insert-menu-bindings change * lisp/help-fns.el (help-fns--insert-menu-bindings): Fix typo in last change. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index cbf8ff1f59..eef895ae88 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -615,16 +615,16 @@ the C sources, too." ;; Then output them. (when strings (when heading - (insert heading) - (seq-do-indexed - (lambda (string i) - (insert - (cond ((zerop i) "") - ((= i (1- (length menus))) " and ") - (t ", "))) - (insert (propertize (string-join (nreverse string)) - 'face 'help-key-binding))) - strings))))) + (insert heading)) + (seq-do-indexed + (lambda (string i) + (insert + (cond ((zerop i) "") + ((= i (1- (length menus))) " and ") + (t ", ")) + (propertize (string-join (nreverse string)) + 'face 'help-key-binding))) + strings)))) (defun help-fns--compiler-macro (function) (pcase-dolist (`(,type . ,handler) commit 71735be475f0e5e72727c567e7344df805206cd5 Author: Lars Ingebrigtsen Date: Mon Oct 3 21:32:01 2022 +0200 Improve help-fns--insert-menu-bindings formatting * lisp/help-fns.el (help-fns--insert-menu-bindings): Make this work better for menus that turn out to not be reachable after all -- i.e., don't insert " and " before the heading in certain cases. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 2bb3e63487..cbf8ff1f59 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -588,36 +588,43 @@ the C sources, too." keys)) (defun help-fns--insert-menu-bindings (menus heading) - (seq-do-indexed - (lambda (menu i) - (insert - (cond ((zerop i) "") - ((= i (1- (length menus))) " and ") - (t ", "))) - (let ((map (lookup-key global-map (seq-take menu 1))) - (start (point))) - (seq-do-indexed - (lambda (entry level) - (when (symbolp map) - (setq map (symbol-function map))) - (when-let ((elem (assq entry (cdr map)))) - (when heading - (insert heading) - (setq heading nil start (point))) - (when (> level 0) - (insert - (if (char-displayable-p ?→) - " → " - " => "))) - (if (eq (nth 1 elem) 'menu-item) - (progn - (insert (nth 2 elem)) - (setq map (cadddr elem))) - (insert (nth 1 elem)) - (setq map (cddr elem))))) - (cdr (seq-into menu 'list))) - (put-text-property start (point) 'face 'help-key-binding))) - menus)) + (let ((strings nil)) + ;; First collect all the printed representations of menus. + (dolist (menu menus) + (let ((map (lookup-key global-map (seq-take menu 1))) + (string nil)) + (seq-do-indexed + (lambda (entry level) + (when (symbolp map) + (setq map (symbol-function map))) + (when-let ((elem (assq entry (cdr map)))) + (when (> level 0) + (push (if (char-displayable-p ?→) + " → " + " => ") + string)) + (if (eq (nth 1 elem) 'menu-item) + (progn + (push (nth 2 elem) string) + (setq map (cadddr elem))) + (push (nth 1 elem) string) + (setq map (cddr elem))))) + (cdr (seq-into menu 'list))) + (when string + (push string strings)))) + ;; Then output them. + (when strings + (when heading + (insert heading) + (seq-do-indexed + (lambda (string i) + (insert + (cond ((zerop i) "") + ((= i (1- (length menus))) " and ") + (t ", "))) + (insert (propertize (string-join (nreverse string)) + 'face 'help-key-binding))) + strings))))) (defun help-fns--compiler-macro (function) (pcase-dolist (`(,type . ,handler) commit 4975f6fa535a17c83f1680570671959f1ec452fa Author: Lars Ingebrigtsen Date: Mon Oct 3 20:27:17 2022 +0200 Add commands to edit/remove ecomplete entries * lisp/ecomplete.el (ecomplete-add-item): Allow forcing new values. (ecomplete--remove-item): (ecomplete--prompt-type): New functions. (ecomplete-edit, ecomplete-remove): New commands. diff --git a/etc/NEWS b/etc/NEWS index dd048b9df3..05e05afc8e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1341,6 +1341,11 @@ change the input method's translation rules, customize the user option ** ecomplete +--- +*** New commands 'ecomplete-edit' and 'ecomplete-remove'. +These allow you to (respectively) edit and bulk-remove entries from +the ecomplete database. + --- *** New user option 'ecomplete-auto-select'. If non-nil and there's only one matching option, auto-select that. diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el index 76438fd25a..6e40eb7456 100644 --- a/lisp/ecomplete.el +++ b/lisp/ecomplete.el @@ -99,8 +99,10 @@ string that was matched." (insert-file-contents ecomplete-database-file) (setq ecomplete-database (read (current-buffer))))))) -(defun ecomplete-add-item (type key text) - "Add item TEXT of TYPE to the database, using KEY as the identifier." +(defun ecomplete-add-item (type key text &optional force) + "Add item TEXT of TYPE to the database, using KEY as the identifier. +By default, the longest version of TEXT will be preserved, but if +FORCE is non-nil, use TEXT exactly as is." (unless ecomplete-database (ecomplete-setup)) (let ((elems (assq type ecomplete-database)) (now (time-convert nil 'integer)) @@ -111,10 +113,24 @@ string that was matched." (pcase-let ((`(,_key ,count ,_time ,oldtext) entry)) (setcdr entry (list (1+ count) now ;; Preserve the "more complete" text. - (if (>= (length text) (length oldtext)) - text oldtext)))) + (if (or force + (>= (length text) (length oldtext))) + text + oldtext)))) (nconc elems (list (list key 1 now text)))))) +(defun ecomplete--remove-item (type key) + "Remove the element of TYPE and KEY from the ecomplete database." + (unless ecomplete-database + (ecomplete-setup)) + (let ((elems (assq type ecomplete-database))) + (unless elems + (user-error "No elements of type %s" type)) + (let ((entry (assoc key elems))) + (unless entry + (user-error "No entry with key %s" key)) + (setcdr elems (delq entry (cdr elems)))))) + (defun ecomplete-get-item (type key) "Return the text for the item identified by KEY of the required TYPE." (assoc key (cdr (assq type ecomplete-database)))) @@ -263,6 +279,48 @@ non-nil and there is only a single completion option available." ecomplete-sort-predicate)))) (complete-with-action action candidates string pred)))))) +(defun ecomplete--prompt-type () + (unless ecomplete-database + (ecomplete-setup)) + (if (length= ecomplete-database 1) + (caar ecomplete-database) + (completing-read "Item type to edit: " + (mapcar #'car ecomplete-database) + nil t))) + +(defun ecomplete-edit () + "Prompt for an item and allow editing it." + (interactive) + (let* ((type (ecomplete--prompt-type)) + (data (cdr (assq type ecomplete-database))) + (key (completing-read "Key to edit: " data nil t)) + (new (read-string "New value (empty to remove): " + (nth 3 (assoc key data))))) + (if (zerop (length new)) + (progn + (ecomplete--remove-item type key) + (message "Removed %s" key)) + (ecomplete-add-item type key new t) + (message "Updated %s to %s" key new)) + (ecomplete-save))) + +(defun ecomplete-remove () + "Remove entries matching a regexp from the ecomplete database." + (interactive) + (let* ((type (ecomplete--prompt-type)) + (data (cdr (assq type ecomplete-database))) + (match (read-regexp (format "Remove %s keys matching (regexp): " + type))) + (elems (seq-filter (lambda (elem) + (string-match-p match (car elem))) + data))) + (when (yes-or-no-p (format "Delete %s matching ecomplete entries? " + (length elems))) + (dolist (elem elems) + (ecomplete--remove-item type (car elem))) + (ecomplete-save) + (message "Deleted entries")))) + (provide 'ecomplete) ;;; ecomplete.el ends here commit f97993ee667f9be7589825f3a4fbc095d6944ec6 Author: Lars Ingebrigtsen Date: Mon Oct 3 19:49:53 2022 +0200 Rename to inhibit-automatic-native-compilation * src/comp.c (maybe_defer_native_compilation): (syms_of_comp): * lisp/subr.el (native-comp-deferred-compilation): * lisp/startup.el (inhibit-native-compilation): (normal-top-level): * lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile-and-load): * lisp/emacs-lisp/comp.el (comp-trampoline-compile): * etc/NEWS: * doc/lispref/compile.texi (Native-Compilation Variables): Rename inhibit-native-compilation to inhibit-automatic-native-compilation. diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index e6e9fd1be8..7ccee08e53 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -973,7 +973,7 @@ whether native-compilation is available should use this predicate. This section documents the variables that control native-compilation. -@defvar inhibit-native-compilation +@defvar inhibit-automatic-native-compilation If your Emacs has support for native compilation, Emacs will (by default) compile the Lisp files you're loading in the background, and then install the native-compiled versions of the functions. If you @@ -987,7 +987,7 @@ files, the compiler may still be invoked to install @dfn{trampolines} if any built-in functions are redefined. However, these trampolines will not get written to disk. -You can also use the @samp{EMACS_INHIBIT_NATIVE_COMPILATION} +You can also use the @samp{EMACS_INHIBIT_AUTOMATIC_NATIVE_COMPILATION} environment variable to disable native compilation. @end defvar diff --git a/etc/NEWS b/etc/NEWS index 9e9f9b6503..dd048b9df3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -171,11 +171,11 @@ time. ** Native Compilation +++ -*** New variable 'inhibit-native-compilation'. +*** New variable 'inhibit-automatic-native-compilation'. If set, Emacs will inhibit native compilation (and won't write anything to the eln cache automatically). The variable is initialised -from the EMACS_INHIBIT_NATIVE_COMPILATION environment variable on -Emacs startup. +from the EMACS_INHIBIT_AUTOMATIC_NATIVE_COMPILATION environment +variable on Emacs startup. --- *** New command 'native-compile-prune-cache'. This command diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 759cedddef..6656b7e57c 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3803,7 +3803,7 @@ Return the trampoline if found or nil otherwise." form nil ;; If we've disabled nativecomp, don't write the trampolines to ;; the eln cache (but create them). - (and (not inhibit-native-compilation) + (and (not inhibit-automatic-native-compilation) (cl-loop for dir in (if native-compile-target-directory (list (expand-file-name comp-native-version-dir diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index c12453e883..7e7ea6aeb9 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -220,8 +220,8 @@ All commands in `lisp-mode-shared-map' are inherited by this map." Load the compiled code when finished. Use `emacs-lisp-byte-compile-and-load' in combination with -`inhibit-native-compilation' set to nil to achieve asynchronous -native compilation." +`inhibit-automatic-native-compilation' set to nil to achieve +asynchronous native compilation." (interactive nil emacs-lisp-mode) (emacs-lisp--before-compile-buffer) (load (native-compile buffer-file-name))) diff --git a/lisp/startup.el b/lisp/startup.el index 03a67cdc0e..04de7e42fe 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -541,7 +541,7 @@ DIRS are relative." (setq comp--compilable t)) (defvar native-comp-eln-load-path) -(defvar inhibit-native-compilation) +(defvar inhibit-automatic-native-compilation) (defvar comp-enable-subr-trampolines) (defvar startup--original-eln-load-path nil @@ -579,7 +579,8 @@ It sets `command-line-processed', processes the command-line, reads the initialization files, etc. It is the default value of the variable `top-level'." ;; Allow disabling automatic .elc->.eln processing. - (setq inhibit-native-compilation (getenv "EMACS_INHIBIT_NATIVE_COMPILATION")) + (setq inhibit-automatic-native-compilation + (getenv "EMACS_INHIBIT_AUTOMATIC_NATIVE_COMPILATION")) (if command-line-processed (message internal--top-level-message) @@ -599,7 +600,7 @@ It is the default value of the variable `top-level'." ;; in this session. This is necessary if libgccjit is not ;; available on MS-Windows, but Emacs was built with ;; native-compilation support. - (setq inhibit-native-compilation t + (setq inhibit-automatic-native-compilation t comp-enable-subr-trampolines nil)) ;; Form `native-comp-eln-load-path'. diff --git a/lisp/subr.el b/lisp/subr.el index 0c9d94db1c..51172b1cb2 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1877,7 +1877,7 @@ instead; it will indirectly limit the specpdl stack size as well.") (make-obsolete-variable 'max-specpdl-size nil "29.1") (make-obsolete-variable 'native-comp-deferred-compilation - 'inhibit-native-compilation "29.1") + 'inhibit-automatic-native-compilation "29.1") ;;;; Alternate names for functions - these are not being phased out. diff --git a/src/comp.c b/src/comp.c index ed64a85072..1b767ba0dd 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5107,7 +5107,7 @@ maybe_defer_native_compilation (Lisp_Object function_name, return; if (!native_comp_deferred_compilation - || !NILP (Vinhibit_native_compilation) + || !NILP (Vinhibit_automatic_native_compilation) || noninteractive || !NILP (Vpurify_flag) || !COMPILEDP (definition) @@ -5611,12 +5611,13 @@ For internal use. */); doc: /* Non-nil when comp.el can be native compiled. For internal use. */); /* Compiler control customizes. */ - DEFVAR_LISP ("inhibit-native-compilation", Vinhibit_native_compilation, + DEFVAR_LISP ("inhibit-automatic-native-compilation", + Vinhibit_automatic_native_compilation, doc: /* If non-nil, inhibit automatic native compilation of loaded .elc files. After compilation, each function definition is updated to the native compiled one. */); - Vinhibit_native_compilation = Qnil; + Vinhibit_automatic_native_compilation = Qnil; DEFVAR_BOOL ("native-comp-deferred-compilation", native_comp_deferred_compilation, commit 81003b53f87597aba0320dd785227b219ae2ad1f Author: Manuel Giraud Date: Mon Oct 3 19:14:26 2022 +0200 ; * src/menu.c: remove unused lwlib include * src/menu.c: remove unused lwlib include (bug#58275). diff --git a/src/menu.c b/src/menu.c index eeb0c9a7e5..c52e9258a1 100644 --- a/src/menu.c +++ b/src/menu.c @@ -32,10 +32,6 @@ along with GNU Emacs. If not, see . */ #include "blockinput.h" #include "buffer.h" -#ifdef USE_X_TOOLKIT -#include "../lwlib/lwlib.h" -#endif - #ifdef HAVE_WINDOW_SYSTEM #include TERM_HEADER #endif /* HAVE_WINDOW_SYSTEM */ commit 59f8c56d9e71a1b61ca8cc0794a6de4aa2f240e4 Author: Stefan Monnier Date: Mon Oct 3 11:17:51 2022 -0400 files.el (major-mode-remap-alist): New custom var (bug#58075) * lisp/files.el (major-mode-remap-alist): New custom var. (set-auto-mode--last): New var. (set-auto-mode-0): Obey `major-mode-remap-alist`. * doc/emacs/modes.texi (Choosing Modes): Document `major-mode-remap-alist`. * lisp/progmodes/cperl-mode.el: Recommend the use of `major-mode-remap-alist` over the crude `defalias` solution. * lisp/textmodes/tex-mode.el (tex--guess-mode): Simplify. (tex--redirect-to-submode): Obey `major-mode-remap-alist`. diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi index c348130807..56b779f8de 100644 --- a/doc/emacs/modes.texi +++ b/doc/emacs/modes.texi @@ -454,6 +454,13 @@ only @emph{after} @code{auto-mode-alist}. By default, files, HTML/XML/SGML files, PostScript files, and Unix style Conf files. +@vindex major-mode-remap-alist + Once a major mode is found, Emacs does a final check to see if the +mode has been remapped by @code{major-mode-remap-alist}, in which case +it uses the remapped mode instead. This is used when several +different major modes can be used for the same file type, so you can +specify which mode you prefer. + @findex normal-mode If you have changed the major mode of a buffer, you can return to the major mode Emacs would have chosen automatically, by typing diff --git a/etc/NEWS b/etc/NEWS index 6e7836e3c0..9e9f9b6503 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -477,6 +477,15 @@ option) and can be set to nil to disable Just-in-time Lock mode. * Changes in Emacs 29.1 ++++ +** New variable 'major-mode-remap-alist' to specify your favorite major modes. +This variable lets you remap the default modes (e.g. 'perl-mode' or +'latex-mode') to your favorite ones (e.g. 'cperl-mode' or +'LaTeX-mode') without having to use 'defalias', which can have +undesirable side effects. +This applies to all modes specified via 'auto-mode-alist', file-local +variables, etc... + --- ** Emacs now supports Unicode Standard version 15.0. diff --git a/lisp/files.el b/lisp/files.el index 40ad11ecfc..667e3325bb 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3333,6 +3333,7 @@ checks if it uses an interpreter listed in `interpreter-mode-alist', matches the buffer beginning against `magic-mode-alist', compares the file name against the entries in `auto-mode-alist', then matches the buffer beginning against `magic-fallback-mode-alist'. +It also obeys `major-mode-remap-alist'. If `enable-local-variables' is nil, or if the file name matches `inhibit-local-variables-regexps', this function does not check @@ -3470,6 +3471,17 @@ we don't actually set it to the same mode the buffer already has." (unless done (set-buffer-major-mode (current-buffer))))) +(defvar-local set-auto-mode--last nil + "Remember the mode we have set via `set-auto-mode-0'.") + +(defcustom major-mode-remap-alist nil + "Alist mapping file-specified mode to actual mode. +Every entry is of the form (MODE . FUNCTION) which means that in order +to activate the major mode MODE (specified via something like +`auto-mode-alist', file-local variables, ...) we should actually call +FUNCTION instead." + :type '(alist (symbol) (function))) + ;; When `keep-mode-if-same' is set, we are working on behalf of ;; set-visited-file-name. In that case, if the major mode specified is the ;; same one we already have, don't actually reset it. We don't want to lose @@ -3480,10 +3492,15 @@ If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of any aliases and compared to current major mode. If they are the same, do nothing and return nil." (unless (and keep-mode-if-same - (eq (indirect-function mode) - (indirect-function major-mode))) + (or (eq (indirect-function mode) + (indirect-function major-mode)) + (and set-auto-mode--last + (eq mode (car set-auto-mode--last)) + (eq major-mode (cdr set-auto-mode--last))))) (when mode - (funcall mode) + (funcall (alist-get mode major-mode-remap-alist mode)) + (unless (eq mode major-mode) + (setq set-auto-mode--last (cons mode major-mode))) mode))) (defvar file-auto-mode-skip "^\\(#!\\|'\\\\\"\\)" @@ -3513,7 +3530,8 @@ have no effect." ;; interpreter invocation. The same holds ;; for '\" in man pages (preprocessor ;; magic for the `man' program). - (and (looking-at file-auto-mode-skip) 2)) t) + (and (looking-at file-auto-mode-skip) 2)) + t) (progn (skip-chars-forward " \t") (setq beg (point)) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index fa428642fa..20a73e238e 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -632,7 +632,7 @@ mode-compile.el. If your Emacs does not default to `cperl-mode' on Perl files, and you want it to: put the following into your .emacs file: - (defalias \\='perl-mode \\='cperl-mode) + (add-to-list \\='major-mode-remap-alist \\='(perl-mode . cperl-mode)) Get perl5-info from $CPAN/doc/manual/info/perl5-old/perl5-info.tar.gz diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index b43537265f..5c2dbdfe5c 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -980,24 +980,23 @@ Inherits `shell-mode-map' with a few additions.") (save-excursion (beginning-of-line) (search-forward "%" search-end t)))))) - (when (and slash (not comment)) - (setq mode - (if (looking-at - (concat - (regexp-opt '("documentstyle" "documentclass" - "begin" "subsection" "section" - "part" "chapter" "newcommand" - "renewcommand" "RequirePackage") - 'words) - "\\|NeedsTeXFormat{LaTeX")) - (if (and (looking-at - "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") - ;; SliTeX is almost never used any more nowadays. - (tex-executable-exists-p slitex-run-command)) - #'slitex-mode - #'latex-mode) - #'plain-tex-mode)))) - mode)) + (if (not (and slash (not comment))) + mode + (if (looking-at + (concat + (regexp-opt '("documentstyle" "documentclass" + "begin" "subsection" "section" + "part" "chapter" "newcommand" + "renewcommand" "RequirePackage") + 'words) + "\\|NeedsTeXFormat{LaTeX")) + (if (and (looking-at + "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") + ;; SliTeX is almost never used any more nowadays. + (tex-executable-exists-p slitex-run-command)) + #'slitex-mode + #'latex-mode) + #'plain-tex-mode))))) ;; `tex-mode' plays two roles: it's the parent of several sub-modes ;; but it's also the function that chooses between those submodes. @@ -1029,20 +1028,18 @@ says which mode to use." ;; We're called from one of the children already. orig-fun (setq tex-mode--recursing t) - (tex--guess-mode))))) + (let ((mode (tex--guess-mode))) + ;; `tex--guess-mode' really tries to guess the *type* of file, + ;; so we still need to consult `major-mode-remap-alist' + ;; to see which mode to use for that type. + (funcall (alist-get mode major-mode-remap-alist mode))))))) ;; The following three autoloaded aliases appear to conflict with -;; AUCTeX. However, even though AUCTeX uses the mixed case variants -;; for all mode relevant variables and hooks, the invocation function -;; and setting of `major-mode' themselves need to be lowercase for -;; AUCTeX to provide a fully functional user-level replacement. So -;; these aliases should remain as they are, in particular since AUCTeX -;; users are likely to use them. -;; Note from Stef: I don't understand the above explanation, the only -;; justification I can find to keep those confusing aliases is for those -;; users who may have files annotated with -*- LaTeX -*- (e.g. because they -;; received them from someone using AUCTeX). - +;; AUCTeX. We keep those confusing aliases for those users who may +;; have files annotated with -*- LaTeX -*- (e.g. because they received +;; them from someone using AUCTeX). +;; FIXME: Turn them into autoloads so that AUCTeX can override them +;; with it's own autoloads? Or maybe rely on `major-mode-remap-alist'? ;;;###autoload (defalias 'TeX-mode #'tex-mode) ;;;###autoload (defalias 'plain-TeX-mode #'plain-tex-mode) ;;;###autoload (defalias 'LaTeX-mode #'latex-mode) commit 5fec9182dbeffa88cef6651d8c798ef9665d6681 Author: Lars Ingebrigtsen Date: Mon Oct 3 15:26:04 2022 +0200 Add new variable 'inhibit-native-compilation' * doc/lispref/compile.texi (Native-Compilation Variables): Document it. * lisp/startup.el (normal-top-level): Set inhibit-native-compilation from environment variable. * lisp/subr.el (native-comp-deferred-compilation): Make obsolete. * lisp/emacs-lisp/comp.el (comp-trampoline-compile): Don't write trampolines to disk. * lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile-and-load): Adjust. * src/comp.c (syms_of_comp): New variable inhibit-native-compilation. (maybe_defer_native_compilation): Use it. diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index 60fc11a22e..e6e9fd1be8 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -973,6 +973,24 @@ whether native-compilation is available should use this predicate. This section documents the variables that control native-compilation. +@defvar inhibit-native-compilation +If your Emacs has support for native compilation, Emacs will (by +default) compile the Lisp files you're loading in the background, and +then install the native-compiled versions of the functions. If you +wish to disable this, you can set this variable to non-@code{nil}. If +you want to set it permanently, this should probably be done from the +early init file, since setting it in the normal init file is probably +too late. + +While setting this variable disables automatic compilation of Lisp +files, the compiler may still be invoked to install @dfn{trampolines} +if any built-in functions are redefined. However, these trampolines +will not get written to disk. + +You can also use the @samp{EMACS_INHIBIT_NATIVE_COMPILATION} +environment variable to disable native compilation. +@end defvar + @defopt native-comp-speed This variable specifies the optimization level for native compilation. Its value should be a number between @minus{}1 and 3. Values between diff --git a/etc/NEWS b/etc/NEWS index d7bc4b0e0c..6e7836e3c0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -170,10 +170,17 @@ time. ** Native Compilation ---- -*** New command 'native-compile-prune-cache'. -This command deletes older ".eln" cache entries (but not the ones for -the current Emacs version). ++++ +*** New variable 'inhibit-native-compilation'. +If set, Emacs will inhibit native compilation (and won't write +anything to the eln cache automatically). The variable is initialised +from the EMACS_INHIBIT_NATIVE_COMPILATION environment variable on +Emacs startup. + + +--- *** New command 'native-compile-prune-cache'. This command +deletes older ".eln" cache entries (but not the ones for the current +Emacs version). --- *** New function 'startup-redirect-eln-cache'. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index abab9107ae..759cedddef 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3801,22 +3801,25 @@ Return the trampoline if found or nil otherwise." (lexical-binding t)) (comp--native-compile form nil - (cl-loop - for dir in (if native-compile-target-directory - (list (expand-file-name comp-native-version-dir - native-compile-target-directory)) - (comp-eln-load-path-eff)) - for f = (expand-file-name - (comp-trampoline-filename subr-name) - dir) - unless (file-exists-p dir) - do (ignore-errors - (make-directory dir t) - (cl-return f)) - when (file-writable-p f) - do (cl-return f) - finally (error "Cannot find suitable directory for output in \ -`native-comp-eln-load-path'"))))) + ;; If we've disabled nativecomp, don't write the trampolines to + ;; the eln cache (but create them). + (and (not inhibit-native-compilation) + (cl-loop + for dir in (if native-compile-target-directory + (list (expand-file-name comp-native-version-dir + native-compile-target-directory)) + (comp-eln-load-path-eff)) + for f = (expand-file-name + (comp-trampoline-filename subr-name) + dir) + unless (file-exists-p dir) + do (ignore-errors + (make-directory dir t) + (cl-return f)) + when (file-writable-p f) + do (cl-return f) + finally (error "Cannot find suitable directory for output in \ +`native-comp-eln-load-path'")))))) ;; Some entry point support code. @@ -4107,6 +4110,7 @@ the deferred compilation mechanism." comp-ctxt (comp-ctxt-output comp-ctxt) (file-exists-p (comp-ctxt-output comp-ctxt))) + (message "Deleting %s" (comp-ctxt-output comp-ctxt)) (delete-file (comp-ctxt-output comp-ctxt))))))) (defun native-compile-async-skip-p (file load selector) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 4ada27a1ac..c12453e883 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -220,7 +220,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map." Load the compiled code when finished. Use `emacs-lisp-byte-compile-and-load' in combination with -`native-comp-deferred-compilation' set to t to achieve asynchronous +`inhibit-native-compilation' set to nil to achieve asynchronous native compilation." (interactive nil emacs-lisp-mode) (emacs-lisp--before-compile-buffer) diff --git a/lisp/startup.el b/lisp/startup.el index 50a8f491d8..03a67cdc0e 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -541,7 +541,7 @@ DIRS are relative." (setq comp--compilable t)) (defvar native-comp-eln-load-path) -(defvar native-comp-deferred-compilation) +(defvar inhibit-native-compilation) (defvar comp-enable-subr-trampolines) (defvar startup--original-eln-load-path nil @@ -578,6 +578,9 @@ the updated value." It sets `command-line-processed', processes the command-line, reads the initialization files, etc. It is the default value of the variable `top-level'." + ;; Allow disabling automatic .elc->.eln processing. + (setq inhibit-native-compilation (getenv "EMACS_INHIBIT_NATIVE_COMPILATION")) + (if command-line-processed (message internal--top-level-message) (setq command-line-processed t) @@ -596,7 +599,7 @@ It is the default value of the variable `top-level'." ;; in this session. This is necessary if libgccjit is not ;; available on MS-Windows, but Emacs was built with ;; native-compilation support. - (setq native-comp-deferred-compilation nil + (setq inhibit-native-compilation t comp-enable-subr-trampolines nil)) ;; Form `native-comp-eln-load-path'. diff --git a/lisp/subr.el b/lisp/subr.el index 4f8273d56f..0c9d94db1c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1876,6 +1876,9 @@ activations. To prevent runaway recursion, use `max-lisp-eval-depth' instead; it will indirectly limit the specpdl stack size as well.") (make-obsolete-variable 'max-specpdl-size nil "29.1") +(make-obsolete-variable 'native-comp-deferred-compilation + 'inhibit-native-compilation "29.1") + ;;;; Alternate names for functions - these are not being phased out. diff --git a/src/comp.c b/src/comp.c index 4813ca04a9..ed64a85072 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5107,6 +5107,7 @@ maybe_defer_native_compilation (Lisp_Object function_name, return; if (!native_comp_deferred_compilation + || !NILP (Vinhibit_native_compilation) || noninteractive || !NILP (Vpurify_flag) || !COMPILEDP (definition) @@ -5610,6 +5611,13 @@ For internal use. */); doc: /* Non-nil when comp.el can be native compiled. For internal use. */); /* Compiler control customizes. */ + DEFVAR_LISP ("inhibit-native-compilation", Vinhibit_native_compilation, + doc: /* If non-nil, inhibit automatic native compilation of loaded .elc files. + +After compilation, each function definition is updated to the native +compiled one. */); + Vinhibit_native_compilation = Qnil; + DEFVAR_BOOL ("native-comp-deferred-compilation", native_comp_deferred_compilation, doc: /* If non-nil compile loaded .elc files asynchronously. commit da02b9edadbc809b25ac83eccf64089f1cf3b160 Author: Po Lu Date: Mon Oct 3 20:18:22 2022 +0800 Fix coding systems used for X input methods * doc/emacs/mule.texi (International): Refer to X Coding as well. (Communication Coding): Document that locale-coding-system is not always used on X to decode keyboard input. (X Coding): New node. * etc/NEWS: Announce change to input method coding resolution. * lisp/term/x-win.el (x-get-input-coding-system): New function. * src/coding.c (syms_of_coding): Update doc string of locale-coding-system. * src/xfns.c (struct x_xim_text_conversion_data) (x_xim_text_to_utf8_unix_1, x_xim_text_to_utf8_unix_2) (x_xim_text_to_utf8_unix): Accept dpyinfo. Use the coding system specified inside if possible. (xic_preedit_draw_callback): Pass dpyinfo. * src/xterm.c (handle_one_xevent): Use XIM coding system for IM input. (xim_open_dpy): Try to determine the input method coding system. (mark_xterm): Mark `xim_coding'. (syms_of_xterm): New variable `x-input-coding-system'. * src/xterm.h (struct x_display_info): New field `xim_coding'. (FRAME_X_XIM_CODING): New macro. diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi index 5f30341838..1bbd7440f3 100644 --- a/doc/emacs/mule.texi +++ b/doc/emacs/mule.texi @@ -61,7 +61,7 @@ can also be input by using the @kbd{C-x 8} prefix, see @ref{Unibyte Mode}. With the X Window System, your locale should be set to an appropriate value to make sure Emacs interprets keyboard input correctly; see -@ref{Language Environments, locales}. +@ref{Language Environments, locales}, and @ref{X Coding}. @end itemize The rest of this chapter describes these issues in detail. @@ -79,6 +79,7 @@ value to make sure Emacs interprets keyboard input correctly; see * Text Coding:: Choosing conversion to use for file text. * Communication Coding:: Coding systems for interprocess communication. * File Name Coding:: Coding systems for file @emph{names}. +* X Coding:: Coding systems for X input methods. * Terminal Coding:: Specifying coding systems for converting terminal input and output. * Fontsets:: Fontsets are collections of fonts @@ -1241,15 +1242,14 @@ current language environment. The variable @code{locale-coding-system} specifies a coding system to use when encoding and decoding system strings such as system error messages and @code{format-time-string} formats and time stamps. That -coding system is also used for decoding non-@acronym{ASCII} keyboard -input on the X Window System and for encoding text sent to the -standard output and error streams when in batch mode. You should -choose a coding system that is compatible -with the underlying system's text representation, which is normally -specified by one of the environment variables @env{LC_ALL}, -@env{LC_CTYPE}, and @env{LANG}. (The first one, in the order -specified above, whose value is nonempty is the one that determines -the text representation.) +coding system might also be used for decoding non-@acronym{ASCII} +keyboard input on the X Window System and will also be used to encode +text sent to the standard output and error streams in batch mode. You +should choose a coding system that is compatible with the underlying +system's text representation, which is normally specified by one of +the environment variables @env{LC_ALL}, @env{LC_CTYPE}, and +@env{LANG}. (The first one, in the order specified above, whose value +is nonempty is the one that determines the text representation.) @node File Name Coding @section Coding Systems for File Names @@ -1311,6 +1311,26 @@ C-w} to specify a new file name for that buffer. system. This prompts for an existing file name, its old coding system, and the coding system to which you wish to convert. +@node X Coding +@section Coding Systems for X Keyboard Input +@cindex X input method coding systems + Input methods under the X Window System specify their own coding +systems that must be used to decode keyboard input. By default, Emacs +determines the coding system used for each input method automatically +upon establishing the connection to the input method server, and uses +that specific coding system to decode keyboard input. However, that +determination can sometimes fail; in that situation, the locale coding +system (@pxref{Communication Coding}) is used instead. + +@cindex X input method coding systems, overriding +@vindex x-input-coding-system + If the input method does not correctly announce the coding system it +uses to encode text, then the coding system used by Emacs to decode +text from input methods must be manually specified. The value of the +variable @code{x-input-coding-system}, when set to a symbol, is +unconditionally used as the coding system used to decode keyboard +input from input methods. + @node Terminal Coding @section Coding Systems for Terminal I/O diff --git a/etc/NEWS b/etc/NEWS index db7c675edb..d7bc4b0e0c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -186,6 +186,19 @@ of 'user-emacs-directory'. * Incompatible changes in Emacs 29.1 ++++ +*** Emacs now picks the correct coding system for X input methods. +Previously, Emacs would use the locale coding system for input +methods, which could in some circumstances be incorrect, especially +when the input method chose to fall back to some other coding system. + +Now, Emacs automatically detects the coding system used by input +methods, and uses that to decode input in preference to the value of +'locale-coding-system'. This unfortunately means that users who have +changed the coding system used to decode X keyboard input must adjust +their customizations to 'locale-coding-system' to the variable +'x-input-coding-system' instead. + +++ *** Bookmarks no longer include context for encrypted files. If you're visiting an encrypted file, setting a bookmark no longer diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index 9d3e780365..57c6b785e7 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el @@ -1613,6 +1613,28 @@ Users should not call this function; see `device-class' instead." (setq x-dnd-movement-function #'x-dnd-movement) (setq x-dnd-unsupported-drop-function #'x-dnd-handle-unsupported-drop) +(defvar x-input-coding-function) + +(defun x-get-input-coding-system (x-locale) + "Return a coding system for the locale X-LOCALE. +Return a coding system that is able to decode text sent with the +X input method locale X-LOCALE, or nil if no coding system was +found." + (if (equal x-locale "C") + ;; Treat the C locale specially, as it means "ascii" under X. + 'ascii + (let ((locale (downcase x-locale))) + (or (locale-name-match locale locale-preferred-coding-systems) + (when locale + (if (string-match "\\.\\([^@]+\\)" locale) + (locale-charset-to-coding-system + (match-string 1 locale)))) + (let ((language-name + (locale-name-match locale locale-language-names))) + (and (consp language-name) (cdr language-name))))))) + +(setq x-input-coding-function #'x-get-input-coding-system) + (provide 'x-win) (provide 'term/x-win) diff --git a/src/coding.c b/src/coding.c index 0ae8eb3282..ab73bda844 100644 --- a/src/coding.c +++ b/src/coding.c @@ -12014,9 +12014,9 @@ See also the function `find-operation-coding-system'. */); Vnetwork_coding_system_alist = Qnil; DEFVAR_LISP ("locale-coding-system", Vlocale_coding_system, - doc: /* Coding system to use with system messages. -Also used for decoding keyboard input on X Window system, and for -encoding standard output and error streams. */); + doc: /* Coding system to use with system messages. +Potentially also used for decoding keyboard input on X Windows, and is +used for encoding standard output and error streams. */); Vlocale_coding_system = Qnil; /* The eol mnemonics are reset in startup.el system-dependently. */ diff --git a/src/xfns.c b/src/xfns.c index bb75ca5ad1..8cea93c669 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3354,22 +3354,30 @@ struct x_xim_text_conversion_data { struct coding_system *coding; char *source; + struct x_display_info *dpyinfo; }; static Lisp_Object -x_xim_text_to_utf8_unix_1 (ptrdiff_t nargs, - Lisp_Object *args) +x_xim_text_to_utf8_unix_1 (ptrdiff_t nargs, Lisp_Object *args) { struct x_xim_text_conversion_data *data; ptrdiff_t nbytes; + Lisp_Object coding_system; data = xmint_pointer (args[0]); + + if (SYMBOLP (Vx_input_coding_system)) + coding_system = Vx_input_coding_system; + else if (!NILP (data->dpyinfo->xim_coding)) + coding_system = data->dpyinfo->xim_coding; + else + coding_system = Vlocale_coding_system; + nbytes = strlen (data->source); data->coding->destination = NULL; - setup_coding_system (Vlocale_coding_system, - data->coding); + setup_coding_system (coding_system, data->coding); data->coding->mode |= (CODING_MODE_LAST_BLOCK | CODING_MODE_SAFE_ENCODING); data->coding->source = (const unsigned char *) data->source; @@ -3382,8 +3390,7 @@ x_xim_text_to_utf8_unix_1 (ptrdiff_t nargs, } static Lisp_Object -x_xim_text_to_utf8_unix_2 (Lisp_Object val, - ptrdiff_t nargs, +x_xim_text_to_utf8_unix_2 (Lisp_Object val, ptrdiff_t nargs, Lisp_Object *args) { struct x_xim_text_conversion_data *data; @@ -3400,7 +3407,8 @@ x_xim_text_to_utf8_unix_2 (Lisp_Object val, /* The string returned is not null-terminated. */ static char * -x_xim_text_to_utf8_unix (XIMText *text, ptrdiff_t *length) +x_xim_text_to_utf8_unix (struct x_display_info *dpyinfo, + XIMText *text, ptrdiff_t *length) { unsigned char *wchar_buf; ptrdiff_t wchar_actual_length, i; @@ -3424,6 +3432,7 @@ x_xim_text_to_utf8_unix (XIMText *text, ptrdiff_t *length) data.coding = &coding; data.source = text->string.multi_byte; + data.dpyinfo = dpyinfo; was_waiting_for_input_p = waiting_for_input; /* Otherwise Fsignal will crash. */ @@ -3441,18 +3450,21 @@ static void xic_preedit_draw_callback (XIC xic, XPointer client_data, XIMPreeditDrawCallbackStruct *call_data) { - struct frame *f = x_xic_to_frame (xic); + struct frame *f; struct x_output *output; - ptrdiff_t text_length = 0; + ptrdiff_t text_length; ptrdiff_t charpos; ptrdiff_t original_size; char *text; char *chg_start, *chg_end; struct input_event ie; + + f = x_xic_to_frame (xic); EVENT_INIT (ie); if (f) { + text_length = 0; output = FRAME_X_OUTPUT (f); if (!output->preedit_active) @@ -3460,7 +3472,8 @@ xic_preedit_draw_callback (XIC xic, XPointer client_data, if (call_data->text) { - text = x_xim_text_to_utf8_unix (call_data->text, &text_length); + text = x_xim_text_to_utf8_unix (FRAME_DISPLAY_INFO (f), + call_data->text, &text_length); if (!text) /* Decoding the IM text failed. */ diff --git a/src/xterm.c b/src/xterm.c index d83b03d1ca..42335f0de0 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -19139,7 +19139,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, &xkey, (char *) copy_bufptr, copy_bufsiz, &keysym, &status_return); - coding = Qnil; + coding = FRAME_X_XIM_CODING (f); if (status_return == XBufferOverflow) { copy_bufsiz = nbytes + 1; @@ -22828,7 +22828,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, &xkey, (char *) copy_bufptr, copy_bufsiz, &keysym, &status_return); - coding = Qnil; + coding = FRAME_X_XIM_CODING (f); if (status_return == XBufferOverflow) { @@ -25488,9 +25488,10 @@ xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data) static void xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name) { +#ifdef HAVE_XIM XIM xim; + const char *locale; -#ifdef HAVE_XIM if (use_xim) { if (dpyinfo->xim) @@ -25513,6 +25514,14 @@ xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name) destroy.client_data = (XPointer)dpyinfo; XSetIMValues (xim, XNDestroyCallback, &destroy, NULL); #endif + + locale = XLocaleOfIM (xim); + + /* Now try to determine the coding system that should be + used. locale is in Host Portable Character Encoding, and + as such can be passed to build_string as is. */ + dpyinfo->xim_coding = safe_call1 (Vx_input_coding_function, + build_string (locale)); } } @@ -29843,7 +29852,7 @@ mark_xterm (void) } #if defined HAVE_XINPUT2 || defined USE_TOOLKIT_SCROLL_BARS \ - || defined HAVE_XRANDR || defined USE_GTK + || defined HAVE_XRANDR || defined USE_GTK || defined HAVE_X_I18N for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) { #ifdef HAVE_XINPUT2 @@ -29856,6 +29865,9 @@ mark_xterm (void) #endif #if defined HAVE_XRANDR || defined USE_GTK mark_object (dpyinfo->last_monitor_attributes_list); +#endif +#if defined HAVE_X_I18N + mark_object (dpyinfo->xim_coding); #endif } #endif @@ -30385,4 +30397,18 @@ on the same display. In addition, when this variable is a list, only preserve the selections whose names are contained within. */); Vx_auto_preserve_selections = list2 (QCLIPBOARD, QPRIMARY); + + DEFVAR_LISP ("x-input-coding-system", Vx_input_coding_system, + doc: /* Coding system used for input from X input methods. +If a symbol and non-nil, this is the coding system that will be used +to decode input from X input methods. It does not affect input from +GTK native input methods enabled through `x-gtk-use-native-input'. */); + Vx_input_coding_system = Qnil; + + DEFVAR_LISP ("x-input-coding-function", Vx_input_coding_function, + doc: /* Function used to determine the coding system used by input methods. +It should accept a single argument, a string describing the locale of +the input method, and return a coding system that can decode keyboard +input generated by said input method. */); + Vx_input_coding_function = Qnil; } diff --git a/src/xterm.h b/src/xterm.h index f3791aa8df..b68a234faa 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -580,6 +580,9 @@ struct x_display_info XIMStyles *xim_styles; struct xim_inst_t *xim_callback_data; XIMStyle preferred_xim_style; + + /* The named coding system to use for this input method. */ + Lisp_Object xim_coding; #endif /* A cache mapping color names to RGB values. */ @@ -1348,6 +1351,12 @@ extern void x_mark_frame_dirty (struct frame *f); #define FRAME_X_XIM_STYLES(f) (FRAME_DISPLAY_INFO (f)->xim_styles) #define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style) #define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs) +#define FRAME_X_XIM_CODING(f) \ + (SYMBOLP (Vx_input_coding_system) \ + ? Vx_input_coding_system \ + : (!NILP (FRAME_DISPLAY_INFO (f)->xim_coding) \ + ? FRAME_DISPLAY_INFO(f)->xim_coding \ + : Vlocale_coding_system)) /* X-specific scroll bar stuff. */ commit e245c4f226979ccb717cccc8f82b2b0a0f96bdac Author: Lars Ingebrigtsen Date: Mon Oct 3 12:45:21 2022 +0200 Add --with-native-compilation=aot configuration option * configure.ac: Allow --with-native-compilation=aot to switch full ahead-of-time on. * lisp/Makefile.in: Use the setting from configure. diff --git a/configure.ac b/configure.ac index 4590ed3506..2d84344050 100644 --- a/configure.ac +++ b/configure.ac @@ -494,7 +494,6 @@ OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support]) OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support]) OPTION_DEFAULT_ON([modules],[don't compile with dynamic modules support]) OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support]) -OPTION_DEFAULT_OFF([native-compilation],[compile with Emacs Lisp native compiler support]) OPTION_DEFAULT_OFF([cygwin32-native-compilation],[use native compilation on 32-bit Cygwin]) OPTION_DEFAULT_ON([xinput2],[don't use version 2 of the X Input Extension for input]) OPTION_DEFAULT_OFF([small-ja-dic],[generate a smaller-size Japanese dictionary]) @@ -1009,6 +1008,29 @@ AC_ARG_ENABLE([gcc-warnings], [gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])]) fi]) +NATIVE_COMPILATION_AOT=no +AC_ARG_WITH([native-compilation], + [AS_HELP_STRING([--with-native-compilation@<:@=TYPE@:>@], + [compile with Emacs Lisp native compiler support. The TYPE + 'yes' (or empty) means to enable it and compile natively + preloaded Lisp files; 'no' means to disable it; + 'aot' will make the build process compile all the Lisp + files in the tree natively ahead of time. (This will + usually be quite slow.)])], + [ + case $withval in + aot) + withval=yes + NATIVE_COMPILATION_AOT=yes + ;; + yes|no) ;; + *) AC_MSG_ERROR([bad value $withval for native-compilation option]) ;; + esac + with_native_compilation=$withval], + [with_native_compilation=no] +) +AC_SUBST([NATIVE_COMPILATION_AOT]) + AC_ARG_ENABLE([check-lisp-object-type], [AS_HELP_STRING([--enable-check-lisp-object-type], [Enable compile time checks for the Lisp_Object data type, diff --git a/etc/NEWS b/etc/NEWS index 8f9b0a0330..db7c675edb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -24,6 +24,12 @@ applies, and please also update docstrings as needed. * Installation Changes in Emacs 29.1 +--- +** Ahead-of-time native compilation can now be specified via configure. +Use --with-native-compilation=aot to specify that all the Lisp files +in the Emacs tree should be natively compiled ahead of time. (This is +slow on most machines.) + +++ ** Emacs can be built with built-in support for accessing SQLite databases. This uses the popular sqlite3 library, and can be disabled by using diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 4c26e42370..256017f6c5 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -31,10 +31,16 @@ EXEEXT = @EXEEXT@ XARGS_LIMIT = @XARGS_LIMIT@ HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@ +NATIVE_COMPILATION_AOT = @NATIVE_COMPILATION_AOT@ ifeq ($(HAVE_NATIVE_COMP),yes) +# Environment variable to enable Ahead-Of-Time compilation. ifndef NATIVE_FULL_AOT NATIVE_SKIP_NONDUMP = 1 endif +# Configured for Ahead-Of-Time compilation. +ifeq ($(NATIVE_COMPILATION_AOT),yes) +NATIVE_SKIP_NONDUMP = "" +endif endif -include ${top_builddir}/src/verbose.mk commit 450d94920f5abc36167beb02be909ff65a7f4111 Author: Lars Ingebrigtsen Date: Mon Oct 3 11:04:16 2022 +0200 Revert "keymap.el: Ease up support for non-`kbd` formats." This reverts commit 570a11052be6178954956a1c59c8ebcbdb77d38e. We do not want to support several keymap formats in `keymap-set' and friends -- the point is to have an interface with easy-to-understand semantics that give good feedback on valid/invalid key sequences. diff --git a/lisp/keymap.el b/lisp/keymap.el index c46e72f0a8..107565590c 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -39,8 +39,7 @@ (defun keymap-set (keymap key definition) "Set KEY to DEFINITION in KEYMAP. -KEY is a string that satisfies `key-valid-p' (or a vector using the -internal representation of key sequences). +KEY is a string that satisfies `key-valid-p'. DEFINITION is anything that can be a key's definition: nil (means key is undefined in this keymap), @@ -58,13 +57,13 @@ DEFINITION is anything that can be a key's definition: or an extended menu item definition. (See info node `(elisp)Extended Menu Items'.)" (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))) - (unless (vectorp key) (keymap--check key)) + (keymap--check key) ;; If we're binding this key to another key, then parse that other ;; key, too. (when (stringp definition) (keymap--check definition) (setq definition (key-parse definition))) - (define-key keymap (if (vectorp key) key (key-parse key)) definition)) + (define-key keymap (key-parse key) definition)) (defun keymap-global-set (key command) "Give KEY a global binding as COMMAND. @@ -284,18 +283,6 @@ See `kbd' for a descripion of KEYS." (setq res (vconcat res key)))))) res))) -(defun key-parse-old-format (keys) - "Convert old-style string representation of KEYS to a vector. -Simpler alternative to the Rube-Goldbergesque composition of -`key-description' and `key-parse'." - (cond - ((vectorp keys) keys) - ((multibyte-string-p keys) (vconcat keys)) - ((stringp keys) - (vconcat (mapcar (lambda (c) (if (> c 127) (logior (- c 128) ?\M-\0) c)) - keys))) - (t (error "Invalid old-style key sequence: %S" keys)))) - (defun key-valid-p (keys) "Say whether KEYS is a valid key. A key is a string consisting of one or more key strokes. diff --git a/lisp/outline.el b/lisp/outline.el index 388a04ed25..93a9247f61 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -496,8 +496,7 @@ See the command `outline-mode' for more information on this mode." " " 'outline-cycle " S-" 'outline-cycle-buffer " S-" 'outline-cycle-buffer - (key-parse-old-format outline-minor-mode-prefix) - outline-mode-prefix-map) + (key-description outline-minor-mode-prefix) outline-mode-prefix-map) (if outline-minor-mode (progn (cond commit 992611b10a2ef4621b5c936d80cf31644ca3653d (refs/remotes/origin/emacs-28) Author: Stefan Kangas Date: Mon Oct 3 02:28:26 2022 +0200 Fix documentation of 'TAB' in cc-mode * doc/emacs/programs.texi (C Indent): Fix documentation of 'TAB' in cc-mode. (Bug#58258) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index c3a70a5fc9..b2a08fa2cc 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -508,9 +508,9 @@ Reindent each line in the balanced expression that follows point about invalid syntax. @item @key{TAB} -@findex c-indent-command -Reindent the current line, and/or in some cases insert a tab character -(@code{c-indent-command}). +@findex c-indent-line-or-region +Reindent the current line, active region, or block starting on this +line (@code{c-indent-line-or-region}). @vindex c-tab-always-indent If @code{c-tab-always-indent} is @code{t}, this command always reindents commit 08e485a2a5e505a2fa6d8102ef4c3f72065188a9 Author: Stefan Kangas Date: Mon Oct 3 02:21:07 2022 +0200 Fix 'org-export-dispatch' command name in manual * doc/emacs/text.texi (Org Authoring): Fix 'org-export-dispatch' command name. (Bug#58260) diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index 8c09f62677..a8aa4a413d 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi @@ -1491,15 +1491,15 @@ etc. @subsection Org as an authoring system @cindex Org exporting -@findex org-export +@findex org-export-dispatch @kindex C-c C-e @r{(Org mode)} You may want to format your Org notes nicely and to prepare them for export and publication. To export the current buffer, type @kbd{C-c -C-e} (@code{org-export}) anywhere in an Org buffer. This command -prompts for an export format; currently supported formats include -HTML, @LaTeX{}, Texinfo, OpenDocument (@file{.odt}), iCalendar, -Markdown, man-page, and PDF@. Some formats, such as PDF, require -certain system tools to be installed. +C-e} (@code{org-export-dispatch}) anywhere in an Org buffer. This +command prompts for an export format; currently supported formats +include HTML, @LaTeX{}, Texinfo, OpenDocument (@file{.odt}), +iCalendar, Markdown, man-page, and PDF@. Some formats, such as PDF, +require certain system tools to be installed. @vindex org-publish-project-alist To export several files at once to a specific directory, either commit e5a49f44ffa66bcfa4b56b5fab088f7437b0ba9d Author: Andreas Schwab Date: Sun Oct 2 12:15:27 2022 +0200 * src/emacs.c (load_pdump): Fix use of xpalloc. diff --git a/src/emacs.c b/src/emacs.c index 602fa802e0..92779a8d0d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -867,9 +867,8 @@ load_pdump (int argc, char **argv) } /* Where's our executable? */ - ptrdiff_t bufsize, exec_bufsize; - emacs_executable = load_pdump_find_executable (argv[0], &bufsize); - exec_bufsize = bufsize; + ptrdiff_t exec_bufsize, needed; + emacs_executable = load_pdump_find_executable (argv[0], &exec_bufsize); /* If we couldn't find our executable, go straight to looking for the dump in the hardcoded location. */ @@ -902,8 +901,8 @@ load_pdump (int argc, char **argv) strip_suffix_length)) exenamelen = prefix_length; } - ptrdiff_t needed = exenamelen + strlen (suffix) + 1; - dump_file = xpalloc (NULL, &bufsize, max (1, needed - bufsize), -1, 1); + ptrdiff_t bufsize = exenamelen + strlen (suffix) + 1; + dump_file = xpalloc (NULL, &bufsize, 1, -1, 1); memcpy (dump_file, emacs_executable, exenamelen); strcpy (dump_file + exenamelen, suffix); result = pdumper_load (dump_file, emacs_executable); commit 7ff520762468b5de4684e4a3d8f0103c8f3bec64 Author: Eli Zaretskii Date: Sun Oct 2 12:58:04 2022 +0300 Avoid assertion violation in 'xpalloc' * src/emacs.c (load_pdump): Ensure the 3rd argument of xpalloc is always positive. (Bug#58232) diff --git a/src/emacs.c b/src/emacs.c index 0a90b0913b..602fa802e0 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -903,7 +903,7 @@ load_pdump (int argc, char **argv) exenamelen = prefix_length; } ptrdiff_t needed = exenamelen + strlen (suffix) + 1; - dump_file = xpalloc (NULL, &bufsize, needed - bufsize, -1, 1); + dump_file = xpalloc (NULL, &bufsize, max (1, needed - bufsize), -1, 1); memcpy (dump_file, emacs_executable, exenamelen); strcpy (dump_file + exenamelen, suffix); result = pdumper_load (dump_file, emacs_executable);