diff --git a/configure.ac b/configure.ac index 94f0bf36fb5..a4daf1414d3 100644 --- a/configure.ac +++ b/configure.ac @@ -4192,6 +4192,21 @@ if test "$ac_cv_func_pthread_setname_np" = "yes"; then AC_DEFINE( HAVE_PTHREAD_SETNAME_NP_1ARG, 1, [Define to 1 if pthread_setname_np takes a single argument.]) + else + AC_CACHE_CHECK( + [whether pthread_setname_np takes three arguments], + [emacs_cv_pthread_setname_np_3arg], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[pthread_setname_np (0, "%s", "a");]])], + [emacs_cv_pthread_setname_np_3arg=yes], + [emacs_cv_pthread_setname_np_3arg=no])]) + if test "$emacs_cv_pthread_setname_np_3arg" = "yes"; then + AC_DEFINE( + HAVE_PTHREAD_SETNAME_NP_3ARG, 1, + [Define to 1 if pthread_setname_np takes three arguments.]) + fi fi fi diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 6b95b12a846..d097f4ee7d8 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -2939,9 +2939,8 @@ done by calling @code{browse-url} as a subroutine It can be useful to add @code{goto-address-mode} to mode hooks and hooks for displaying an incoming message -(e.g., @code{rmail-show-message-hook} for Rmail, and -@code{mh-show-mode-hook} for MH-E). This is not needed for Gnus, -which has a similar feature of its own. +(e.g., @code{rmail-show-message-hook} for Rmail). This is not needed +for Gnus or MH-E, which have similar features of their own. @node FFAP @subsection Finding Files and URLs at Point diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index 5ef21d06710..27fa5385e35 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi @@ -777,6 +777,9 @@ non-@code{nil}, it is added at the end. The argument @var{symbol} is not implicitly quoted; @code{add-to-list} is an ordinary function, like @code{set} and unlike @code{setq}. Quote the argument yourself if that is what you want. + +Do not use this function when @var{symbol} refers to a lexical +variable. @end defun Here's a scenario showing how to use @code{add-to-list}: @@ -799,8 +802,9 @@ foo ;; @r{@code{foo} was changed.} @var{value})} is this: @example -(or (member @var{value} @var{var}) - (setq @var{var} (cons @var{value} @var{var}))) +(if (member @var{value} @var{var}) + @var{var} + (setq @var{var} (cons @var{value} @var{var}))) @end example @defun add-to-ordered-list symbol element &optional order @@ -828,6 +832,7 @@ and unlike @code{setq}. Quote the argument yourself if necessary. The ordering information is stored in a hash table on @var{symbol}'s @code{list-order} property. +@var{symbol} cannot refer to a lexical variable. @end defun Here's a scenario showing how to use @code{add-to-ordered-list}: diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 0f60b3fd00d..ac38b9d390d 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -572,6 +572,7 @@ and returns the updated history list. It limits the list length to the value of @var{maxelt} (if non-@code{nil}) or @code{history-length} (described below). The possible values of @var{maxelt} have the same meaning as the values of @code{history-length}. +@var{history-var} cannot refer to a lexical variable. Normally, @code{add-to-history} removes duplicate members from the history list if @code{history-delete-duplicates} is non-@code{nil}. diff --git a/doc/misc/mh-e.texi b/doc/misc/mh-e.texi index 0630b60ca6f..962f22af5d2 100644 --- a/doc/misc/mh-e.texi +++ b/doc/misc/mh-e.texi @@ -2256,10 +2256,10 @@ signature block is more to your liking. Two hooks can be used to control how messages are displayed. The first hook, @code{mh-show-mode-hook}, is called early on in the process of the message display. It is usually used to perform some action on the -message's content. The second hook, @code{mh-show-hook}, is the last +message's buffer. The second hook, @code{mh-show-hook}, is the last thing called after messages are displayed. It's used to affect the -behavior of MH-E in general or when @code{mh-show-mode-hook} is too -early. +message's content, the behavior of MH-E in general, or when +@code{mh-show-mode-hook} is too early. @cindex MH-Show mode @cindex modes, MH-Show diff --git a/etc/NEWS.27 b/etc/NEWS.27 index 433f1f76b80..54a71c9e494 100644 --- a/etc/NEWS.27 +++ b/etc/NEWS.27 @@ -2630,6 +2630,14 @@ will be chosen even if you have an entry for "image/*" in your overrides all system and Emacs-provided defaults. To get the old method back, set 'mailcap-prefer-mailcap-viewers' to nil. +** MH-E ++++ +*** The hook 'mh-show-mode-hook' is now called before the message is inserted. +Functions that want to affect the message text (for example, to change +highlighting) can no longer use 'mh-show-mode-hook', because the +message contents will not yet have been inserted when the hook is +called. Such functions should now be attached to 'mh-show-hook'. + ** URL --- diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el index 9bc3aad2785..25961d41089 100644 --- a/lisp/autoinsert.el +++ b/lisp/autoinsert.el @@ -171,7 +171,7 @@ If this contains a %s, that will be replaced by the matching rule." (mapatoms (lambda (mode) (let ((name (symbol-name mode))) (when (string-match "-mode$" name) - (add-to-list 'modes name))))) + (push name modes))))) (sort modes 'string<))) (completing-read "Local variables for mode: " v1 nil t) " . ((" diff --git a/lisp/cedet/mode-local.el b/lisp/cedet/mode-local.el index a6e143cfcd6..a1aea30c20d 100644 --- a/lisp/cedet/mode-local.el +++ b/lisp/cedet/mode-local.el @@ -819,14 +819,12 @@ META-NAME is a cons (OVERLOADABLE-SYMBOL . MAJOR-MODE)." ) ;; Order symbols by type (mapatoms - #'(lambda (s) - (add-to-list (cond - ((get s 'mode-variable-flag) - (if (get s 'constant-flag) 'mc 'mv)) - ((get s 'override-flag) - (if (get s 'constant-flag) 'fo 'ov)) - ('us)) - s)) + (lambda (s) (push s (cond + ((get s 'mode-variable-flag) + (if (get s 'constant-flag) mc mv)) + ((get s 'override-flag) + (if (get s 'constant-flag) fo ov)) + (t us)))) table) ;; Print symbols by type (when us diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index a6be04e313d..828ac633dc5 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -497,7 +497,9 @@ If MODE is not set, try to find mode automatically." (let ((auto-mode-alist (delq (rassq 'doc-view-mode-maybe auto-mode-alist) (copy-sequence auto-mode-alist)))) - (set-auto-mode) + ;; Don't run hooks that might assume buffer-file-name + ;; really associates buffer with a file (bug#39190). + (delay-mode-hooks (set-auto-mode)) (setq mode major-mode))) ;; Do not fontify if the guess mode is fundamental. (unless (eq major-mode 'fundamental-mode) diff --git a/lisp/ido.el b/lisp/ido.el index 355be5eaa66..6707d814077 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -4732,6 +4732,9 @@ For details of keybindings, see `ido-find-file'." (delete-overlay ido--overlay)) (let ((o (make-overlay (point-max) (point-max) nil t t))) (when (> (length inf) 0) + ;; For hacks that redefine ido-completions function (bug#39379) + (when (eq (aref inf 0) ?\n) + (setq inf (concat " " inf))) (put-text-property 0 1 'cursor t inf)) (overlay-put o 'after-string inf) (setq ido--overlay o))) diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el index 5c85b3907e6..dd05d691c91 100644 --- a/lisp/mh-e/mh-e.el +++ b/lisp/mh-e/mh-e.el @@ -3380,13 +3380,14 @@ used to affect the behavior of MH-E in general or when (defcustom-mh mh-show-mode-hook nil "Hook run upon entry to `mh-show-mode'. -This hook is called early on in the process of the message -display. It is usually used to perform some action on the -message's content. See `mh-show-hook'." +This hook is called early on in the process of the message display, +before the message contents have been inserted into the buffer. +It is usually used to perform some action on the +buffer itself. See also `mh-show-hook'." :type 'hook :group 'mh-hooks :group 'mh-show - :package-version '(MH-E . "6.0")) + :package-version '(MH-E . "8.7")) (defcustom-mh mh-unseen-updated-hook nil "Hook run after the unseen sequence has been updated. diff --git a/lisp/mh-e/mh-show.el b/lisp/mh-e/mh-show.el index 952579fd3dd..3c07d426b7d 100644 --- a/lisp/mh-e/mh-show.el +++ b/lisp/mh-e/mh-show.el @@ -63,7 +63,7 @@ you wish to see all of them, use the command \\[mh-header-display]. Two hooks can be used to control how messages are displayed. The first hook, `mh-show-mode-hook', is called early on in the process of the message display. It is usually used to perform -some action on the message's content. The second hook, +some action on the message's buffer. The second hook, `mh-show-hook', is the last thing called after messages are displayed. It's used to affect the behavior of MH-E in general or when `mh-show-mode-hook' is too early. @@ -234,6 +234,9 @@ Sets the current buffer to the show buffer." (mh-add-missing-mime-version-header) (setf (mh-buffer-data) (mh-make-buffer-data)) (mh-mime-display)) + (mh-show-unquote-From) + (mh-show-xface) + (mh-show-addr) ;; Header cleanup (goto-char (point-min)) (cond (clean-message-header @@ -840,9 +843,6 @@ See also `mh-folder-mode'. (mh-tool-bar-init :show)) (set (make-local-variable 'mail-header-separator) mh-mail-header-separator) (setq paragraph-start (default-value 'paragraph-start)) - (mh-show-unquote-From) - (mh-show-xface) - (mh-show-addr) (setq buffer-invisibility-spec '((vanish . t) t)) (set (make-local-variable 'line-move-ignore-invisible) t) (make-local-variable 'font-lock-defaults) diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index 7dd778dc8d5..9436f45aa32 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -5,7 +5,7 @@ ;; Author: Eric Ding ;; Maintainer: emacs-devel@gnu.org ;; Created: 15 Aug 1995 -;; Keywords: mh-e, www, mouse, mail +;; Keywords: www, mouse, mail ;; This file is part of GNU Emacs. @@ -32,10 +32,10 @@ ;; INSTALLATION ;; -;; To use goto-address in a particular mode (for example, while -;; reading mail in mh-e), add this to your init file: +;; To use goto-address in a particular mode (this example uses +;; the fictional rich-text-mode), add this to your init file: ;; -;; (add-hook 'mh-show-mode-hook 'goto-address) +;; (add-hook 'rich-text-mode-hook 'goto-address) ;; ;; The mouse click method is bound to [mouse-2] on highlighted URLs or ;; e-mail addresses only; it functions normally everywhere else. To bind diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index 92c98486f46..1998042d699 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -368,7 +368,7 @@ used to cache connection properties of the local machine." (let ((hash (gethash key tramp-cache-data)) properties) (when (hash-table-p hash) - (maphash (lambda (x _y) (add-to-list 'properties x 'append)) hash)) + (maphash (lambda (x _y) (push x properties)) hash)) properties)) (setq tramp-cache-data-changed t) (remhash key tramp-cache-data)) @@ -417,7 +417,7 @@ used to cache connection properties of the local machine." (when (and (tramp-file-name-p key) (null (tramp-file-name-localname key)) (tramp-connection-property-p key "process-buffer")) - (add-to-list 'result key))) + (push key result))) tramp-cache-data) result)) diff --git a/lisp/net/zeroconf.el b/lisp/net/zeroconf.el index b8becd712f5..cb3c0f2a7ee 100644 --- a/lisp/net/zeroconf.el +++ b/lisp/net/zeroconf.el @@ -256,17 +256,17 @@ supported keys depend on the service type.") "Return all discovered Avahi service names as list." (let (result) (maphash - (lambda (_key value) (add-to-list 'result (zeroconf-service-name value))) + (lambda (_key value) (push (zeroconf-service-name value) result)) zeroconf-services-hash) - result)) + (delete-dups result))) (defun zeroconf-list-service-types () "Return all discovered Avahi service types as list." (let (result) (maphash - (lambda (_key value) (add-to-list 'result (zeroconf-service-type value))) + (lambda (_key value) (push (zeroconf-service-type value) result)) zeroconf-services-hash) - result)) + (delete-dups result))) (defun zeroconf-list-services (type) "Return all discovered Avahi services for a given service type TYPE. @@ -278,9 +278,9 @@ format of SERVICE." (maphash (lambda (_key value) (when (equal type (zeroconf-service-type value)) - (add-to-list 'result value))) + (push value result))) zeroconf-services-hash) - result)) + (delete-dups result))) (defvar zeroconf-service-added-hooks-hash (make-hash-table :test 'equal) "Hash table of hooks for newly added services. diff --git a/lisp/org/org.el b/lisp/org/org.el index 1581625a8e5..e8e1ef99f26 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -18682,13 +18682,14 @@ With prefix arg UNCOMPILED, load the uncompiled versions." (and (string= org-dir contrib-dir) (org-load-noerror-mustsuffix (concat contrib-dir f))) (and (org-load-noerror-mustsuffix (concat (org-find-library-dir f) f)) - (add-to-list 'load-uncore f 'append) + (push f load-uncore) 't) f)) lfeat))) (when load-uncore (message "The following feature%s found in load-path, please check if that's correct:\n%s" - (if (> (length load-uncore) 1) "s were" " was") load-uncore)) + (if (> (length load-uncore) 1) "s were" " was") + (reverse load-uncore))) (if load-misses (message "Some error occurred while reloading Org feature%s\n%s\nPlease check *Messages*!\n%s" (if (> (length load-misses) 1) "s" "") load-misses (org-version nil 'full)) diff --git a/lisp/subr.el b/lisp/subr.el index 0e09228f6f6..b5ec0de156a 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1845,6 +1845,7 @@ COMPARE-FN if that's non-nil. If ELEMENT is added, it is added at the beginning of the list, unless the optional argument APPEND is non-nil, in which case ELEMENT is added at the end. +LIST-VAR should not refer to a lexical variable. The return value is the new value of LIST-VAR. @@ -1934,6 +1935,7 @@ of ELEMENT if it has one. The list order for each element is stored in LIST-VAR's `list-order' property. +LIST-VAR cannot refer to a lexical variable. The return value is the new value of LIST-VAR." (let ((ordering (get list-var 'list-order))) @@ -1962,7 +1964,8 @@ variable. The possible values of maximum length have the same meaning as the values of `history-length'. Remove duplicates of NEWELT if `history-delete-duplicates' is non-nil. If optional fourth arg KEEP-ALL is non-nil, add NEWELT to history even -if it is empty or duplicates the most recent entry in the history." +if it is empty or duplicates the most recent entry in the history. +HISTORY-VAR cannot refer to a lexical variable." (unless maxelt (setq maxelt (or (get history-var 'history-length) history-length))) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index ebb0c566ad1..fac27f41ba9 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -51,11 +51,11 @@ :version "27.1") (defface tab-bar - '((((type x w32 ns) (class color)) + '((((class color) (min-colors 88)) :inherit variable-pitch :background "grey85" :foreground "black") - (((type x) (class mono)) + (((class mono)) :background "grey") (t :inverse-video t)) diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 149fe8289c4..8f1221abe41 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -42,12 +42,12 @@ :version "27.1") (defface tab-line - '((((type x w32 ns) (class color)) + '((((class color) (min-colors 88)) :inherit variable-pitch :height 0.9 :background "grey85" :foreground "black") - (((type x) (class mono)) + (((class mono)) :background "grey") (t :inverse-video t)) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 2dbab802086..d61c363c821 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2719,7 +2719,9 @@ hunk text is not found in the source file." (cl-assert (null buffer-file-name)) (let ((enable-local-variables :safe) ;; to find `mode:' (buffer-file-name file)) - (set-auto-mode) + ;; Don't run hooks that might assume buffer-file-name + ;; really associates buffer with a file (bug#39190). + (delay-mode-hooks (set-auto-mode)) ;; FIXME: Is this really worth the trouble? (when (and (fboundp 'generic-mode-find-file-hook) (memq #'generic-mode-find-file-hook diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index f64b6c06310..ec252b74d47 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2098,7 +2098,9 @@ Unlike `vc-find-revision-save', doesn't save the buffer to the file." ;; For non-interactive, skip any questions (let ((enable-local-variables :safe) ;; to find `mode:' (buffer-file-name file)) - (ignore-errors (set-auto-mode))) + ;; Don't run hooks that might assume buffer-file-name + ;; really associates buffer with a file (bug#39190). + (ignore-errors (delay-mode-hooks (set-auto-mode)))) (normal-mode)) (set-buffer-modified-p nil) (setq buffer-read-only t)) diff --git a/lisp/whitespace.el b/lisp/whitespace.el index fde73295233..0137ddcf04f 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -1684,7 +1684,7 @@ cleaning up these problems." (mapcar #'(lambda (option) (when force - (add-to-list 'style (car option))) + (push (car option) style)) (goto-char rstart) (let ((regexp (cond diff --git a/src/systhread.c b/src/systhread.c index c649ae853a3..0d600d6895e 100644 --- a/src/systhread.c +++ b/src/systhread.c @@ -214,11 +214,13 @@ sys_thread_set_name (const char *name) char p_name[TASK_COMM_LEN]; strncpy (p_name, name, TASK_COMM_LEN - 1); p_name[TASK_COMM_LEN - 1] = '\0'; - #ifdef HAVE_PTHREAD_SETNAME_NP_1ARG +# ifdef HAVE_PTHREAD_SETNAME_NP_1ARG pthread_setname_np (p_name); - #else +# elif defined HAVE_PTHREAD_SETNAME_NP_3ARG + pthread_setname_np (pthread_self (), "%s", p_name); +# else pthread_setname_np (pthread_self (), p_name); - #endif +# endif #endif } diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el index 3ffef177711..1888baf6017 100644 --- a/test/lisp/emacs-lisp/map-tests.el +++ b/test/lisp/emacs-lisp/map-tests.el @@ -227,7 +227,7 @@ Evaluate BODY for each created map. (with-maps-do map (let ((result nil)) (map-do (lambda (k v) - (add-to-list 'result (list (int-to-string k) v))) + (push (list (int-to-string k) v) result)) map) (should (equal result '(("2" 5) ("1" 4) ("0" 3)))))))