From: hendeigr <hendeigr@protonmail.com>
To: tpeplt <tpeplt@gmail.com>
Cc: hendeigr via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Error with add-function and process-filter
Date: Mon, 11 Mar 2024 20:29:20 +0000 [thread overview]
Message-ID: <Z0y5IJZ9A2PnCfw9n-9Lj93d77pbJvifWaXTf-tUsItD5qo3TmjGwSaSfFkjaWF3NUW7qj7nw7gpFpj8tHJ-trkPC47QORz35m0v7ZWeSws=@protonmail.com> (raw)
In-Reply-To: <87cys0zlr3.fsf@gmail.com>
Sent with Proton Mail secure email.
On Monday, 11 March 2024 at 18:06, tpeplt <tpeplt@gmail.com> wrote:
> 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.
>
> --
Thank you - this is great advice! I usually have the menu bar hidden but realize now that this is a mistake while I am learning elisp - I have been missing out on a lot of helpful functionality. Really appreciate the steer.
Thanks again,
James
prev parent reply other threads:[~2024-03-11 20:29 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
2024-03-11 20:29 ` hendeigr [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='Z0y5IJZ9A2PnCfw9n-9Lj93d77pbJvifWaXTf-tUsItD5qo3TmjGwSaSfFkjaWF3NUW7qj7nw7gpFpj8tHJ-trkPC47QORz35m0v7ZWeSws=@protonmail.com' \
--to=hendeigr@protonmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=tpeplt@gmail.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.
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.