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

110
eat.el
View file

@ -4983,22 +4983,21 @@ 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"
(let ((locals '( eat--slow-blink-state eat--fast-blink-state
eat--slow-blink-remap eat--fast-blink-remap
eat--slow-blink-timer eat--fast-blink-timer)))
(cond (cond
(eat-blink-mode (eat-blink-mode
(setq eat-blink-mode nil) (setq eat-blink-mode nil)
(require 'face-remap) (require 'face-remap)
(setq eat-blink-mode t) (setq eat-blink-mode t)
(make-local-variable 'eat--slow-blink-state) (mapc #'make-local-variable locals)
(make-local-variable 'eat--fast-blink-state)
(make-local-variable 'eat--slow-blink-remap)
(make-local-variable 'eat--fast-blink-remap)
(make-local-variable 'eat--slow-blink-timer)
(make-local-variable 'eat--fast-blink-timer)
(setq eat--slow-blink-state nil eat--fast-blink-state nil (setq eat--slow-blink-state nil eat--fast-blink-state nil
eat--slow-blink-remap eat--slow-blink-remap
(face-remap-add-relative 'eat-term-slow-blink '(:box nil)) (face-remap-add-relative 'eat-term-slow-blink '(:box nil))
eat--fast-blink-remap eat--fast-blink-remap
(face-remap-add-relative 'eat-term-fast-blink '(: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
@ -5007,12 +5006,7 @@ return \"eat-color\", otherwise return \"eat-mono\"."
(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)
(kill-local-variable 'eat--slow-blink-state) (mapc #'kill-local-variable locals)))))
(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
(let ((locals '(eat--cursor-blink-state eat--cursor-blink-timer)))
(cond (cond
(eat--cursor-blink-mode (eat--cursor-blink-mode
(make-local-variable 'eat--cursor-blink-state) (mapc #'make-local-variable locals)
(make-local-variable 'eat--cursor-blink-timer)
(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
t)
(add-hook 'post-command-hook #'eat--cursor-blink-start-timers (add-hook 'post-command-hook #'eat--cursor-blink-start-timers
nil t) nil t)
(when (current-idle-time) (when (current-idle-time)
(eat--cursor-blink-start-timers))) (eat--cursor-blink-start-timers)))
(t (t
(eat--cursor-blink-stop-timers) (eat--cursor-blink-stop-timers)
(remove-hook 'pre-command-hook #'eat--cursor-blink-stop-timers t) (remove-hook 'pre-command-hook #'eat--cursor-blink-stop-timers
t)
(remove-hook 'post-command-hook #'eat--cursor-blink-start-timers (remove-hook 'post-command-hook #'eat--cursor-blink-start-timers
t) t)
(kill-local-variable 'eat--cursor-blink-state) (mapc #'kill-local-variable locals)))))
(kill-local-variable 'eat--cursor-blink-timer))))
;;;; 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,19 +6163,20 @@ 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
(let ((locals '(cursor-type
glyphless-char-display
track-mouse
filter-buffer-substring-function
eat--terminal
eat--process
eat--synchronize-scroll-function
eat--mouse-grabbing-type
eat--pending-output-chunks
eat--output-queue-first-chunk-time
eat--process-output-queue-timer)))
(cond (cond
(eat--eshell-local-mode (eat--eshell-local-mode
(make-local-variable 'cursor-type) (mapc #'make-local-variable locals)
(make-local-variable 'glyphless-char-display)
(make-local-variable 'track-mouse)
(make-local-variable 'filter-buffer-substring-function)
(make-local-variable 'eat--terminal)
(make-local-variable 'eat--process)
(make-local-variable 'eat--synchronize-scroll-function)
(make-local-variable 'eat--mouse-grabbing-type)
(make-local-variable 'eat--pending-output-chunks)
(make-local-variable 'eat--output-queue-first-chunk-time)
(make-local-variable 'eat--process-output-queue-timer)
(setq eat--synchronize-scroll-function (setq eat--synchronize-scroll-function
#'eat--eshell-synchronize-scroll #'eat--eshell-synchronize-scroll
filter-buffer-substring-function filter-buffer-substring-function
@ -6193,17 +6189,7 @@ sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
(t (t
(when eat-enable-blinking-text (when eat-enable-blinking-text
(eat-blink-mode -1)) (eat-blink-mode -1))
(kill-local-variable 'cursor-type) (mapc #'kill-local-variable locals)))))
(kill-local-variable 'glyphless-char-display)
(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))