Support Emacs 26.1

* eat.el: Depend on Emacs 26.1.
* eat.el (eat--t-handle-output, eat--handle-uic)
(eat--eshell-handle-uic): Don't use '(not CHAR)' form in 'rx'
forms.
* eat.el (eat--eshell-process-output-queue): Use
'combine-change-calls' if available.
* README.org: Update to reflect support for Emacs 26.
This commit is contained in:
Akib Azmain Turja 2023-10-07 20:45:26 +06:00
parent 09e1198dd4
commit 957fdb4a8f
No known key found for this signature in database
GPG key ID: 5535FCF54D88616B
2 changed files with 23 additions and 19 deletions

View file

@ -98,15 +98,15 @@ be accessed with =C-h i m Eat=, also available [[https://elpa.nongnu.org/nongnu-
* Installation * Installation
Eat requires at least Emacs 27.1 or above. Eat requires at least Emacs 26.1 or above.
** NonGNU ELPA ** NonGNU ELPA
Eat is available on NonGNU ELPA. So you can just do Eat is available on NonGNU ELPA. So you can just do
=M-x package-install RET eat RET=. =M-x package-install RET eat RET=.
If you're on Emacs 27, you'll need to add NonGNU ELPA to your If you're on Emacs 27 or earlier, you'll need to add NonGNU ELPA to
~package-archives~ by putting the following in your ~init.el~: your ~package-archives~ by putting the following in your ~init.el~:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-to-list 'package-archives (add-to-list 'package-archives
@ -153,7 +153,7 @@ native-compiled Term even without byte-compilation, and when Eat is
byte-compiled, Eat is more than three times fast. Also, Term byte-compiled, Eat is more than three times fast. Also, Term
flickers, just try to run =emacs -nw= in it. It doesn't support flickers, just try to run =emacs -nw= in it. It doesn't support
remote connections, for example over Tramp. However, it's builtin remote connections, for example over Tramp. However, it's builtin
from the early days of Emacs, while Eat needs atleast Emacs 27.1. from the early days of Emacs, while Eat needs atleast Emacs 26.1.
** Vterm ** Vterm
@ -161,7 +161,7 @@ Vterm is powered by a C library, libvterm. For this reason, it can
process huge amount of text quickly. It is about 1.5 times faster process huge amount of text quickly. It is about 1.5 times faster
than Eat (byte-compiled or native-compiled) (and about 2.75 faster than Eat (byte-compiled or native-compiled) (and about 2.75 faster
then Eat without byte-compilation). But it doesn't have a char mode then Eat without byte-compilation). But it doesn't have a char mode
(however you can make a char mode spending some effort). And it too (however you can make a char mode by putting some effort). And it too
flickers like Term, so despite being much faster that Eat, it seems to flickers like Term, so despite being much faster that Eat, it seems to
be slow. If you need your terminal to handle huge bursts (megabytes) be slow. If you need your terminal to handle huge bursts (megabytes)
of data, you should use Vterm. of data, you should use Vterm.

32
eat.el
View file

@ -5,7 +5,7 @@
;; Author: Akib Azmain Turja <akib@disroot.org> ;; Author: Akib Azmain Turja <akib@disroot.org>
;; Created: 2022-08-15 ;; Created: 2022-08-15
;; Version: 0.8 ;; Version: 0.8
;; Package-Requires: ((emacs "27.1") (compat "29.1")) ;; Package-Requires: ((emacs "29.1") (compat "29.1"))
;; Keywords: terminals processes ;; Keywords: terminals processes
;; Homepage: https://codeberg.org/akib/emacs-eat ;; Homepage: https://codeberg.org/akib/emacs-eat
@ -3694,7 +3694,7 @@ If NULLIFY is non-nil, nullify flushed part of Sixel buffer."
;; OSC 5 2 ; <t> ; <s> ST. ;; OSC 5 2 ; <t> ; <s> ST.
((rx string-start "52;" ((rx string-start "52;"
(let targets (let targets
(zero-or-more (not ?\;))) (zero-or-more (not (any ?\;))))
?\; (let data (zero-or-more anything)) ?\; (let data (zero-or-more anything))
string-end) string-end)
(eat--t-manipulate-selection (eat--t-manipulate-selection
@ -5362,7 +5362,7 @@ BUFFER is the terminal buffer."
;; more parameters. ;; more parameters.
;; UIC e ; A ; <t> ; <s> ST. ;; UIC e ; A ; <t> ; <s> ST.
((rx string-start "e;A;" ((rx string-start "e;A;"
(let host (zero-or-more (not ?\;))) (let host (zero-or-more (not (any ?\;))))
?\; (let path (zero-or-more anything)) ?\; (let path (zero-or-more anything))
string-end) string-end)
(eat--set-cwd-uic host path)) (eat--set-cwd-uic host path))
@ -5395,14 +5395,14 @@ BUFFER is the terminal buffer."
(eat--set-cmd-status (string-to-number status))) (eat--set-cmd-status (string-to-number status)))
;; UIC e ; I ; 0 ; <t> ; <t> ; <t> ST. ;; UIC e ; I ; 0 ; <t> ; <t> ; <t> ST.
((rx string-start "e;I;0;" ((rx string-start "e;I;0;"
(let format (zero-or-more (not ?\;))) (let format (zero-or-more (not (any ?\;))))
?\; (let host (zero-or-more (not ?\;))) ?\; (let host (zero-or-more (not (any ?\;))))
?\; (let path (zero-or-more anything)) ?\; (let path (zero-or-more anything))
string-end) string-end)
(eat--get-shell-history (cons host path) format)) (eat--get-shell-history (cons host path) format))
;; UIC e ; I ; 1 ; <t> ; <t> ST. ;; UIC e ; I ; 1 ; <t> ; <t> ST.
((rx string-start "e;I;1;" ((rx string-start "e;I;1;"
(let format (zero-or-more (not ?\;))) (let format (zero-or-more (not (any ?\;))))
?\; (let hist (zero-or-more anything)) ?\; (let hist (zero-or-more anything))
string-end) string-end)
(eat--get-shell-history hist format)) (eat--get-shell-history hist format))
@ -7209,7 +7209,7 @@ PROGRAM can be a shell command."
(pcase cmd (pcase cmd
;; UIC e ; A ; <t> ; <s> ST. ;; UIC e ; A ; <t> ; <s> ST.
((rx string-start "e;A;" ((rx string-start "e;A;"
(let host (zero-or-more (not ?\;))) (let host (zero-or-more (not (any ?\;))))
?\; (let path (zero-or-more anything)) ?\; (let path (zero-or-more anything))
string-end) string-end)
(eat--set-cwd-uic host path)) (eat--set-cwd-uic host path))
@ -7335,12 +7335,15 @@ PROGRAM can be a shell command."
(setq eat--output-queue-first-chunk-time nil) (setq eat--output-queue-first-chunk-time nil)
(let ((queue eat--pending-output-chunks)) (let ((queue eat--pending-output-chunks))
(setq eat--pending-output-chunks nil) (setq eat--pending-output-chunks nil)
(combine-change-calls (if (< emacs-major-version 27)
(eat-term-beginning eat-terminal) (eshell-output-filter
(eat-term-end eat-terminal) process (string-join (nreverse queue)))
;; TODO: Is `string-join' OK or should we use a loop? (combine-change-calls
(eshell-output-filter (eat-term-beginning eat-terminal)
process (string-join (nreverse queue)))))))) (eat-term-end eat-terminal)
;; TODO: Is `string-join' OK or should we use a loop?
(eshell-output-filter
process (string-join (nreverse queue)))))))))
(defun eat--eshell-filter (process string) (defun eat--eshell-filter (process string)
"Process output STRING from PROCESS." "Process output STRING from PROCESS."
@ -7499,6 +7502,8 @@ symbol `buffer', in which case the point of current buffer is set."
"Update the current working directory." "Update the current working directory."
(setq eat--eshell-invocation-directory default-directory)) (setq eat--eshell-invocation-directory default-directory))
(defvar eshell-variable-aliases-list) ; In `esh-var'.
(define-minor-mode eat--eshell-local-mode (define-minor-mode eat--eshell-local-mode
"Toggle Eat terminal emulation is Eshell." "Toggle Eat terminal emulation is Eshell."
:interactive nil :interactive nil
@ -7553,7 +7558,6 @@ symbol `buffer', in which case the point of current buffer is set."
(declare-function eshell-gather-process-output "esh-proc" (declare-function eshell-gather-process-output "esh-proc"
(command args)) (command args))
(defvar eshell-variable-aliases-list) ; In `esh-var'.
(defvar eshell-last-async-proc) ; In `esh-cmd'. (defvar eshell-last-async-proc) ; In `esh-cmd'.
(defvar eshell-last-async-procs) ; In `esh-cmd'. (defvar eshell-last-async-procs) ; In `esh-cmd'.