From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tpeplt Newsgroups: gmane.emacs.help Subject: Re: Error with add-function and process-filter Date: Mon, 11 Mar 2024 14:06:24 -0400 Message-ID: <87cys0zlr3.fsf@gmail.com> References: 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="20518"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: hendeigr To: hendeigr via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 11 19:06:56 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 1rjk35-00057b-T6 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 11 Mar 2024 19:06:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjk2p-0003hB-GB; Mon, 11 Mar 2024 14:06:39 -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 1rjk2n-0003gl-EW for help-gnu-emacs@gnu.org; Mon, 11 Mar 2024 14:06:38 -0400 Original-Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rjk2d-0003pJ-1H for help-gnu-emacs@gnu.org; Mon, 11 Mar 2024 14:06:37 -0400 Original-Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-221a37a29f5so2020790fac.3 for ; Mon, 11 Mar 2024 11:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710180385; x=1710785185; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AV/e76d5gx1D8LWBEOonRuGfpcsDsKbeILWgL/VjdT8=; b=Ait83TboL0EifElj+oAXSNYn0gcf02qGyIFZxd2pYJqLdGNq0VK1QGomFcc8dc4xwH +jEnLbHmgah+d8kPqOos2xSzeQ8GTdm7/0FXUSmu4Lb+P6Xk8vUO0sGzMGDxADWInxlj F4bUMLlxD5uAnINtC5G+J8vEncSMDsin0uddHbeYS6K7ZGFCo1qsmoM7GBRhqp3ksUiR iHc8j7pu0D8evrCtfxCErETAFhb+VyOCgvSUd6Hp9xtbQCDTvCJVzqqwu00BtHkSEIU2 835fEzTaNhIcq9A/ko+Z6bIefpsLTwZVOO3dUFnYWhCoa4Mlfp5M1nz5Qj4H15Vih5ln nUdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710180385; x=1710785185; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AV/e76d5gx1D8LWBEOonRuGfpcsDsKbeILWgL/VjdT8=; b=hu40QI86aFr04yndJVfzg5t448xhlyU8O+PCiMGp9g7AVFxpjluLJ/ADPGReeTrW6G DL/C1DqGE73NnZkc5P4ByvzzhK/7PpfTiQRxUHJR2IdfcK9npltMp6zC/TmIziCcprkJ 00uiSZ9cSmZoM4+akjLm2YVO0QD3LGBqfQMaa/mDeVhs4wJjmZ1dZT2mee2xpjwWX3zW /YoaA6HgkOVNZCDQaeLV4LdfOspiHEUQ7tEqAJuWW5iIlKN1RsvJTHLRGV/t+BIydNVi DzJhwNXXaa5lhUCw2QUZRcLmOfG5CGjddYcYPWB1XzLKSFW3dRWfHysyffu8k+GYW0vu lbeg== X-Gm-Message-State: AOJu0Yzftk4gIlA1Kg9Xhw00GyBioudh0JelWS1uMML6FJfbk532POLW 5MF1IHyyHBKlNTi7wjTjYVN4bFbVn+chkWYNyNNJwyBy2ppfuu3OM+W5CnYI5Vw= X-Google-Smtp-Source: AGHT+IHWgYWUxDQfSf9z34P4+yHuYRDLO+wq2A6glgF1lfAhUTXFwjsgvYUZQRh4mNISHp4n3pDBuw== X-Received: by 2002:a05:6870:41d1:b0:220:8d0d:e25e with SMTP id z17-20020a05687041d100b002208d0de25emr8107844oac.47.1710180385589; Mon, 11 Mar 2024 11:06:25 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a821:2b00::cfce]) by smtp.gmail.com with ESMTPSA id dc7-20020a056214174700b0068ff0778895sm2889911qvb.81.2024.03.11.11.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 11:06:25 -0700 (PDT) In-Reply-To: (hendeigr via Users list for the's message of "Mon, 11 Mar 2024 10:20:14 +0000") Received-SPF: pass client-ip=2001:4860:4864:20::32; envelope-from=tpeplt@gmail.com; helo=mail-oa1-x32.google.com 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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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:146076 Archived-At: hendeigr via Users list for the GNU Emacs text editor 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-Functi= ons.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))) 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 =E2=80=98term-send-raw-string=E2=80=99 is not kn= own to be defined. Warning: the function =E2=80=98vterm=E2=80=99 is not known to be defin= ed. (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=E2=80=99s 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. --