commit dcc564415252c97f92c9a3afe306d515b0f0fd8c (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Thu Dec 22 22:40:23 2022 -0800 Leap seconds are planned to go away by the year 2035. diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi index 89a340e7343..ef9990c057a 100644 --- a/doc/misc/calc.texi +++ b/doc/misc/calc.texi @@ -11040,7 +11040,8 @@ Date Forms have Calc's date forms switch from the Julian to Gregorian calendar at any specified date. -Today's timekeepers introduce an occasional ``leap second''. +A few platforms support leap seconds, such as the time stamp +1972-06-30 23:59:60 UTC, an extra second appended to June 1972. These do not occur regularly and Calc does not take these minor effects into account. (If it did, it would have to report a non-integer number of days between, say, commit 6d5d693b2388fe65d10b2c41193d8312ae5134cf Merge: 99feed933ac 5a34e7c86ca Author: Stefan Kangas Date: Fri Dec 23 06:30:12 2022 +0100 ; Merge from origin/emacs-29 The following commits were skipped: 5a34e7c86ca ; * admin/notes/git-workflow: Adding "Backport:" is optio... baaa9f42e57 vc-git-checkin: Don't try to apply an empty patch commit 99feed933ac8b8a3384eeb40254ef2e2de4f31de Merge: 17bf6a829ca 0754173c923 Author: Stefan Kangas Date: Fri Dec 23 06:30:12 2022 +0100 Merge from origin/emacs-29 0754173c923 ; Fix docstring 014232d3840 Eglot: eglot--servers-by-xrefed-file doesn't need to be v... bbe35c280c2 Prevent stale servers when using eglot-extend-to-xref 9bf13a3fb9e ; * src/alloc.c (Fmemory_info): Doc fix. baa33a5c054 * etc/tutorials/TUTORIAL.cn: Fix typos. (Bug#60221) 98d7f76b451 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... a488a6870ac Add alias for removed font-lock function 02e046566e2 Set beginning/end-of-defun-function in treesit-major-mode... 7dea58b88db Add treesit-defun-at-point and fix c-ts-mode-indent-defun 69123d4aa4e ; Fix treesit--defuns-around 05d8310fb5d Use the new keyword ':repeat' in repeatable keymaps. commit 5a34e7c86ca1bfd5bc6ae362ae25c02d21ec0315 (refs/remotes/origin/emacs-29) Author: Sean Whitton Date: Thu Dec 22 13:38:48 2022 -0700 ; * admin/notes/git-workflow: Adding "Backport:" is optional. diff --git a/admin/notes/git-workflow b/admin/notes/git-workflow index 265a106bad5..717fc550776 100644 --- a/admin/notes/git-workflow +++ b/admin/notes/git-workflow @@ -70,7 +70,7 @@ commit 958b768a6534ae6e77a8547a56fc31b46b63710b cd ~/emacs/emacs-28 git cherry-pick -xe 958b768a6534ae6e77a8547a56fc31b46b63710b -and add "Backport:" to the commit string. Then +and optionally add "Backport:" to the commit string. Then git push commit baaa9f42e574aa5eceeb4b9354a42ccb8ff1969a Author: Sean Whitton Date: Tue Dec 20 15:53:19 2022 -0700 vc-git-checkin: Don't try to apply an empty patch * lisp/vc/vc-git.el (vc-git-checkin): Don't try to apply an empty patch to the index, because in that case 'git apply' fails. (cherry picked from commit 1424342225ef5b18c630364dd88e004f4ebb1c7f) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index b5959d535c0..afaaa44e908 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1041,12 +1041,13 @@ vc-git-checkin (string-replace file-diff "" vc-git-patch-string)) (user-error "Index not empty")) (setq pos (point)))))) - (let ((patch-file (make-nearby-temp-file "git-patch"))) - (with-temp-file patch-file - (insert vc-git-patch-string)) - (unwind-protect - (vc-git-command nil 0 patch-file "apply" "--cached") - (delete-file patch-file)))) + (unless (string-empty-p vc-git-patch-string) + (let ((patch-file (make-nearby-temp-file "git-patch"))) + (with-temp-file patch-file + (insert vc-git-patch-string)) + (unwind-protect + (vc-git-command nil 0 patch-file "apply" "--cached") + (delete-file patch-file))))) (cl-flet ((boolean-arg-fn (argument) (lambda (value) (when (equal value "yes") (list argument))))) commit 17bf6a829ca2fd2920c01e1aee30ab16b9c672eb Author: Jim Porter Date: Tue Dec 20 13:47:20 2022 -0800 Simplify handling of /dev/null redirection in Eshell This also fixes an issue where "echo hi > foo > /dev/null" didn't write to the file "foo". (Note that users can still use their system's null device name when redirecting; Eshell doesn't need to do anything special to support that.) * lisp/eshell/esh-io.el (eshell-virtual-targets): Add "/dev/null". (eshell-set-output-handle): Handle 'eshell-null-device'. * test/lisp/eshell/esh-io-tests.el (esh-io-test/redirect-subcommands/dev-null) (esh-io-test/virtual/dev-null, esh-io-test/virtual/dev-null/multiple): New tests. diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 58084db28a8..f2bc87374c1 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -116,16 +116,22 @@ eshell-print-queue-size :group 'eshell-io) (defcustom eshell-virtual-targets - '(("/dev/eshell" eshell-interactive-print nil) + '(;; The literal string "/dev/null" is intentional here. It just + ;; provides compatibility so that users can redirect to + ;; "/dev/null" no matter the actual value of `null-device'. + ("/dev/null" (lambda (_mode) (throw 'eshell-null-device t)) t) + ("/dev/eshell" eshell-interactive-print nil) ("/dev/kill" (lambda (mode) - (if (eq mode 'overwrite) - (kill-new "")) - 'eshell-kill-append) t) + (when (eq mode 'overwrite) + (kill-new "")) + #'eshell-kill-append) + t) ("/dev/clip" (lambda (mode) - (if (eq mode 'overwrite) - (let ((select-enable-clipboard t)) - (kill-new ""))) - 'eshell-clipboard-append) t)) + (when (eq mode 'overwrite) + (let ((select-enable-clipboard t)) + (kill-new ""))) + #'eshell-clipboard-append) + t)) "Map virtual devices name to Emacs Lisp functions. If the user specifies any of the filenames above as a redirection target, the function in the second element will be called. @@ -138,10 +144,8 @@ eshell-virtual-targets The output function is then called repeatedly with single strings, which represents successive pieces of the output of the command, until nil -is passed, meaning EOF. - -NOTE: /dev/null is handled specially as a virtual target, and should -not be added to this variable." +is passed, meaning EOF." + :version "30.1" :type '(repeat (list (string :tag "Target") function @@ -357,21 +361,17 @@ eshell-set-output-handle "Set handle INDEX for the current HANDLES to point to TARGET using MODE. If HANDLES is nil, use `eshell-current-handles'." (when target - (let ((handles (or handles eshell-current-handles))) - (if (and (stringp target) - (string= target (null-device))) - (aset handles index nil) - (let* ((where (eshell-get-target target mode)) - (handle (or (aref handles index) - (aset handles index (list nil nil 1)))) - (current (car handle)) - (defaultp (cadr handle))) - (if (not defaultp) - (unless (member where current) - (setq current (append current (list where)))) - (setq current (list where))) - (setcar handle current) - (setcar (cdr handle) nil)))))) + (let* ((handles (or handles eshell-current-handles)) + (handle (or (aref handles index) + (aset handles index (list nil nil 1)))) + (defaultp (cadr handle)) + (current (unless defaultp (car handle)))) + (catch 'eshell-null-device + (let ((where (eshell-get-target target mode))) + (unless (member where current) + (setq current (append current (list where)))))) + (setcar handle current) + (setcar (cdr handle) nil)))) (defun eshell-copy-output-handle (index index-to-copy &optional handles) "Copy the handle INDEX-TO-COPY to INDEX for the current HANDLES. diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index ccf8ac1b9a1..9a3c14f365f 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el @@ -166,6 +166,17 @@ esh-io-test/redirect-subcommands/override (should (equal (buffer-string) "bar"))) (should (equal (buffer-string) "foobaz")))) +(ert-deftest esh-io-test/redirect-subcommands/dev-null () + "Check that redirecting subcommands applies to all subcommands. +Include a redirect to /dev/null to ensure it only applies to its +statement." + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-insert-command + (format "{echo foo; echo bar > /dev/null; echo baz} > #<%s>" + bufname))) + (should (equal (buffer-string) "foobaz")))) + (ert-deftest esh-io-test/redirect-subcommands/interpolated () "Check that redirecting interpolated subcommands applies to all subcommands." (eshell-with-temp-buffer bufname "old" @@ -302,12 +313,30 @@ esh-io-test/redirect-pipe ;; Virtual targets -(ert-deftest esh-io-test/virtual-dev-eshell () +(ert-deftest esh-io-test/virtual/dev-null () + "Check that redirecting to /dev/null works." + (with-temp-eshell + (eshell-match-command-output "echo hi > /dev/null" "\\`\\'"))) + +(ert-deftest esh-io-test/virtual/dev-null/multiple () + "Check that redirecting to /dev/null works alongside other redirections." + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-match-command-output + (format "echo new > /dev/null > #<%s>" bufname) "\\`\\'")) + (should (equal (buffer-string) "new"))) + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-match-command-output + (format "echo new > #<%s> > /dev/null" bufname) "\\`\\'")) + (should (equal (buffer-string) "new")))) + +(ert-deftest esh-io-test/virtual/dev-eshell () "Check that redirecting to /dev/eshell works." (with-temp-eshell (eshell-match-command-output "echo hi > /dev/eshell" "hi"))) -(ert-deftest esh-io-test/virtual-dev-kill () +(ert-deftest esh-io-test/virtual/dev-kill () "Check that redirecting to /dev/kill works." (with-temp-eshell (eshell-insert-command "echo one > /dev/kill") commit 6defbd65b664b17ad7389a936743debe23d5257e Author: Jim Porter Date: Tue Dec 20 09:39:07 2022 -0800 Fix handling of output handles in nested Eshell forms Previously, the output handles in nested forms would be reset to the default, leading to wrong behavior for commands like {echo a; echo b} > file "b" would be written to "file" as expected, but "a" would go to standard output (bug#59545). * lisp/eshell/esh-cmd.el (eshell-parse-command): Use 'eshell-with-copied-handles' for each statement within the whole Eshell command. * test/lisp/eshell/esh-io-tests.el (esh-io-test/redirect-subcommands) (esh-io-test/redirect-subcommands/override) (esh-io-test/redirect-subcommands/interpolated): New tests. * test/lisp/eshell/em-script-tests.el (em-script-test/source-script/redirect) (em-script-test/source-script/redirect/dev-null): New tests. (em-script-test/source-script, em-script-test/source-script/arg-vars) (em-script-test/source-script/all-args-var): Tweak names/docstrings. * test/lisp/eshell/em-extpipe-tests.el (em-extpipe-tests--deftest): Skip over the newly-added 'eshell-with-copied-handles' form when checking the parse results. * test/lisp/eshell/em-tramp-tests.el (em-tramp-test/su-default) (em-tramp-test/su-user, em-tramp-test/su-login) (em-tramp-test/sudo-shell, em-tramp-test/sudo-user-shell) (em-tramp-test/doas-shell, em-tramp-test/doas-user-shell): Update expected command forms. diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index f9796d69a9a..118ee80acb9 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi @@ -2162,11 +2162,6 @@ Bugs and ideas @item Allow all Eshell buffers to share the same history and list-dir -@item There is a problem with script commands that output to @file{/dev/null} - -If a script file, somewhere in the middle, uses @samp{> /dev/null}, -output from all subsequent commands is swallowed. - @item Split up parsing of text after @samp{$} in @file{esh-var.el} Make it similar to the way that @file{esh-arg.el} is structured. diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 03388236b06..79957aeb416 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -418,8 +418,12 @@ eshell-parse-command (eshell-separate-commands terms "[&;]" nil 'eshell--sep-terms)))) (let ((cmd commands)) (while cmd - (if (cdr cmd) - (setcar cmd `(eshell-commands ,(car cmd)))) + ;; Copy I/O handles so each full statement can manipulate them + ;; if they like. As a small optimization, skip this for the + ;; last top-level one; we won't use these handles again + ;; anyway. + (when (or (not toplevel) (cdr cmd)) + (setcar cmd `(eshell-with-copied-handles ,(car cmd)))) (setq cmd (cdr cmd)))) (if toplevel `(eshell-commands (progn diff --git a/test/lisp/eshell/em-extpipe-tests.el b/test/lisp/eshell/em-extpipe-tests.el index 04e78279427..a2646a0296b 100644 --- a/test/lisp/eshell/em-extpipe-tests.el +++ b/test/lisp/eshell/em-extpipe-tests.el @@ -42,7 +42,7 @@ em-extpipe-tests--deftest (shell-command-switch "-c")) ;; Strip `eshell-trap-errors'. (should (equal ,expected - (cadr (eshell-parse-command input)))))) + (cadadr (eshell-parse-command input)))))) (with-substitute-for-temp (&rest body) ;; Substitute name of an actual temporary file and/or ;; buffer into `input'. The substitution logic is diff --git a/test/lisp/eshell/em-script-tests.el b/test/lisp/eshell/em-script-tests.el index b837d464ccd..f720f697c67 100644 --- a/test/lisp/eshell/em-script-tests.el +++ b/test/lisp/eshell/em-script-tests.el @@ -35,21 +35,43 @@ ;;; Tests: (ert-deftest em-script-test/source-script () - "Test sourcing script with no argumentss" + "Test sourcing a simple script." (ert-with-temp-file temp-file :text "echo hi" (with-temp-eshell (eshell-match-command-output (format "source %s" temp-file) "hi\n")))) -(ert-deftest em-script-test/source-script-arg-vars () - "Test sourcing script with $0, $1, ... variables" +(ert-deftest em-script-test/source-script/redirect () + "Test sourcing a script and redirecting its output." + (ert-with-temp-file temp-file + :text "echo hi\necho bye" + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-match-command-output + (format "source %s > #<%s>" temp-file bufname) + "\\`\\'")) + (should (equal (buffer-string) "hibye"))))) + +(ert-deftest em-script-test/source-script/redirect/dev-null () + "Test sourcing a script and redirecting its output, including to /dev/null." + (ert-with-temp-file temp-file + :text "echo hi\necho bad > /dev/null\necho bye" + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-match-command-output + (format "source %s > #<%s>" temp-file bufname) + "\\`\\'")) + (should (equal (buffer-string) "hibye"))))) + +(ert-deftest em-script-test/source-script/arg-vars () + "Test sourcing script with $0, $1, ... variables." (ert-with-temp-file temp-file :text "printnl $0 \"$1 $2\"" (with-temp-eshell (eshell-match-command-output (format "source %s one two" temp-file) (format "%s\none two\n" temp-file))))) -(ert-deftest em-script-test/source-script-all-args-var () - "Test sourcing script with the $* variable" +(ert-deftest em-script-test/source-script/all-args-var () + "Test sourcing script with the $* variable." (ert-with-temp-file temp-file :text "printnl $*" (with-temp-eshell (eshell-match-command-output (format "source %s" temp-file) diff --git a/test/lisp/eshell/em-tramp-tests.el b/test/lisp/eshell/em-tramp-tests.el index 6cc35ecdb1b..982a1eba279 100644 --- a/test/lisp/eshell/em-tramp-tests.el +++ b/test/lisp/eshell/em-tramp-tests.el @@ -27,21 +27,23 @@ em-tramp-test/su-default "Test Eshell `su' command with no arguments." (should (equal (catch 'eshell-replace-command (eshell/su)) - `(eshell-trap-errors - (eshell-named-command - "cd" - (list ,(format "/su:root@%s:%s" - tramp-default-host default-directory))))))) + `(eshell-with-copied-handles + (eshell-trap-errors + (eshell-named-command + "cd" + (list ,(format "/su:root@%s:%s" + tramp-default-host default-directory)))))))) (ert-deftest em-tramp-test/su-user () "Test Eshell `su' command with USER argument." (should (equal (catch 'eshell-replace-command (eshell/su "USER")) - `(eshell-trap-errors - (eshell-named-command - "cd" - (list ,(format "/su:USER@%s:%s" - tramp-default-host default-directory))))))) + `(eshell-with-copied-handles + (eshell-trap-errors + (eshell-named-command + "cd" + (list ,(format "/su:USER@%s:%s" + tramp-default-host default-directory)))))))) (ert-deftest em-tramp-test/su-login () "Test Eshell `su' command with -/-l/--login option." @@ -50,10 +52,11 @@ em-tramp-test/su-login ("-"))) (should (equal (catch 'eshell-replace-command (apply #'eshell/su args)) - `(eshell-trap-errors - (eshell-named-command - "cd" - (list ,(format "/su:root@%s:~/" tramp-default-host)))))))) + `(eshell-with-copied-handles + (eshell-trap-errors + (eshell-named-command + "cd" + (list ,(format "/su:root@%s:~/" tramp-default-host))))))))) (defun mock-eshell-named-command (&rest args) "Dummy function to test Eshell `sudo' command rewriting." @@ -91,21 +94,23 @@ em-tramp-test/sudo-shell ("-s"))) (should (equal (catch 'eshell-replace-command (apply #'eshell/sudo args)) - `(eshell-trap-errors - (eshell-named-command - "cd" - (list ,(format "/sudo:root@%s:%s" - tramp-default-host default-directory)))))))) + `(eshell-with-copied-handles + (eshell-trap-errors + (eshell-named-command + "cd" + (list ,(format "/sudo:root@%s:%s" + tramp-default-host default-directory))))))))) (ert-deftest em-tramp-test/sudo-user-shell () "Test Eshell `sudo' command with -s and -u options." (should (equal (catch 'eshell-replace-command (eshell/sudo "-u" "USER" "-s")) - `(eshell-trap-errors - (eshell-named-command - "cd" - (list ,(format "/sudo:USER@%s:%s" - tramp-default-host default-directory))))))) + `(eshell-with-copied-handles + (eshell-trap-errors + (eshell-named-command + "cd" + (list ,(format "/sudo:USER@%s:%s" + tramp-default-host default-directory)))))))) (ert-deftest em-tramp-test/doas-basic () "Test Eshell `doas' command with default user." @@ -144,20 +149,22 @@ em-tramp-test/doas-shell ("-s"))) (should (equal (catch 'eshell-replace-command (apply #'eshell/doas args)) - `(eshell-trap-errors - (eshell-named-command - "cd" - (list ,(format "/doas:root@%s:%s" - tramp-default-host default-directory)))))))) + `(eshell-with-copied-handles + (eshell-trap-errors + (eshell-named-command + "cd" + (list ,(format "/doas:root@%s:%s" + tramp-default-host default-directory))))))))) (ert-deftest em-tramp-test/doas-user-shell () "Test Eshell `doas' command with -s and -u options." (should (equal (catch 'eshell-replace-command (eshell/doas "-u" "USER" "-s")) - `(eshell-trap-errors - (eshell-named-command - "cd" - (list ,(format "/doas:USER@%s:%s" - tramp-default-host default-directory))))))) + `(eshell-with-copied-handles + (eshell-trap-errors + (eshell-named-command + "cd" + (list ,(format "/doas:USER@%s:%s" + tramp-default-host default-directory)))))))) ;;; em-tramp-tests.el ends here diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index 37b234eaf06..ccf8ac1b9a1 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el @@ -146,6 +146,34 @@ esh-io-test/redirect-multiple/repeat (should (equal (buffer-string) "new")) (should (equal eshell-test-value "new"))))) +(ert-deftest esh-io-test/redirect-subcommands () + "Check that redirecting subcommands applies to all subcommands." + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-insert-command (format "{echo foo; echo bar} > #<%s>" bufname))) + (should (equal (buffer-string) "foobar")))) + +(ert-deftest esh-io-test/redirect-subcommands/override () + "Check that redirecting subcommands applies to all subcommands. +Include a redirect to another location in the subcommand to +ensure only its statement is redirected." + (eshell-with-temp-buffer bufname "old" + (eshell-with-temp-buffer bufname-2 "also old" + (with-temp-eshell + (eshell-insert-command + (format "{echo foo; echo bar > #<%s>; echo baz} > #<%s>" + bufname-2 bufname))) + (should (equal (buffer-string) "bar"))) + (should (equal (buffer-string) "foobaz")))) + +(ert-deftest esh-io-test/redirect-subcommands/interpolated () + "Check that redirecting interpolated subcommands applies to all subcommands." + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-insert-command + (format "echo ${echo foo; echo bar} > #<%s>" bufname))) + (should (equal (buffer-string) "foobar")))) + ;; Redirecting specific handles commit 54087e84df872c9aa30866b880e8ac0b917cbd94 Author: Jim Porter Date: Mon Dec 19 22:21:10 2022 -0800 Add 'eshell-duplicate-handles' to return a copy of file handles * lisp/eshell/esh-io.el (eshell-create-handles): Support creating with multiple targets for stdout and/or stderr. Make the targets for a handle always be a list, and store whether the targets are the default in a separate 'default' field. (eshell-protect-handles, eshell-close-handles) (eshell-copy-output-handle, eshell-interactive-output-p) (eshell-output-object): Update for changes in 'eshell-create-handles'. (eshell-duplicate-handles, eshell-get-targets): New functions. * lisp/eshell/esh-cmd.el (eshell-copy-handles): Rename and alias to... (eshell-with-copied-handles): ... this function, and use 'eshell-duplicate-handles'. (eshell-execute-pipeline): Use 'eshell-duplicate-handles'. diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 1fb84991120..03388236b06 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -788,16 +788,15 @@ eshell-trap-errors (defvar eshell-output-handle) ;Defined in esh-io.el. (defvar eshell-error-handle) ;Defined in esh-io.el. -(defmacro eshell-copy-handles (object) +(defmacro eshell-with-copied-handles (object) "Duplicate current I/O handles, so OBJECT works with its own copy." `(let ((eshell-current-handles - (eshell-create-handles - (car (aref eshell-current-handles - eshell-output-handle)) nil - (car (aref eshell-current-handles - eshell-error-handle)) nil))) + (eshell-duplicate-handles eshell-current-handles))) ,object)) +(define-obsolete-function-alias 'eshell-copy-handles + #'eshell-with-copied-handles "30.1") + (defmacro eshell-protect (object) "Protect I/O handles, so they aren't get closed after eval'ing OBJECT." `(progn @@ -808,7 +807,7 @@ eshell-do-pipelines "Execute the commands in PIPELINE, connecting each to one another. This macro calls itself recursively, with NOTFIRST non-nil." (when (setq pipeline (cadr pipeline)) - `(eshell-copy-handles + `(eshell-with-copied-handles (progn ,(when (cdr pipeline) `(let ((nextproc @@ -880,11 +879,8 @@ eshell-execute-pipeline (progn ,(if (fboundp 'make-process) `(eshell-do-pipelines ,pipeline) - `(let ((tail-handles (eshell-create-handles - (car (aref eshell-current-handles - ,eshell-output-handle)) nil - (car (aref eshell-current-handles - ,eshell-error-handle)) nil))) + `(let ((tail-handles (eshell-duplicate-handles + eshell-current-handles))) (eshell-do-pipelines-synchronously ,pipeline))) (eshell-process-identity (cons (symbol-value headproc) (symbol-value tailproc)))))) diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 4620565f857..58084db28a8 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -291,25 +291,42 @@ eshell--apply-redirections (defun eshell-create-handles (stdout output-mode &optional stderr error-mode) "Create a new set of file handles for a command. -The default location for standard output and standard error will go to -STDOUT and STDERR, respectively. -OUTPUT-MODE and ERROR-MODE are either `overwrite', `append' or `insert'; -a nil value of mode defaults to `insert'." +The default target for standard output and standard error will +go to STDOUT and STDERR, respectively. OUTPUT-MODE and +ERROR-MODE are either `overwrite', `append' or `insert'; a nil +value of mode defaults to `insert'. + +The result is a vector of file handles. Each handle is of the form: + + (TARGETS DEFAULT REF-COUNT) + +TARGETS is a list of destinations for output. DEFAULT is non-nil +if handle has its initial default value (always t after calling +this function). REF-COUNT is the number of references to this +handle (initially 1); see `eshell-protect-handles' and +`eshell-close-handles'." (let* ((handles (make-vector eshell-number-of-handles nil)) - (output-target (eshell-get-target stdout output-mode)) + (output-target (eshell-get-targets stdout output-mode)) (error-target (if stderr - (eshell-get-target stderr error-mode) + (eshell-get-targets stderr error-mode) output-target))) - (aset handles eshell-output-handle (cons output-target 1)) - (aset handles eshell-error-handle (cons error-target 1)) + (aset handles eshell-output-handle (list output-target t 1)) + (aset handles eshell-error-handle (list error-target t 1)) handles)) +(defun eshell-duplicate-handles (handles) + "Create a duplicate of the file handles in HANDLES. +This will copy the targets of each handle in HANDLES, setting the +DEFAULT field to t (see `eshell-create-handles')." + (eshell-create-handles + (car (aref handles eshell-output-handle)) nil + (car (aref handles eshell-error-handle)) nil)) + (defun eshell-protect-handles (handles) "Protect the handles in HANDLES from a being closed." (dotimes (idx eshell-number-of-handles) - (when (aref handles idx) - (setcdr (aref handles idx) - (1+ (cdr (aref handles idx)))))) + (when-let ((handle (aref handles idx))) + (setcar (nthcdr 2 handle) (1+ (nth 2 handle))))) handles) (defun eshell-close-handles (&optional exit-code result handles) @@ -330,8 +347,8 @@ eshell-close-handles (let ((handles (or handles eshell-current-handles))) (dotimes (idx eshell-number-of-handles) (when-let ((handle (aref handles idx))) - (setcdr handle (1- (cdr handle))) - (when (= (cdr handle) 0) + (setcar (nthcdr 2 handle) (1- (nth 2 handle))) + (when (= (nth 2 handle) 0) (dolist (target (ensure-list (car (aref handles idx)))) (eshell-close-target target (= eshell-last-command-status 0))) (setcar handle nil)))))) @@ -344,15 +361,17 @@ eshell-set-output-handle (if (and (stringp target) (string= target (null-device))) (aset handles index nil) - (let ((where (eshell-get-target target mode)) - (current (car (aref handles index)))) - (if (listp current) + (let* ((where (eshell-get-target target mode)) + (handle (or (aref handles index) + (aset handles index (list nil nil 1)))) + (current (car handle)) + (defaultp (cadr handle))) + (if (not defaultp) (unless (member where current) (setq current (append current (list where)))) (setq current (list where))) - (if (not (aref handles index)) - (aset handles index (cons nil 1))) - (setcar (aref handles index) current)))))) + (setcar handle current) + (setcar (cdr handle) nil)))))) (defun eshell-copy-output-handle (index index-to-copy &optional handles) "Copy the handle INDEX-TO-COPY to INDEX for the current HANDLES. @@ -482,6 +501,13 @@ eshell-get-target (error "Invalid redirection target: %s" (eshell-stringify target))))) +(defun eshell-get-targets (targets &optional mode) + "Convert TARGETS into valid output targets. +TARGETS can be a single raw target or a list thereof. MODE is either +`overwrite', `append' or `insert'; if it is omitted or nil, it +defaults to `insert'." + (mapcar (lambda (i) (eshell-get-target i mode)) (ensure-list targets))) + (defun eshell-interactive-output-p (&optional index handles) "Return non-nil if the specified handle is bound for interactive display. HANDLES is the set of handles to check; if nil, use @@ -493,9 +519,9 @@ eshell-interactive-output-p (let ((handles (or handles eshell-current-handles)) (index (or index eshell-output-handle))) (if (eq index 'all) - (and (eq (car (aref handles eshell-output-handle)) t) - (eq (car (aref handles eshell-error-handle)) t)) - (eq (car (aref handles index)) t)))) + (and (equal (car (aref handles eshell-output-handle)) '(t)) + (equal (car (aref handles eshell-error-handle)) '(t))) + (equal (car (aref handles index)) '(t))))) (defvar eshell-print-queue nil) (defvar eshell-print-queue-count -1) @@ -602,15 +628,10 @@ eshell-output-object If HANDLE-INDEX is nil, output to `eshell-output-handle'. HANDLES is the set of file handles to use; if nil, use `eshell-current-handles'." - (let ((target (car (aref (or handles eshell-current-handles) - (or handle-index eshell-output-handle))))) - (if (listp target) - (while target - (eshell-output-object-to-target object (car target)) - (setq target (cdr target))) - (eshell-output-object-to-target object target) - ;; Explicitly return nil to match the list case above. - nil))) + (let ((targets (car (aref (or handles eshell-current-handles) + (or handle-index eshell-output-handle))))) + (dolist (target targets) + (eshell-output-object-to-target object target)))) (provide 'esh-io) ;;; esh-io.el ends here commit d3f1682ae9f95ee912d9bc5a2ab5c58659abf065 Author: Michael Albinus Date: Thu Dec 22 19:39:59 2022 +0100 Handle make-directory return values in file name handlers * lisp/net/ange-ftp.el (ange-ftp-make-directory): Handle return values. * lisp/net/tramp.el (tramp-skeleton-make-directory): New defmacro. Handle also return values. * lisp/net/tramp-adb.el (tramp-adb-handle-make-directory): * lisp/net/tramp-crypt.el (tramp-crypt-handle-make-directory): * lisp/net/tramp-fuse.el (tramp-fuse-handle-make-directory): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-make-directory): * lisp/net/tramp-sh.el (tramp-sh-handle-make-directory): * lisp/net/tramp-smb.el (tramp-smb-handle-make-directory): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-make-directory): Use it. * test/lisp/net/tramp-tests.el (tramp-test13-make-directory): Handle return values. diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 9781ebf863a..f8e2858bc3f 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -4129,7 +4129,7 @@ ange-ftp-make-directory (or (file-exists-p parent) (ange-ftp-make-directory parent parents)))) (if (file-exists-p dir) - (unless parents + (if parents t (signal 'file-already-exists (list "Cannot make directory: file already exists" dir))) @@ -4158,7 +4158,8 @@ ange-ftp-make-directory (format "Could not make directory %s: %s" dir (cdr result)))) - (ange-ftp-add-file-entry dir t)) + (ange-ftp-add-file-entry dir t) + nil) (ange-ftp-real-make-directory dir))))) (defun ange-ftp-delete-directory (dir &optional recursive trash) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 90020fbb1b6..5a025130ecf 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -411,20 +411,11 @@ tramp-adb-ls-output-name-less-p (defun tramp-adb-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." - (setq dir (expand-file-name dir)) - (with-parsed-tramp-file-name dir nil - (when (and (null parents) (file-exists-p dir)) - (tramp-error v 'file-already-exists dir)) - (when parents - (let ((par (expand-file-name ".." dir))) - (unless (file-directory-p par) - (make-directory par parents)))) - (tramp-flush-directory-properties v localname) - (unless (or (tramp-adb-send-command-and-check - v (format "mkdir -m %#o %s" - (default-file-modes) - (tramp-shell-quote-argument localname))) - (and parents (file-directory-p dir))) + (tramp-skeleton-make-directory dir parents + (unless (tramp-adb-send-command-and-check + v (format "mkdir -m %#o %s" + (default-file-modes) + (tramp-shell-quote-argument localname))) (tramp-error v 'file-error "Couldn't make directory %s" dir)))) (defun tramp-adb-handle-delete-directory (directory &optional recursive trash) diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el index 249b3fcd4d7..e6c0ebccbff 100644 --- a/lisp/net/tramp-crypt.el +++ b/lisp/net/tramp-crypt.el @@ -800,16 +800,9 @@ tramp-crypt-handle-lock-file (defun tramp-crypt-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." - (with-parsed-tramp-file-name (expand-file-name dir) nil - (when (and (null parents) (file-exists-p dir)) - (tramp-error v 'file-already-exists dir)) + (tramp-skeleton-make-directory dir parents (let (tramp-crypt-enabled) - (make-directory (tramp-crypt-encrypt-file-name dir) parents)) - ;; When PARENTS is non-nil, DIR could be a chain of non-existent - ;; directories a/b/c/... Instead of checking, we simply flush the - ;; whole cache. - (tramp-flush-directory-properties - v (if parents "/" (file-name-directory localname))))) + (make-directory (tramp-crypt-encrypt-file-name dir) parents)))) (defun tramp-crypt-handle-rename-file (filename newname &optional ok-if-already-exists) diff --git a/lisp/net/tramp-fuse.el b/lisp/net/tramp-fuse.el index ea6b5a0622c..5176c6e9c48 100644 --- a/lisp/net/tramp-fuse.el +++ b/lisp/net/tramp-fuse.el @@ -127,14 +127,8 @@ tramp-fuse-handle-insert-directory (defun tramp-fuse-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." - (with-parsed-tramp-file-name (expand-file-name dir) nil - (make-directory (tramp-fuse-local-file-name dir) parents) - ;; When PARENTS is non-nil, DIR could be a chain of non-existent - ;; directories a/b/c/... Instead of checking, we simply flush the - ;; whole file cache. - (tramp-flush-file-properties v localname) - (tramp-flush-directory-properties - v (if parents "/" (file-name-directory localname))))) + (tramp-skeleton-make-directory dir parents + (make-directory (tramp-fuse-local-file-name dir) parents))) ;; File name helper functions. diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index da7641774fb..66f4de989d0 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1560,27 +1560,13 @@ tramp-gvfs-handle-file-system-info (defun tramp-gvfs-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." - (setq dir (directory-file-name (expand-file-name dir))) - (with-parsed-tramp-file-name dir nil - (when (and (null parents) (file-exists-p dir)) - (tramp-error v 'file-already-exists dir)) - (tramp-flush-directory-properties v localname) + (tramp-skeleton-make-directory dir parents (save-match-data - (let ((ldir (file-name-directory dir))) - ;; Make missing directory parts. "gvfs-mkdir -p ..." does not - ;; work robust. - (when (and parents (not (file-directory-p ldir))) - (make-directory ldir parents)) - ;; Just do it. - (or (when-let ((mkdir-succeeded - (and - (tramp-gvfs-send-command - v "gvfs-mkdir" (tramp-gvfs-url-file-name dir)) - (tramp-gvfs-info dir)))) - (set-file-modes dir (default-file-modes)) - mkdir-succeeded) - (and parents (file-directory-p dir)) - (tramp-error v 'file-error "Couldn't make directory %s" dir)))))) + (if (and (tramp-gvfs-send-command + v "gvfs-mkdir" (tramp-gvfs-url-file-name dir)) + (tramp-gvfs-info dir)) + (set-file-modes dir (default-file-modes)) + (tramp-error v 'file-error "Couldn't make directory %s" dir))))) (defun tramp-gvfs-handle-rename-file (filename newname &optional ok-if-already-exists) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 6087f16431e..19c160f4d6d 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2559,19 +2559,10 @@ tramp-do-copy-or-rename-file-out-of-band (defun tramp-sh-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." - (setq dir (expand-file-name dir)) - (with-parsed-tramp-file-name dir nil - (when (and (null parents) (file-exists-p dir)) - (tramp-error v 'file-already-exists dir)) - ;; When PARENTS is non-nil, DIR could be a chain of non-existent - ;; directories a/b/c/... Instead of checking, we simply flush the - ;; whole cache. - (tramp-flush-directory-properties - v (if parents "/" (file-name-directory localname))) + (tramp-skeleton-make-directory dir parents (tramp-barf-unless-okay v (format "%s -m %#o %s" - (if parents "mkdir -p" "mkdir") - (default-file-modes) + "mkdir" (default-file-modes) (tramp-shell-quote-argument localname)) "Couldn't make directory %s" dir))) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index cd73b9b8eca..b51f42deb45 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -1172,30 +1172,14 @@ tramp-smb-handle-insert-directory (defun tramp-smb-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." - (setq dir (directory-file-name (expand-file-name dir))) - (unless (file-name-absolute-p dir) - (setq dir (expand-file-name dir default-directory))) - (with-parsed-tramp-file-name dir nil - (when (and (null parents) (file-exists-p dir)) - (tramp-error v 'file-already-exists dir)) - (let* ((ldir (file-name-directory dir))) - ;; Make missing directory parts. - (when (and parents - (tramp-smb-get-share v) - (not (file-directory-p ldir))) - (make-directory ldir parents)) - ;; Just do it. - (when (file-directory-p ldir) - (tramp-smb-send-command - v (if (tramp-smb-get-cifs-capabilities v) - (format "posix_mkdir %s %o" - (tramp-smb-shell-quote-localname v) (default-file-modes)) - (format "mkdir %s" (tramp-smb-shell-quote-localname v)))) - ;; We must also flush the cache of the directory, because - ;; `file-attributes' reads the values from there. - (tramp-flush-file-properties v localname)) - (unless (file-directory-p dir) - (tramp-error v 'file-error "Couldn't make directory %s" dir))))) + (tramp-skeleton-make-directory dir parents + (tramp-smb-send-command + v (if (tramp-smb-get-cifs-capabilities v) + (format "posix_mkdir %s %o" + (tramp-smb-shell-quote-localname v) (default-file-modes)) + (format "mkdir %s" (tramp-smb-shell-quote-localname v)))) + (unless (file-directory-p dir) + (tramp-error v 'file-error "Couldn't make directory %s" dir)))) ;; This is not used anymore. (defun tramp-smb-handle-make-directory-internal (directory) diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index fcc27dd8343..8774367cefe 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -626,18 +626,9 @@ tramp-sudoedit-handle-file-writable-p (defun tramp-sudoedit-handle-make-directory (dir &optional parents) "Like `make-directory' for Tramp files." - (setq dir (expand-file-name dir)) - (with-parsed-tramp-file-name dir nil - (when (and (null parents) (file-exists-p dir)) - (tramp-error v 'file-already-exists "Directory already exists %s" dir)) - ;; When PARENTS is non-nil, DIR could be a chain of non-existent - ;; directories a/b/c/... Instead of checking, we simply flush the - ;; whole cache. - (tramp-flush-directory-properties - v (if parents "/" (file-name-directory localname))) + (tramp-skeleton-make-directory dir parents (unless (tramp-sudoedit-send-command - v (if parents '("mkdir" "-p") "mkdir") - "-m" (format "%#o" (default-file-modes)) + v "mkdir" "-m" (format "%#o" (default-file-modes)) (tramp-compat-file-name-unquote localname)) (tramp-error v 'file-error "Couldn't make directory %s" dir)))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index ca8963fbf54..e39c9ccc31a 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3537,6 +3537,27 @@ tramp-skeleton-file-local-copy ;; Trigger the `file-missing' error. (signal 'error nil))))) +(defmacro tramp-skeleton-make-directory (dir &optional parents &rest body) + "Skeleton for `tramp-*-handle-make-directory'. +BODY is the backend specific code." + ;; Since Emacs 29.1, PARENTS isn't propagated to the handlers + ;; anymore. And the return values are specified since then as well. + (declare (indent 2) (debug t)) + `(let* ((dir (directory-file-name (expand-file-name ,dir))) + (par (file-name-directory dir))) + (with-parsed-tramp-file-name dir nil + (when (and (null ,parents) (file-exists-p dir)) + (tramp-error v 'file-already-exists dir)) + ;; Make missing directory parts. + (when ,parents + (unless (file-directory-p par) + (make-directory par ,parents))) + ;; Just do it. + (if (file-exists-p dir) t + (tramp-flush-file-properties v localname) + ,@body + nil)))) + (defmacro tramp-skeleton-set-file-modes-times-uid-gid (filename &rest body) "Skeleton for `tramp-*-set-file-{modes,times,uid-gid}'. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 79b2fc803d6..d7f4576335c 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2857,6 +2857,7 @@ tramp-test13-make-directory This tests also `file-directory-p' and `file-accessible-directory-p'." (skip-unless (tramp--test-enabled)) + ;; Since Emacs 29.1, `make-directory' has defined return values. (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (expand-file-name "foo/bar" tmp-name1)) @@ -2865,7 +2866,9 @@ tramp-test13-make-directory (unwind-protect (progn (with-file-modes unusual-file-mode-1 - (make-directory tmp-name1)) + (if (tramp--test-emacs29-p) + (should-not (make-directory tmp-name1)) + (make-directory tmp-name1))) (should-error (make-directory tmp-name1) :type 'file-already-exists) @@ -2878,15 +2881,19 @@ tramp-test13-make-directory (make-directory tmp-name2) :type 'file-error) (with-file-modes unusual-file-mode-2 - (make-directory tmp-name2 'parents)) + (if (tramp--test-emacs29-p) + (should-not (make-directory tmp-name2 'parents)) + (make-directory tmp-name2 'parents))) (should (file-directory-p tmp-name2)) (should (file-accessible-directory-p tmp-name2)) (when (tramp--test-supports-set-file-modes-p) (should (equal (format "%#o" unusual-file-mode-2) (format "%#o" (file-modes tmp-name2))))) ;; If PARENTS is non-nil, `make-directory' shall not - ;; signal an error when DIR exists already. - (make-directory tmp-name2 'parents)) + ;; signal an error when DIR exists already. It returns t. + (if (tramp--test-emacs29-p) + (should (make-directory tmp-name2 'parents)) + (make-directory tmp-name2 'parents))) ;; Cleanup. (ignore-errors (delete-directory tmp-name1 'recursive)))))) commit 0754173c923a1888a1b18b4c6c5d1dc72e6cc6af Author: Ikumi Keita Date: Thu Dec 22 18:23:34 2022 +0100 ; Fix docstring * lisp/textmodes/reftex-vars.el (reftex-allow-detached-macro-args): Fix macro name in docstring. diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index ee94cc5d693..51dedddf3a5 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -2096,8 +2096,8 @@ reftex-plug-into-AUCTeX (defcustom reftex-allow-detached-macro-args nil "Non-nil means, allow arguments of macros to be detached by whitespace. -When this is t, `aaa' will be considered as argument of \\bb in the following -construct: \\bbb [xxx] {aaa}." +When this is t, `aaa' will be considered as argument of \\bbb in +the following construct: \\bbb [xxx] {aaa}." :group 'reftex-miscellaneous-configurations :type 'boolean) commit 014232d3840e9d7249fe28636935b7166b85e675 Author: João Távora Date: Thu Dec 22 15:44:11 2022 +0000 Eglot: eglot--servers-by-xrefed-file doesn't need to be value-weak * lisp/progmodes/eglot.el (eglot--servers-by-xrefed-file): Doesn't need to be weak. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index e7782ea8112..15cb1b6fad0 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -908,8 +908,7 @@ eglot-shutdown-all do (with-demoted-errors "[eglot] shutdown all: %s" (cl-loop for s in ss do (eglot-shutdown s nil nil preserve-buffers))))) -(defvar eglot--servers-by-xrefed-file - (make-hash-table :test 'equal :weakness 'value)) +(defvar eglot--servers-by-xrefed-file (make-hash-table :test 'equal)) (defun eglot--on-shutdown (server) "Called by jsonrpc.el when SERVER is already dead." commit bbe35c280c2bf9fb2fd9b6e33b2950b8fae67e2c Author: João Távora Date: Thu Dec 22 11:29:49 2022 +0000 Prevent stale servers when using eglot-extend-to-xref A weak-valued hash-table is not enough to guarantee that a reference to a zombie server in eglot--servers-by-xrefed-file variable won't survive long enough to confuse the next call to eglot--current-server in some buffers. So, before this fix it was common to get "Process EGLOT ... not running" errors if some xref-extended buffers (like system libraries) were open and M-x eglot-reconnect was issued. This should be prevented now. Note however, that even after this the eglot-extend-to-xref logic is still flawed. For example, if a buffer for the xref-extended buffer happens to be already visited by the time M-. is issued to navigate to it, Eglot won't be activated. A half-decent workaround is to kill the buffer and re-visit it. * lisp/progmodes/eglot.el (eglot--servers-by-xrefed-file): Move up. (eglot--on-shutdown): Make sure to cleanup eglot--servers-by-xrefed-file. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 0f1bfd0447d..e7782ea8112 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -908,6 +908,9 @@ eglot-shutdown-all do (with-demoted-errors "[eglot] shutdown all: %s" (cl-loop for s in ss do (eglot-shutdown s nil nil preserve-buffers))))) +(defvar eglot--servers-by-xrefed-file + (make-hash-table :test 'equal :weakness 'value)) + (defun eglot--on-shutdown (server) "Called by jsonrpc.el when SERVER is already dead." ;; Turn off `eglot--managed-mode' where appropriate. @@ -926,6 +929,9 @@ eglot--on-shutdown (setf (gethash (eglot--project server) eglot--servers-by-project) (delq server (gethash (eglot--project server) eglot--servers-by-project))) + (maphash (lambda (f s) + (when (eq s server) (remhash f eglot--servers-by-xrefed-file))) + eglot--servers-by-xrefed-file) (cond ((eglot--shutdown-requested server) t) ((not (eglot--inhibit-autoreconnect server)) @@ -1057,9 +1063,6 @@ eglot-lsp-context (put 'eglot-lsp-context 'variable-documentation "Dynamically non-nil when searching for projects in LSP context.") -(defvar eglot--servers-by-xrefed-file - (make-hash-table :test 'equal :weakness 'value)) - (defun eglot--current-project () "Return a project object for Eglot's LSP purposes. This relies on `project-current' and thus on commit 9bf13a3fb9e197dfa741625fb7089ee7924cc581 Author: Eli Zaretskii Date: Thu Dec 22 13:02:45 2022 +0200 ; * src/alloc.c (Fmemory_info): Doc fix. diff --git a/src/alloc.c b/src/alloc.c index 9feca7ae024..9a7c759dc1d 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -7437,7 +7437,7 @@ DEFUN ("memory-info", Fmemory_info, Smemory_info, 0, 0, 0, All values are in Kbytes. If there is no swap space, last two values are zero. If the system is not supported or memory information can't be obtained, return nil. -If `default-directory’ is remote, return memory information of the +If `default-directory' is remote, return memory information of the respective remote host. */) (void) { commit baa33a5c054d06cef9a18bc876893d395baf288b Author: Xi Lu Date: Tue Dec 20 23:19:13 2022 +0800 * etc/tutorials/TUTORIAL.cn: Fix typos. (Bug#60221) diff --git a/etc/tutorials/TUTORIAL.cn b/etc/tutorials/TUTORIAL.cn index 770d9a83be3..cb430d3fdb0 100644 --- a/etc/tutorials/TUTORIAL.cn +++ b/etc/tutorials/TUTORIAL.cn @@ -299,7 +299,7 @@ Emacs 可以有多个“窗格”,每个窗格显示不同的文字。后面 >> 试试 C-u 8 *,这将会插入 ********。 -好,现在你应该已经掌握了最基本的的文本插入和修改功能,其实删除还可以 +好,现在你应该已经掌握了最基本的文本插入和修改功能,其实删除还可以 “以词为单位”进行,下面是一个关于“删除”操作的小结: 删除光标前的一个字符 @@ -316,7 +316,7 @@ Emacs 可以有多个“窗格”,每个窗格显示不同的文字。后面 注意“ 和 C-d”还有“M- 和 M-d”是根据前述惯例从 C-f和 M-f 衍生 出来的(其实不是控制字符,我们先忽略这一点)。C-k和 M-k 的关系在 -某种程度上与 C-e 和 M-e 一样――如果把“一行”和“一句”作一个类比的话。 +某种程度上与 C-e 和 M-e 一样――如果把“一行”和“一句”做一个类比的话。 你也可以用一种通用的办法来移除缓冲区里的任何一部分:首先把光标移动到你 想要移除的区域的一端,然后按 C-指空格)【注意,C- 往 commit 98d7f76b451311830db5a9848378356d53da4e45 Merge: a488a6870ac 02e046566e2 Author: Eli Zaretskii Date: Thu Dec 22 11:00:41 2022 +0200 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/emacs into emacs-29 commit a488a6870acc6df67cc6790a756c5d45f21d7b85 Author: Benson Chu Date: Wed Dec 21 17:41:32 2022 -0600 Add alias for removed font-lock function As part of 18947103fabf8070738b3bd9c5a8d02f90988a3d, `font-lock-fontify-syntactically-region' was renamed to `font-lock-default-fontify-sytactically'. * lisp/font-lock.el (font-lock-fontify-syntactically-region): Add obsolete alias for the renamed function. Copyright-paperwork-exempt: yes diff --git a/lisp/font-lock.el b/lisp/font-lock.el index bf9a179d6ae..2dfbe3ad232 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -2361,6 +2361,7 @@ cpp-font-lock-keywords (define-obsolete-function-alias 'font-lock-after-fontify-buffer #'ignore "29.1") (define-obsolete-function-alias 'font-lock-after-unfontify-buffer #'ignore "29.1") +(define-obsolete-function-alias 'font-lock-fontify-syntactically-region #'font-lock-default-fontify-syntactically "29.1") (provide 'font-lock) commit 02e046566e2c70cf268f359ef29802268ab43de1 Author: Yuan Fu Date: Thu Dec 22 00:41:58 2022 -0800 Set beginning/end-of-defun-function in treesit-major-mode-setup * lisp/treesit.el (treesit-major-mode-setup): Set them. diff --git a/lisp/treesit.el b/lisp/treesit.el index a7882dda2cc..ec5b3e399f9 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1941,7 +1941,16 @@ treesit-major-mode-setup (keymap-set (current-local-map) " " #'treesit-beginning-of-defun) (keymap-set (current-local-map) " " - #'treesit-end-of-defun))) + #'treesit-end-of-defun) + ;; `end-of-defun' will not work completely correctly in nested + ;; defuns due to its implementation. However, many lisp programs + ;; use `beginning/end-of-defun', so we should still set + ;; `beginning/end-of-defun-function' so they still mostly work. + ;; This is also what `cc-mode' does: rebind user commands and set + ;; the variables. In future we should update `end-of-defun' to + ;; work with nested defuns. + (setq-local beginning-of-defun-function #'treesit-beginning-of-defun) + (setq-local end-of-defun-function #'treesit-end-of-defun))) ;;; Debugging commit 7dea58b88db3e272e01e537a3a5d2158ef7f9608 Author: Yuan Fu Date: Tue Dec 20 21:22:30 2022 -0800 Add treesit-defun-at-point and fix c-ts-mode-indent-defun * lisp/treesit.el (treesit-defun-at-point): New function. * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-defun): Implement with treesit-defun-at-point. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 8ed1a77637a..ea9891f3345 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -556,13 +556,10 @@ c-ts-mode-indent-defun `treesit-defun-type-regexp' defines what constructs to indent." (interactive "*") - (let ((orig-point (point-marker))) - ;; If `treesit-beginning-of-defun' returns nil, we are not in a - ;; defun, so don't indent anything. - (when (treesit-beginning-of-defun) - (let ((start (point))) - (treesit-end-of-defun) - (indent-region start (point)))) + (when-let ((orig-point (point-marker)) + (node (treesit-defun-at-point))) + (indent-region (treesit-node-start node) + (treesit-node-end node)) (goto-char orig-point))) (defvar-keymap c-ts-mode-map diff --git a/lisp/treesit.el b/lisp/treesit.el index e4f3698dcd9..a7882dda2cc 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1834,6 +1834,29 @@ treesit--navigate-defun ;; Counter equal to 0 means we successfully stepped ARG steps. (if (eq counter 0) pos nil))) +;; TODO: In corporate into thing-at-point. +(defun treesit-defun-at-point () + "Return the defun at point or nil if none is found. + +Respects `treesit-defun-tactic': return the top-level defun if it +is `top-level', return the immediate parent defun if it is +`nested'." + (pcase-let* ((`(,regexp . ,pred) + (if (consp treesit-defun-type-regexp) + treesit-defun-type-regexp + (cons treesit-defun-type-regexp nil))) + (`(,_ ,next ,parent) + (treesit--defuns-around (point) regexp pred)) + ;; If point is at the beginning of a defun, we + ;; prioritize that defun over the parent in nested + ;; mode. + (node (or (and (eq (treesit-node-start next) (point)) + next) + parent))) + (if (eq treesit-defun-tactic 'top-level) + (treesit--top-level-defun node regexp pred) + node))) + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) commit 69123d4aa4e8a116d4fe328146af5829f3790fc7 Author: Yuan Fu Date: Tue Dec 20 21:21:48 2022 -0800 ; Fix treesit--defuns-around Now it doesn't move point. * lisp/treesit.el (treesit--defuns-around): Wrap some code with save-excursion. diff --git a/lisp/treesit.el b/lisp/treesit.el index 64076691186..e4f3698dcd9 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1657,10 +1657,13 @@ treesit--defuns-around ;; defun, in that case we want to use a node that's actually ;; before/after point. (node-before (if (>= (treesit-node-start node) pos) - (treesit-search-forward-goto node "" t t t) + (save-excursion + (treesit-search-forward-goto node "" t t t)) node)) (node-after (if (<= (treesit-node-end node) pos) - (treesit-search-forward-goto node "" nil nil t) + (save-excursion + (treesit-search-forward-goto + node "" nil nil t)) node)) (result (list nil nil nil)) (pred (or pred (lambda (_) t)))) commit 05d8310fb5ddb35c2566c2b50ca07e86edf3c670 Author: Juri Linkov Date: Thu Dec 22 10:03:09 2022 +0200 Use the new keyword ':repeat' in repeatable keymaps. * lisp/bindings.el (undo-repeat-map) (buffer-navigation-repeat-map, next-error-repeat-map) (page-navigation-repeat-map): * lisp/comint.el (comint-repeat-map): * lisp/dired.el (dired-jump-map): * lisp/outline.el (outline-navigation-repeat-map) (outline-editing-repeat-map): * lisp/shell.el (shell-repeat-map): * lisp/tab-bar.el (tab-bar-switch-repeat-map) (tab-bar-move-repeat-map): * lisp/window.el (other-window-repeat-map) (resize-window-repeat-map): * lisp/winner.el (winner-repeat-map): * lisp/eshell/em-prompt.el (eshell-prompt-repeat-map): * lisp/eshell/esh-mode.el (eshell-command-repeat-map): Add the keyword ':repeat' to 'defvar-keymap' instead of setting the symbol property 'repeat-map' explicitly. * lisp/keymap.el (defvar-keymap): Check for 'props' that is used in 'defvar-form'. diff --git a/lisp/bindings.el b/lisp/bindings.el index c1ad5f7520e..c298a43952f 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1010,8 +1010,8 @@ global-map ;; (define-key ctl-x-map "U" 'undo-only) (defvar-keymap undo-repeat-map :doc "Keymap to repeat undo key sequences \\`C-x u u'. Used in `repeat-mode'." + :repeat t "u" #'undo) -(put 'undo 'repeat-map 'undo-repeat-map) (define-key global-map '[(control ??)] 'undo-redo) (define-key global-map [?\C-\M-_] 'undo-redo) @@ -1031,12 +1031,10 @@ global-map (defvar-keymap buffer-navigation-repeat-map :doc "Keymap to repeat `next-buffer' and `previous-buffer'. Used in `repeat-mode'." + :repeat t "" #'next-buffer "" #'previous-buffer) -(put 'next-buffer 'repeat-map 'buffer-navigation-repeat-map) -(put 'previous-buffer 'repeat-map 'buffer-navigation-repeat-map) - (let ((map minibuffer-local-map)) (define-key map "\en" 'next-history-element) (define-key map [next] 'next-history-element) @@ -1109,12 +1107,11 @@ ctl-x-map (defvar-keymap next-error-repeat-map :doc "Keymap to repeat `next-error' key sequences. Used in `repeat-mode'." + :repeat t "n" #'next-error "M-n" #'next-error "p" #'previous-error "M-p" #'previous-error) -(put 'next-error 'repeat-map 'next-error-repeat-map) -(put 'previous-error 'repeat-map 'next-error-repeat-map) (defvar-keymap goto-map :doc "Keymap for navigation commands." @@ -1472,12 +1469,10 @@ ctl-x-map (defvar-keymap page-navigation-repeat-map :doc "Keymap to repeat page navigation key sequences. Used in `repeat-mode'." + :repeat t "]" #'forward-page "[" #'backward-page) -(put 'forward-page 'repeat-map 'page-navigation-repeat-map) -(put 'backward-page 'repeat-map 'page-navigation-repeat-map) - (define-key ctl-x-map "\C-p" 'mark-page) (define-key ctl-x-map "l" 'count-lines-page) (define-key ctl-x-map "np" 'narrow-to-page) diff --git a/lisp/comint.el b/lisp/comint.el index f0bb8da4355..fd0e06a3612 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -606,12 +606,10 @@ comint-mode-map (defvar-keymap comint-repeat-map :doc "Keymap to repeat comint key sequences. Used in `repeat-mode'." + :repeat t "C-n" #'comint-next-prompt "C-p" #'comint-previous-prompt) -(put #'comint-next-prompt 'repeat-map 'comint-repeat-map) -(put #'comint-previous-prompt 'repeat-map 'comint-repeat-map) - ;; Fixme: Is this still relevant? (defvar comint-ptyp t "Non-nil if communications via pty; false if by pipe. Buffer local. diff --git a/lisp/dired.el b/lisp/dired.el index 81e62f88cf1..f5d1b90abf4 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -4882,9 +4882,9 @@ dired-jump-other-window (defvar-keymap dired-jump-map :doc "Keymap to repeat `dired-jump'. Used in `repeat-mode'." + :repeat t "j" #'dired-jump "C-j" #'dired-jump) -(put 'dired-jump 'repeat-map 'dired-jump-map) ;;; Miscellaneous commands diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index a8744de1dba..abb123bcff2 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -102,12 +102,10 @@ eshell-prompt-mode-map (defvar-keymap eshell-prompt-repeat-map :doc "Keymap to repeat eshell-prompt key sequences. Used in `repeat-mode'." + :repeat t "C-n" #'eshell-next-prompt "C-p" #'eshell-previous-prompt) -(put #'eshell-next-prompt 'repeat-map 'eshell-prompt-repeat-map) -(put #'eshell-previous-prompt 'repeat-map 'eshell-prompt-repeat-map) - ;;; Functions: (define-minor-mode eshell-prompt-mode diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 4357a0e29a0..b3db0f6af45 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -282,12 +282,10 @@ eshell-command-map (defvar-keymap eshell-command-repeat-map :doc "Keymap to repeat eshell-command key sequences. Used in `repeat-mode'." + :repeat t "C-f" #'eshell-forward-argument "C-b" #'eshell-backward-argument) -(put #'eshell-forward-argument 'repeat-map 'eshell-command-repeat-map) -(put #'eshell-backward-argument 'repeat-map 'eshell-command-repeat-map) - ;;; User Functions: (defun eshell-kill-buffer-function () diff --git a/lisp/keymap.el b/lisp/keymap.el index b355f68aa2f..e93e3c5f3bc 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -625,7 +625,7 @@ defvar-keymap `(defvar ,variable-name (define-keymap ,@(nreverse opts) ,@defs) ,@(and doc (list doc))))) - (if repeat + (if props `(progn ,defvar-form ,@(nreverse props)) diff --git a/lisp/outline.el b/lisp/outline.el index 53bfc4d556f..c2b33b4c58f 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -1868,6 +1868,7 @@ outline--fix-buttons-after-change (defvar-keymap outline-navigation-repeat-map + :repeat t "C-b" #'outline-backward-same-level "b" #'outline-backward-same-level "C-f" #'outline-forward-same-level @@ -1879,14 +1880,8 @@ outline-navigation-repeat-map "C-u" #'outline-up-heading "u" #'outline-up-heading) -(dolist (command '(outline-backward-same-level - outline-forward-same-level - outline-next-visible-heading - outline-previous-visible-heading - outline-up-heading)) - (put command 'repeat-map 'outline-navigation-repeat-map)) - (defvar-keymap outline-editing-repeat-map + :repeat t "C-v" #'outline-move-subtree-down "v" #'outline-move-subtree-down "C-^" #'outline-move-subtree-up @@ -1896,12 +1891,6 @@ outline-editing-repeat-map "C-<" #'outline-promote "<" #'outline-promote) -(dolist (command '(outline-move-subtree-down - outline-move-subtree-up - outline-demote - outline-promote)) - (put command 'repeat-map 'outline-editing-repeat-map)) - (provide 'outline) (provide 'noutline) diff --git a/lisp/shell.el b/lisp/shell.el index dadbdcbc034..727f2aa0dd7 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -395,12 +395,10 @@ shell-mode-map (defvar-keymap shell-repeat-map :doc "Keymap to repeat shell key sequences. Used in `repeat-mode'." + :repeat t "C-f" #'shell-forward-command "C-b" #'shell-backward-command) -(put #'shell-forward-command 'repeat-map 'shell-repeat-map) -(put #'shell-backward-command 'repeat-map 'shell-repeat-map) - (defcustom shell-mode-hook '() "Hook for customizing Shell mode." :type 'hook diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index a4779af04aa..114294615b4 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -2626,18 +2626,16 @@ 'tab-list (defvar-keymap tab-bar-switch-repeat-map :doc "Keymap to repeat tab switch key sequences \\`C-x t o o O'. Used in `repeat-mode'." + :repeat t "o" #'tab-next "O" #'tab-previous) -(put 'tab-next 'repeat-map 'tab-bar-switch-repeat-map) -(put 'tab-previous 'repeat-map 'tab-bar-switch-repeat-map) (defvar-keymap tab-bar-move-repeat-map :doc "Keymap to repeat tab move key sequences \\`C-x t m m M'. Used in `repeat-mode'." + :repeat t "m" #'tab-move "M" #'tab-bar-move-tab-backward) -(put 'tab-move 'repeat-map 'tab-bar-move-repeat-map) -(put 'tab-bar-move-tab-backward 'repeat-map 'tab-bar-move-repeat-map) (provide 'tab-bar) diff --git a/lisp/window.el b/lisp/window.el index a4a84218818..5dd5b808831 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -10561,26 +10561,23 @@ ctl-x-4-map (defvar-keymap other-window-repeat-map :doc "Keymap to repeat `other-window' key sequences. Used in `repeat-mode'." + :repeat t "o" #'other-window "O" (lambda () (interactive) (setq repeat-map 'other-window-repeat-map) (other-window -1))) -(put 'other-window 'repeat-map 'other-window-repeat-map) (defvar-keymap resize-window-repeat-map :doc "Keymap to repeat window resizing commands. Used in `repeat-mode'." + :repeat t ;; Standard keys: "^" #'enlarge-window "}" #'enlarge-window-horizontally "{" #'shrink-window-horizontally ;; Additional keys: "v" #'shrink-window) -(put 'enlarge-window 'repeat-map 'resize-window-repeat-map) -(put 'enlarge-window-horizontally 'repeat-map 'resize-window-repeat-map) -(put 'shrink-window-horizontally 'repeat-map 'resize-window-repeat-map) -(put 'shrink-window 'repeat-map 'resize-window-repeat-map) (defvar-keymap window-prefix-map :doc "Keymap for subcommands of \\`C-x w'." diff --git a/lisp/winner.el b/lisp/winner.el index c8354b18bec..aed57aa0371 100644 --- a/lisp/winner.el +++ b/lisp/winner.el @@ -330,12 +330,10 @@ winner-mode-map (defvar-keymap winner-repeat-map :doc "Keymap to repeat winner key sequences. Used in `repeat-mode'." + :repeat t "" #'winner-undo "" #'winner-redo) -(put #'winner-undo 'repeat-map 'winner-repeat-map) -(put #'winner-redo 'repeat-map 'winner-repeat-map) - ;;;###autoload (define-minor-mode winner-mode