From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: hendeigr Newsgroups: gmane.emacs.help Subject: Re: Error with add-function and process-filter Date: Mon, 11 Mar 2024 20:29:20 +0000 Message-ID: References: <87cys0zlr3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10914"; mail-complaints-to="usenet@ciao.gmane.io" Cc: hendeigr via Users list for the GNU Emacs text editor To: tpeplt Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 11 21:30:23 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rjmHv-0002bo-ID for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 11 Mar 2024 21:30:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjmHP-0003ZP-8L; Mon, 11 Mar 2024 16:29:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjmHE-0003Ve-TV for help-gnu-emacs@gnu.org; Mon, 11 Mar 2024 16:29:42 -0400 Original-Received: from mail-4324.protonmail.ch ([185.70.43.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjmHC-0005Te-Lf for help-gnu-emacs@gnu.org; Mon, 11 Mar 2024 16:29:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1710188976; x=1710448176; bh=VThdc1HdG9SmL9DX4NFC+VuZiLP1OAzlRa1RfkRPs4s=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=cnz4qBjQ2Psq30fdXCbIjFsuo7k8ndE/O+bDFVtWszPzbs0ZoHn98F/2/8jktG5mF PwJgbjFNd9F9k3/GCJ54WeebrlSOHklNTztlujZLwVG9PN9f+JVz18YNrop98uQUSX NFE2Ezy9mGZ0/8wroj1QJUK7ocm8sHlBsuk+oPId0OXY84374SHx4krbfRX7Q45dH/ RaPUPbLWzRxw7yk65vhP9+ybPDuXo6UtlcGx1pwHcWVHB4sRbslwIymdaQVdLy3a15 cHnNjk1BY1VF+wFvLOM2HAtXTYuUCpdwhvxI1cEwpvAWVdbDNe+a/pBN7SbUiVj6yu AFjn83UVIDNew== In-Reply-To: <87cys0zlr3.fsf@gmail.com> Feedback-ID: 22618419:user:proton Received-SPF: pass client-ip=185.70.43.24; envelope-from=hendeigr@protonmail.com; helo=mail-4324.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:146078 Archived-At: Sent with Proton Mail secure email. On Monday, 11 March 2024 at 18:06, tpeplt wrote: > hendeigr via Users list for the GNU Emacs text editor > help-gnu-emacs@gnu.org writes: >=20 > > Hi - > >=20 > > (Apologies if this is a dup - my first attempt seemed to disappear so > > after 24 hours, I have resent). > >=20 > > 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-Func= tions.html > >=20 > > defun h/trace (proc string) > > (message (format "tracing: %s" string))) > >=20 > > 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))) >=20 >=20 > 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.) >=20 > 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: >=20 > In h/trace: > Warning: Unused lexical argument `proc' >=20 > In end of data: > Warning: the function =E2=80=98term-send-raw-string=E2=80=99 is not known= to be defined. > Warning: the function =E2=80=98vterm=E2=80=99 is not known to be defined. >=20 > (File name and line/columns numbers omitted.) These warning messages > may vary depending on your version of Emacs. >=20 > 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=E2=80=99s contents follow th= e menu > from Emacs-Lisp -> Linting -> Lint Buffer. >=20 >=20 > 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. >=20 > -- Thank you - this is great advice! I usually have the menu bar hidden but re= alize now that this is a mistake while I am learning elisp - I have been mi= ssing out on a lot of helpful functionality. Really appreciate the steer. Thanks again, James