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

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

Re: Error with add-function and process-filter


From: hendeigr
Subject: Re: Error with add-function and process-filter
Date: Mon, 11 Mar 2024 20:29:20 +0000





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



reply via email to

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