unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How to modify a function of a package
Date: Fri, 13 Oct 2023 06:24:31 +0200	[thread overview]
Message-ID: <ZSjGf0TAXYWBNg0Q@tuxteam.de> (raw)
In-Reply-To: <87h6mvzehz.fsf@posteo.net>

[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]

On Thu, Oct 12, 2023 at 10:02:00PM +0000, Philip Kaludercic wrote:
> Maske <maske1foro@gmail.com> writes:
> 
> > 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
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2023-10-13  4:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 19:39 How to modify a function of a package Maske
2023-10-12 22:02 ` Philip Kaludercic
2023-10-13  4:24   ` tomas [this message]
2023-10-12 23:54 ` Emanuel Berg
2023-10-28 13:18 ` Nikolay Kudryavtsev
2023-10-28 23:55   ` Maske

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZSjGf0TAXYWBNg0Q@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).