From: tpeplt <tpeplt@gmail.com>
To: hendeigr via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Cc: hendeigr <hendeigr@protonmail.com>
Subject: Re: Error with add-function and process-filter
Date: Mon, 11 Mar 2024 14:06:24 -0400 [thread overview]
Message-ID: <87cys0zlr3.fsf@gmail.com> (raw)
In-Reply-To: <P_iJn_mWIxbC4ZsLTlf6YVxXunk5S5HBVHvBD0Go-t9cCMjm86CxmEwnA02YRM13xYdUe7x2jPvAMlN0Axa3Wr7uXDStHH-KZbDTmno3kCs=@protonmail.com> (hendeigr via Users list for the's message of "Mon, 11 Mar 2024 10:20:14 +0000")
hendeigr via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> 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)))
1. When you are editing an Emacs Lisp file, then two details for you to
note are that a) the major mode is Emacs Lisp (indicated by the text
(Elisp... in the mode line) and b) the menu bar will include an
"Emacs-Lisp" entry. While you are new to Emacs Lisp, it will be
helpful for you to use that menu item. (If you spend a lot of time
writing in Emacs Lisp, then you will eventually want to learn key
sequences and command names that will enable you to execute commands
more quickly.)
Using the "Emacs-Lisp" menu, locate the "Byte-compile This File"
entry. When you click on this, then for the code that you provided, you
will see the following warnings:
In h/trace:
Warning: Unused lexical argument `proc'
In end of data:
Warning: the function ‘term-send-raw-string’ is not known to be defined.
Warning: the function ‘vterm’ is not known to be defined.
(File name and line/columns numbers omitted.) These warning messages
may vary depending on your version of Emacs.
2. In addition to the byte-compiler, Emacs includes a lint utility that
can be helpful for finding errors (although it can have problems
understanding macros, but that mostly should not be a concern for new
users). To run the Emacs lint on your buffer’s contents follow the menu
from Emacs-Lisp -> Linting -> Lint Buffer.
Once you have resolved any byte-compiler problems, then if your problem
still persists you should send a sufficiently complete segment of code
that allows readers to byte-compile the code and reproduce the problem.
--
next prev parent reply other threads:[~2024-03-11 18:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-03-11 20:29 ` hendeigr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cys0zlr3.fsf@gmail.com \
--to=tpeplt@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=hendeigr@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).