help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie error with add-function and process-filter


From: hendeigr
Subject: Newbie error with add-function and process-filter
Date: Sun, 10 Mar 2024 11:07:19 +0000

Hi -

I'm new to elisp and am trying to use add-function/remove-function to 
add/remove a custom process filter (in order to automate some commands in 
vterm). I thought I followed the example here: 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html

(defun h/trace (proc string)
(message (format "tracing: %s" string)))

(defun h/test ()
(interactive)
(set-buffer (vterm))
(let* ((h-proc (get-buffer-process (current-buffer))))
(message (format "%s" (process-filter h-proc)))
(add-function :before (process-filter h-proc) #'h/trace)
(term-send-raw-string "ssh whatami@doingwrong.here")
(remove-function (process-filter h-proc) #'h/trace)
) )

However, am getting this error:
Symbol’s value as variable is void: v

When I debug, it seems the process value is not being passed down correctly. 
What am I doing wrong, please?

Debugger entered--returning value: (lambda nil (process-filter v))
#'(lambda nil (process-filter v))
* (cons #'(lambda nil (process-filter v)) #'(lambda (gv--val) 
(set-process-filter v gv--val)))
* (let* ((v h-proc)) (cons #'(lambda nil (process-filter v)) #'(lambda 
(gv--val) (set-process-filter v gv--val))))
* (advice--add-function :before (let* ((v h-proc)) (cons #'(lambda nil 
(process-filter v)) #'(lambda (gv--val) (set-process-filter v gv--val)))) 
#'h/trace nil)
(let* ((h-proc (get-buffer-process (current-buffer)))) (message (format "%s" 
(process-filter h-proc))) (debug) (advice--add-function :before (let* ((v 
h-proc)) (cons #'(lambda nil (process-filter v)) #'(lambda (gv--val) 
(set-process-filter v gv--val)))) #'h/trace nil) (term-send-raw-string "ssh 
whatami@doingwrong.here") (let* ((v h-proc) (new (advice--remove-function 
(process-filter v) #'h/trace))) (if (eq new (process-filter v)) nil 
(set-process-filter v new))))
h/test()
funcall-interactively(h/test)
command-execute(h/test record)

Thanks!

Sent with [Proton Mail](https://proton.me/) secure email.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]