update packages

This commit is contained in:
2025-03-11 21:14:26 +01:00
parent 45d49daef0
commit 14dcaaddde
440 changed files with 13229 additions and 8718 deletions

View File

@@ -172,11 +172,26 @@ the executable."
:type 'string
:group 'vterm)
(defcustom vterm-tramp-shells '(("docker" "/bin/sh"))
(defcustom vterm-tramp-shells
'(("ssh" login-shell) ("scp" login-shell) ("docker" "/bin/sh"))
"The shell that gets run in the vterm for tramp.
`vterm-tramp-shells' has to be a list of pairs of the format:
\(TRAMP-METHOD SHELL)"
\(TRAMP-METHOD SHELL)
Use t as TRAMP-METHOD to specify a default shell for all methods.
Specific methods always take precedence over t.
Set SHELL to \\='login-shell to use the user's login shell on the host.
The login-shell detection currently works for POSIX-compliant remote
hosts that have the getent command (regular GNU/Linux distros, *BSDs,
but not MacOS X unfortunately).
You can specify an additional second SHELL command as a fallback
that is used when the login-shell detection fails, e.g.,
\\='((\"ssh\" login-shell \"/bin/bash\") ...)
If no second SHELL command is specified with \\='login-shell, vterm will
fall back to tramp's shell."
:type '(alist :key-type string :value-type string)
:group 'vterm)
@@ -425,58 +440,98 @@ copy-mode and set to nil on leaving."
(defface vterm-color-black
`((t :inherit term-color-black))
"Face used to render black color code.
The foreground color is used as ANSI color 0 and the background
color is used as ANSI color 8."
"Face used to render black color code."
:group 'vterm)
(defface vterm-color-red
`((t :inherit term-color-red))
"Face used to render red color code.
The foreground color is used as ANSI color 1 and the background
color is used as ANSI color 9."
"Face used to render red color code."
:group 'vterm)
(defface vterm-color-green
`((t :inherit term-color-green))
"Face used to render green color code.
The foreground color is used as ANSI color 2 and the background
color is used as ANSI color 10."
"Face used to render green color code."
:group 'vterm)
(defface vterm-color-yellow
`((t :inherit term-color-yellow))
"Face used to render yellow color code.
The foreground color is used as ANSI color 3 and the background
color is used as ANSI color 11."
"Face used to render yellow color code."
:group 'vterm)
(defface vterm-color-blue
`((t :inherit term-color-blue))
"Face used to render blue color code.
The foreground color is used as ANSI color 4 and the background
color is used as ANSI color 12."
"Face used to render blue color code."
:group 'vterm)
(defface vterm-color-magenta
`((t :inherit term-color-magenta))
"Face used to render magenta color code.
The foreground color is used as ansi color 5 and the background
color is used as ansi color 13."
"Face used to render magenta color code."
:group 'vterm)
(defface vterm-color-cyan
`((t :inherit term-color-cyan))
"Face used to render cyan color code.
The foreground color is used as ansi color 6 and the background
color is used as ansi color 14."
"Face used to render cyan color code."
:group 'vterm)
(defface vterm-color-white
`((t :inherit term-color-white))
"Face used to render white color code.
The foreground color is used as ansi color 7 and the background
color is used as ansi color 15."
"Face used to render white color code."
:group 'vterm)
(defface vterm-color-bright-black
`((t :inherit ,(if (facep 'term-color-bright-black)
'term-color-bright-black
'term-color-black)))
"Face used to render bright black color code."
:group 'vterm)
(defface vterm-color-bright-red
`((t :inherit ,(if (facep 'term-color-bright-red)
'term-color-bright-red
'term-color-red)))
"Face used to render bright red color code."
:group 'vterm)
(defface vterm-color-bright-green
`((t :inherit ,(if (facep 'term-color-bright-green)
'term-color-bright-green
'term-color-green)))
"Face used to render bright green color code."
:group 'vterm)
(defface vterm-color-bright-yellow
`((t :inherit ,(if (facep 'term-color-bright-yellow)
'term-color-bright-yellow
'term-color-yellow)))
"Face used to render bright yellow color code."
:group 'vterm)
(defface vterm-color-bright-blue
`((t :inherit ,(if (facep 'term-color-bright-blue)
'term-color-bright-blue
'term-color-blue)))
"Face used to render bright blue color code."
:group 'vterm)
(defface vterm-color-bright-magenta
`((t :inherit ,(if (facep 'term-color-bright-magenta)
'term-color-bright-magenta
'term-color-magenta)))
"Face used to render bright magenta color code."
:group 'vterm)
(defface vterm-color-bright-cyan
`((t :inherit ,(if (facep 'term-color-bright-cyan)
'term-color-bright-cyan
'term-color-cyan)))
"Face used to render bright cyan color code."
:group 'vterm)
(defface vterm-color-bright-white
`((t :inherit ,(if (facep 'term-color-bright-white)
'term-color-bright-white
'term-color-white)))
"Face used to render bright white color code."
:group 'vterm)
(defface vterm-color-underline
@@ -501,7 +556,15 @@ Only background is used."
vterm-color-blue
vterm-color-magenta
vterm-color-cyan
vterm-color-white]
vterm-color-white
vterm-color-bright-black
vterm-color-bright-red
vterm-color-bright-green
vterm-color-bright-yellow
vterm-color-bright-blue
vterm-color-bright-magenta
vterm-color-bright-cyan
vterm-color-bright-white]
"Color palette for the foreground and background.")
(defvar-local vterm--term nil
@@ -703,7 +766,7 @@ Exceptions are defined by `vterm-keymap-exceptions'."
(inhibit-eol-conversion nil)
(coding-system-for-read 'binary)
(process-adaptive-read-buffering nil)
(width (max (- (window-body-width) (vterm--get-margin-width))
(width (max (- (window-max-chars-per-line) (vterm--get-margin-width))
vterm-min-window-width)))
(setq vterm--term (vterm--new (window-body-height)
width vterm-max-scrollback
@@ -765,16 +828,72 @@ Exceptions are defined by `vterm-keymap-exceptions'."
(vterm--set-pty-name vterm--term (process-tty-name vterm--process))
(process-put vterm--process 'adjust-window-size-function
#'vterm--window-adjust-process-window-size)
;; Set the truncation slot for 'buffer-display-table' to the ASCII code for a
;; space character (32) to make the vterm buffer display a space instead of
;; the default truncation character ($) when a line is truncated.
(let* ((display-table (or buffer-display-table (make-display-table))))
(set-display-table-slot display-table 'truncation 32)
(setq buffer-display-table display-table))
;; Support to compilation-shell-minor-mode
;; Is this necessary? See vterm--compilation-setup
(setq next-error-function 'vterm-next-error-function)
(setq-local bookmark-make-record-function 'vterm--bookmark-make-record))
(defun vterm--tramp-get-shell (method)
"Get the shell for a remote location as specified in `vterm-tramp-shells'.
The argument METHOD is the method string (as used by tramp) to get the shell
for, or t to get the default shell for all methods."
(let* ((specs (cdr (assoc method vterm-tramp-shells)))
(first (car specs))
(second (cadr specs)))
;; Allow '(... login-shell) or '(... 'login-shell).
(if (or (eq first 'login-shell)
(and (consp first) (eq (cadr first) 'login-shell)))
;; If the first element is 'login-shell, try to determine the user's
;; login shell on the remote host. This should work for all
;; POSIX-compliant systems with the getent command in PATH. This
;; includes regular GNU/Linux distros, *BSDs, but not MacOS X. If
;; the login-shell determination fails at any point, the second
;; element in the shell spec is used (if present, otherwise nil is
;; returned).
(let* ((entry (ignore-errors
(with-output-to-string
(with-current-buffer standard-output
;; The getent command returns the passwd entry
;; for the specified user independently of the
;; used name service (i.e., not only for static
;; passwd files, but also for LDAP, etc).
;;
;; Use a shell command here to get $LOGNAME.
;; Using the tramp user does not always work as
;; it can be nil, e.g., with ssh host configs.
;; $LOGNAME is defined in all POSIX-compliant
;; systems.
(unless (= 0 (process-file-shell-command
"getent passwd $LOGNAME"
nil (current-buffer) nil))
(error "Unexpected return value"))
;; If we have more than one line, the output is
;; not the expected single passwd entry.
;; Most likely, $LOGNAME is not set.
(when (> (count-lines (point-min) (point-max)) 1)
(error "Unexpected output"))))))
(shell (when entry
;; The returned Unix passwd entry is a colon-
;; separated line. The 6th (last) element specifies
;; the user's shell.
(nth 6 (split-string entry ":" nil "[ \t\n\r]+")))))
(or shell second))
first)))
(defun vterm--get-shell ()
"Get the shell that gets run in the vterm."
(if (ignore-errors (file-remote-p default-directory))
(with-parsed-tramp-file-name default-directory nil
(or (cadr (assoc method vterm-tramp-shells))
(or (vterm--tramp-get-shell method)
(vterm--tramp-get-shell t)
(with-connection-local-variables shell-file-name)
vterm-shell))
vterm-shell))
@@ -824,7 +943,8 @@ it to the bookmarked directory if needed."
`'compilation-shell-minor-mode' would change the value of local
variable `next-error-function', so we should call this function in
`compilation-shell-minor-mode-hook'."
(when (eq major-mode 'vterm-mode)
(when (or (eq major-mode 'vterm-mode)
(derived-mode-p 'vterm-mode))
(setq next-error-function 'vterm-next-error-function)))
(add-hook 'compilation-shell-minor-mode-hook #'vterm--compilation-setup)
@@ -880,7 +1000,8 @@ A conventient way to exit `vterm-copy-mode' is with
:group 'vterm
:lighter " VTermCopy"
:keymap vterm-copy-mode-map
(if (equal major-mode 'vterm-mode)
(if (or (equal major-mode 'vterm-mode)
(derived-mode-p 'vterm-mode))
(if vterm-copy-mode
(vterm--enter-copy-mode)
(vterm--exit-copy-mode))
@@ -1474,7 +1595,7 @@ Then triggers a redraw from the module."
(- count 1 partial)))
'eight-bit))
(cl-incf partial))
(when (> count partial 0)
(when (> (1+ count) partial 0)
(setq vterm--undecoded-bytes
(substring decoded-substring (- partial)))
(setq decoded-substring
@@ -1501,7 +1622,8 @@ Argument EVENT process event."
(defun vterm--text-scale-mode (&optional _argv)
"Fix `line-number' height for scaled text."
(and text-scale-mode
(equal major-mode 'vterm-mode)
(or (equal major-mode 'vterm-mode)
(derived-mode-p 'vterm-mode))
(boundp 'display-line-numbers)
(let ((height (expt text-scale-mode-step
text-scale-mode-amount)))
@@ -1606,29 +1728,27 @@ If N is negative backward-line from end of buffer."
(when raw-pwd
(vterm--get-directory raw-pwd)))))
(defun vterm--get-color (index)
"Get color by index from `vterm-color-palette'.
Argument INDEX index of the terminal color.
Special values for INDEX are:
-11 foreground for cells with underline attribute, foreground of
the `vterm-color-underline' face is used in this case.
-12 background for cells with inverse video attribute, background
of the `vterm-color-inverse-video' face is used in this case."
(cond
((and (>= index 0) (< index 8))
(face-foreground
(elt vterm-color-palette index)
nil 'default))
((and (>= index 8) (< index 16))
(face-background
(elt vterm-color-palette (% index 8))
nil 'default))
((= index -11)
(face-foreground 'vterm-color-underline nil 'default))
((= index -12)
(face-background 'vterm-color-inverse-video nil 'default))
(t
nil)))
(defun vterm--get-color (index &rest args)
"Get color by INDEX from `vterm-color-palette'.
Special INDEX of -1 is used to represent default colors. ARGS
may optionally contain `:underline' or `:inverse-video' for cells
with underline or inverse video attribute. If ARGS contains
`:foreground', use foreground color of the respective face
instead of background."
(let ((foreground (member :foreground args))
(underline (member :underline args))
(inverse-video (member :inverse-video args)))
(funcall (if foreground #'face-foreground #'face-background)
(cond
((and (>= index 0) (< index 16))
(elt vterm-color-palette index))
((and (= index -1) foreground underline)
'vterm-color-underline)
((and (= index -1) (not foreground) inverse-video)
'vterm-color-inverse-video)
(t 'default))
nil 'default)))
(defun vterm--eval (str)
"Check if string STR is `vterm-eval-cmds' and execute command.