Fix compiler warnings

* eat.el: Wrap all 'emacs-major-version' checks with
'eval-when-compile'.
* eat.el (eat--process-input-queue): Don't use obsolete
generalized variable 'buffer-local-value'.
This commit is contained in:
Akib Azmain Turja 2023-10-17 12:08:02 +06:00
parent e0fa65c225
commit 187e18a24a
No known key found for this signature in database
GPG key ID: 5535FCF54D88616B

85
eat.el
View file

@ -783,7 +783,8 @@ If your process is choking on big inputs, try lowering the value."
(let ((face (intern (format "eat-term-color-%i" face-counter)))) (let ((face (intern (format "eat-term-color-%i" face-counter))))
(custom-declare-face (custom-declare-face
face `((t :inherit face `((t :inherit
,(intern (format (if (>= emacs-major-version 28) ,(intern (format (if (eval-when-compile
(>= emacs-major-version 28))
"ansi-color-%s" "ansi-color-%s"
"term-color-%s") "term-color-%s")
color)))) color))))
@ -797,7 +798,8 @@ If your process is choking on big inputs, try lowering the value."
(let ((face (intern (format "eat-term-color-%i" face-counter)))) (let ((face (intern (format "eat-term-color-%i" face-counter))))
(custom-declare-face (custom-declare-face
face `((t :inherit face `((t :inherit
,(intern (format (if (>= emacs-major-version 28) ,(intern (format (if (eval-when-compile
(>= emacs-major-version 28))
"ansi-color-bright-%s" "ansi-color-bright-%s"
"term-color-%s") "term-color-%s")
color)))) color))))
@ -4454,7 +4456,8 @@ client process may get confused."
(pos (if (memq 'drag modifiers) (pos (if (memq 'drag modifiers)
(event-end mouse) (event-end mouse)
(event-start mouse))) (event-start mouse)))
(x-y (if (< emacs-major-version 29) (x-y (if (eval-when-compile
(< emacs-major-version 29))
(posn-col-row pos) (posn-col-row pos)
(with-suppressed-warnings (with-suppressed-warnings
((callargs posn-col-row)) ((callargs posn-col-row))
@ -4474,7 +4477,8 @@ client process may get confused."
b))) b)))
(when ref-pos (when ref-pos
(let ((ref-x-y (let ((ref-x-y
(if (< emacs-major-version 29) (if (eval-when-compile
(< emacs-major-version 29))
(posn-col-row ref-pos) (posn-col-row ref-pos)
(with-suppressed-warnings (with-suppressed-warnings
((callargs posn-col-row)) ((callargs posn-col-row))
@ -4552,7 +4556,8 @@ client process may get confused."
(pred mouse-movement-p) (pred mouse-movement-p)
movement) movement)
(let* ((pos (event-start movement)) (let* ((pos (event-start movement))
(x-y (if (< emacs-major-version 29) (x-y (if (eval-when-compile
(< emacs-major-version 29))
(posn-col-row pos) (posn-col-row pos)
(with-suppressed-warnings (with-suppressed-warnings
((callargs posn-col-row)) ((callargs posn-col-row))
@ -4566,7 +4571,8 @@ client process may get confused."
35))) 35)))
(when ref-pos (when ref-pos
(let ((ref-x-y (let ((ref-x-y
(if (< emacs-major-version 29) (if (eval-when-compile
(< emacs-major-version 29))
(posn-col-row ref-pos) (posn-col-row ref-pos)
(with-suppressed-warnings (with-suppressed-warnings
((callargs posn-col-row)) ((callargs posn-col-row))
@ -5663,11 +5669,11 @@ ARG is passed to `yank', which see."
STRING and ARG are passed to `yank-pop', which see." STRING and ARG are passed to `yank-pop', which see."
(interactive (interactive
(progn (progn
(unless (>= emacs-major-version 28) (unless (eval-when-compile (>= emacs-major-version 28))
(error "`eat-yank-from-kill-ring' requires at least Emacs 28")) (error "`eat-yank-from-kill-ring' requires at least Emacs 28"))
(list (read-from-kill-ring "Yank from kill-ring: ") (list (read-from-kill-ring "Yank from kill-ring: ")
current-prefix-arg))) current-prefix-arg)))
(unless (>= emacs-major-version 28) (unless (eval-when-compile (>= emacs-major-version 28))
(error "`eat-yank-from-kill-ring' requires at least Emacs 28")) (error "`eat-yank-from-kill-ring' requires at least Emacs 28"))
(when eat-terminal (when eat-terminal
(funcall eat--synchronize-scroll-function (funcall eat--synchronize-scroll-function
@ -6752,22 +6758,21 @@ OS's."
(defun eat--process-input-queue (buffer) (defun eat--process-input-queue (buffer)
"Process the input queue on BUFFER." "Process the input queue on BUFFER."
(setf (buffer-local-value 'eat--process-input-queue-timer buffer) (when (buffer-live-p buffer)
nil)
(when-let* (((buffer-live-p buffer))
(terminal (buffer-local-value 'eat-terminal buffer))
(proc (eat-term-parameter terminal 'eat--process))
((process-live-p proc)))
(with-current-buffer buffer (with-current-buffer buffer
;; We don't want to recurse this function. ;; We don't want to recurse this function.
(unless eat--defer-input-processing (unless eat--defer-input-processing
(let ((inhibit-quit t) ; Don't disturb! (let ((inhibit-quit t) ; Don't disturb!
(eat--defer-input-processing t)) (eat--defer-input-processing t)
(while eat--pending-input-chunks (proc (eat-term-parameter eat-terminal 'eat--process)))
(let ((chunks (nreverse eat--pending-input-chunks))) (when (process-live-p proc)
(setq eat--pending-input-chunks nil) (while eat--pending-input-chunks
(dolist (str chunks) (let ((chunks (nreverse eat--pending-input-chunks)))
(eat--send-string proc str))))))))) (setq eat--pending-input-chunks nil)
(dolist (str chunks)
(eat--send-string proc str)))))))
(when eat--process-input-queue-timer
(cancel-timer eat--process-input-queue-timer)))))
(defun eat--process-output-queue (buffer) (defun eat--process-output-queue (buffer)
"Process the output queue on BUFFER." "Process the output queue on BUFFER."
@ -7331,7 +7336,7 @@ PROGRAM can be a shell command."
#'eat--eshell-handle-uic) #'eat--eshell-handle-uic)
(eat--set-term-sixel-params) (eat--set-term-sixel-params)
(setf (eat-term-parameter eat-terminal 'eat--process) proc) (setf (eat-term-parameter eat-terminal 'eat--process) proc)
(unless (>= emacs-major-version 29) (unless (eval-when-compile (>= emacs-major-version 29))
(setf (eat-term-parameter eat-terminal 'eat--input-process) (setf (eat-term-parameter eat-terminal 'eat--input-process)
proc)) proc))
(setf (eat-term-parameter eat-terminal 'eat--output-process) proc) (setf (eat-term-parameter eat-terminal 'eat--output-process) proc)
@ -7359,9 +7364,12 @@ PROGRAM can be a shell command."
(set-marker eshell-last-output-end (point)) (set-marker eshell-last-output-end (point))
(eat--cursor-blink-mode -1) (eat--cursor-blink-mode -1)
(eat--grab-mouse nil nil) (eat--grab-mouse nil nil)
(set-process-filter (eat-term-parameter (set-process-filter
eat-terminal 'eat--output-process) (eat-term-parameter
#'eshell-output-filter) eat-terminal 'eat--output-process)
(if (eval-when-compile (< emacs-major-version 30))
#'eshell-output-filter
#'eshell-interactive-process-filter))
(eat-term-delete eat-terminal) (eat-term-delete eat-terminal)
(setq eat-terminal nil) (setq eat-terminal nil)
(kill-local-variable 'eshell-output-filter-functions) (kill-local-variable 'eshell-output-filter-functions)
@ -7372,6 +7380,8 @@ PROGRAM can be a shell command."
(run-hooks 'eat-eshell-exit-hook))) (run-hooks 'eat-eshell-exit-hook)))
(declare-function eshell-output-filter "esh-mode" (process string)) (declare-function eshell-output-filter "esh-mode" (process string))
(declare-function eshell-interactive-process-filter "esh-mode"
(process string))
(defun eat--eshell-process-output-queue (process buffer) (defun eat--eshell-process-output-queue (process buffer)
"Process the output queue on BUFFER from PROCESS." "Process the output queue on BUFFER from PROCESS."
@ -7382,15 +7392,18 @@ 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)
(if (< emacs-major-version 27) (if (eval-when-compile (< emacs-major-version 27))
(eshell-output-filter (eshell-output-filter
process (string-join (nreverse queue))) process (string-join (nreverse queue)))
(combine-change-calls (combine-change-calls
(eat-term-beginning eat-terminal) (eat-term-beginning eat-terminal)
(eat-term-end eat-terminal) (eat-term-end eat-terminal)
;; TODO: Is `string-join' OK or should we use a loop? ;; TODO: Is `string-join' OK or should we use a loop?
(eshell-output-filter (if (eval-when-compile (< emacs-major-version 30))
process (string-join (nreverse queue))))))))) (eshell-output-filter
process (string-join (nreverse queue)))
(eshell-interactive-process-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."
@ -7469,7 +7482,7 @@ Disable terminal emulation? ")))
(unwind-protect (unwind-protect
(cond (cond
;; Emacs 29 and above. ;; Emacs 29 and above.
((>= emacs-major-version 29) ((eval-when-compile (>= emacs-major-version 29))
(cl-letf* (cl-letf*
((make-process (symbol-function #'make-process)) ((make-process (symbol-function #'make-process))
((symbol-function #'make-process) ((symbol-function #'make-process)
@ -7662,7 +7675,7 @@ symbol `buffer', in which case the point of current buffer is set."
(dolist (buffer (buffer-list)) (dolist (buffer (buffer-list))
(with-current-buffer buffer (with-current-buffer buffer
(when (eq major-mode #'eshell-mode) (when (eq major-mode #'eshell-mode)
(when (if (< emacs-major-version 29) (when (if (eval-when-compile (< emacs-major-version 29))
(bound-and-true-p eshell-last-async-proc) (bound-and-true-p eshell-last-async-proc)
(bound-and-true-p eshell-last-async-procs)) (bound-and-true-p eshell-last-async-procs))
(user-error (user-error
@ -7677,7 +7690,7 @@ symbol `buffer', in which case the point of current buffer is set."
(add-hook 'eshell-directory-change-hook #'eat--eshell-update-cwd) (add-hook 'eshell-directory-change-hook #'eat--eshell-update-cwd)
(advice-add #'eshell-gather-process-output :around (advice-add #'eshell-gather-process-output :around
#'eat--eshell-adjust-make-process-args) #'eat--eshell-adjust-make-process-args)
(when (>= emacs-major-version 29) (when (eval-when-compile (>= emacs-major-version 29))
(advice-add #'eshell-resume-eval :after (advice-add #'eshell-resume-eval :after
#'eat--eshell-set-input-process))) #'eat--eshell-set-input-process)))
(t (t
@ -7687,7 +7700,7 @@ symbol `buffer', in which case the point of current buffer is set."
(with-current-buffer buffer (with-current-buffer buffer
(when (and (eq major-mode #'eshell-mode) (when (and (eq major-mode #'eshell-mode)
eat--eshell-local-mode) eat--eshell-local-mode)
(when (if (< emacs-major-version 29) (when (if (eval-when-compile (< emacs-major-version 29))
(bound-and-true-p eshell-last-async-proc) (bound-and-true-p eshell-last-async-proc)
(bound-and-true-p eshell-last-async-procs)) (bound-and-true-p eshell-last-async-procs))
(user-error (user-error
@ -7703,7 +7716,7 @@ symbol `buffer', in which case the point of current buffer is set."
#'eat--eshell-update-cwd) #'eat--eshell-update-cwd)
(advice-remove #'eshell-gather-process-output (advice-remove #'eshell-gather-process-output
#'eat--eshell-adjust-make-process-args) #'eat--eshell-adjust-make-process-args)
(when (>= emacs-major-version 29) (when (eval-when-compile (>= emacs-major-version 29))
(advice-remove #'eshell-resume-eval (advice-remove #'eshell-resume-eval
#'eat--eshell-set-input-process))))) #'eat--eshell-set-input-process)))))