From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Newsgroups: gmane.emacs.devel Subject: Re: Calling internal-default-process-sentinel from another sentinel? Date: Wed, 18 Nov 2020 15:37:48 +0100 Message-ID: <87pn4a688z.fsf@gmail.com> References: <87sg966bh5.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="17119"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.31 (https://notmuchmail.org) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 18 15:35:54 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kfOYs-0004KO-Ec for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 15:35:54 +0100 Original-Received: from localhost ([::1]:39998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfOYr-0001MY-5J for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 09:35:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfOXx-0000wj-Nh for emacs-devel@gnu.org; Wed, 18 Nov 2020 09:34:57 -0500 Original-Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:33768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kfOXw-00030D-3V for emacs-devel@gnu.org; Wed, 18 Nov 2020 09:34:57 -0500 Original-Received: by mail-ej1-x62d.google.com with SMTP id 7so3096403ejm.0 for ; Wed, 18 Nov 2020 06:34:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-transfer-encoding; bh=0esJLX9oOr8BR1uWioyN3XqG/CkZEurKwjystA4kQD0=; b=UmF6XB5WwZ2jR709J7jv2Ko8FcBxZwRRj8rdN8ENGfo3vI8aTpIpL3qsu6FOMhEdDP hhr4sSTRRpCT2+RLeNCj+utUWIlw6kwVa+CBW5LmJNaC8K7RHRQhLKmk031s7S9m/CCw NWGJtKrm0EADXKBQd3a/7oZg4Wr41QiJHuuzoLUqdYd3vdwssiH7ZrfYpipI8xn4H+3h Cq/l1GOcq9yyroKrP7uzjrbGtE3DQVT/uqw1VR5YDcdXK8AhA6PIkTIYM624MpZ/b2vL Lt83B4mXVv5GtXTE040rqgrt1djcWKmfo3cFqjVihTu9VZD3ZOZuJEBe3cw4NXG1br8c u8xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=0esJLX9oOr8BR1uWioyN3XqG/CkZEurKwjystA4kQD0=; b=hnJhMTNztIpxRxmwTS2ifBej2zO8AtVNuigaNxlEB/IhXzJWUGDuWYpURLkXq0YOlI hNTo+BWoDd750TdD3V/cZ5LssCED9eOjQRoQOCWMKy31+mXd2t3j35F7jo9IUQxS8Kv5 vq3PopCpj5MER4BstaU5f5z1KMsrdGIIzrotE4fKgbKd3jEauq9FHioHZ9ICDO4jF6If YOTOle/wr4RbqP8lJ09wV8SdskeNc03B5IVyHrNxOjfF6OUxCJkGKVxLf9PrlX4TWq4R cuSptcL+HnzxnBkYH65565SCwbnpczJDkSoXNXMUzBOczV7YLqTxDz6KREwrHuNtfYSN ZEnw== X-Gm-Message-State: AOAM533WXoTiX/mc9aKSn4pTF0TDdQNO+Q4Lbq7LiSIxyCqMdV+cA2Zx UQhptWndiuAQzow3HOYZbIFvXzsk9Fw= X-Google-Smtp-Source: ABdhPJyqRD8jKnYhFyNp4SDEMXlUilnU4zKWWfcc2bowJ1Lpv9g+s4dJti06ehuE44tPSLwpTTVc0Q== X-Received: by 2002:a17:907:2146:: with SMTP id rk6mr18112687ejb.199.1605710094412; Wed, 18 Nov 2020 06:34:54 -0800 (PST) Original-Received: from localhost ([185.112.167.39]) by smtp.gmail.com with ESMTPSA id b15sm13649443edv.85.2020.11.18.06.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 06:34:53 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=stepnem@gmail.com; helo=mail-ej1-x62d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259345 Archived-At: On Wed, 18 Nov 2020 09:19:36 -0500 Stefan Monnier wrote: >> Such a use case doesn't seem uncommon and simply calling >> 'internal-default-process-sentinel' from a custom sentinel would seem a >> good solution, but the "internal-" prefix or the fact that such usage is >> completely absent from Emacs core and very rare even in 3rd party >> code[1] don't inspire confidence. > > `add-function` is your friend. > > (add-function :around (process-sentinel proc) > (lambda (orig-fun proc state) > (if (one particular case) > (do the thing) > (funcall orig-fun proc state)))) Thanks, I've seen similar examples in the code base, but always advising an Elisp sentinel, not 'internal-default-process-sentinel', which is a C function, and IIUC also would/might be called from C (e.g. from status_notify ?). Or is the actual default sentinel some kind of a wrapper? And even for Elisp sentinels, I figured I'd rather avoid advice, as even when using a self-removing piece of advice, it still applies to all (even unrelated) calls of the same sentinel function occurring until the removal. Or am I missing something? --=20 =C5=A0t=C4=9Bp=C3=A1n