commit 3bc9c38c471983431bc6768dd6cfe9e059e44a3b (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Tue May 7 09:21:59 2024 +0800 Simplify Emacs server detection on Android * lib-src/emacsclient.c (set_local_socket) [HAVE_ANDROID]: Do not consider XDG_RUNTIME_DIR or test the ownership or accessibility of TMPDIR. diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index ea34d5f7b93..bee95e2bd5c 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1460,8 +1460,8 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen, this user's directory and does not let others write to it; this fends off some symlink attacks. To avoid races, keep the parent directory open while checking. */ - char *emacsdirend = sockname + tmpdirlen + suffixlen - - strlen(server_name) - 1; + char *emacsdirend = (sockname + tmpdirlen + suffixlen + - strlen(server_name) - 1); *emacsdirend = '\0'; int dir = open (sockname, O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC); *emacsdirend = '/'; @@ -1505,6 +1505,7 @@ set_local_socket (char const *server_name) } else { +#ifndef HAVE_ANDROID /* socket_name is a file name component. */ char const *xdg_runtime_dir = egetenv ("XDG_RUNTIME_DIR"); if (xdg_runtime_dir) @@ -1534,10 +1535,35 @@ set_local_socket (char const *server_name) if (tmpdirlen < 0) tmpdirlen = snprintf (sockname, socknamesize, "/tmp"); } + sock_status = local_sockname (s, sockname, tmpdirlen, uid, server_name); tmpdir_used = true; } +#else /* HAVE_ANDROID */ + char const *tmpdir; + int socknamelen; + uintmax_t uidmax; + + /* The TMPDIR of any process to which this binary is + accessible must be reserved for Emacs, so the checks in + local_sockname and the like are redundant. */ + tmpdir = egetenv ("TMPDIR"); + + /* Resort to the usual location of the cache directory, though + this location is not guaranteed to remain stable over + future releases of Android. */ + if (!tmpdir) + tmpdir = "/data/data/org.gnu.emacs/cache"; + + uidmax = uid; + socknamelen = snprintf (sockname, socknamesize, + "%s/emacs%"PRIuMAX"/%s", + tmpdir, uidmax, server_name); + sock_status = (0 <= socknamelen && socknamelen < socknamesize + ? connect_socket (AT_FDCWD, sockname, s, 0) + : ENAMETOOLONG); +#endif /* !HAVE_ANDROID */ } if (sock_status == 0) commit d4d9db8dc6ee20d3c0c1b2e647f40ebf2cc719f3 Author: Po Lu Date: Tue May 7 09:02:00 2024 +0800 Disable text-conversion in map-ynp * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Bind overriding-text-conversion-style to nil around read-event and arrange that the input method be reset. diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el index b603f2e6d0b..60e572fba30 100644 --- a/lisp/emacs-lisp/map-ynp.el +++ b/lisp/emacs-lisp/map-ynp.el @@ -35,6 +35,9 @@ ;;; Code: (declare-function x-popup-dialog "menu.c" (position contents &optional header)) +(declare-function set-text-conversion-style "textconv.c") + +(defvar overriding-text-conversion-style) (defun map-y-or-n-p (prompter actor list &optional help action-alist no-cursor-in-echo-area) @@ -168,7 +171,11 @@ The function's value is the number of actions taken." (key-description (vector help-char))) (if minibuffer-auto-raise (raise-frame (window-frame (minibuffer-window)))) - (setq char (read-event)) + (unwind-protect + (let ((overriding-text-conversion-style nil)) + (set-text-conversion-style text-conversion-style) + (setq char (read-event))) + (set-text-conversion-style text-conversion-style)) ;; Show the answer to the question. (message "%s(y, n, !, ., q, %sor %s) %s" prompt user-keys commit 6583916a058324f857d83af5a716d1142f94758f Author: Po Lu Date: Tue May 7 08:51:25 2024 +0800 Fix bug#66151 * src/fontset.c (free_realized_fontsets): Never call recompute_basic_faces on dead frames. (bug#66151) diff --git a/src/fontset.c b/src/fontset.c index d27fa22015e..dfa0d59d31d 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -1366,10 +1366,11 @@ free_realized_fontsets (Lisp_Object base) if (CHAR_TABLE_P (this) && EQ (FONTSET_BASE (this), base)) { Fclear_face_cache (Qt); - /* This is in case some Lisp calls this function and then - proceeds with calling some other function, like font-at, - which needs the basic faces. */ - recompute_basic_faces (XFRAME (FONTSET_FRAME (this))); + if (FRAME_LIVE_P (XFRAME (FONTSET_FRAME (this)))) + /* This is in case some Lisp calls this function and then + proceeds with calling some other function, like font-at, + which needs the basic faces. */ + recompute_basic_faces (XFRAME (FONTSET_FRAME (this))); break; } } commit 67e1b9d0553238ec6a5af68b41f43ba157f529e1 Author: Alan Mackenzie Date: Mon May 6 20:14:57 2024 +0000 `read': give fuller error message for errors following "#". This solves bug#70702. * src/lread.c (READ_AND_BUFFER, INVALID_SYNTAX_WITH_BUFFER): New macros. (read0): For errors in characters sequences beginning with "#", output the entire character sequence rather than just "#". * test/src/lread-tests.el (lread-test-bug70702): New test. diff --git a/src/lread.c b/src/lread.c index 7806c3972ee..d0067fb974b 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3969,6 +3969,27 @@ read_stack_reset (intmax_t sp) rdstack.sp = sp; } +#define READ_AND_BUFFER(c) \ + c = READCHAR; \ + if (multibyte) \ + p += CHAR_STRING (c, (unsigned char *) p); \ + else \ + *p++ = c; \ + if (end - p < MAX_MULTIBYTE_LENGTH + 1) \ + { \ + offset = p - read_buffer; \ + read_buffer = grow_read_buffer (read_buffer, offset, \ + &heapbuf, &read_buffer_size, count); \ + p = read_buffer + offset; \ + end = read_buffer + read_buffer_size; \ + } + +#define INVALID_SYNTAX_WITH_BUFFER() \ + { \ + *p = 0; \ + invalid_syntax (read_buffer, readcharfun); \ + } + /* Read a Lisp object. If LOCATE_SYMS is true, symbols are read with position. */ static Lisp_Object @@ -3977,6 +3998,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) char stackbuf[64]; char *read_buffer = stackbuf; ptrdiff_t read_buffer_size = sizeof stackbuf; + ptrdiff_t offset; char *heapbuf = NULL; specpdl_ref base_pdl = SPECPDL_INDEX (); @@ -4078,7 +4100,13 @@ read0 (Lisp_Object readcharfun, bool locate_syms) case '#': { - int ch = READCHAR; + char *p = read_buffer; + char *end = read_buffer + read_buffer_size; + + *p++ = '#'; + int ch; + READ_AND_BUFFER (ch); + switch (ch) { case '\'': @@ -4096,11 +4124,11 @@ read0 (Lisp_Object readcharfun, bool locate_syms) case 's': /* #s(...) -- a record or hash-table */ - ch = READCHAR; + READ_AND_BUFFER (ch); if (ch != '(') { UNREAD (ch); - invalid_syntax ("#s", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); } read_stack_push ((struct read_stack_entry) { .type = RE_record, @@ -4113,7 +4141,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) case '^': /* #^[...] -- char-table #^^[...] -- sub-char-table */ - ch = READCHAR; + READ_AND_BUFFER (ch); if (ch == '^') { ch = READCHAR; @@ -4130,7 +4158,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) else { UNREAD (ch); - invalid_syntax ("#^^", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); } } else if (ch == '[') @@ -4146,7 +4174,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) else { UNREAD (ch); - invalid_syntax ("#^", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); } case '(': @@ -4256,12 +4284,12 @@ read0 (Lisp_Object readcharfun, bool locate_syms) int c; for (;;) { - c = READCHAR; + READ_AND_BUFFER (c); if (c < '0' || c > '9') break; if (ckd_mul (&n, n, 10) || ckd_add (&n, n, c - '0')) - invalid_syntax ("#", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); } if (c == 'r' || c == 'R') { @@ -4302,18 +4330,18 @@ read0 (Lisp_Object readcharfun, bool locate_syms) = XHASH_TABLE (read_objects_map); ptrdiff_t i = hash_lookup (h, make_fixnum (n)); if (i < 0) - invalid_syntax ("#", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); obj = HASH_VALUE (h, i); break; } else - invalid_syntax ("#", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); } else - invalid_syntax ("#", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); } else - invalid_syntax ("#", readcharfun); + INVALID_SYNTAX_WITH_BUFFER (); } break; } diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 4d7f8b71838..cc17f7eb3fa 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el @@ -174,6 +174,17 @@ literals (Bug#20852)." (load "somelib" nil t) (should (string-suffix-p "/somelib.el" (caar load-history))))) +(ert-deftest lread-test-bug70702 () + "Test for certain wholesome error messages from `read'." + (setq eval-expression-debug-on-error nil) + (setq ert-debug-on-error nil) + (with-temp-buffer + (goto-char (point-min)) + (insert "#") + (goto-char (point-min)) + (should (equal (should-error (read (current-buffer))) + '(invalid-read-syntax "#<" 1 2))))) + (ert-deftest lread-lread--substitute-object-in-subtree () (let ((x (cons 0 1))) (setcar x x) commit f63615208adf2852b9384fe817e930588920a894 Author: Stefan Monnier Date: Mon May 6 14:33:43 2024 -0400 edebug.el: Fix `edebug-remove-instrumentation` (bug#70791) * lisp/emacs-lisp/edebug.el (edebug-unwrap*): Traverse interpreted functions. diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 3414bb592c0..381b7964a35 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -1313,6 +1313,12 @@ infinite loops when the code/environment contains a circular object.") (aref sexp 0) (aref sexp 1) (vconcat (mapcar #'edebug-unwrap* (aref sexp 2))) (nthcdr 3 (append sexp ())))) + ((interpreted-function-p sexp) + (make-interpreted-closure + (aref sexp 0) (mapcar #'edebug-unwrap* (aref sexp 1)) + (mapcar (lambda (x) (if (consp x) (cons (car x) (edebug-unwrap* (cdr x))) x)) + (aref sexp 2)) + (documentation sexp 'raw) (interactive-form sexp))) (t sexp))) commit 92147d2c9334d3df731562b039cfc26c3486c621 Author: Mattias EngdegÄrd Date: Mon May 6 16:09:08 2024 +0200 ; * lisp/kmacro.el (kmacro-add-counter): cut useless variable ref diff --git a/lisp/kmacro.el b/lisp/kmacro.el index a16f70105c1..07a13d5632c 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -342,7 +342,7 @@ information." (setq kmacro-last-counter kmacro-counter kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg)) last - kmacro-counter (+ kmacro-counter arg)))) + (+ kmacro-counter arg)))) (unless executing-kbd-macro (kmacro-display-counter))) commit 13d8b0eb63c568196cf692cde6a9153a00696a57 Author: Juri Linkov Date: Mon May 6 20:10:43 2024 +0300 * lisp/tab-bar.el (tab-bar-mouse-1): Avoid infinite recursion (bug#70086). diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 17698225682..dac57ce2070 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -352,6 +352,7 @@ regardless of where you click on it. Also add a new tab." (tab-number (tab-bar--key-to-number (nth 0 item)))) (cond ((and (memq (car item) '(add-tab history-back history-forward global)) + (not (eq (nth 1 item) 'tab-bar-mouse-1)) (functionp (nth 1 item))) (call-interactively (nth 1 item))) ((and (nth 2 item) (not (eq tab-number t))) commit 446031722546513ace2dc6f3ee86999bb7e17b39 Author: Juri Linkov Date: Mon May 6 20:00:23 2024 +0300 * lisp/emacs-lisp/warnings.el (display-warning): Add guardrails for window. Check for non-nil 'window' returned from 'display-buffer' for the case when users decide to use 'allow-no-window' in 'display-buffer-alist' (#70795). diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el index 8c1e43934ff..68db33bfa68 100644 --- a/lisp/emacs-lisp/warnings.el +++ b/lisp/emacs-lisp/warnings.el @@ -377,10 +377,10 @@ entirely by setting `warning-suppress-types' or (window-height . (lambda (window) (fit-window-to-buffer window 10))) (category . warning)))))) - (when (and (markerp warning-series) + (when (and window (markerp warning-series) (eq (marker-buffer warning-series) buffer)) (set-window-start window warning-series)) - (when warning-display-at-bottom + (when (and window warning-display-at-bottom) (with-selected-window window (goto-char (point-max)) (forward-line -1) commit 6e835dfaca2655a9ba1cfac2d3d3e236fd59674f Author: Juri Linkov Date: Mon May 6 19:48:04 2024 +0300 * lisp/tab-bar.el (tab-bar-select-restore-windows): Use 'special-mode'. diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 26023f24389..17698225682 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1451,7 +1451,6 @@ if it was visiting a file." (new-buffer (generate-new-buffer (format " *Old buffer %s*" name)))) (with-current-buffer new-buffer - (set-auto-mode) (insert (format-message "This window displayed the %s `%s'.\n" (if file "file" "buffer") name)) @@ -1464,7 +1463,7 @@ if it was visiting a file." (set-window-point window (nth 3 quad)))) (insert "\n")) (goto-char (point-min)) - (setq buffer-read-only t) + (special-mode) (set-window-buffer window new-buffer)))))) (defcustom tab-bar-select-restore-context t commit 9ecd65a6607aaaaf4ef74f52e252ab1c64dcbdff Author: Juri Linkov Date: Mon May 6 19:43:50 2024 +0300 * lisp/tab-bar.el: Support mouse clicks for multi-item 'global-mode-string'. (tab-bar-format-global): Split elements of 'global-mode-string' to separate items of the tab bar, so events for each item are handled separately (bug#70086). diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 2e3d9a6b4ac..26023f24389 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1119,7 +1119,9 @@ When `tab-bar-format-global' is added to `tab-bar-format' then modes that display information on the mode line using `global-mode-string' will display the same text on the tab bar instead." - `((global menu-item ,(format-mode-line global-mode-string) ignore))) + (mapcar (lambda (string) + `(global menu-item ,(format-mode-line string) ignore)) + global-mode-string)) (defun tab-bar-format-list (format-list) (let ((i 0)) commit 5522cc7879a17cab28383c4b1cce611c78c28995 Author: Stefan Monnier Date: Mon May 6 11:19:11 2024 -0400 (Fkey_description): Fix corner (bug#59305) * src/keymap.c (Fkey_description): Don't mistake latin-1 chars for ASCII-chars-with-meta. diff --git a/src/keymap.c b/src/keymap.c index 10378767c65..b9d8d18931d 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -2125,7 +2125,7 @@ For an approximate inverse of this, see `kbd'. */) if (STRINGP (list)) { int c = fetch_string_char_advance (list, &i, &i_byte); - if (SINGLE_BYTE_CHAR_P (c) && (c & 0200)) + if (!STRING_MULTIBYTE (list) && (c & 0200)) c ^= 0200 | meta_modifier; key = make_fixnum (c); } commit c5b4bd69faf9e9af9d95f7c995fffb80a7fc47c9 Author: Po Lu Date: Mon May 6 20:55:49 2024 +0800 Expressly disable large file APIs on Android 4.4 and earlier * configure.ac (CFLAGS): Add -D_FILE_OFFSET_BITS=32 on SDK 20 and earlier that unserviceable functions may not be selected. Problem reported by Ruth Elburn . diff --git a/configure.ac b/configure.ac index d3effc0f4f3..69a8ba0a9f8 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,13 @@ if test "$XCONFIGURE" = "android"; then CFLAGS="$ANDROID_CFLAGS -Werror=implicit-function-declaration" # Don't explicitly enable support for large files unless Emacs is # being built for API 21 or later. Otherwise, mmap does not work. + # + # Moreover, 64-bit variants of file IO functions in the C library are + # liable to fail with ENOSYS or EINVAL on earlier API versions, and as + # such their definitions must be explicitly disabled on NDK releases + # that enable them by default. AS_IF([test "$ANDROID_SDK" -lt "21"], [ + CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=32" enable_largefile=no enable_year2038=no]) fi commit e091967ce2d0b14cfe5444858d065b1f203121fa Author: Eli Zaretskii Date: Mon May 6 15:02:37 2024 +0300 Revert "Disable text conversion in map-ynp" This reverts commit f50a58123a3d386b9bba7c4ba14df62479887bd4. Please don't make such changes without discussing them. diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el index d769b7ace64..b603f2e6d0b 100644 --- a/lisp/emacs-lisp/map-ynp.el +++ b/lisp/emacs-lisp/map-ynp.el @@ -168,7 +168,7 @@ The function's value is the number of actions taken." (key-description (vector help-char))) (if minibuffer-auto-raise (raise-frame (window-frame (minibuffer-window)))) - (setq char (read-key)) + (setq char (read-event)) ;; Show the answer to the question. (message "%s(y, n, !, ., q, %sor %s) %s" prompt user-keys commit 74ebd729c7b8a4b957ab9eebc603c69d6aac00be Author: Eli Zaretskii Date: Mon May 6 13:54:19 2024 +0300 ; Avoid byte-compiler warning in comp.el * lisp/emacs-lisp/comp.el (comp--symbol-func-to-fun): Move to before its first use. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index e69de84362e..fa866b802cc 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -189,6 +189,11 @@ Useful to hook into pass checkers.") finally return h) "Hash table function -> `comp-constraint'.") +(defsubst comp--symbol-func-to-fun (symbol-func) + "Given a function called SYMBOL-FUNC return its `comp-func'." + (gethash (gethash symbol-func (comp-ctxt-sym-to-c-name-h comp-ctxt)) + (comp-ctxt-funcs-h comp-ctxt))) + (defun comp--get-function-cstr (function) "Given FUNCTION return the corresponding `comp-constraint'." (when (symbolp function) @@ -603,11 +608,6 @@ In use by the back-end." finally return t) t)) -(defsubst comp--symbol-func-to-fun (symbol-func) - "Given a function called SYMBOL-FUNC return its `comp-func'." - (gethash (gethash symbol-func (comp-ctxt-sym-to-c-name-h comp-ctxt)) - (comp-ctxt-funcs-h comp-ctxt))) - (defun comp--function-pure-p (f) "Return t if F is pure." (or (get f 'pure) commit 5bf4ff806b8ad12fa8a0ab7a8c8032d46b363b6c Author: Po Lu Date: Mon May 6 17:23:57 2024 +0800 ; * java/org/gnu/emacs/EmacsTileObject.java: Fix copyright dates. diff --git a/java/org/gnu/emacs/EmacsTileObject.java b/java/org/gnu/emacs/EmacsTileObject.java index 34a35e83bfb..2caa28cbcd6 100644 --- a/java/org/gnu/emacs/EmacsTileObject.java +++ b/java/org/gnu/emacs/EmacsTileObject.java @@ -1,6 +1,6 @@ /* Communication module for Android terminals. -*- c-file-style: "GNU" -*- -Copyright (C) 2023-2024 Free Software Foundation, Inc. +Copyright (C) 2024 Free Software Foundation, Inc. This file is part of GNU Emacs. commit f50a58123a3d386b9bba7c4ba14df62479887bd4 Author: Po Lu Date: Mon May 6 15:53:49 2024 +0800 Disable text conversion in map-ynp * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Read response with read-key, not read-char. diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el index b603f2e6d0b..d769b7ace64 100644 --- a/lisp/emacs-lisp/map-ynp.el +++ b/lisp/emacs-lisp/map-ynp.el @@ -168,7 +168,7 @@ The function's value is the number of actions taken." (key-description (vector help-char))) (if minibuffer-auto-raise (raise-frame (window-frame (minibuffer-window)))) - (setq char (read-event)) + (setq char (read-key)) ;; Show the answer to the question. (message "%s(y, n, !, ., q, %sor %s) %s" prompt user-keys