Make sure to run the correct per-buffer filter functions by using closure

This commit is contained in:
shg 2022-05-11 07:29:40 +09:00
parent 9c6a7cd313
commit fcb13f4906

View file

@ -109,7 +109,8 @@ recreated."
(vterm-shell julia-vterm-repl-program)) (vterm-shell julia-vterm-repl-program))
(with-current-buffer buffer (with-current-buffer buffer
(julia-vterm-repl-mode) (julia-vterm-repl-mode)
(add-function :filter-args (process-filter vterm--process) #'julia-vterm-repl-run-filter-functions)) (add-function :filter-args (process-filter vterm--process)
(julia-vterm-repl-run-filter-functions-func session-name)))
buffer))) buffer)))
(defun julia-vterm-repl-buffer (&optional session-name restart) (defun julia-vterm-repl-buffer (&optional session-name restart)
@ -149,14 +150,16 @@ If there's already one with the process alive, just open it."
(defvar-local julia-vterm-repl-filter-functions '() (defvar-local julia-vterm-repl-filter-functions '()
"List of filter functions that process the output to the REPL buffer.") "List of filter functions that process the output to the REPL buffer.")
(defun julia-vterm-repl-run-filter-functions (args) (defun julia-vterm-repl-run-filter-functions-func (session)
"Run registered filter functions with ARGS." "Return a function that runs registered filter functions for SESSION with args."
(let ((proc (car args)) (lambda (args)
(str (cadr args))) (with-current-buffer (julia-vterm-repl-buffer session)
(let ((funcs julia-vterm-repl-filter-functions)) (let ((proc (car args))
(while funcs (str (cadr args)))
(setq str (apply (pop funcs) (list str)))) (let ((funcs julia-vterm-repl-filter-functions))
(list proc str)))) (while funcs
(setq str (apply (pop funcs) (list str))))
(list proc str))))))
(defun julia-vterm-repl-buffer-status () (defun julia-vterm-repl-buffer-status ()
(let* ((bs (buffer-string)) (let* ((bs (buffer-string))