commit eba7d7970f330068d3332419623f87caf6953e6c (HEAD, refs/remotes/origin/master) Author: Wilhelm H Kirschbaum Date: Thu Mar 16 22:11:59 2023 +0200 ; Fix source file headers for some test files (bug#62227) * test/lisp/progmodes/elixir-ts-mode-tests.el: Fix source file header. * test/lisp/progmodes/heex-ts-mode-tests.el: Add source file header and footer. diff --git a/test/lisp/progmodes/elixir-ts-mode-tests.el b/test/lisp/progmodes/elixir-ts-mode-tests.el index 8e546ad5cc6..488fc1b646f 100644 --- a/test/lisp/progmodes/elixir-ts-mode-tests.el +++ b/test/lisp/progmodes/elixir-ts-mode-tests.el @@ -1,4 +1,4 @@ -;;; c-ts-mode-tests.el --- Tests for Tree-sitter-based C mode -*- lexical-binding: t; -*- +;;; elixir-ts-mode-tests.el --- Tests for elixir-ts-mode -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Free Software Foundation, Inc. diff --git a/test/lisp/progmodes/heex-ts-mode-tests.el b/test/lisp/progmodes/heex-ts-mode-tests.el index b59126e136a..def6d845de9 100644 --- a/test/lisp/progmodes/heex-ts-mode-tests.el +++ b/test/lisp/progmodes/heex-ts-mode-tests.el @@ -1,3 +1,24 @@ +;;; heex-ts-mode-tests.el --- Tests for heex-ts-mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + (require 'ert) (require 'ert-x) (require 'treesit) @@ -7,3 +28,4 @@ heex-ts-mode-test-indentation (ert-test-erts-file (ert-resource-file "indent.erts"))) (provide 'heex-ts-mode-tests) +;;; heex-ts-mode-tests.el ends here commit 1565dbcae35c1e42b22066fde226e3b063614a9e Author: Jim Porter Date: Sat Jan 28 17:04:11 2023 -0800 Simplify usage of 'while' forms in Eshell's iterative evaluation Now, 'eshell-do-eval' rewrites 'while' forms to let-bind variables for the command and test bodies. This means that external code, such as command rewriting hooks, no longer has to worry about this, making it easier to pass "normal" Lisp forms to 'eshell-do-eval' (bug#61954). * lisp/eshell/esh-cmd.el (eshell-command-body, eshell-test-body): No longer used outside of 'eshell-do-eval', so rename to... (eshell--command-body, eshell--test-body): ... these. (Command evaluation macros): Remove obsolete description about 'if' and 'while' forms. (eshell-rewrite-for-command, eshell-structure-basic-command): Remove 'eshell-command-body' and 'eshell-test-body'. (eshell-do-eval): Reimplement handling of 'while' forms. diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 5dbbd770582..93f2616020c 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -494,8 +494,8 @@ eshell-rewrite-named-command (t (list sym (car terms)))))) -(defvar eshell-command-body) -(defvar eshell-test-body) +(defvar eshell--command-body) +(defvar eshell--test-body) (defsubst eshell-invokify-arg (arg &optional share-output silent) "Change ARG so it can be invoked from a structured command. @@ -540,9 +540,7 @@ eshell-rewrite-for-command (if (listp elem) elem `(list ,elem))) - (nthcdr 3 terms)))) - (eshell-command-body '(nil)) - (eshell-test-body '(nil))) + (nthcdr 3 terms))))) (while for-items (let ((,(intern (cadr terms)) (car for-items)) (eshell--local-vars (cons ',(intern (cadr terms)) @@ -579,8 +577,7 @@ eshell-structure-basic-command ;; finally, create the form that represents this structured ;; command - `(let ((eshell-command-body '(nil)) - (eshell-test-body '(nil))) + `(progn (,func ,test ,body ,else) (eshell-close-handles))) @@ -745,10 +742,6 @@ eshell-separate-commands ;; `condition-case', `if', `let', `prog1', `progn', `quote', `setq', ;; `unwind-protect', and `while'. ;; -;; @ When using `while', first let-bind `eshell-test-body' and -;; `eshell-command-body' to '(nil). Eshell uses these variables to -;; handle evaluating its subforms multiple times. -;; ;; @ The two `special' variables are `eshell-current-handles' and ;; `eshell-current-subjob-p'. Bind them locally with a `let' if you ;; need to change them. Change them directly only if your intention @@ -1128,24 +1121,34 @@ eshell-do-eval (let ((args (cdr form))) (cond ((eq (car form) 'while) + ;; Wrap the `while' form with let-bindings for the command and + ;; test bodies. This helps us resume evaluation midway + ;; through the loop. + (let ((new-form (copy-tree `(let ((eshell--command-body nil) + (eshell--test-body nil)) + (eshell--wrapped-while ,@args))))) + (eshell-manipulate "modifying while form" + (setcar form (car new-form)) + (setcdr form (cdr new-form))) + (eshell-do-eval form synchronous-p))) + ((eq (car form) 'eshell--wrapped-while) + (when eshell--command-body + (cl-assert (not synchronous-p)) + (eshell-do-eval eshell--command-body) + (setq eshell--command-body nil + eshell--test-body nil)) ;; `copy-tree' is needed here so that the test argument - ;; doesn't get modified and thus always yield the same result. - (when (car eshell-command-body) - (cl-assert (not synchronous-p)) - (eshell-do-eval (car eshell-command-body)) - (setcar eshell-command-body nil) - (setcar eshell-test-body nil)) - (unless (car eshell-test-body) - (setcar eshell-test-body (copy-tree (car args)))) - (while (cadr (eshell-do-eval (car eshell-test-body) synchronous-p)) - (setcar eshell-command-body - (if (cddr args) - `(progn ,@(copy-tree (cdr args))) - (copy-tree (cadr args)))) - (eshell-do-eval (car eshell-command-body) synchronous-p) - (setcar eshell-command-body nil) - (setcar eshell-test-body (copy-tree (car args)))) - (setcar eshell-command-body nil)) + ;; doesn't get modified and thus always yield the same result. + (unless eshell--test-body + (setq eshell--test-body (copy-tree (car args)))) + (while (cadr (eshell-do-eval eshell--test-body synchronous-p)) + (setq eshell--command-body + (if (cddr args) + `(progn ,@(copy-tree (cdr args))) + (copy-tree (cadr args)))) + (eshell-do-eval eshell--command-body synchronous-p) + (setq eshell--command-body nil + eshell--test-body (copy-tree (car args))))) ((eq (car form) 'if) (eshell-manipulate "evaluating if condition" (setcar args (eshell-do-eval (car args) synchronous-p))) commit e01660ca50ad360db78e5a0206ed824465c2aada Author: Jim Porter Date: Sat Jan 28 15:06:31 2023 -0800 Simplify how Eshell's iterative evaluation handles 'if' forms The previous implementation used 'eshell-test-body' and 'eshell-command-body' to track the condition and the then/else forms, but those special variables are only needed for looping. 'if' only evaluates each form once at most (bug#61954). * lisp/eshell/esh-cmd.el (Command evaluation macros): Remove 'if' from the notes about 'eshell-test-body' and 'eshell-command-body'. (eshell-do-eval): Reimplement evaluation of 'if' forms. (eshell-eval-command): Don't let-bind 'eshell-command-body' and 'eshell-test-body'; they're no longer needed here. diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 2dd8f5d6042..5dbbd770582 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -745,9 +745,9 @@ eshell-separate-commands ;; `condition-case', `if', `let', `prog1', `progn', `quote', `setq', ;; `unwind-protect', and `while'. ;; -;; @ When using `if' or `while', first let-bind `eshell-test-body' and +;; @ When using `while', first let-bind `eshell-test-body' and ;; `eshell-command-body' to '(nil). Eshell uses these variables to -;; handle conditional evaluation. +;; handle evaluating its subforms multiple times. ;; ;; @ The two `special' variables are `eshell-current-handles' and ;; `eshell-current-subjob-p'. Bind them locally with a `let' if you @@ -1031,9 +1031,7 @@ eshell-eval-command ;; We can just stick the new command at the end of the current ;; one, and everything will happen as it should. (setcdr (last (cdr eshell-current-command)) - (list `(let ((here (and (eobp) (point))) - (eshell-command-body '(nil)) - (eshell-test-body '(nil))) + (list `(let ((here (and (eobp) (point)))) ,(and input `(insert-and-inherit ,(concat input "\n"))) (if here @@ -1149,23 +1147,17 @@ eshell-do-eval (setcar eshell-test-body (copy-tree (car args)))) (setcar eshell-command-body nil)) ((eq (car form) 'if) - ;; `copy-tree' is needed here so that the test argument - ;; doesn't get modified and thus always yield the same result. - (if (car eshell-command-body) - (progn - (cl-assert (not synchronous-p)) - (eshell-do-eval (car eshell-command-body))) - (unless (car eshell-test-body) - (setcar eshell-test-body (copy-tree (car args)))) - (setcar eshell-command-body - (copy-tree - (if (cadr (eshell-do-eval (car eshell-test-body) - synchronous-p)) - (cadr args) - (car (cddr args))))) - (eshell-do-eval (car eshell-command-body) synchronous-p)) - (setcar eshell-command-body nil) - (setcar eshell-test-body nil)) + (eshell-manipulate "evaluating if condition" + (setcar args (eshell-do-eval (car args) synchronous-p))) + (eshell-do-eval + (cond + ((eval (car args)) ; COND is non-nil + (cadr args)) + ((cdddr args) ; Multiple ELSE forms + `(progn ,@(cddr args))) + (t ; Zero or one ELSE forms + (caddr args))) + synchronous-p)) ((eq (car form) 'setcar) (setcar (cdr args) (eshell-do-eval (cadr args) synchronous-p)) (eval form)) commit 67a2b320f61642d0cbbce31ac34d4e1ce77c9230 Author: Jim Porter Date: Thu Jan 26 23:18:42 2023 -0800 Simplify iteration in Eshell for loops The previous code fixed an issue in Eshell's iterative evaluation where deferred commands caused an infinite loop (see bug#12571). However, with the fix to unwinding let forms in 'eshell-do-eval' (see bug#59469), we can just write this code as we normally would (bug#61954). * lisp/eshell/esh-cmd.el (eshell-rewrite-for-command): Simplify. diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index d609711402a..2dd8f5d6042 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -533,25 +533,23 @@ eshell-rewrite-for-command (equal (nth 2 terms) "in")) (let ((body (car (last terms)))) (setcdr (last terms 2) nil) - `(let ((for-items - (copy-tree - (append - ,@(mapcar - (lambda (elem) - (if (listp elem) - elem - `(list ,elem))) - (cdr (cddr terms)))))) - (eshell-command-body '(nil)) + `(let ((for-items + (append + ,@(mapcar + (lambda (elem) + (if (listp elem) + elem + `(list ,elem))) + (nthcdr 3 terms)))) + (eshell-command-body '(nil)) (eshell-test-body '(nil))) - (while (car for-items) - (let ((,(intern (cadr terms)) (car for-items)) + (while for-items + (let ((,(intern (cadr terms)) (car for-items)) (eshell--local-vars (cons ',(intern (cadr terms)) - eshell--local-vars))) + eshell--local-vars))) (eshell-protect ,(eshell-invokify-arg body t))) - (setcar for-items (cadr for-items)) - (setcdr for-items (cddr for-items))) + (setq for-items (cdr for-items))) (eshell-close-handles))))) (defun eshell-structure-basic-command (func names keyword test body commit 0330cff65ae837e93ae4d059acf643734d16386d Author: Michael Albinus Date: Thu Mar 16 12:41:13 2023 +0100 Fix regression in Tramp (bug#62194) * lisp/net/tramp.el (tramp-handle-make-process): * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band) (tramp-sh-handle-file-notify-add-watch) (tramp-maybe-open-connection): Don't set process property `shared-socket'. (Bug#62194) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 882b79b3ee7..2f990af334d 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2427,7 +2427,7 @@ tramp-do-copy-or-rename-file-out-of-band ;; This is neded for ssh or PuTTY based processes, and ;; only if the respective options are set. Perhaps, ;; the setting could be more fine-grained. - (process-put p 'shared-socket t) + ;; (process-put p 'shared-socket t) (process-put p 'adjust-window-size-function #'ignore) (set-process-query-on-exit-flag p nil) @@ -3760,7 +3760,7 @@ tramp-sh-handle-file-notify-add-watch ;; This is neded for ssh or PuTTY based processes, and only if ;; the respective options are set. Perhaps, the setting could ;; be more fine-grained. - (process-put p 'shared-socket t) + ;; (process-put p 'shared-socket t) ;; Needed for process filter. (process-put p 'events events) (process-put p 'watch-name localname) @@ -5124,7 +5124,7 @@ tramp-maybe-open-connection ;; This is neded for ssh or PuTTY based processes, and ;; only if the respective options are set. Perhaps, ;; the setting could be more fine-grained. - (process-put p 'shared-socket t) + ;; (process-put p 'shared-socket t) (process-put p 'adjust-window-size-function #'ignore) (set-process-query-on-exit-flag p nil) (setq tramp-current-connection (cons vec (current-time))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index b6e985db6b1..0c8f8acc07d 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -5091,7 +5091,7 @@ tramp-handle-make-process ;; This is neded for ssh or PuTTY based processes, and ;; only if the respective options are set. Perhaps, the ;; setting could be more fine-grained. - (process-put p 'shared-socket t) + ;; (process-put p 'shared-socket t) (process-put p 'remote-command orig-command) (tramp-set-connection-property p "remote-command" orig-command) @@ -5809,6 +5809,7 @@ tramp-accept-process-output ;; There could be other processes which use the same socket for ;; communication. This could block the output for the current ;; process. Read such output first. (Bug#61350) + ;; The process property isn't set anymore due to Bug#62194. (when-let (((process-get proc 'shared-socket)) (v (process-get proc 'vector))) (dolist (p (delq proc (process-list))) commit 997a8dbc48c0bfa366f74c80eb4ecd8871820ce5 Author: Wilhelm H Kirschbaum Date: Mon Mar 13 21:47:50 2023 +0200 Fix elixir-ts-mode.elc warning (bug#62155) * lisp/progmodes/elixir-ts-mode.el: Only require heex-ts-mode once elixir-ts-mode loads to avoid calling (treesit-ready-p 'heex) during byte-compilation. diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index 136275b0f5f..286f3e39f43 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -44,7 +44,6 @@ ;;; Code: (require 'treesit) -(require 'heex-ts-mode) (eval-when-compile (require 'rx)) (declare-function treesit-parser-create "treesit.c") @@ -480,6 +479,10 @@ elixir-ts--treesit-range-rules :host 'elixir '((sigil (sigil_name) @name (:match "^[HF]$" @name) (quoted_content) @heex))))) +(defvar heex-ts--sexp-regexp) +(defvar heex-ts--indent-rules) +(defvar heex-ts--font-lock-settings) + (defun elixir-ts--forward-sexp (&optional arg) "Move forward across one balanced expression (sexp). With ARG, do it many times. Negative ARG means move backward." @@ -566,8 +569,12 @@ elixir-ts-mode (when (treesit-ready-p 'elixir) ;; The HEEx parser has to be created first for elixir to ensure elixir ;; is the first language when looking for treesit ranges. - (if (treesit-ready-p 'heex) - (treesit-parser-create 'heex)) + (when (treesit-ready-p 'heex) + ;; Require heex-ts-mode only when we load elixir-ts-mode + ;; so that we don't get a tree-sitter compilation warning for + ;; elixir-ts-mode. + (require 'heex-ts-mode) + (treesit-parser-create 'heex)) (treesit-parser-create 'elixir) commit a066487a0d47e3f9c2e871b8a27a5f025dba6f84 Author: Michael Albinus Date: Wed Mar 15 18:01:48 2023 +0100 Minor Tramp cleanup * lisp/net/tramp-sh.el (tramp-run-test): Add VEC argument. (tramp-sh-handle-file-executable-p) (tramp-sh-handle-file-readable-p) (tramp-sh-handle-file-directory-p) (tramp-sh-handle-file-writable-p): Adapt callees. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 5227897fbec..882b79b3ee7 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1651,7 +1651,7 @@ tramp-sh-handle-file-executable-p (if (tramp-file-property-p v localname "file-attributes") (or (tramp-check-cached-permissions v ?x) (tramp-check-cached-permissions v ?s)) - (tramp-run-test "-x" filename))))) + (tramp-run-test v "-x" localname))))) (defun tramp-sh-handle-file-readable-p (filename) "Like `file-readable-p' for Tramp files." @@ -1661,7 +1661,7 @@ tramp-sh-handle-file-readable-p ;; satisfied without remote operation. (if (tramp-file-property-p v localname "file-attributes") (tramp-handle-file-readable-p filename) - (tramp-run-test "-r" filename))))) + (tramp-run-test v "-r" localname))))) ;; Functions implemented using the basic functions above. @@ -1682,7 +1682,7 @@ tramp-sh-handle-file-directory-p (tramp-get-file-property v (tramp-file-local-name truename) "file-attributes")) t) - (tramp-run-test "-d" filename)))))) + (tramp-run-test v "-d" localname)))))) (defun tramp-sh-handle-file-writable-p (filename) "Like `file-writable-p' for Tramp files." @@ -1693,7 +1693,7 @@ tramp-sh-handle-file-writable-p ;; Examine `file-attributes' cache to see if request can ;; be satisfied without remote operation. (tramp-check-cached-permissions v ?w) - (tramp-run-test "-w" filename)) + (tramp-run-test v "-w" localname)) ;; If file doesn't exist, check if directory is writable. (and (file-directory-p (file-name-directory filename)) @@ -4020,17 +4020,14 @@ tramp-maybe-send-script (tramp-set-connection-property (tramp-get-connection-process vec) "scripts" (cons name scripts)))))) -(defun tramp-run-test (switch filename) - "Run `test' on the remote system, given a SWITCH and a FILENAME. +(defun tramp-run-test (vec switch localname) + "Run `test' on the remote system VEC, given a SWITCH and a LOCALNAME. Returns the exit code of the `test' program." - (with-parsed-tramp-file-name filename nil - (tramp-send-command-and-check - v - (format - "%s %s %s" - (tramp-get-test-command v) - switch - (tramp-shell-quote-argument localname))))) + (tramp-send-command-and-check + vec + (format + "%s %s %s" + (tramp-get-test-command vec) switch (tramp-shell-quote-argument localname)))) (defun tramp-find-executable (vec progname dirlist &optional ignore-tilde ignore-path) commit 146389f873e4e41940127c1ccb5df3f9cf357060 Author: Philip Kaludercic Date: Wed Mar 15 16:47:48 2023 +0100 Always display the "Archive" column in the package list * lisp/emacs-lisp/package.el (package-menu-mode): Always display column. (package-menu--print-info-simple): Always provide column information. Since NonGNU ELPA has been added to the default value of 'package-archives', this condition is practically never satisfied, meaning the code can be simplified. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index a0bb5e75393..0258ed52bee 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -3083,8 +3083,7 @@ package-menu-mode `[("Package" ,package-name-column-width package-menu--name-predicate) ("Version" ,package-version-column-width package-menu--version-predicate) ("Status" ,package-status-column-width package-menu--status-predicate) - ,@(if (cdr package-archives) - `(("Archive" ,package-archive-column-width package-menu--archive-predicate))) + ("Archive" ,package-archive-column-width package-menu--archive-predicate) ("Description" 0 package-menu--description-predicate)]) (setq tabulated-list-padding 2) (setq tabulated-list-sort-key (cons "Status" nil)) @@ -3512,9 +3511,8 @@ package-menu--print-info-simple (package-desc-version pkg))) 'font-lock-face face) ,(propertize status 'font-lock-face face) - ,@(if (cdr package-archives) - (list (propertize (or (package-desc-archive pkg) "") - 'font-lock-face face))) + ,(propertize (or (package-desc-archive pkg) "") + 'font-lock-face face) ,(propertize (package-desc-summary pkg) 'font-lock-face 'package-description)]))) commit 67a660eb13818a620b301775065c4819a2178428 Author: Mattias Engdegård Date: Wed Mar 15 12:43:18 2023 +0100 ; * lisp/progmodes/elixir-ts-mode.el: remove duplicates from regexp diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index 8adf647b081..136275b0f5f 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -87,7 +87,7 @@ elixir-ts-font-sigil-name-face (defconst elixir-ts--sexp-regexp (rx bol (or "call" "stab_clause" "binary_operator" "list" "tuple" "map" "pair" - "sigil" "string" "atom" "pair" "alias" "arguments" "atom" "identifier" + "sigil" "string" "atom" "alias" "arguments" "identifier" "boolean" "quoted_content") eol)) commit 0fdc953edf7cfd0fe236b6b6e5726e4e58d9a94f Author: João Távora Date: Wed Mar 15 10:27:24 2023 +0000 Unbreak Eglot (as a :core ELPA package) on Emacs 26.3 Because of the lack of regular automated testing on a CI system, many recent developments in and outside Eglot had wrecked this compatibility. The GitHub CI available at https://github.com/joaotavora/eglot/actions can be used to run this combination of eglot.el + eglot-tests.el on 26.3, 27.2 and 28.2. * etc/EGLOT-NEWS: Mention new version. * lisp/progmodes/eglot.el (eglot--reporter-update): New compatibility shim. (eglot-handle-notification $/progress): Use it. (eglot-handle-notification textDocument/publishDiagnostics): Use two-arg assoc-delete-all. (Version): Bump to 1.13. * test/lisp/progmodes/eglot-tests.el (Commentary): Tweak. (tramp): Tweak require; (eglot-test-diagnostic-tags-unnecessary-code): Use jsonrpc--encode. (eglot--call-with-tramp-test): Adjust dependency on ert-remote-temporary-file-directory. (eglot-test-rust-on-type-formatting) (eglot-test-project-wide-diagnostics-rust-analyzer): Wait longer. diff --git a/etc/EGLOT-NEWS b/etc/EGLOT-NEWS index dc77e4fe624..dd04e677285 100644 --- a/etc/EGLOT-NEWS +++ b/etc/EGLOT-NEWS @@ -12,11 +12,16 @@ This file is about changes in Eglot, the Emacs client for LSP (Language Server Protocol) distributed with GNU Emacs since Emacs version 29.1 and with GNU ELPA since 2018. -Note: references to Eglot issues are presented as "github#nnnn". -This refers to https://github.com/joaotavora/eglot/issues/. -That is, to look up issue github#1234, go to +Note: references to some Eglot issues are presented as "github#nnnn". +This refers to https://github.com/joaotavora/eglot/issues/. That is, +to look up issue github#1234, go to https://github.com/joaotavora/eglot/issues/1234. + +* Changes in Eglot 1.13 (15/03/2023) + +** ELPA installations on Emacs 26.3 are supported again. + * Changes in Eglot 1.12 (13/03/2023) @@ -328,7 +333,7 @@ This disconnects the server after last managed buffer is killed. (github#217, github#270) -** Completion support support has been fixed. +** Completion support has been fixed. Among other things, consider LSP's "filterText" cookies, which enable a kind of poor-man's flex-matching for some backends. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 037cc87148f..6c1b9eafe43 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2018-2023 Free Software Foundation, Inc. -;; Version: 1.12 +;; Version: 1.13 ;; Author: João Távora ;; Maintainer: João Távora ;; URL: https://github.com/joaotavora/eglot @@ -2147,6 +2147,10 @@ eglot-handle-notification (_server (_method (eql telemetry/event)) &rest _any) "Handle notification telemetry/event.") ;; noop, use events buffer +(defalias 'eglot--reporter-update + (if (> emacs-major-version 26) #'progress-reporter-update + (lambda (a b &optional _c) (progress-reporter-update a b)))) + (cl-defmethod eglot-handle-notification (server (_method (eql $/progress)) &key token value) "Handle $/progress notification identified by TOKEN from SERVER." @@ -2162,10 +2166,10 @@ eglot-handle-notification (make-progress-reporter prefix 0 100 percentage 1 0) (make-progress-reporter prefix nil nil nil 1 0)) (eglot--progress-reporters server)))) - (progress-reporter-update pr percentage (fmt title message)))) + (eglot--reporter-update pr percentage (fmt title message)))) ("report" (when-let ((pr (gethash token (eglot--progress-reporters server)))) - (progress-reporter-update pr percentage (fmt title message)))) + (eglot--reporter-update pr percentage (fmt title message)))) ("end" (remhash token (eglot--progress-reporters server)))))))) (cl-defmethod eglot-handle-notification @@ -2183,7 +2187,7 @@ eglot-handle-notification (buffer (find-buffer-visiting path))) (with-current-buffer buffer (cl-loop - initially (assoc-delete-all path flymake-list-only-diagnostics #'string=) + initially (assoc-delete-all path flymake-list-only-diagnostics) for diag-spec across diagnostics collect (eglot--dbind ((Diagnostic) range code message severity source tags) diag-spec @@ -2237,7 +2241,7 @@ eglot-handle-notification into diags finally (setq flymake-list-only-diagnostics - (assoc-delete-all path flymake-list-only-diagnostics #'string=)) + (assoc-delete-all path flymake-list-only-diagnostics)) (push (cons path diags) flymake-list-only-diagnostics))))) (cl-defun eglot--register-unregister (server things how) diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index b95e527c510..7ac26732737 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el @@ -31,23 +31,20 @@ ;; Some of these tests rely on the GNU ELPA package company.el and ;; yasnippet.el being available. -;; Some of the tests require access to a remote host files. Since -;; this could be problematic, a mock-up connection method "mock" is -;; used. Emulating a remote connection, it simply calls "sh -i". -;; Tramp's file name handlers still run, so this test is sufficient -;; except for connection establishing. - -;; If you want to test a real Tramp connection, set -;; $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable value in order to -;; overwrite the default value. If you want to skip tests accessing a -;; remote host, set this environment variable to "/dev/null" or -;; whatever is appropriate on your system. +;; Some of the tests require access to a remote host files, which is +;; mocked in the simplest case. If you want to test a real Tramp +;; connection, override $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable +;; value (FIXME: like what?) in order to overwrite the default value. +;; +;; IMPORTANT: Since Eglot is a :core ELPA package, these tests are + ;;supposed to run on Emacsen down to 26.3. Do not use bleeding-edge + ;;functionality not compatible with that Emacs version. ;;; Code: (require 'eglot) (require 'cl-lib) (require 'ert) -(require 'tramp) ; must be prior ert-x +(require 'tramp) (require 'ert-x) ; ert-simulate-command (require 'edebug) (require 'python) ; some tests use pylsp @@ -463,7 +460,7 @@ eglot-test-diagnostic-tags-unnecessary-code (eglot--make-file-or-dir '(".git")) (eglot--make-file-or-dir `("compile_commands.json" . - ,(json-serialize + ,(jsonrpc--json-encode `[(:directory ,default-directory :command "/usr/bin/c++ -Wall -c main.cpp" :file ,(expand-file-name "main.cpp"))]))) (let ((eglot-server-programs '((c++-mode . ("clangd"))))) @@ -744,7 +741,7 @@ eglot-test-rust-on-type-formatting (should (zerop (shell-command "cargo init"))) (eglot--sniffing (:server-notifications s-notifs) (should (eglot--tests-connect)) - (eglot--wait-for (s-notifs 10) (&key method &allow-other-keys) + (eglot--wait-for (s-notifs 20) (&key method &allow-other-keys) (string= method "textDocument/publishDiagnostics"))) (goto-char (point-max)) (eglot--simulate-key-event ?.) @@ -810,7 +807,7 @@ eglot-test-project-wide-diagnostics-typescript (should (= 4 (length (flymake--project-diagnostics)))))))))) (ert-deftest eglot-test-project-wide-diagnostics-rust-analyzer () - "Test diagnostics through multiple files in a TypeScript LSP." + "Test diagnostics through multiple files in rust-analyzer." (skip-unless (executable-find "rust-analyzer")) (skip-unless (executable-find "cargo")) (skip-unless (executable-find "git")) @@ -829,7 +826,7 @@ eglot-test-project-wide-diagnostics-rust-analyzer (eglot--sniffing (:server-notifications s-notifs) (eglot--tests-connect) (flymake-start) - (eglot--wait-for (s-notifs 15) + (eglot--wait-for (s-notifs 20) (&key _id method params &allow-other-keys) (and (string= method "textDocument/publishDiagnostics") (string-suffix-p "main.rs" (plist-get params :uri)))) @@ -1272,18 +1269,28 @@ eglot-test-glob-test (defvar tramp-histfile-override) (defun eglot--call-with-tramp-test (fn) + (unless (>= emacs-major-version 27) + (ert-skip "Eglot Tramp support only on Emacs >= 27")) ;; Set up a Tramp method that’s just a shell so the remote host is ;; really just the local host. - (let* ((tramp-remote-path (cons 'tramp-own-remote-path tramp-remote-path)) + (let* ((tramp-remote-path (cons 'tramp-own-remote-path + tramp-remote-path)) (tramp-histfile-override t) (tramp-verbose 1) (temporary-file-directory (or (bound-and-true-p ert-remote-temporary-file-directory) - temporary-file-directory)) + (prog1 (format "/mock::%s" temporary-file-directory) + (add-to-list + 'tramp-methods + '("mock" + (tramp-login-program "sh") (tramp-login-args (("-i"))) + (tramp-direct-async ("-c")) (tramp-remote-shell "/bin/sh") + (tramp-remote-shell-args ("-c")) (tramp-connection-timeout 10))) + (add-to-list 'tramp-default-host-alist + `("\\`mock\\'" nil ,(system-name))) + (when (and noninteractive (not (file-directory-p "~/"))) + (setenv "HOME" temporary-file-directory))))) (default-directory temporary-file-directory)) - ;; We must check the remote LSP server. So far, just "clangd" is used. - (unless (executable-find "clangd" 'remote) - (ert-skip "Remote clangd not found")) (funcall fn))) (ert-deftest eglot-test-tramp-test ()