commit 5056b8e589753698ce7ee935980ca03de0e41bf5 (HEAD, refs/remotes/origin/master) Merge: da4f1fa550f 7e1012765c4 Author: Stefan Kangas Date: Thu Mar 9 06:30:23 2023 +0100 Merge from origin/emacs-29 7e1012765c4 Fix libwebp check for some webp installations c2ca009da4c Avoid potential infloop 34c14430e9d Don't misindent 'else:' after 'if re.match:' in Python 8a2a554192a * Make sure `default-directory' exists before spawning pr... 1862e7eb7ef Fix sed expression in install-etc make target c8ec0017cb9 Avoid using bash in the emacsclient desktop file a588937094f Fix documentation of the 'line-height' text property 971ded31c4f Add 'declare' specs to with- and without-restriction commit 7e1012765c40a10a8a051c39566778913dc7e224 (refs/remotes/origin/emacs-29) Author: Po Lu Date: Thu Mar 9 08:52:54 2023 +0800 Fix libwebp check for some webp installations * configure.ac: Look for WebPGetInfo; if it is not there, look for libwebpdecoder as well. (bug#61988) diff --git a/configure.ac b/configure.ac index bc7e61048c3..ac93d003b70 100644 --- a/configure.ac +++ b/configure.ac @@ -2806,6 +2806,25 @@ AC_DEFUN WEBP_MODULE="libwebpdemux >= $WEBP_REQUIRED" EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE]) + + # WebPGetInfo is sometimes not present inside libwebpdemux, so + # if it does not link, also check for libwebpdecoder. + + OLD_CFLAGS=$CFLAGS + OLD_LIBS=$LIBS + CFLAGS="$CFLAGS $WEBP_CFLAGS" + LIBS="$LIBS $WEBP_LIBS" + + AC_CHECK_FUNC([WebPGetInfo], [], + [WEBP_MODULE="$WEBP_MODULE libwebpdecoder >= $WEBP_REQUIRED" + HAVE_WEBP=no + AS_UNSET([WEBP_LIBS]) + AS_UNSET([WEBP_CFLAGS]) + EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE])]) + + CFLAGS=$OLD_CFLAGS + LIBS=$OLD_LIBS + AC_SUBST([WEBP_CFLAGS]) AC_SUBST([WEBP_LIBS]) fi commit da4f1fa550f753e76c611b313d4f00987daed5ad Author: Sean Whitton Date: Sat Mar 4 14:53:01 2023 -0700 server-eval-at: Signal more specific condition on unreadable result * lisp/server.el (server-return-invalid-read-syntax): New error signal. (server-eval-at): Re-signal invalid-read-syntax as server-return-invalid-read-syntax (bug#61658). diff --git a/lisp/server.el b/lisp/server.el index 35b38ef8fa6..89aedc72d52 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1929,12 +1929,22 @@ server-unload-function ;; continue standard unloading nil) +(define-error 'server-return-invalid-read-syntax + "Emacs server returned unreadable result of evaluation" + 'invalid-read-syntax) + (defun server-eval-at (server form) "Contact the Emacs server named SERVER and evaluate FORM there. -Returns the result of the evaluation, or signals an error if it -cannot contact the specified server. For example: +Returns the result of the evaluation. For example: (server-eval-at \"server\" \\='(emacs-pid)) -returns the process ID of the Emacs instance running \"server\"." +returns the process ID of the Emacs instance running \"server\". + +This function signals `error' if it could not contact the server. + +This function signals `server-return-invalid-read-syntax' if it +couldn't read the result of evaluation printed by the server. +This will occur whenever the result of evaluating FORM is something +not readably printable." (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir)) (server-file (expand-file-name server server-dir)) (coding-system-for-read 'binary) @@ -1980,8 +1990,14 @@ server-eval-at (progn (skip-chars-forward "^\n") (point)))))) (if (not (equal answer "")) - (read (decode-coding-string (server-unquote-arg answer) - 'emacs-internal))))))) + (condition-case err + (read + (decode-coding-string (server-unquote-arg answer) + 'emacs-internal)) + ;; Re-signal with a more specific condition. + (invalid-read-syntax + (signal 'server-return-invalid-read-syntax + (cdr err))))))))) (provide 'server) commit c2ca009da4cc2c81be364a1ddac15e8c7585ddf6 Author: Dmitry Gutov Date: Thu Mar 9 00:43:31 2023 +0200 Avoid potential infloop * lisp/progmodes/python.el (python-info-dedenter-opening-block-positions): Avoid potential infloop (bug#62031). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 81475f31f60..630250c15c3 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -5792,9 +5792,9 @@ python-info-dedenter-opening-block-positions (catch 'exit (while (python-nav--syntactically (lambda () - (cl-loop for pt = (re-search-backward (python-rx block-start) nil t) - until (memq (char-before) '(nil ?\s ?\t ?\n)) - finally return pt)) + (cl-loop while (re-search-backward (python-rx block-start) nil t) + if (memq (char-before) '(nil ?\s ?\t ?\n)) + return t)) #'<) (let ((indentation (current-indentation))) (when (and (not (memq indentation collected-indentations)) commit 38427494d5b86d803f941b77134886ba5eec20dd Author: Jim Porter Date: Thu Feb 9 23:27:50 2023 -0800 Fix Pcompletion of "tar" when using unrecognized arguments Previously, arguments to tar like "--warning=no-timestamp" would cause Pcompletion to hang (bug#58921). This simplifies the logic flow by moving all the cases for "--" arguments inside the THEN form of '(if (pcomplete-match "^--" 0)', and for all "-" arguments inside the ELSE form. * lisp/pcmpl-gnu.el (pcmpl-gnu--tar-long-options): New variable. (pcomplete/tar): Properly handle completion of arguments that look like "--ARG=", even if they're not recognized by this function. diff --git a/lisp/pcmpl-gnu.el b/lisp/pcmpl-gnu.el index 7d270ea789f..1553c3efed7 100644 --- a/lisp/pcmpl-gnu.el +++ b/lisp/pcmpl-gnu.el @@ -184,6 +184,86 @@ pcmpl-gnu-with-file-buffer (when (and (not ,exist) (buffer-live-p ,buf)) (kill-buffer ,buf)))))) +(defvar pcmpl-gnu--tar-long-options + ;; FIXME: Extract this list from "tar --help". + '("--absolute-names" + "--after-date=" + "--append" + "--atime-preserve" + "--backup" + "--block-number" + "--blocking-factor=" + "--catenate" + "--checkpoint" + "--compare" + "--compress" + "--concatenate" + "--confirmation" + "--create" + "--delete" + "--dereference" + "--diff" + "--directory=" + "--exclude=" + "--exclude-from=" + "--extract" + "--file=" + "--files-from=" + "--force-local" + "--get" + "--group=" + "--gzip" + "--help" + "--ignore-failed-read" + "--ignore-zeros" + "--incremental" + "--info-script=" + "--interactive" + "--keep-old-files" + "--label=" + "--list" + "--listed-incremental" + "--mode=" + "--modification-time" + "--multi-volume" + "--new-volume-script=" + "--newer=" + "--newer-mtime" + "--no-recursion" + "--null" + "--numeric-owner" + "--old-archive" + "--one-file-system" + "--owner=" + "--portability" + "--posix" + "--preserve" + "--preserve-order" + "--preserve-permissions" + "--read-full-records" + "--record-size=" + "--recursive-unlink" + "--remove-files" + "--rsh-command=" + "--same-order" + "--same-owner" + "--same-permissions" + "--sparse" + "--starting-file=" + "--suffix=" + "--tape-length=" + "--to-stdout" + "--totals" + "--uncompress" + "--ungzip" + "--unlink-first" + "--update" + "--use-compress-program=" + "--verbose" + "--verify" + "--version" + "--volno-file=")) + ;;;###autoload (defun pcomplete/tar () "Completion for the GNU tar utility." @@ -192,148 +272,53 @@ pcomplete/tar (while (pcomplete-match "^-" 0) (setq saw-option t) (if (pcomplete-match "^--" 0) - (if (pcomplete-match "^--\\([^= \t\n\f]*\\)\\'" 0) - ;; FIXME: Extract this list from "tar --help". - (pcomplete-here* - '("--absolute-names" - "--after-date=" - "--append" - "--atime-preserve" - "--backup" - "--block-number" - "--blocking-factor=" - "--catenate" - "--checkpoint" - "--compare" - "--compress" - "--concatenate" - "--confirmation" - "--create" - "--delete" - "--dereference" - "--diff" - "--directory=" - "--exclude=" - "--exclude-from=" - "--extract" - "--file=" - "--files-from=" - "--force-local" - "--get" - "--group=" - "--gzip" - "--help" - "--ignore-failed-read" - "--ignore-zeros" - "--incremental" - "--info-script=" - "--interactive" - "--keep-old-files" - "--label=" - "--list" - "--listed-incremental" - "--mode=" - "--modification-time" - "--multi-volume" - "--new-volume-script=" - "--newer=" - "--newer-mtime" - "--no-recursion" - "--null" - "--numeric-owner" - "--old-archive" - "--one-file-system" - "--owner=" - "--portability" - "--posix" - "--preserve" - "--preserve-order" - "--preserve-permissions" - "--read-full-records" - "--record-size=" - "--recursive-unlink" - "--remove-files" - "--rsh-command=" - "--same-order" - "--same-owner" - "--same-permissions" - "--sparse" - "--starting-file=" - "--suffix=" - "--tape-length=" - "--to-stdout" - "--totals" - "--uncompress" - "--ungzip" - "--unlink-first" - "--update" - "--use-compress-program=" - "--verbose" - "--verify" - "--version" - "--volno-file="))) - (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")) - (cond - ((pcomplete-match "\\`-\\'" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--after-date=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--backup=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--blocking-factor=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--directory=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-dirs) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--exclude-from=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-entries) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--exclude=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--\\(extract\\|list\\)\\'" 0) - (setq complete-within t)) - ((pcomplete-match "\\`--file=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--files-from=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-entries) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--group=\\(.*\\)" 0) - (pcomplete-here* (pcmpl-unix-group-names) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--info-script=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-entries) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--label=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--mode=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--new-volume-script=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-entries) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--newer=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--owner=\\(.*\\)" 0) - (pcomplete-here* (pcmpl-unix-user-names) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--record-size=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--rsh-command=\\(.*\\)" 0) - (pcomplete-here* (funcall pcomplete-command-completion-function) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--starting-file=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-entries) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--suffix=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--tape-length=" 0) - (pcomplete-here*)) - ((pcomplete-match "\\`--use-compress-program=\\(.*\\)" 0) - (pcomplete-here* (funcall pcomplete-command-completion-function) - (pcomplete-match-string 1 0))) - ((pcomplete-match "\\`--volno-file=\\(.*\\)" 0) - (pcomplete-here* (pcomplete-entries) - (pcomplete-match-string 1 0))))) + (cond + ((pcomplete-match "^--\\([^= \t\n\f]*\\)\\'" 0) + (pcomplete-here* pcmpl-gnu--tar-long-options)) + ((pcomplete-match "\\`--directory=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-dirs) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--exclude-from=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-entries) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--\\(extract\\|list\\)\\'" 0) + (setq complete-within t)) + ((pcomplete-match "\\`--file=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-dirs-or-entries + pcmpl-gnu-tarfile-regexp) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--files-from=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-entries) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--group=\\(.*\\)" 0) + (pcomplete-here* (pcmpl-unix-group-names) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--info-script=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-entries) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--new-volume-script=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-entries) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--owner=\\(.*\\)" 0) + (pcomplete-here* (pcmpl-unix-user-names) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--rsh-command=\\(.*\\)" 0) + (pcomplete-here* (funcall pcomplete-command-completion-function) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--starting-file=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-entries) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--use-compress-program=\\(.*\\)" 0) + (pcomplete-here* (funcall pcomplete-command-completion-function) + (pcomplete-match-string 1 0))) + ((pcomplete-match "\\`--volno-file=\\(.*\\)" 0) + (pcomplete-here* (pcomplete-entries) + (pcomplete-match-string 1 0))) + (t + (pcomplete-here*))) + (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz") + (when (pcomplete-match "\\`-\\'" 0) + (pcomplete-here*)))) (unless saw-option (pcomplete-here (mapcar #'char-to-string commit 34c14430e9d070ffc98527fc95677dd5c5758536 Author: Dmitry Gutov Date: Wed Mar 8 22:41:23 2023 +0200 Don't misindent 'else:' after 'if re.match:' in Python * lisp/progmodes/python.el (python-info-dedenter-opening-block-positions): Check that the supposed block start is not a method call (bug#62031). * test/lisp/progmodes/python-tests.el (python-indent-after-re-match): New test. Co-authored-by: Lele Gaifax diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 1f970633bfc..81475f31f60 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -5792,7 +5792,9 @@ python-info-dedenter-opening-block-positions (catch 'exit (while (python-nav--syntactically (lambda () - (re-search-backward (python-rx block-start) nil t)) + (cl-loop for pt = (re-search-backward (python-rx block-start) nil t) + until (memq (char-before) '(nil ?\s ?\t ?\n)) + finally return pt)) #'<) (let ((indentation (current-indentation))) (when (and (not (memq indentation collected-indentations)) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 4f24c042c6a..6928e313dc4 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -1982,6 +1982,18 @@ python-indent-after-case-block (should (eq (car (python-indent-context)) :after-block-start)) (should (= (python-indent-calculate-indentation) 8)))) +(ert-deftest python-indent-after-re-match () + "Test BUG 62031 regression." + (python-tests-with-temp-buffer + " +def test_re(string): + if re.match('^[a-c]+$', string): + print('yes') + else: + " + (python-tests-look-at "else:") + (should (= (python-indent-calculate-indentation) 4)))) + ;;; Filling commit 8a2a554192a936257e88f12b4dfbd4f923d135f3 Author: Andrea Corallo Date: Wed Mar 8 21:08:49 2023 +0100 * Make sure `default-directory' exists before spawning processes (bug#62004) * lisp/emacs-lisp/comp.el (comp-final, comp-run-async-workers): Bind `default-directory' to `invocation-directory'. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index a1838b1abf2..283c00103b5 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3726,7 +3726,8 @@ comp-final (temp-file (make-temp-file (concat "emacs-int-comp-" (file-name-base output) "-") - nil ".el"))) + nil ".el")) + (default-directory invocation-directory)) (with-temp-file temp-file (insert ";; -*-coding: utf-8-emacs-unix; -*-\n") (mapc (lambda (e) @@ -4023,6 +4024,7 @@ comp-run-async-workers (comp-log "\n") (mapc #'comp-log expr-strings))) (load1 load) + (default-directory invocation-directory) (process (make-process :name (concat "Compiling: " source-file) :buffer (with-current-buffer commit 2e73dec15f2555128c370ba48a077f1a178b2731 Author: Stefan Monnier Date: Wed Mar 8 15:08:00 2023 -0500 gud.el: Fix bug#62041 Add a new `gud-shared-mode-map` where we put the bindings shared between `gud-minor-mode-map` and `gud-mode-map`. * lisp/progmodes/gud.el (gud-shared-mode-map): New keymap. (gud-mode-map, gud-minor-mode-map): Use it as parent. (gud-menu-map): Put the menu in that new keymap. (gud-speedbar-buttons, gdb-script-font-lock-syntactic-face) (gdb-script-indent-line): Skip obsolete face variables. diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 92e018aaec1..cfe5f75d19f 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -135,9 +135,9 @@ gud-target-name (defun gud-goto-info () "Go to relevant Emacs info node." (interactive) - (if (eq gud-minor-mode 'gdbmi) - (info-other-window "(emacs)GDB Graphical Interface") - (info-other-window "(emacs)Debuggers"))) + (info-other-window (if (eq gud-minor-mode 'gdbmi) + "(emacs)GDB Graphical Interface" + "(emacs)Debuggers"))) (defun gud-tool-bar-item-visible-no-fringe () (not (or (eq (buffer-local-value 'major-mode (window-buffer)) 'speedbar-mode) @@ -159,14 +159,17 @@ gud-stop-subjob (t (comint-interrupt-subjob))))) +(defvar-keymap gud-shared-mode-map + :doc "Keymap shared between `gud-mode' and `gud-minor-mode'.") + (defvar-keymap gud-mode-map - ;; Will inherit from comint-mode via define-derived-mode. - :doc "`gud-mode' keymap.") + :doc "`gud-mode' keymap." + :parent (make-composed-keymap gud-shared-mode-map comint-mode-map)) (defvar-keymap gud-minor-mode-map - :parent gud-mode-map) + :parent gud-shared-mode-map) -(easy-menu-define gud-menu-map gud-mode-map +(easy-menu-define gud-menu-map gud-shared-mode-map "Menu for `gud-mode'." '("Gud" ["Continue" gud-cont @@ -535,9 +538,9 @@ gud-speedbar-buttons (value (nth 4 var)) (status (nth 5 var)) (has-more (nth 6 var))) (put-text-property - 0 (length expr) 'face font-lock-variable-name-face expr) + 0 (length expr) 'face 'font-lock-variable-name-face expr) (put-text-property - 0 (length type) 'face font-lock-type-face type) + 0 (length type) 'face 'font-lock-type-face type) (while (string-match "\\." varnum start) (setq depth (1+ depth) start (1+ (match-beginning 0)))) @@ -1260,7 +1263,7 @@ gud-dbx-repeat-map (define-key map key cmd)) (when (or gud-mips-p gud-irix-p) - (define-key map "f" 'gud-finish)) + (define-key map "f" #'gud-finish)) map) "Keymap to repeat `dbx' stepping instructions \\`C-x C-a C-n n n'. Used in `repeat-mode'.") @@ -3422,9 +3425,9 @@ gdb-script-syntax-propertize-function (defun gdb-script-font-lock-syntactic-face (state) (cond - ((nth 3 state) font-lock-string-face) - ((nth 7 state) font-lock-doc-face) - (t font-lock-comment-face))) + ((nth 3 state) 'font-lock-string-face) + ((nth 7 state) 'font-lock-doc-face) + (t 'font-lock-comment-face))) (defvar gdb-script-basic-indent 2) @@ -3455,7 +3458,7 @@ gdb-script-calculate-indentation (defun gdb-script-indent-line () "Indent current line of GDB script." (interactive) - (if (and (eq (get-text-property (point) 'face) font-lock-doc-face) + (if (and (eq (get-text-property (point) 'face) 'font-lock-doc-face) (save-excursion (forward-line 0) (skip-chars-forward " \t") commit 1862e7eb7efd721cd0f335d9ee0bb5e763cf5478 Author: Ulrich Müller Date: Wed Mar 8 19:48:33 2023 +0100 Fix sed expression in install-etc make target * Makefile.in (install-etc): Fix sed expression for emacsclient desktop files. (Bug#62045) diff --git a/Makefile.in b/Makefile.in index 2fb7754d683..4f2f2f15c97 100644 --- a/Makefile.in +++ b/Makefile.in @@ -841,7 +841,7 @@ install-etc: rm -f $${tmp} tmp=etc/emacsclient.tmpdesktop; rm -f $${tmp}; \ client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \ - sed -e "/^Exec=emacsclient/ s|emacsclient|${bindir}/$${client_name}|" \ + sed -e "/^Exec=/ s|emacsclient|${bindir}/$${client_name}|" \ -e "/^Icon=emacs/ s/emacs/${EMACS_NAME}/" \ $(USE_STARTUP_NOTIFICATION_SED_CMD) \ ${srcdir}/etc/emacsclient.desktop > $${tmp}; \ @@ -855,7 +855,7 @@ install-etc: rm -f $${tmp} tmp=etc/emacsclient-mail.tmpdesktop; rm -f $${tmp}; \ client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \ - sed -e "/^Exec=emacsclient/ s|emacsclient|${bindir}/$${client_name}|" \ + sed -e "/^Exec=/ s|emacsclient|${bindir}/$${client_name}|" \ -e "/^Icon=emacs/ s/emacs/${EMACS_NAME}/" \ ${srcdir}/etc/emacsclient-mail.desktop > $${tmp}; \ ${INSTALL_DATA} $${tmp} "$(DESTDIR)${desktopdir}/$${client_name}-mail.desktop"; \ commit c8ec0017cb96d4ac98be21e1fe9a95e1aa723e99 Author: Ulrich Müller Date: Wed Mar 8 19:37:27 2023 +0100 Avoid using bash in the emacsclient desktop file * etc/emacsclient-mail.desktop (Exec): Use sh and sed instead of bash, because the latter may not be available everywhere. diff --git a/etc/emacsclient-mail.desktop b/etc/emacsclient-mail.desktop index 49c6f99f317..0a2420ddead 100644 --- a/etc/emacsclient-mail.desktop +++ b/etc/emacsclient-mail.desktop @@ -2,9 +2,9 @@ Categories=Network;Email; Comment=GNU Emacs is an extensible, customizable text editor - and more # We want to pass the following commands to the shell wrapper: -# u=${1//\\/\\\\}; u=${u//\"/\\\"}; exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")" +# u=$(echo "$1" | sed 's/[\"]/\\&/g'); exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")" # Special chars '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\'. -Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u +Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u Icon=emacs Name=Emacs (Mail, Client) MimeType=x-scheme-handler/mailto; @@ -16,7 +16,7 @@ Actions=new-window;new-instance; [Desktop Action new-window] Name=New Window -Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u +Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u [Desktop Action new-instance] Name=New Instance commit a588937094f7beb7c716c1badff681afa8c4d5ae Author: Eli Zaretskii Date: Wed Mar 8 19:29:33 2023 +0200 Fix documentation of the 'line-height' text property * doc/lispref/display.texi (Line Height): More accurate documentation of the value t of 'line-height' text property. (Bug#62048) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index a8311f5c9a2..550d711c73a 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -2345,10 +2345,11 @@ Line Height @item t If the property value is @code{t}, the newline character has no effect on the displayed height of the line---the visible contents -alone determine the height. The @code{line-spacing} property, -described below, is also ignored in this case. This is useful for -tiling small images (or image slices) without adding blank areas -between the images. +alone determine the height. The @code{line-spacing} property of the +newline, described below, is also ignored in this case. This is +useful for tiling small images (or image slices) without adding blank +areas between the images. + @item (@var{height} @var{total}) If the property value is a list of the form shown, that adds extra space @emph{below} the display line. First Emacs uses @var{height} as @@ -2409,7 +2410,9 @@ Line Height property that can enlarge the default frame line spacing and the buffer local @code{line-spacing} variable: if its value is larger than the buffer or frame defaults, that larger value is used instead, for -the display line ending in that newline. +the display line ending in that newline (unless the newline also has +the @code{line-height} property whose value is one of the special +values which cause @code{line-spacing} to be ignored, see above). One way or another, these mechanisms specify a Lisp value for the spacing of each line. The value is a height spec, and it translates commit 971ded31c4fc5f115777fba388f9e6a5623d08bc Author: Gregory Heytings Date: Wed Mar 8 09:55:06 2023 +0000 Add 'declare' specs to with- and without-restriction * lisp/subr.el (with-restriction): (without-restriction): Add 'declare' specs. diff --git a/lisp/subr.el b/lisp/subr.el index b8bda0efd3d..c800f380261 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3959,6 +3959,7 @@ with-restriction same LABEL argument. \(fn START END [:label LABEL] BODY)" + (declare (indent 0) (debug t)) (if (eq (car rest) :label) `(internal--with-restriction ,start ,end (lambda () ,@(cddr rest)) ,(cadr rest)) @@ -3981,6 +3982,7 @@ without-restriction are lifted. \(fn [:label LABEL] BODY)" + (declare (indent 0) (debug t)) (if (eq (car rest) :label) `(internal--without-restriction (lambda () ,@(cddr rest)) ,(cadr rest)) commit 5ff018524c740c77215ddb5d5983dbfcadb05599 Merge: 4e8b50ec57b f9b7913656f Author: Stefan Kangas Date: Wed Mar 8 06:30:18 2023 +0100 Merge from origin/emacs-29 f9b7913656f Fix empty line indentation in c-ts-mode (bug#61997) 90504f9d898 Fix tree-sitter indent preset prev-line (bug#61998) ed3bab3cc72 Revert 'forward-sentence-default-function' to return poin... bfe62b10413 ; * etc/NEWS: Fix typos. 3c1693d08b0 Fix Elisp code injection vulnerability in emacsclient-mai... ab417c8a6ee Fix problem with debuginfod queries in "M-x gdb" # Conflicts: # etc/NEWS commit f9b7913656f9e4728a1140b61ddb7f07009e28e6 Author: Yuan Fu Date: Tue Mar 7 16:35:23 2023 -0800 Fix empty line indentation in c-ts-mode (bug#61997) * lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Handle the empty line case. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test. * doc/lispref/modes.texi (Parser-based Indentation): Update manual. * lisp/treesit.el (treesit-simple-indent-presets): Support null as a value for NODE-TYPE in the 'match' matcher. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index c12224230fc..fff1ea65b07 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -5064,6 +5064,9 @@ Parser-based Indentation (match nil "argument_list" nil nil 0 0) @end example +In addition, @var{node-type} can be a special value @code{null}, +which matches when the value of @var{node} is @code{nil}. + @item n-p-gp Short for ``node-parent-grandparent'', this matcher is a function of 3 arguments: @var{node-type}, @var{parent-type}, and diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 0b775b2d5c8..fdd962ff020 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -419,7 +419,9 @@ c-ts-mode--indent-styles ((parent-is "field_declaration_list") c-ts-mode--anchor-prev-sibling 0) ;; Statement in {} blocks. - ((match nil "compound_statement" nil 1 1) standalone-parent c-ts-mode-indent-offset) + ((or (match nil "compound_statement" nil 1 1) + (match null "compound_statement")) + standalone-parent c-ts-mode-indent-offset) ((parent-is "compound_statement") c-ts-mode--anchor-prev-sibling 0) ;; Opening bracket. ((node-is "compound_statement") standalone-parent c-ts-mode-indent-offset) diff --git a/lisp/treesit.el b/lisp/treesit.el index 44a93f5e261..c118f5d52a4 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1107,9 +1107,11 @@ treesit-simple-indent-presets (&optional node-type parent-type node-field node-index-min node-index-max) (lambda (node parent &rest _) - (and (or (null node-type) - (string-match-p - node-type (or (treesit-node-type node) ""))) + (and (pcase node-type + ('nil t) + ('null (null node)) + (_ (string-match-p + node-type (or (treesit-node-type node) "")))) (or (null parent-type) (string-match-p parent-type (treesit-node-type parent))) @@ -1302,6 +1304,7 @@ treesit-simple-indent-presets (match nil \"argument_list\" nil nil 0 0). NODE-TYPE, PARENT-TYPE, and NODE-FIELD are regexps. + NODE-TYPE can also be `null', which matches when NODE is nil. no-node diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts index 77bfeb5ad6e..9e28ef203fd 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts @@ -418,3 +418,19 @@ required_matrix_height (struct window *w) | } =-=-= + +Name: Empty Line + +=-= +int +main (void) +{ +| +} +=-= +int +main (void) +{ + | +} +=-=-= commit 90504f9d8982c12a033286fe06b40583f553d267 Author: Yuan Fu Date: Tue Mar 7 16:26:33 2023 -0800 Fix tree-sitter indent preset prev-line (bug#61998) * lisp/treesit.el (treesit-simple-indent-presets): Fix return value. diff --git a/lisp/treesit.el b/lisp/treesit.el index 19484ceb0c2..44a93f5e261 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1253,7 +1253,8 @@ treesit-simple-indent-presets (save-excursion (goto-char bol) (forward-line -1) - (skip-chars-forward " \t")))) + (skip-chars-forward " \t") + (point)))) (cons 'column-0 (lambda (_n _p bol &rest _) (save-excursion (goto-char bol) commit ed3bab3cc728f19f8691024a3b77e178cf1945e6 Author: Manuel Giraud Date: Tue Mar 7 20:03:53 2023 +0100 Revert 'forward-sentence-default-function' to return point (bug#62027) * lisp/textmodes/paragraphs.el (forward-sentence-default-function): Revert to return the position of point. (count-sentences): Adapt to this change. diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index 73abb155aaa..a9e28a3275b 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el @@ -477,8 +477,7 @@ forward-sentence (skip-chars-backward " \t\n") (goto-char par-end))) (setq arg (1- arg))) - (let ((npoint (constrain-to-field nil opoint t))) - (not (= npoint opoint))))) + (constrain-to-field nil opoint t))) (defun count-sentences (start end) "Count sentences in current buffer from START to END." @@ -488,8 +487,13 @@ count-sentences (save-restriction (narrow-to-region start end) (goto-char (point-min)) - (while (ignore-errors (forward-sentence)) - (setq sentences (1+ sentences))) + (let* ((prev (point)) + (next (forward-sentence))) + (while (and (not (null next)) + (not (= prev next))) + (setq prev next + next (ignore-errors (forward-sentence)) + sentences (1+ sentences)))) ;; Remove last possibly empty sentence (when (/= (skip-chars-backward " \t\n") 0) (setq sentences (1- sentences))) commit bfe62b104133d321df8c266c86a78d612a9a9534 Author: Michael Albinus Date: Tue Mar 7 18:50:44 2023 +0100 ; * etc/NEWS: Fix typos. diff --git a/etc/NEWS b/etc/NEWS index 5e1a1c4e344..01ab4b8a1db 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2091,7 +2091,7 @@ completion, and adds the Emoji into the search string. *** New user option 'gdb-debuginfod-enable-setting'. On capable platforms, GDB 10.1 and later can download missing source and debug info files from special-purpose servers, called "debuginfod -servers". Use this new option to control whether "M-x gdb" instructs +servers". Use this new option to control whether 'M-x gdb' instructs GDB to download missing files from debuginfod servers when you debug the corresponding programs. The default is to ask you at the beginning of each debugging session whether to download the files for commit 4e8b50ec57bc0d70bdb1279756eec679eb4eab0d Author: Alan Mackenzie Date: Tue Mar 7 17:38:20 2023 +0000 * test/lisp/subr-tests.el (subr--safe-copy-tree): New tests for safe-copy-tree diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 050ee22ac18..37fe09c1716 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -1205,5 +1205,31 @@ subr--delete-consecutive-dups (should (equal a-dedup '("a" "b" "a" "b" "c"))) (should (eq a a-dedup)))) +(ert-deftest subr--safe-copy-tree () + (should (null (safe-copy-tree nil))) + (let* ((foo '(1 2 (3 4))) (bar (safe-copy-tree foo))) + (should (equal bar foo)) + (should-not (eq bar foo)) + (should-not (eq (caddr bar) (caddr foo)))) + (let* ((foo '#1=(a #1#)) (bar (safe-copy-tree foo))) + (should (eq (car bar) (car foo))) +; (should-not (proper-list-p bar)) + (should (eq (caadr bar) (caadr foo))) + (should (eq (caadr bar) 'a))) + (let* ((foo [1 2 3 4]) (bar (safe-copy-tree foo))) + (should (eq bar foo))) + (let* ((foo [1 (2 3) 4]) (bar (safe-copy-tree foo t))) + (should-not (eq bar foo)) + (should (equal bar foo)) + (should-not (eq (aref bar 1) (aref foo 1)))) + (let* ((foo [1 [2 3] 4]) (bar (safe-copy-tree foo t))) + (should (equal bar foo)) + (should-not (eq bar foo)) + (should-not (eq (aref bar 1) (aref foo 1)))) + (let* ((foo (record 'foo 1 "two" 3)) (bar (safe-copy-tree foo t))) + (should (equal bar foo)) + (should-not (eq bar foo)) + (should (eq (aref bar 2) (aref foo 2))))) + (provide 'subr-tests) ;;; subr-tests.el ends here commit 3c1693d08b0a71d40a77e7b40c0ebc42dca2d2cc Author: Ulrich Müller Date: Tue Mar 7 18:25:37 2023 +0100 Fix Elisp code injection vulnerability in emacsclient-mail.desktop A crafted mailto URI could contain unescaped double-quote characters, allowing injection of Elisp code. Therefore, any '\' and '"' characters are replaced by '\\' and '\"', using Bash pattern substitution (which is not available in the POSIX shell). We want to pass literal 'u=${1//\\/\\\\}; u=${u//\"/\\\"};' in the bash -c command, but in the desktop entry '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\', respectively (backslashes are expanded twice, see the Desktop Entry Specification). Reported by Gabriel Corona . * etc/emacsclient-mail.desktop (Exec): Escape backslash and double-quote characters. diff --git a/etc/emacsclient-mail.desktop b/etc/emacsclient-mail.desktop index 91df122c594..49c6f99f317 100644 --- a/etc/emacsclient-mail.desktop +++ b/etc/emacsclient-mail.desktop @@ -1,7 +1,10 @@ [Desktop Entry] Categories=Network;Email; Comment=GNU Emacs is an extensible, customizable text editor - and more -Exec=sh -c "exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$1\\\\\\")\\"" sh %u +# We want to pass the following commands to the shell wrapper: +# u=${1//\\/\\\\}; u=${u//\"/\\\"}; exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")" +# Special chars '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\'. +Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u Icon=emacs Name=Emacs (Mail, Client) MimeType=x-scheme-handler/mailto; @@ -13,7 +16,7 @@ Actions=new-window;new-instance; [Desktop Action new-window] Name=New Window -Exec=sh -c "exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$1\\\\\\")\\"" sh %u +Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u [Desktop Action new-instance] Name=New Instance commit 29f65920fb49588dd4fa29b33e7ed024afc6ffb6 Author: Alan Mackenzie Date: Tue Mar 7 15:26:20 2023 +0000 safe-copy-tree. Correct mistakes from earlier patch. * lisp/emacs-lisp/bytecomp.el (compile-defun): Remove unintended change. * lisp/subr.el (safe-copy-tree--seen): Correct grammatical error in doc string. (safe-copy-tree): Delete hash table at end of function. * doc/lispref/lists.texi (Building Lists): Add an "@end defun" line. diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index 911defbc211..3478049c84f 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi @@ -719,6 +719,7 @@ Building Lists non-@code{nil}, it copies vectors and records too (and operates recursively on their elements). This function handles circular lists and vectors, and is thus slower than @code{copy-tree} for typical cases. +@end defun @defun flatten-tree tree This function returns a ``flattened'' copy of @var{tree}, that is, diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 243d4b11b5f..12850c27b88 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2294,19 +2294,12 @@ compile-defun (symbols-with-pos-enabled t) (value (eval (displaying-byte-compile-warnings -;;;; NEW STOUGH, 2023-03-05 - (byte-run-strip-symbol-positions -;;;; END OF NEW STOUGH (byte-compile-sexp (let ((form (read-positioning-symbols (current-buffer)))) (push form byte-compile-form-stack) (eval-sexp-add-defvars form - start-read-position))) -;;;; NEW STOUGH, 2023-03-05 - ) -;;;; END OF NEW STOUGH - ) + start-read-position)))) lexical-binding))) (cond (arg (message "Compiling from buffer... done.") diff --git a/lisp/subr.el b/lisp/subr.el index 2066be581d1..e29c8ddd6c4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -848,8 +848,8 @@ copy-tree (defvar safe-copy-tree--seen nil "A hash table for conses/vectors/records already seen by safe-copy-tree-1. -It's key is a cons or vector/record seen by the algorithm, and its value is -the corresponding cons/vector/record in the copy.") +Its key is a cons or vector/record seen by the algorithm, and its +value is the corresponding cons/vector/record in the copy.") (defun safe-copy-tree--1 (tree &optional vecp) "Make a copy of TREE, taking circular structure into account. @@ -896,7 +896,10 @@ safe-copy-tree Contrast to `copy-sequence', which copies only along the cdrs. With second argument VECP, this copies vectors and records as well as conses." (setq safe-copy-tree--seen (make-hash-table :test #'eq)) - (safe-copy-tree--1 tree vecp)) + (unwind-protect + (safe-copy-tree--1 tree vecp) + (clrhash safe-copy-tree--seen) + (setq safe-copy-tree--seen nil))) ;;;; Various list-search functions. commit ab417c8a6eeb7df7ccce3e5f8416f48544a5174e Author: Eli Zaretskii Date: Tue Mar 7 14:39:27 2023 +0200 Fix problem with debuginfod queries in "M-x gdb" * lisp/progmodes/gdb-mi.el (gdb-debuginfod-enable-setting): New defcustom. (gdb-debuginfod-message): New function. (gdb-init-1): Initialize gdb-debuginfod-enable. Ask the user about debuginfod queries and display any error messages. (Bug#61973) * etc/NEWS: Announce the change. diff --git a/etc/NEWS b/etc/NEWS index 189ca590e3f..5e1a1c4e344 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2085,6 +2085,18 @@ command accepts the Unicode name of an Emoji (for example, "smiling face" or "heart with arrow"), like 'C-x 8 e e', with minibuffer completion, and adds the Emoji into the search string. +** GDB/MI + +--- +*** New user option 'gdb-debuginfod-enable-setting'. +On capable platforms, GDB 10.1 and later can download missing source +and debug info files from special-purpose servers, called "debuginfod +servers". Use this new option to control whether "M-x gdb" instructs +GDB to download missing files from debuginfod servers when you debug +the corresponding programs. The default is to ask you at the +beginning of each debugging session whether to download the files for +that session. + ** Glyphless Characters +++ diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 8b157dd3333..8db16729163 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -255,6 +255,9 @@ gdb-non-stop It is initialized to `gdb-non-stop-setting' at the beginning of every GDB session.") +(defvar gdb-debuginfod-enable nil + "Whether the current GDB session can query debuginfod servers.") + (defvar-local gdb-buffer-type nil "One of the symbols bound in `gdb-buffer-rules'.") @@ -467,6 +470,30 @@ gdb-non-stop-setting :group 'gdb-non-stop :version "26.1") +(defcustom gdb-debuginfod-enable-setting + ;; debuginfod servers are only for ELF executables, and elfutils, of + ;; which libdebuginfod is a part, is not usually available on + ;; MS-Windows. + (if (not (eq system-type 'windows-nt)) 'ask) + "Whether to enable downloading missing debug info from debuginfod servers. +The debuginfod servers are HTTP servers for distributing source +files and debug info files of programs. If GDB was built with +debuginfod support, it can query these servers when you debug a +program for which some of these files are not available locally, +and download the files if the servers have them. + +The value nil means never to download from debuginfod servers. +The value t means always download from debuginfod servers when +some source or debug info files are missing. +The value `ask', the default, means ask at the beginning of each +debugging session whether to download from debuginfod servers +during that session." + :type '(choice (const :tag "Never download from debuginfod servers" nil) + (const :tag "Download from debuginfod servers when necessary" t) + (const :tag "Ask whether to download for each session" ask)) + :group 'gdb + :version "29.1") + ;; TODO Some commands can't be called with --all (give a notice about ;; it in setting doc) (defcustom gdb-gud-control-all-threads t @@ -1021,6 +1048,11 @@ gdb (run-hooks 'gdb-mode-hook)) +(defconst gdb--string-regexp (rx "\"" + (* (or (seq "\\" nonl) + (not (any "\"\\")))) + "\"")) + (defun gdb-init-1 () ;; (Re-)initialize. (setq gdb-selected-frame nil @@ -1044,7 +1076,8 @@ gdb-init-1 gdb-threads-list '() gdb-breakpoints-list '() gdb-register-names '() - gdb-non-stop gdb-non-stop-setting) + gdb-non-stop gdb-non-stop-setting + gdb-debuginfod-enable gdb-debuginfod-enable-setting) ;; (gdbmi-bnf-init) ;; @@ -1053,6 +1086,15 @@ gdb-init-1 (gdb-force-mode-line-update (propertize "initializing..." 'face font-lock-variable-name-face)) + ;; This needs to be done before we ask GDB for anything that might + ;; trigger questions about debuginfod queries. + (if (eq gdb-debuginfod-enable 'ask) + (setq gdb-debuginfod-enable + (y-or-n-p "Enable querying debuginfod servers for this session?"))) + (gdb-input (format "-gdb-set debuginfod enabled %s" + (if gdb-debuginfod-enable "on" "off")) + 'gdb-debuginfod-message) + (gdb-get-buffer-create 'gdb-inferior-io) (gdb-clear-inferior-io) (gdb-inferior-io--init-proc (get-process "gdb-inferior")) @@ -1080,6 +1122,18 @@ gdb-init-1 (gdb-input "-file-list-exec-source-file" 'gdb-get-source-file) (gdb-input "-gdb-show prompt" 'gdb-get-prompt)) +(defun gdb-debuginfod-message () + "Show in the echo area GDB error response for a debuginfod command, if any." + (goto-char (point-min)) + (cond + ((re-search-forward "msg=\\(\".+\"\\)$" nil t) + ;; Supports debuginfod, but cannot perform command. + (message "%s" (buffer-substring (1+ (match-beginning 1)) + (1- (line-end-position))))) + ((re-search-forward "No symbol" nil t) + (message "This version of GDB doesn't support debuginfod commands.")) + (t (message nil)))) + (defun gdb-non-stop-handler () (goto-char (point-min)) (if (re-search-forward "No symbol" nil t) @@ -1148,11 +1202,6 @@ gdb-create-define-alist (declare-function tooltip-show "tooltip" (text &optional use-echo-area text-face default-face)) -(defconst gdb--string-regexp (rx "\"" - (* (or (seq "\\" nonl) - (not (any "\"\\")))) - "\"")) - (defun gdb-tooltip-print (expr) (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) (goto-char (point-min)) commit fa83b236111ea024b75a8bb33b78a99f437a9a67 Author: Alan Mackenzie Date: Tue Mar 7 08:00:25 2023 +0000 eval-and-compile: Strip symbol positions for eval but not for compile. This fixes bug #61962. * lisp/subr.el (safe-copy-tree): New function. * lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment): Amend the entry for eval-and-compile to use safe-copy-tree and byte-run-strip-symbol-positions for the eval part. * doc/lispref/lists.texi (Building Lists): Document safe-copy-tree. * etc/NEWS: Note the new function safe-copy-tree. diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index f3758f5ce60..911defbc211 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi @@ -705,9 +705,21 @@ Building Lists Normally, when @var{tree} is anything other than a cons cell, @code{copy-tree} simply returns @var{tree}. However, if @var{vecp} is non-@code{nil}, it copies vectors too (and operates recursively on -their elements). +their elements). This function cannot cope with circular lists. @end defun +@defun safe-copy-tree tree &optional vecp +This function returns a copy of the tree @var{tree}. If @var{tree} is +a cons cell, this make a new cons cell with the same @sc{car} and +@sc{cdr}, then recursively copies the @sc{car} and @sc{cdr} in the +same way. + +Normally, when @var{tree} is anything other than a cons cell, +@code{copy-tree} simply returns @var{tree}. However, if @var{vecp} is +non-@code{nil}, it copies vectors and records too (and operates +recursively on their elements). This function handles circular lists +and vectors, and is thus slower than @code{copy-tree} for typical cases. + @defun flatten-tree tree This function returns a ``flattened'' copy of @var{tree}, that is, a list containing all the non-@code{nil} terminal nodes, or leaves, of diff --git a/etc/NEWS b/etc/NEWS index 7e0454b3b9e..540b59a628f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -358,6 +358,11 @@ was to catch all errors, add an explicit handler for 'error', or use This warning can be suppressed using 'with-suppressed-warnings' with the warning name 'suspicious'. ++++ +** New function 'safe-copy-tree' +This function is a version of copy-tree which handles circular lists +and circular vectors/records. + +++ ** New function 'file-user-uid'. This function is like 'user-uid', but is aware of file name handlers, diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 6f3d7a70903..243d4b11b5f 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -533,7 +533,9 @@ byte-compile-initial-macro-environment (macroexpand--all-toplevel form macroexpand-all-environment))) - (eval expanded lexical-binding) + (eval (byte-run-strip-symbol-positions + (safe-copy-tree expanded)) + lexical-binding) expanded))))) (with-suppressed-warnings . ,(lambda (warnings &rest body) @@ -2292,12 +2294,19 @@ compile-defun (symbols-with-pos-enabled t) (value (eval (displaying-byte-compile-warnings +;;;; NEW STOUGH, 2023-03-05 + (byte-run-strip-symbol-positions +;;;; END OF NEW STOUGH (byte-compile-sexp (let ((form (read-positioning-symbols (current-buffer)))) (push form byte-compile-form-stack) (eval-sexp-add-defvars form - start-read-position)))) + start-read-position))) +;;;; NEW STOUGH, 2023-03-05 + ) +;;;; END OF NEW STOUGH + ) lexical-binding))) (cond (arg (message "Compiling from buffer... done.") diff --git a/lisp/subr.el b/lisp/subr.el index 8ff3b868fab..2066be581d1 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -845,6 +845,59 @@ copy-tree (aset tree i (copy-tree (aref tree i) vecp))) tree) tree))) + +(defvar safe-copy-tree--seen nil + "A hash table for conses/vectors/records already seen by safe-copy-tree-1. +It's key is a cons or vector/record seen by the algorithm, and its value is +the corresponding cons/vector/record in the copy.") + +(defun safe-copy-tree--1 (tree &optional vecp) + "Make a copy of TREE, taking circular structure into account. +If TREE is a cons cell, this recursively copies both its car and its cdr. +Contrast to `copy-sequence', which copies only along the cdrs. With second +argument VECP, this copies vectors and records as well as conses." + (cond + ((gethash tree safe-copy-tree--seen)) + ((consp tree) + (let* ((result (cons (car tree) (cdr tree))) + (newcons result) + hash) + (while (and (not hash) (consp tree)) + (if (setq hash (gethash tree safe-copy-tree--seen)) + (setq newcons hash) + (puthash tree newcons safe-copy-tree--seen)) + (setq tree newcons) + (unless hash + (if (or (consp (car tree)) + (and vecp (or (vectorp (car tree)) (recordp (car tree))))) + (let ((newcar (safe-copy-tree--1 (car tree) vecp))) + (setcar tree newcar))) + (setq newcons (if (consp (cdr tree)) + (cons (cadr tree) (cddr tree)) + (cdr tree))) + (setcdr tree newcons) + (setq tree (cdr tree)))) + (nconc result + (if (and vecp (or (vectorp tree) (recordp tree))) + (safe-copy-tree--1 tree vecp) tree)))) + ((and vecp (or (vectorp tree) (recordp tree))) + (let* ((newvec (copy-sequence tree)) + (i (length newvec))) + (puthash tree newvec safe-copy-tree--seen) + (setq tree newvec) + (while (>= (setq i (1- i)) 0) + (aset tree i (safe-copy-tree--1 (aref tree i) vecp))) + tree)) + (t tree))) + +(defun safe-copy-tree (tree &optional vecp) + "Make a copy of TREE, taking circular structure into account. +If TREE is a cons cell, this recursively copies both its car and its cdr. +Contrast to `copy-sequence', which copies only along the cdrs. With second +argument VECP, this copies vectors and records as well as conses." + (setq safe-copy-tree--seen (make-hash-table :test #'eq)) + (safe-copy-tree--1 tree vecp)) + ;;;; Various list-search functions. commit 8179555730d23f43b3043df0bfecc9f9c4f36eda Merge: 1e5393a57a3 bd07cec8442 Author: Stefan Kangas Date: Tue Mar 7 06:30:10 2023 +0100 Merge from origin/emacs-29 bd07cec8442 Fix regression in Fido mode (bug#62015) 0e3c7ac13da * Fix `emacs-lisp-native-compile-and-load' for (bug#61917) 4a7e657389a * lisp/emacs-lisp/comp.el (comp-prettyformat-insn): Fix (... 8a8a994cfab Revert "Fix configuration of webp libraries" de4277af009 Fix configuration of webp libraries commit bd07cec844257ba8ae95b2ab2e66982360576c9d Author: João Távora Date: Mon Mar 6 22:28:47 2023 +0000 Fix regression in Fido mode (bug#62015) To understand the regression consider this recipe where the 'fo' pattern is typed by the user in the last step. emacs -Q C-x b foo RET C-x b afoo RET C-x b *scratch* RET M-x fido-mode RET C-x b fo This used to offer both 'foo' and 'afoo' as candidates but now only offered 'foo'. This is because the pattern 'fo' matches 'foo', but not 'afoo' with 'basic' completion style. Fido mode, however, prioritizes 'flex' completion style, and that is not happening here as it used to. This was introduced in this commit commit bf81df86e52fdc995bec8d9646f84d114cb896d1 Author: João Távora Date: Wed Dec 7 10:43:59 2022 +0000 Don't override completion-category-defaults in fido-mode I took away the nil setting of 'completion-category-defaults; in Fido mode's minibuffer. It seemed generally the correct thing to do, and was done mainly because Eglot added its style preferences to that variable instead of completion-category-overrides directly, which is a nono. So, to be able use the Fido UI with Eglot successfully, 'completion-category-defaults' should stay untouched. Or so I thought. However, I failed to notice that, for most categories, the default value of 'completion-category-defaults' prioritizes the 'basic' completion style. For example, in the 'buffer' category, the default value has the styles list '(basic substring)'. This means that if a pattern matches accoring to the 'basic' style, 'substring' will not be tried. And neither will 'completion-styles' which in Fido mode's case happens to be 'flex'. The solution in this commit is to craft a value for completion category defaults that is just like the default one, but prioritizes 'flex' completion for every category. * lisp/icomplete.el (icomplete--fido-ccd): New helper. (icomplete--fido-mode-setup): Use it. diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 0adb0e5afeb..f46127a20e0 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -419,6 +419,16 @@ icomplete-fido-mode-map "C-." #'icomplete-forward-completions "C-," #'icomplete-backward-completions) +(defun icomplete--fido-ccd () + "Make value for `completion-category-defaults' prioritizing `flex'." + (cl-loop + for (cat . alist) in completion-category-defaults collect + `(,cat . ,(cl-loop + for entry in alist for (prop . val) = entry + if (eq prop 'styles) + collect `(,prop . (flex ,@(delq 'flex val))) + else collect entry)))) + (defun icomplete--fido-mode-setup () "Setup `fido-mode''s minibuffer." (when (and icomplete-mode (icomplete-simple-completing-p)) @@ -430,6 +440,7 @@ icomplete--fido-mode-setup icomplete-scroll (not (null icomplete-vertical-mode)) completion-styles '(flex) completion-flex-nospace nil + completion-category-defaults (icomplete--fido-ccd) completion-ignore-case t read-buffer-completion-ignore-case t read-file-name-completion-ignore-case t))) commit 0e3c7ac13da7039d873fdd0f879c2bea75fe7d5a Author: Andrea Corallo Date: Mon Mar 6 17:27:32 2023 +0100 * Fix `emacs-lisp-native-compile-and-load' for (bug#61917) * lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile-and-load): Don't load if no compialtion happened. diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index b2709616d22..6fbb87fa3a8 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -224,7 +224,8 @@ emacs-lisp-native-compile-and-load native compilation." (interactive nil emacs-lisp-mode) (emacs-lisp--before-compile-buffer) - (load (native-compile buffer-file-name))) + (when-let ((out (native-compile buffer-file-name))) + (load out))) (defun emacs-lisp-macroexpand () "Macroexpand the form after point. commit 4a7e657389a2c6367911b381bdf86dd83c09d325 Author: Andrea Corallo Date: Mon Mar 6 16:51:07 2023 +0100 * lisp/emacs-lisp/comp.el (comp-prettyformat-insn): Fix (bug#61917) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 72e9b8e37dc..a1838b1abf2 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1137,10 +1137,12 @@ comp-prettyformat-mvar (comp-cstr-to-type-spec mvar))) (defun comp-prettyformat-insn (insn) - (cl-typecase insn - (comp-mvar (comp-prettyformat-mvar insn)) - (atom (prin1-to-string insn)) - (cons (concat "(" (mapconcat #'comp-prettyformat-insn insn " ") ")")))) + (cond + ((comp-mvar-p insn) + (comp-prettyformat-mvar insn)) + ((proper-list-p insn) + (concat "(" (mapconcat #'comp-prettyformat-insn insn " ") ")")) + (t (prin1-to-string insn)))) (defun comp-log-func (func verbosity) "Log function FUNC at VERBOSITY. commit 8a8a994cfab0a7413caa0f0849063accadf81393 Author: Eli Zaretskii Date: Mon Mar 6 17:31:57 2023 +0200 Revert "Fix configuration of webp libraries" This reverts commit de4277af009115ceba7fe920163c05c608ea9524. It breaks WebP support at least on my system. There's no reason to require libwebpdecoder library to be installed, since we don't use the functions from it, at least not in libwebp 1.2.1. diff --git a/configure.ac b/configure.ac index 2787370fbff..bc7e61048c3 100644 --- a/configure.ac +++ b/configure.ac @@ -2803,8 +2803,7 @@ AC_DEFUN || test "${HAVE_W32}" = "yes" || test "${HAVE_NS}" = "yes" \ || test "${HAVE_BE_APP}" = "yes" || test "${HAVE_PGTK}" = "yes"; then WEBP_REQUIRED=0.6.0 - WEBP_MODULE="libwebpdemux >= $WEBP_REQUIRED \ - libwebpdecoder >= $WEBP_REQUIRED" + WEBP_MODULE="libwebpdemux >= $WEBP_REQUIRED" EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE]) AC_SUBST([WEBP_CFLAGS]) commit 1e5393a57a3bbe3f9167fee59232c2e424afadf2 Author: Vibhav Pant Date: Wed Mar 1 15:04:34 2023 +0530 Don't modify interactive closures destructively (Bug#60974). * lisp/emacs-lisp/cconv.el (cconv-convert): When form is an interactive lambda form, don't destructively modify it, as it might be a constant literal. Instead, create a new list with the relevant place(s) changed. * test/lisp/emacs-lisp/cconv-tests.el (cconv-tests-interactive-form-modify-bug60974): New test. diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index ad9d8ab0a51..601e2c13d61 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el @@ -477,7 +477,7 @@ cconv-convert branch)) cond-forms))) - (`(function (lambda ,args . ,body) . ,_) + (`(function (lambda ,args . ,body) . ,rest) (let* ((docstring (if (eq :documentation (car-safe (car body))) (cconv-convert (cadr (pop body)) env extend))) (bf (if (stringp (car body)) (cdr body) body)) @@ -485,15 +485,32 @@ cconv-convert (gethash form cconv--interactive-form-funs))) (wrapped (pcase if (`#'(lambda (&rest _cconv--dummy) .,_) t) (_ nil))) (cif (when if (cconv-convert if env extend))) - (_ (pcase cif - ('nil nil) - (`#',f - (setf (cadr (car bf)) (if wrapped (nth 2 f) cif)) - (setq cif nil)) - ;; The interactive form needs special treatment, so the form - ;; inside the `interactive' won't be used any further. - (_ (setf (cadr (car bf)) nil)))) - (cf (cconv--convert-function args body env form docstring))) + (cf nil)) + ;; TODO: Because we need to non-destructively modify body, this code + ;; is particularly ugly. This should ideally be moved to + ;; cconv--convert-function. + (pcase cif + ('nil (setq bf nil)) + (`#',f + (pcase-let ((`((,f1 . (,_ . ,f2)) . ,f3) bf)) + (setq bf `((,f1 . (,(if wrapped (nth 2 f) cif) . ,f2)) . ,f3))) + (setq cif nil)) + ;; The interactive form needs special treatment, so the form + ;; inside the `interactive' won't be used any further. + (_ (pcase-let ((`((,f1 . (,_ . ,f2)) . ,f3) bf)) + (setq bf `((,f1 . (nil . ,f2)) . ,f3))))) + (when bf + ;; If we modified bf, re-build body and form as + ;; copies with the modified bits. + (setq body (if (stringp (car body)) + (cons (car body) bf) + bf) + form `(function (lambda ,args . ,body) . ,rest)) + ;; Also, remove the current old entry on the alist, replacing + ;; it with the new one. + (let ((entry (pop cconv-freevars-alist))) + (push (cons body (cdr entry)) cconv-freevars-alist))) + (setq cf (cconv--convert-function args body env form docstring)) (if (not cif) ;; Normal case, the interactive form needs no special treatment. cf diff --git a/test/lisp/emacs-lisp/cconv-tests.el b/test/lisp/emacs-lisp/cconv-tests.el index 349ffeb7e47..6facd3452ea 100644 --- a/test/lisp/emacs-lisp/cconv-tests.el +++ b/test/lisp/emacs-lisp/cconv-tests.el @@ -376,6 +376,18 @@ cconv-safe-for-space (eval '(lambda (x) :closure-dont-trim-context (+ x 1)) `((y . ,magic-string))))))) +(ert-deftest cconv-tests-interactive-form-modify-bug60974 () + (let* ((f '(function (lambda (&optional arg) + (interactive + (list (if current-prefix-arg + (prefix-numeric-value current-prefix-arg) + 'toggle))) + (ignore arg)))) + (if (cadr (nth 2 (cadr f)))) + (if2)) + (cconv-closure-convert f) + (setq if2 (cadr (nth 2 (cadr f)))) + (should (eq if if2)))) (provide 'cconv-tests) ;;; cconv-tests.el ends here commit de4277af009115ceba7fe920163c05c608ea9524 Author: Po Lu Date: Mon Mar 6 21:42:29 2023 +0800 Fix configuration of webp libraries * configure.ac: Link with libwebpdecoder along with libwebpdemux. (bug#61988) diff --git a/configure.ac b/configure.ac index bc7e61048c3..2787370fbff 100644 --- a/configure.ac +++ b/configure.ac @@ -2803,7 +2803,8 @@ AC_DEFUN || test "${HAVE_W32}" = "yes" || test "${HAVE_NS}" = "yes" \ || test "${HAVE_BE_APP}" = "yes" || test "${HAVE_PGTK}" = "yes"; then WEBP_REQUIRED=0.6.0 - WEBP_MODULE="libwebpdemux >= $WEBP_REQUIRED" + WEBP_MODULE="libwebpdemux >= $WEBP_REQUIRED \ + libwebpdecoder >= $WEBP_REQUIRED" EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE]) AC_SUBST([WEBP_CFLAGS]) commit 186643ea8a8e36bf3264b36c4106793cea25c6b3 Author: Michael Albinus Date: Mon Mar 6 13:35:49 2023 +0100 Add tramp-use-ssh-controlmaster-options value `suppress'. * doc/misc/tramp.texi (Ssh setup): Explain tramp-use-ssh-controlmaster-options value `suppress'. (Remote processes): Add reference to "Using ssh connection sharing". * etc/NEWS: Extend 'tramp-use-ssh-controlmaster-options' values. ;; Fix typos. * lisp/net/tramp-sh.el (tramp-use-ssh-controlmaster-options): Allow new value `suppress'. (tramp-ssh-option-exists-p): New defun. (tramp-ssh-controlmaster-options): Implement `suppress' actions. diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 7f6182ae17c..acf32726895 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -2728,6 +2728,7 @@ Ssh setup There is no counter which could be set. +@anchor{Using ssh connection sharing} @subsection Using ssh connection sharing @vindex ControlPath@r{, ssh option} @@ -2758,19 +2759,32 @@ Ssh setup @samp{%%r}, @samp{%%h} and @samp{%%p}. @vindex tramp-use-ssh-controlmaster-options -If the @file{~/.ssh/config} file is configured appropriately for the -above behavior, then any changes to @command{ssh} can be suppressed -with this @code{nil} setting: +Using a predefined string in @code{tramp-ssh-controlmaster-options}, +or puzzling an own string, happens only when user option +@code{tramp-use-ssh-controlmaster-options} is set to @code{t}. If the +@file{~/.ssh/config} file is configured appropriately for the above +behavior, then any changes to @command{ssh} can be suppressed with +this @code{nil} setting: @lisp (customize-set-variable 'tramp-use-ssh-controlmaster-options nil) @end lisp +Sometimes, it is not possible to use OpenSSH's @option{ControlMaster} +option for remote processes. This could result in concurrent access +to the OpenSSH socket when reading data by different processes, which +could block Emacs. In this case, setting +@code{tramp-use-ssh-controlmaster-options} to @code{suppress} disables +shared access. It is not needed to set this user option permanently +to @code{suppress}, binding the user option prior calling +@code{make-process} is sufficient. @value{tramp} does this for +esxample for compilation processes on its own. + @vindex ProxyCommand@r{, ssh option} @vindex ProxyJump@r{, ssh option} -This should also be set to @code{nil} if you use the -@option{ProxyCommand} or @option{ProxyJump} options in your -@command{ssh} configuration. +@code{tramp-use-ssh-controlmaster-options} should also be set to +@code{nil} or @code{suppress} if you use the @option{ProxyCommand} or +@option{ProxyJump} options in your @command{ssh} configuration. In order to use the @option{ControlMaster} option, @value{tramp} must check whether the @command{ssh} client supports this option. This is @@ -4288,7 +4302,8 @@ Remote processes @code{start-file-process}. Furthermore, you might set @code{tramp-use-ssh-controlmaster-options} to @code{nil} in order to bypass @value{tramp}'s handling of the @option{ControlMaster} options, -and use your own settings in @file{~/.ssh/config}. +and use your own settings in @file{~/.ssh/config}, @ref{Using ssh +connection sharing}. @node Cleanup remote connections diff --git a/etc/NEWS b/etc/NEWS index 116b60d8b11..7e0454b3b9e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -100,7 +100,7 @@ If you want to get back the old behavior, set the user option to the value *** New user option 'grep-use-headings'. When non-nil, the output of Grep is split into sections, one for each file, instead of having file names prefixed to each line. It is -equivalent to the --heading option of some tools such as 'git grep' +equivalent to the "--heading" option of some tools such as 'git grep' and 'rg'. The headings are displayed using the new 'grep-heading' face. @@ -116,7 +116,7 @@ switches for shortlogs, such as the one produced by 'C-x v L'. +++ *** 'diff-ignore-whitespace-hunk' can now be applied to all hunks. -When called with a non-nil prefix argument +When called with a non-nil prefix argument, 'diff-ignore-whitespace-hunk' now iterates over all the hunks in the current diff, regenerating them without whitespace changes. @@ -161,7 +161,7 @@ this to your configuration: --- *** You can now properly unload Eshell. -Calling "(unload-feature 'eshell)" no longer signals an error, and now +Calling '(unload-feature 'eshell)' no longer signals an error, and now correctly unloads Eshell and all of its modules. +++ @@ -184,6 +184,12 @@ point is not in a comment or a string. It is by default bound to *** New connection method "toolbox". This allows accessing system containers provided by Toolbox. ++++ +*** New value 'suppress' for user option 'tramp-use-ssh-controlmaster-options'. +This user option allows now the values t, nil, and 'suppress'. The +latter suppresses also "ControlMaster" settings in the user's +"~/.ssh/config" file. + ** EWW +++ @@ -211,7 +217,7 @@ asynchronously (which is the default behavior). * New Modes and Packages in Emacs 30.1 -** New major modes based on the tree-sitter library. +** New major modes based on the tree-sitter library +++ *** New major mode 'html-ts-mode'. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 49da0e425ff..3ae5208154a 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -108,11 +108,18 @@ tramp-end-of-heredoc (defcustom tramp-use-ssh-controlmaster-options (not (eq system-type 'windows-nt)) "Whether to use `tramp-ssh-controlmaster-options'. +Set it to t, if you want Tramp to apply these options. Set it to nil, if you use Control* or Proxy* options in your ssh -configuration." +configuration. +Set it to `suppress' if you want to disable settings in your +\"~/.ssh/config¸\"." :group 'tramp - :version "28.1" - :type 'boolean) + :version "29.2" + :type '(choice (const :tag "Set ControlMaster" t) + (const :tag "Don't set ControlMaster" nil) + (const :tag "Suppress ControlMaster" suppress)) + ;; Check with (safe-local-variable-p 'tramp-use-ssh-controlmaster-options 'suppress) + :safe (lambda (val) (and (memq val '(t nil suppress)) t))) (defvar tramp-ssh-controlmaster-options nil "Which ssh Control* arguments to use. @@ -123,8 +130,8 @@ tramp-ssh-controlmaster-options spec must be doubled, because the string is used as format string. Otherwise, it will be auto-detected by Tramp, if -`tramp-use-ssh-controlmaster-options' is non-nil. The value -depends on the installed local ssh version. +`tramp-use-ssh-controlmaster-options' is t. The value depends on +the installed local ssh version. The string is used in `tramp-methods'.") @@ -4811,6 +4818,15 @@ tramp-find-inline-compress (tramp-message vec 2 "Couldn't find an inline transfer compress command"))))) +(defun tramp-ssh-option-exists-p (vec option) + "Check, whether local ssh OPTION is applicable." + ;; We don't want to cache it persistently. + (with-tramp-connection-property nil option + ;; We use a non-existing IP address for check, in order to avoid + ;; useless connections, and DNS timeouts. + (zerop + (tramp-call-process vec "ssh" nil nil nil "-G" "-o" option "0.0.0.1")))) + (defun tramp-ssh-controlmaster-options (vec) "Return the Control* arguments of the local ssh." (cond @@ -4820,40 +4836,30 @@ tramp-ssh-controlmaster-options "") ;; There is already a value to be used. - ((stringp tramp-ssh-controlmaster-options) tramp-ssh-controlmaster-options) + ((and (eq tramp-use-ssh-controlmaster-options t) + (stringp tramp-ssh-controlmaster-options)) + tramp-ssh-controlmaster-options) ;; Determine the options. - (t (setq tramp-ssh-controlmaster-options "") - (let ((case-fold-search t)) - (ignore-errors - (with-tramp-progress-reporter - vec 4 "Computing ControlMaster options" - ;; We use a non-existing IP address, in order to avoid - ;; useless connections, and DNS timeouts. - (when (zerop - (tramp-call-process - vec "ssh" nil nil nil - "-G" "-o" "ControlMaster=auto" "0.0.0.1")) - (setq tramp-ssh-controlmaster-options - "-o ControlMaster=auto") - (if (zerop - (tramp-call-process - vec "ssh" nil nil nil - "-G" "-o" "ControlPath=tramp.%C" "0.0.0.1")) - (setq tramp-ssh-controlmaster-options - (concat tramp-ssh-controlmaster-options - " -o ControlPath=tramp.%%C")) - (setq tramp-ssh-controlmaster-options - (concat tramp-ssh-controlmaster-options - " -o ControlPath=tramp.%%r@%%h:%%p"))) - (when (zerop - (tramp-call-process - vec "ssh" nil nil nil - "-G" "-o" "ControlPersist=no" "0.0.0.1")) - (setq tramp-ssh-controlmaster-options - (concat tramp-ssh-controlmaster-options - " -o ControlPersist=no"))))))) - tramp-ssh-controlmaster-options))) + (t (ignore-errors + ;; ControlMaster and ControlPath options are introduced in OpenSSH 3.9. + (when (tramp-ssh-option-exists-p vec "ControlMaster=auto") + (concat + "-o ControlMaster=" + (if (eq tramp-use-ssh-controlmaster-options 'suppress) + "no" "auto") + + " -o ControlPath=" + (if (eq tramp-use-ssh-controlmaster-options 'suppress) + "none" + ;; Hashed tokens are introduced in OpenSSH 6.7. + (if (tramp-ssh-option-exists-p vec "ControlPath=tramp.%C") + "tramp.%%C" "tramp.%%r@%%h:%%p")) + + ;; ControlPersist option is introduced in OpenSSH 5.6. + (when (and (not (eq tramp-use-ssh-controlmaster-options 'suppress)) + (tramp-ssh-option-exists-p vec "ControlPersist=no")) + " -o ControlPersist=no"))))))) (defun tramp-scp-strict-file-name-checking (vec) "Return the strict file name checking argument of the local scp."