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 16:12:48 +0100 Message-ID: <87mtze66mn.fsf@gmail.com> References: <87sg966bh5.fsf@gmail.com> <87pn4a688z.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="17283"; 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 16:11:08 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 1kfP6w-0004Mi-K9 for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 16:11:06 +0100 Original-Received: from localhost ([::1]:56060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfP6v-0004Ta-HP for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 10:11:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfP5q-0003pa-00 for emacs-devel@gnu.org; Wed, 18 Nov 2020 10:09:58 -0500 Original-Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:44870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kfP5o-00083m-8l for emacs-devel@gnu.org; Wed, 18 Nov 2020 10:09:57 -0500 Original-Received: by mail-ed1-x532.google.com with SMTP id l5so2324829edq.11 for ; Wed, 18 Nov 2020 07:09: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=1405/cT6UYmKw/anScRJRwYewtOBCS+yBAs6+viopgI=; b=mb3hxf9A30xos2vrJiA49rBga+mJSZtdSsE34B9enwoPjf5/+iUWGprmKZ0aUu68gv 0ta8oVDdbYAIyMrWnMl2pK0CAW7ZmsDut+X5fqoJsynzGjIbLWzGP1ylyCANpsfYEXFz InT/eh8Av/RI/lLGNhqg1hzp1Mj0kyY0+Pmtsq9lWedfqs3v7SUhx3UVpVzX0iiXVXaR bh/3bhOAfcyFKPhYIQcUeEIBnrrrmOPZKBiBJcTIVMA9DCk9XUsSY3fb1nMfDnYGpbUn NHldtkWcs2OUnGkCn2Cg6wd+fm6hINvEwmfQ0L50lVxc3J2PBKUF9cqeFLOeVEkHoMjC kFxw== 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=1405/cT6UYmKw/anScRJRwYewtOBCS+yBAs6+viopgI=; b=uLhQ9e3DJSmAUOzDXLql8Yxk6gjJkby6NuaQSbmqtPckXk/zX+3u4cMlLf/8pFRXu7 8+64Pcv/SYTDTsuYX41B4XOd2Ebdhf323A39Cp+5bOPUvD65cR0LNrhGARWZLFOWQeJh 34vXj1q372Co7QulniRrBadLUHnnAZtb6c2NkDkyiKgx4CCsDQfogZWWYNPiiu/wrCdH mBRXnN3icPfY22rl+zMA8ahcx2Tug7IqEG4a61NeFUiN89Q+5Va46jiqIVEKqFHt7ZeK YSo3D9Wp+Ama40+Kxcw557AkZV6FRU60V0bcQXJDWN6wml8IRcKQtJjJA3x+ziR7rjud 5QUg== X-Gm-Message-State: AOAM530R3VT52gYd00TdKGMRMMI8j9+dNbnU5vZhZRcIcNXIewXh3OH9 jJ0waU0BDl/fVu9VWNBKRGo= X-Google-Smtp-Source: ABdhPJyn06KKSLCVRtfpgP5m3d3lF8+5i31n19I9f83SI298ulpiehcq2yJ/UPXLEjvMmMM0wxPZCQ== X-Received: by 2002:aa7:ca57:: with SMTP id j23mr3046602edt.292.1605712194643; Wed, 18 Nov 2020 07:09:54 -0800 (PST) Original-Received: from localhost ([185.112.167.39]) by smtp.gmail.com with ESMTPSA id w4sm4482317ejv.63.2020.11.18.07.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 07:09:54 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=stepnem@gmail.com; helo=mail-ed1-x532.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:259349 Archived-At: On Wed, 18 Nov 2020 09:44:18 -0500 Stefan Monnier wrote: >>> `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? > > This is not advising 'internal-default-process-sentinel'. It just > replaces the sentinel by a new function which often delegates to the > previous function, whichever that previous function was and without > affecting that previous function's definition. > >> 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? > > You're confused: this is not an "advice". Indeed, I hadn't realized that, even though "(process-sentinel proc)" above would (before the add-function modification) evaluate to 'internal-default-process-sentinel', using `add-function' on that form really works through `set-process-sentinel' (via a gv place reference) and is thus different from advising 'internal-default-process-sentinel' directly. Thank you! --=20 =C5=A0t=C4=9Bp=C3=A1n