unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Newbie error with add-function and process-filter
@ 2024-03-10 11:07 hendeigr via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; only message in thread
From: hendeigr via Users list for the GNU Emacs text editor @ 2024-03-10 11:07 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-10 11:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-10 11:07 Newbie error with add-function and process-filter hendeigr via Users list for the GNU Emacs text editor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).