From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: How to modify a function of a package Date: Fri, 13 Oct 2023 06:24:31 +0200 Message-ID: References: <87h6mvzehz.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7EQFDwFeUBWPgom2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8077"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 13 06:25:28 2023 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 1qr9js-0001tU-4v for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 13 Oct 2023 06:25:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qr9j5-00086f-VT; Fri, 13 Oct 2023 00:24: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 1qr9j3-00086R-Ne for help-gnu-emacs@gnu.org; Fri, 13 Oct 2023 00:24:37 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qr9j1-00005g-Ep for help-gnu-emacs@gnu.org; Fri, 13 Oct 2023 00:24:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ILeoGG7fOaN/YIELYu0mUnjJRqGUhfNoUc0bfq21XRE=; b=CFcmRo8zDU/q9q3OuZ7748Y54L 8QrWpjSro0bXdgPmd3gfZKZGC+qnbu7iNYEhjTB5TrWT77M5a3yyZXIzdhWknBH7FW7t1zW6r6vu6 jvKqiXDJAvJakZoJhiye9gWubVWz93hXyLpirlcrmdBpNWssysRKZsNSDV4vi99uotU13ypflfPnG zqwkfU5jOT0EYjeYCoBkYE5z5NqpoP+OIPvcSWSqk/Y8FlnS0AbcOT4Z09mQrGJBdciRYg3G8OeW4 4+1MmhSHMfZmzLHVxOA8ryRlgxeT/GKc1xGFS2PETiwuqB6db3mqCUnjorF1P2CboRR4FPeIU83ha k1mdXWdA==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1qr9ix-0001Ah-GD for help-gnu-emacs@gnu.org; Fri, 13 Oct 2023 06:24:31 +0200 Content-Disposition: inline In-Reply-To: <87h6mvzehz.fsf@posteo.net> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:145279 Archived-At: --7EQFDwFeUBWPgom2 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 12, 2023 at 10:02:00PM +0000, Philip Kaludercic wrote: > Maske writes: >=20 > > Hi > > > > I have installed a package and I want to modify a function of it [...] > > so I have added the function modified in my init file. But, > > it doesn't work. The package behavior is not altered. [...] Apart from Philip's very valid points: - advice lets you change a function's behaviour, but still use the original function. This is usually what you want to do (this is *not*, however, what a packager should do, usually) - talk with the authors > > What would be the correct way? what is probably happening is that the package is loaded *after* your function definition in the init file, thus overwriting your definition. Since packages are often loaded lazily, you haven't always control of when it happens. To avoid that, you can either load the package explicitly before you do your function definition or (much better) look into `eval-after-load', which was made for such things. You'll have to do that also if you go the advice route: the function wants to exist before you attach some advice to it. Cheers --=20 t --7EQFDwFeUBWPgom2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZSjGeQAKCRAFyCz1etHa RuQpAJ92MGEiSw6Z3iTZnzfUhgsHhD6BHQCfb3U1cdZYK0LLqBrWA+wLEDCkHYo= =0+cS -----END PGP SIGNATURE----- --7EQFDwFeUBWPgom2--