Use 'mapc' to make & kill multiple local variables

* eat.el (eat-blink-mode, eat--cursor-blink-mode, eat-mode)
(eat--eshell-local-mode, eat-trace-replay-mode): Use 'mapc' to
make & kill multiple local variables.
This commit is contained in:
Akib Azmain Turja 2022-11-29 00:58:09 +06:00
parent 528bfe424d
commit 10d9f3cb56
No known key found for this signature in database
GPG key ID: 5535FCF54D88616B

194
eat.el
View file

@ -4983,36 +4983,30 @@ return \"eat-color\", otherwise return \"eat-mono\"."
(define-minor-mode eat-blink-mode (define-minor-mode eat-blink-mode
"Toggle blinking of text with blink attribute." "Toggle blinking of text with blink attribute."
:lighter " Eat-Blink" :lighter " Eat-Blink"
(cond (let ((locals '( eat--slow-blink-state eat--fast-blink-state
(eat-blink-mode eat--slow-blink-remap eat--fast-blink-remap
(setq eat-blink-mode nil) eat--slow-blink-timer eat--fast-blink-timer)))
(require 'face-remap) (cond
(setq eat-blink-mode t) (eat-blink-mode
(make-local-variable 'eat--slow-blink-state) (setq eat-blink-mode nil)
(make-local-variable 'eat--fast-blink-state) (require 'face-remap)
(make-local-variable 'eat--slow-blink-remap) (setq eat-blink-mode t)
(make-local-variable 'eat--fast-blink-remap) (mapc #'make-local-variable locals)
(make-local-variable 'eat--slow-blink-timer) (setq eat--slow-blink-state nil eat--fast-blink-state nil
(make-local-variable 'eat--fast-blink-timer) eat--slow-blink-remap
(setq eat--slow-blink-state nil eat--fast-blink-state nil (face-remap-add-relative 'eat-term-slow-blink '(:box nil))
eat--slow-blink-remap eat--fast-blink-remap
(face-remap-add-relative 'eat-term-slow-blink '(:box nil)) (face-remap-add-relative 'eat-term-fast-blink
eat--fast-blink-remap '(:box nil)))
(face-remap-add-relative 'eat-term-fast-blink '(:box nil))) (add-hook 'pre-command-hook #'eat--blink-stop-timers nil t)
(add-hook 'pre-command-hook #'eat--blink-stop-timers nil t) (add-hook 'post-command-hook #'eat--blink-start-timers nil t))
(add-hook 'post-command-hook #'eat--blink-start-timers nil t)) (t
(t (eat--blink-stop-timers)
(eat--blink-stop-timers) (face-remap-remove-relative eat--slow-blink-remap)
(face-remap-remove-relative eat--slow-blink-remap) (face-remap-remove-relative eat--fast-blink-remap)
(face-remap-remove-relative eat--fast-blink-remap) (remove-hook 'pre-command-hook #'eat--blink-stop-timers t)
(remove-hook 'pre-command-hook #'eat--blink-stop-timers t) (remove-hook 'post-command-hook #'eat--blink-start-timers t)
(remove-hook 'post-command-hook #'eat--blink-start-timers t) (mapc #'kill-local-variable locals)))))
(kill-local-variable 'eat--slow-blink-state)
(kill-local-variable 'eat--fast-blink-state)
(kill-local-variable 'eat--slow-blink-remap)
(kill-local-variable 'eat--fast-blink-remap)
(kill-local-variable 'eat--slow-blink-timer)
(kill-local-variable 'eat--fast-blink-timer))))
;;;; Buffer-local Cursor Blinking. ;;;; Buffer-local Cursor Blinking.
@ -5059,23 +5053,24 @@ return \"eat-color\", otherwise return \"eat-mono\"."
(define-minor-mode eat--cursor-blink-mode (define-minor-mode eat--cursor-blink-mode
"Toggle blinking of cursor." "Toggle blinking of cursor."
:interactive nil :interactive nil
(cond (let ((locals '(eat--cursor-blink-state eat--cursor-blink-timer)))
(eat--cursor-blink-mode (cond
(make-local-variable 'eat--cursor-blink-state) (eat--cursor-blink-mode
(make-local-variable 'eat--cursor-blink-timer) (mapc #'make-local-variable locals)
(setq eat--cursor-blink-state nil eat--cursor-blink-timer nil) (setq eat--cursor-blink-state nil eat--cursor-blink-timer nil)
(add-hook 'pre-command-hook #'eat--cursor-blink-stop-timers nil t) (add-hook 'pre-command-hook #'eat--cursor-blink-stop-timers nil
(add-hook 'post-command-hook #'eat--cursor-blink-start-timers t)
nil t) (add-hook 'post-command-hook #'eat--cursor-blink-start-timers
(when (current-idle-time) nil t)
(eat--cursor-blink-start-timers))) (when (current-idle-time)
(t (eat--cursor-blink-start-timers)))
(eat--cursor-blink-stop-timers) (t
(remove-hook 'pre-command-hook #'eat--cursor-blink-stop-timers t) (eat--cursor-blink-stop-timers)
(remove-hook 'post-command-hook #'eat--cursor-blink-start-timers (remove-hook 'pre-command-hook #'eat--cursor-blink-stop-timers
t) t)
(kill-local-variable 'eat--cursor-blink-state) (remove-hook 'post-command-hook #'eat--cursor-blink-start-timers
(kill-local-variable 'eat--cursor-blink-timer)))) t)
(mapc #'kill-local-variable locals)))))
;;;; User Interface. ;;;; User Interface.
@ -5494,21 +5489,21 @@ END if it's safe to do so."
(define-derived-mode eat-mode fundamental-mode "Eat" (define-derived-mode eat-mode fundamental-mode "Eat"
"Major mode for Eat." "Major mode for Eat."
:group 'eat-ui :group 'eat-ui
(make-local-variable 'buffer-read-only) (mapc #'make-local-variable '(buffer-read-only
(make-local-variable 'buffer-undo-list) buffer-undo-list
(make-local-variable 'filter-buffer-substring-function) filter-buffer-substring-function
(make-local-variable 'mode-line-process) mode-line-process
(make-local-variable 'mode-line-buffer-identification) mode-line-buffer-identification
(make-local-variable 'glyphless-char-display) glyphless-char-display
(make-local-variable 'cursor-type) cursor-type
(make-local-variable 'track-mouse) track-mouse
(make-local-variable 'eat--terminal) eat--terminal
(make-local-variable 'eat--process) eat--process
(make-local-variable 'eat--synchronize-scroll-function) eat--synchronize-scroll-function
(make-local-variable 'eat--mouse-grabbing-type) eat--mouse-grabbing-type
(make-local-variable 'eat--pending-output-chunks) eat--pending-output-chunks
(make-local-variable 'eat--output-queue-first-chunk-time) eat--output-queue-first-chunk-time
(make-local-variable 'eat--process-output-queue-timer) eat--process-output-queue-timer))
;; This is intended; input methods don't work on read-only buffers. ;; This is intended; input methods don't work on read-only buffers.
(setq buffer-read-only nil buffer-undo-list t (setq buffer-read-only nil buffer-undo-list t
eat--synchronize-scroll-function #'eat--synchronize-scroll eat--synchronize-scroll-function #'eat--synchronize-scroll
@ -6168,42 +6163,33 @@ sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
"Toggle Eat terminal emulation is Eshell." "Toggle Eat terminal emulation is Eshell."
:interactive nil :interactive nil
:keymap eat-eshell-emacs-mode-map :keymap eat-eshell-emacs-mode-map
(cond (let ((locals '(cursor-type
(eat--eshell-local-mode glyphless-char-display
(make-local-variable 'cursor-type) track-mouse
(make-local-variable 'glyphless-char-display) filter-buffer-substring-function
(make-local-variable 'track-mouse) eat--terminal
(make-local-variable 'filter-buffer-substring-function) eat--process
(make-local-variable 'eat--terminal) eat--synchronize-scroll-function
(make-local-variable 'eat--process) eat--mouse-grabbing-type
(make-local-variable 'eat--synchronize-scroll-function) eat--pending-output-chunks
(make-local-variable 'eat--mouse-grabbing-type) eat--output-queue-first-chunk-time
(make-local-variable 'eat--pending-output-chunks) eat--process-output-queue-timer)))
(make-local-variable 'eat--output-queue-first-chunk-time) (cond
(make-local-variable 'eat--process-output-queue-timer) (eat--eshell-local-mode
(setq eat--synchronize-scroll-function (mapc #'make-local-variable locals)
#'eat--eshell-synchronize-scroll (setq eat--synchronize-scroll-function
filter-buffer-substring-function #'eat--eshell-synchronize-scroll
#'eat--filter-buffer-substring) filter-buffer-substring-function
;; Make sure glyphless character don't display a huge box glyph, #'eat--filter-buffer-substring)
;; that would break the display. ;; Make sure glyphless character don't display a huge box glyph,
(eat--setup-glyphless-chars) ;; that would break the display.
(when eat-enable-blinking-text (eat--setup-glyphless-chars)
(eat-blink-mode +1))) (when eat-enable-blinking-text
(t (eat-blink-mode +1)))
(when eat-enable-blinking-text (t
(eat-blink-mode -1)) (when eat-enable-blinking-text
(kill-local-variable 'cursor-type) (eat-blink-mode -1))
(kill-local-variable 'glyphless-char-display) (mapc #'kill-local-variable locals)))))
(kill-local-variable 'track-mouse)
(make-local-variable 'filter-buffer-substring-function)
(kill-local-variable 'eat--terminal)
(kill-local-variable 'eat--process)
(kill-local-variable 'eat--synchronize-scroll-function)
(kill-local-variable 'eat--mouse-grabbing-type)
(kill-local-variable 'eat--pending-output-chunks)
(kill-local-variable 'eat--output-queue-first-chunk-time)
(kill-local-variable 'eat--process-output-queue-timer))))
(declare-function eshell-gather-process-output "esh-proc" (declare-function eshell-gather-process-output "esh-proc"
(command args)) (command args))
@ -6805,12 +6791,12 @@ N defaults to 1. Interactively, N is the prefix argument."
(define-derived-mode eat-trace-replay-mode special-mode (define-derived-mode eat-trace-replay-mode special-mode
"Eat-Trace-Replay" "Eat-Trace-Replay"
"Major mode for replaying terminal according to trace output." "Major mode for replaying terminal according to trace output."
(make-local-variable 'eat--terminal) (mapc #'make-local-variable '(eat--terminal
(make-local-variable 'eat--trace-replay-source-buffer) eat--trace-replay-source-buffer
(make-local-variable 'eat--trace-replay-recording-start-time) eat--trace-replay-recording-start-time
(make-local-variable 'eat--trace-replay-progress) eat--trace-replay-progress
(make-local-variable 'eat--trace-replay-frame-count) eat--trace-replay-frame-count
(make-local-variable 'eat--trace-replay-progress-frame) eat--trace-replay-progress-frame))
(setq-local (setq-local
mode-line-process mode-line-process
'("[" (:eval (number-to-string eat--trace-replay-progress-frame)) '("[" (:eval (number-to-string eat--trace-replay-progress-frame))