Gnus development mailing list
 help / color / mirror / Atom feed
* How to change definition of gnus-summary-exit?
@ 2015-10-14 17:28 Nikolaus Rath
  2015-10-14 18:08 ` Adam Sjøgren
  0 siblings, 1 reply; 8+ messages in thread
From: Nikolaus Rath @ 2015-10-14 17:28 UTC (permalink / raw)
  To: ding

Hello,

I would like to change the definition of the gnus-summary-exit function.

I have made a copy of gnus-sum.el, put it in a new directory, modified
it, and added this directory to my load path in ~/.emacs:

| (add-to-list 'load-path "/home/nikratio/dir-with-gnus-sum.el")


If I start gnus and do C-h f gnus-summary-exit, it tells me that the
function is defined in gnus-sum.el. If I click on gnus-sum.el, Emacs
opens my modified gnus-sum.el file.

*However*, the version of gnus-summary-exit that Gnus is actually using
is *not* my modified one, but the original.

In order to use my version, I have to explicitly eval the definition
using C-x C-e. After that, it is used by Gnus.


What is happening here? Why does the help refer me to the modified
version, but the version in memory is actually the original one? And how
do I tell emacs/gnus to use my version?

Thanks,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to change definition of gnus-summary-exit?
  2015-10-14 17:28 How to change definition of gnus-summary-exit? Nikolaus Rath
@ 2015-10-14 18:08 ` Adam Sjøgren
  2015-10-15  6:34   ` Tassilo Horn
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Sjøgren @ 2015-10-14 18:08 UTC (permalink / raw)
  To: ding

Nikolaus writes:

> What is happening here? Why does the help refer me to the modified
> version, but the version in memory is actually the original one? And how
> do I tell emacs/gnus to use my version?

I'm sure somebody with more hardcore knowledge than me will jump in;
just a guess: could it be a byte compiled file (.elc) that is being
picked up?

There is some kind of command to see what shadows what, but I don't use
it enough to remember it...


  Best regards,

    Adam

-- 
 "The world is short of delimiters," says Don.                Adam Sjøgren
                                                         asjo@koldfront.dk




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to change definition of gnus-summary-exit?
  2015-10-14 18:08 ` Adam Sjøgren
@ 2015-10-15  6:34   ` Tassilo Horn
  2015-10-15 17:47     ` Nikolaus Rath
  0 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2015-10-15  6:34 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding

asjo@koldfront.dk (Adam Sjøgren) writes:

>> What is happening here?  Why does the help refer me to the modified
>> version, but the version in memory is actually the original one?  And
>> how do I tell emacs/gnus to use my version?

Why do you copy the complete gnus-sum.el when you just want to
change one function?  As a result, you won't see any future changes of
gnus-sum.el (bugfixes and new features).

What do you want to change exactly?  Oftentimes, a simple advice will do
without having to override the complete function.

> I'm sure somebody with more hardcore knowledge than me will jump in;
> just a guess: could it be a byte compiled file (.elc) that is being
> picked up?

Indeed, if Nikolaus copied both gnus-sum.el and gnus-sum.elc into his
other directory, then modified gnus-sum.el but didn't recompile it, and
additionally `load-prefer-newer' is nil, that would explain the issue.

> There is some kind of command to see what shadows what, but I don't use
> it enough to remember it...

It's `list-load-path-shadows'.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to change definition of gnus-summary-exit?
  2015-10-15  6:34   ` Tassilo Horn
@ 2015-10-15 17:47     ` Nikolaus Rath
  2015-10-15 19:16       ` Tassilo Horn
  2015-10-15 20:17       ` Emanuel Berg
  0 siblings, 2 replies; 8+ messages in thread
From: Nikolaus Rath @ 2015-10-15 17:47 UTC (permalink / raw)
  To: ding

On Oct 15 2015, Tassilo Horn <tsdh@gnu.org> wrote:
> asjo@koldfront.dk (Adam Sjøgren) writes:
>
>>> What is happening here?  Why does the help refer me to the modified
>>> version, but the version in memory is actually the original one?  And
>>> how do I tell emacs/gnus to use my version?
>
> Why do you copy the complete gnus-sum.el when you just want to
> change one function?  As a result, you won't see any future changes of
> gnus-sum.el (bugfixes and new features).

Not quite, the 'modified version' is actually a clone of the gnus git
repo.

> What do you want to change exactly?  Oftentimes, a simple advice will do
> without having to override the complete function.

What's an advice (in this context)? I am interested in fixing/working
around https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21071.

>> I'm sure somebody with more hardcore knowledge than me will jump in;
>> just a guess: could it be a byte compiled file (.elc) that is being
>> picked up?
>
> Indeed, if Nikolaus copied both gnus-sum.el and gnus-sum.elc into his
> other directory, then modified gnus-sum.el but didn't recompile it, and
> additionally `load-prefer-newer' is nil, that would explain the issue.

Thanks, that was it! I was assuming that Emacs would automatically
ignore the .elc file if the .el file was newer.

Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to change definition of gnus-summary-exit?
  2015-10-15 17:47     ` Nikolaus Rath
@ 2015-10-15 19:16       ` Tassilo Horn
  2015-10-15 23:27         ` Nikolaus Rath
  2015-10-15 20:17       ` Emanuel Berg
  1 sibling, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2015-10-15 19:16 UTC (permalink / raw)
  To: ding

Nikolaus Rath <Nikolaus@rath.org> writes:

>>>> What is happening here?  Why does the help refer me to the modified
>>>> version, but the version in memory is actually the original one?  And
>>>> how do I tell emacs/gnus to use my version?
>>
>> Why do you copy the complete gnus-sum.el when you just want to
>> change one function?  As a result, you won't see any future changes of
>> gnus-sum.el (bugfixes and new features).
>
> Not quite, the 'modified version' is actually a clone of the gnus git
> repo.

Ah, I see.  Well, then I'd just use the complete git version if I were
you.

>> What do you want to change exactly?  Oftentimes, a simple advice will
>> do without having to override the complete function.
>
> What's an advice (in this context)?

An advice is a function which is run before, after, instead of, or
"around" some other function.  See (info "(elisp)Advising Functions").

>> Indeed, if Nikolaus copied both gnus-sum.el and gnus-sum.elc into his
>> other directory, then modified gnus-sum.el but didn't recompile it, and
>> additionally `load-prefer-newer' is nil, that would explain the issue.
>
> Thanks, that was it!

Wow, my crystal ball is working perfectly today! :-)

> I was assuming that Emacs would automatically ignore the .elc file if
> the .el file was newer.

It doesn't do so probably for backwards compatibility reasons.  But
there's the new variable `load-prefer-newer' for controlling that
behavior.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to change definition of gnus-summary-exit?
  2015-10-15 17:47     ` Nikolaus Rath
  2015-10-15 19:16       ` Tassilo Horn
@ 2015-10-15 20:17       ` Emanuel Berg
  1 sibling, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2015-10-15 20:17 UTC (permalink / raw)
  To: ding

Nikolaus Rath <Nikolaus@rath.org> writes:

> What's an advice (in this context)?

An advice can be a lot of things, in the Emacs
context, but in the context of your issue, I suspect
the person who gave the piece of advice to use an
advice, he suspected that you want something to always
happen say, before or after the invocation of the
regular function.

This can be done with advices. Here is an example that
I use, which isn't complicated to figure out what
it does:

    (advice-add 'gnus-summary-insert-old-articles :after
                (lambda (dummy) (gnus-apply-kill-file)))

Typically, advices are used when you don't want any
major and complicated changes to a function. (But
there are many thing that can be done with them.)

However, just because they can be done doesn't mean
that is the best way, and always so. Indeed, sometimes
it is better to redefine the function as you did.

However, in my experience the *best* way to do it is
to write a brand new function - use the existing code
if need be, but do everything new - that way, no
collisions, the help is intact, etc. But the best
advantage to this method is security. Because say you
invoke function F at situation S. It doesn't do
exactly what you want. So you change F and all is well
- *at S*! But often F is used in other situations, and
even by other software which you are unaware of.
So instead, copy and edit F into F', and at S, change
the keybinding that previously invoked F, so that it
now invokes F'!

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to change definition of gnus-summary-exit?
  2015-10-15 19:16       ` Tassilo Horn
@ 2015-10-15 23:27         ` Nikolaus Rath
  2015-10-16  7:19           ` Tassilo Horn
  0 siblings, 1 reply; 8+ messages in thread
From: Nikolaus Rath @ 2015-10-15 23:27 UTC (permalink / raw)
  To: ding

On Oct 15 2015, Tassilo Horn <tsdh@gnu.org> wrote:
> Nikolaus Rath <Nikolaus@rath.org> writes:
>
>>>>> What is happening here?  Why does the help refer me to the modified
>>>>> version, but the version in memory is actually the original one?  And
>>>>> how do I tell emacs/gnus to use my version?
>>>
>>> Why do you copy the complete gnus-sum.el when you just want to
>>> change one function?  As a result, you won't see any future changes of
>>> gnus-sum.el (bugfixes and new features).
>>
>> Not quite, the 'modified version' is actually a clone of the gnus git
>> repo.
>
> Ah, I see.  Well, then I'd just use the complete git version if I were
> you.

That's what I'm trying to do. Isn't putting the lisp/ directory from the
git clone sufficient to achieve that?

>>> What do you want to change exactly?  Oftentimes, a simple advice will
>>> do without having to override the complete function.
>>
>> What's an advice (in this context)?
>
> An advice is a function which is run before, after, instead of, or
> "around" some other function.  See (info "(elisp)Advising Functions").

Uh, that's pretty cool. It seems I need to do some reading.


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to change definition of gnus-summary-exit?
  2015-10-15 23:27         ` Nikolaus Rath
@ 2015-10-16  7:19           ` Tassilo Horn
  0 siblings, 0 replies; 8+ messages in thread
From: Tassilo Horn @ 2015-10-16  7:19 UTC (permalink / raw)
  To: ding

Nikolaus Rath <Nikolaus@rath.org> writes:

>> Ah, I see.  Well, then I'd just use the complete git version if I
>> were you.
>
> That's what I'm trying to do. Isn't putting the lisp/ directory from
> the git clone sufficient to achieve that?

Ah, sorry, I had understood that you are trying to use the Gnus version
that comes with Emacs but with the gnus-sum.el that comes with Gnus' git
version.

I also run the Git version of Gnus, and that's what you need to do:

Once: clone the git repo && ./configure && make
Regularly: git pull && make

And in my ~/.emacs there is

  (add-to-list 'load-path "~/Repos/el/gnus/lisp")
  (add-to-list 'Info-directory-list "~/Repos/el/gnus/texi")
  (require 'gnus-load)

which you have to adapt to your Gnus checkout directory accordingly.

>>>> What do you want to change exactly?  Oftentimes, a simple advice
>>>> will do without having to override the complete function.
>>>
>>> What's an advice (in this context)?
>>
>> An advice is a function which is run before, after, instead of, or
>> "around" some other function.  See (info "(elisp)Advising
>> Functions").
>
> Uh, that's pretty cool. It seems I need to do some reading.

Yes, it is.  However, in the current case you could only use

  (advice-add 'gnus-summary-exit :override
              #'your-version-of-gnus-summary-exit)

which would override the normal version with your patched version.  I
guess in this situation, it is better to apply your patch to the git
version, run it for some time, and then report back to the bug report
that nothing breaks (if nothing breaks, of course).  Then someone will
hopefully commit it to Gnus.  If nobody reacts, feel free to ping me, I
have push access.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-10-16  7:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-14 17:28 How to change definition of gnus-summary-exit? Nikolaus Rath
2015-10-14 18:08 ` Adam Sjøgren
2015-10-15  6:34   ` Tassilo Horn
2015-10-15 17:47     ` Nikolaus Rath
2015-10-15 19:16       ` Tassilo Horn
2015-10-15 23:27         ` Nikolaus Rath
2015-10-16  7:19           ` Tassilo Horn
2015-10-15 20:17       ` Emanuel Berg

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 NNTP newsgroup(s).