all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Error with add-function and process-filter
@ 2024-03-11 10:20 hendeigr via Users list for the GNU Emacs text editor
  2024-03-11 13:21 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-03-11 18:06 ` tpeplt
  0 siblings, 2 replies; 6+ messages in thread
From: hendeigr via Users list for the GNU Emacs text editor @ 2024-03-11 10:20 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Hi -

(Apologies if this is a dup - my first attempt seemed to disappear so after 24 hours, I have resent).

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,

James

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-11 20:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-11 10:20 Error with add-function and process-filter hendeigr via Users list for the GNU Emacs text editor
2024-03-11 13:21 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-03-11 18:01   ` tpeplt
2024-03-11 18:21     ` hendeigr
2024-03-11 18:06 ` tpeplt
2024-03-11 20:29   ` hendeigr

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.