GNU bug report logs - #6871
Please make linum-mode per buffer, not per major mode

Previous Next

Package: emacs;

Reported by: Lennart Borgman <lennart.borgman <at> gmail.com>

Date: Tue, 17 Aug 2010 02:06:02 UTC

Severity: wishlist

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6871 in the body.
You can then email your comments to 6871 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Tue, 17 Aug 2010 02:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 17 Aug 2010 02:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Emacs Bugs <bug-gnu-emacs <at> gnu.org>
Subject: Please make linum-mode per buffer, not per major mode
Date: Tue, 17 Aug 2010 04:06:01 +0200
Line numbers should work even in multi major mode buffers. Please add
the following lines to linum.el:

(put 'linum-overlays  'permanent-local t)
(put 'linum-available 'permanent-local t)
(put 'linum-mode      'permanent-local t)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Tue, 17 Aug 2010 08:59:02 GMT) Full text and rfc822 format available.

Message #8 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Tue, 17 Aug 2010 10:59:13 +0200
> Line numbers should work even in multi major mode buffers. Please add
> the following lines to linum.el:

> (put 'linum-overlays  'permanent-local t)
> (put 'linum-available 'permanent-local t)
> (put 'linum-mode      'permanent-local t)

I don't think that's going to be sufficient: you'll probably at least
also want to remove the

        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)

I.e. you can't just make some vars permanent-local, you have to adjust
the major mode from "mode-specific" to "permanent-local".


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Tue, 17 Aug 2010 11:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Tue, 17 Aug 2010 13:23:53 +0200
On Tue, Aug 17, 2010 at 10:59 AM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>> Line numbers should work even in multi major mode buffers. Please add
>> the following lines to linum.el:
>
>> (put 'linum-overlays  'permanent-local t)
>> (put 'linum-available 'permanent-local t)
>> (put 'linum-mode      'permanent-local t)
>
> I don't think that's going to be sufficient: you'll probably at least
> also want to remove the
>
>        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
>
> I.e. you can't just make some vars permanent-local, you have to adjust
> the major mode from "mode-specific" to "permanent-local".

Yes, I know. I have added code to take careof this for linum in
mumamo.el. But we do not yet have code in Emacs for taking care of
this more generally.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Tue, 17 Aug 2010 12:11:01 GMT) Full text and rfc822 format available.

Message #14 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Tue, 17 Aug 2010 14:11:55 +0200
>>> Line numbers should work even in multi major mode buffers. Please add
>>> the following lines to linum.el:
>> 
>>> (put 'linum-overlays  'permanent-local t)
>>> (put 'linum-available 'permanent-local t)
>>> (put 'linum-mode      'permanent-local t)
>> 
>> I don't think that's going to be sufficient: you'll probably at least
>> also want to remove the
>> 
>>        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
>> 
>> I.e. you can't just make some vars permanent-local, you have to adjust
>> the major mode from "mode-specific" to "permanent-local".

> Yes, I know. I have added code to take careof this for linum in
> mumamo.el. But we do not yet have code in Emacs for taking care of
> this more generally.

But your report is about fixing it in linum.el (where it belongs), which
means to turn linum-mode from a major-mode-specific minor-mode to
a permanent-local major-mode.  I think such a change is acceptable
(although the motivation of multi-major-mode buffers might not be that
compelling, since it tends to lead to the idea that most/all
minor-modes should be made permanent-local), but we need a proper patch
for it.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Tue, 17 Aug 2010 12:35:02 GMT) Full text and rfc822 format available.

Message #17 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Tue, 17 Aug 2010 14:35:19 +0200
On Tue, Aug 17, 2010 at 2:11 PM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>>>> Line numbers should work even in multi major mode buffers. Please add
>>>> the following lines to linum.el:
>>>
>>>> (put 'linum-overlays  'permanent-local t)
>>>> (put 'linum-available 'permanent-local t)
>>>> (put 'linum-mode      'permanent-local t)
>>>
>>> I don't think that's going to be sufficient: you'll probably at least
>>> also want to remove the
>>>
>>>        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
>>>
>>> I.e. you can't just make some vars permanent-local, you have to adjust
>>> the major mode from "mode-specific" to "permanent-local".
>
>> Yes, I know. I have added code to take careof this for linum in
>> mumamo.el. But we do not yet have code in Emacs for taking care of
>> this more generally.
>
> But your report is about fixing it in linum.el (where it belongs), which
> means to turn linum-mode from a major-mode-specific minor-mode to
> a permanent-local major-mode.  I think such a change is acceptable
> (although the motivation of multi-major-mode buffers might not be that
> compelling, since it tends to lead to the idea that most/all
> minor-modes should be made permanent-local), but we need a proper patch
> for it.

How about also removing adding linum to change-major-mode-hook?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Tue, 17 Aug 2010 23:47:01 GMT) Full text and rfc822 format available.

Message #20 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: 6871 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Tue, 17 Aug 2010 19:47:22 -0400
> I think such a change is acceptable (although the motivation of
> multi-major-mode buffers might not be that compelling, since it
> tends to lead to the idea that most/all minor-modes should be made
> permanent-local), but we need a proper patch for it.

Thats potentially a lot of overlays to persist in buffers which:

- may not always be visible
- may be visible but don't need the linum minor-mode behaviour
  automatically persisted

Will such a change negatively impact redisplay elsewhere?
I ask because of this comment here from linum.el:

,----
|
| (add-hook 'window-configuration-change-hook
| 	  ;; FIXME: If the buffer is shown in N windows, this
| 	  ;; will be called N times rather than once.  We should use
| 	  ;; something like linum-update-window instead.
|  'linum-update-current nil t)
|
`----

Also, linum-mode activation already sets timers when linum-eager is
non-nil... will these timers now persist as well on major-mode
changes? If so how will they impact redisplay?

More concretely, how many (more) permanent-locals does Lennart need in
order to attain mumamo.el bliss?

And, while your giving permanent-locals away so freely can maybe you
spare a few for the slime guys?  Or the geiser/quack/scheme guys I'm
sure they could use some too... :-P

--
/s_P\




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Wed, 18 Aug 2010 00:15:02 GMT) Full text and rfc822 format available.

Message #23 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Wed, 18 Aug 2010 02:14:47 +0200
On Wed, Aug 18, 2010 at 1:47 AM, MON KEY <monkey <at> sandpframing.com> wrote:
>> I think such a change is acceptable (although the motivation of
>> multi-major-mode buffers might not be that compelling, since it
>> tends to lead to the idea that most/all minor-modes should be made
>> permanent-local), but we need a proper patch for it.
>
> Thats potentially a lot of overlays to persist in buffers which:
>
> - may not always be visible
> - may be visible but don't need the linum minor-mode behaviour
>  automatically persisted
>
> Will such a change negatively impact redisplay elsewhere?
> I ask because of this comment here from linum.el:
>
> ,----
> |
> | (add-hook 'window-configuration-change-hook
> |         ;; FIXME: If the buffer is shown in N windows, this
> |         ;; will be called N times rather than once.  We should use
> |         ;; something like linum-update-window instead.
> |  'linum-update-current nil t)
> |
> `----
>
> Also, linum-mode activation already sets timers when linum-eager is
> non-nil... will these timers now persist as well on major-mode
> changes? If so how will they impact redisplay?
>
> More concretely, how many (more) permanent-locals does Lennart need in
> order to attain mumamo.el bliss?

Those things are not related.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Wed, 18 Aug 2010 07:19:02 GMT) Full text and rfc822 format available.

Message #26 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Wed, 18 Aug 2010 09:19:41 +0200
>>>> I don't think that's going to be sufficient: you'll probably at least
>>>> also want to remove the
>>>>        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
[...]
>> minor-modes should be made permanent-local), but we need a proper patch
>> for it.
> How about also removing adding linum to change-major-mode-hook?

Yes, that's what I suggested, isn't it?
Please write a patch, test it (after removing the workarounds you
currently use), and send it here.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Wed, 18 Aug 2010 07:20:03 GMT) Full text and rfc822 format available.

Message #29 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Wed, 18 Aug 2010 09:20:34 +0200
>> I think such a change is acceptable (although the motivation of
>> multi-major-mode buffers might not be that compelling, since it
>> tends to lead to the idea that most/all minor-modes should be made
>> permanent-local), but we need a proper patch for it.

> Thats potentially a lot of overlays to persist in buffers which:

> - may not always be visible
> - may be visible but don't need the linum minor-mode behaviour
>   automatically persisted

It's relatively rare to use linum-mode and then to change major-mode.
So (until proven otherwise) it's a non-issue.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 04:29:02 GMT) Full text and rfc822 format available.

Message #32 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 06:29:42 +0200
[Message part 1 (text/plain, inline)]
On Wed, Aug 18, 2010 at 9:19 AM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>>>>> I don't think that's going to be sufficient: you'll probably at least
>>>>> also want to remove the
>>>>>        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
> [...]
>>> minor-modes should be made permanent-local), but we need a proper patch
>>> for it.
>> How about also removing adding linum to change-major-mode-hook?
>
> Yes, that's what I suggested, isn't it?

I was not quite sure.

> Please write a patch, test it (after removing the workarounds you
> currently use), and send it here.


Attached the patch. There are some other changes to linum.el too.

The handling in after-change-functions was not optimal. Maybe the doc
string for these hook should explain a bit more about how to use it?
[linum-multi-major.diff (application/octet-stream, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 12:13:02 GMT) Full text and rfc822 format available.

Message #35 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 14:13:27 +0200
On Thu, Aug 19, 2010 at 06:29, Lennart Borgman
<lennart.borgman <at> gmail.com> wrote:

> Attached the patch.

That is not a patch, it's a full linum.el. And there is no ChangeLog.

> There are some other changes to linum.el too.

Why? If they are not related, that should be sent as another patch.

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 13:25:02 GMT) Full text and rfc822 format available.

Message #38 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 15:25:44 +0200
[Message part 1 (text/plain, inline)]
On Thu, Aug 19, 2010 at 2:13 PM, Juanma Barranquero <lekktu <at> gmail.com> wrote:
> On Thu, Aug 19, 2010 at 06:29, Lennart Borgman
> <lennart.borgman <at> gmail.com> wrote:
>
>> Attached the patch.
>
> That is not a patch, it's a full linum.el. And there is no ChangeLog.

Ah, shit. Thanks. I must learn to switch buffer before I save the diff....

I think I have attached the diff now ;-)


>> There are some other changes to linum.el too.
>
> Why? If they are not related, that should be sent as another patch.

Maybe. Linum is rather small and it is quicker to do it this way.
[linum-multi-major.diff (application/octet-stream, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 13:38:02 GMT) Full text and rfc822 format available.

Message #41 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 15:38:30 +0200
On Thu, Aug 19, 2010 at 15:25, Lennart Borgman
<lennart.borgman <at> gmail.com> wrote:

> Ah, shit. Thanks. I must learn to switch buffer before I save the diff....
>
> I think I have attached the diff now ;-)

That's better, thanks. Still no ChangeLog to explain the changes, though.

> Maybe. Linum is rather small and it is quicker to do it this way.

Quicker for you, perhaps, but if the changes are unrelated should be
committed separately, so harder for someone at some point.

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 14:00:03 GMT) Full text and rfc822 format available.

Message #44 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 16:00:24 +0200
On Thu, Aug 19, 2010 at 3:38 PM, Juanma Barranquero <lekktu <at> gmail.com> wrote:
> On Thu, Aug 19, 2010 at 15:25, Lennart Borgman
> <lennart.borgman <at> gmail.com> wrote:
>
>> Ah, shit. Thanks. I must learn to switch buffer before I save the diff....
>>
>> I think I have attached the diff now ;-)
>
> That's better, thanks. Still no ChangeLog to explain the changes, though.

It is still just for communication.

>> Maybe. Linum is rather small and it is quicker to do it this way.
>
> Quicker for you, perhaps, but if the changes are unrelated should be
> committed separately, so harder for someone at some point.

Do they have to be committed separately? It is just small (but
important) changes.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 14:40:03 GMT) Full text and rfc822 format available.

Message #47 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 16:40:38 +0200
On Thu, Aug 19, 2010 at 16:00, Lennart Borgman
<lennart.borgman <at> gmail.com> wrote:

> It is still just for communication.

ChangeLog entries help communicate intent.

> Do they have to be committed separately?

At the risk of repeating me thrice: if they are unrelated, yes, they
should be committed separately.

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 14:45:03 GMT) Full text and rfc822 format available.

Message #50 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: Juanma Barranquero <lekktu <at> gmail.com>, 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 16:45:16 +0200
> I think I have attached the diff now ;-)

Yes, this time it looks right, thanks.

>>> There are some other changes to linum.el too.
>> Why? If they are not related, that should be sent as another patch.
> Maybe. Linum is rather small and it is quicker to do it this way.

I don't mind a few cosmetic changes as long as they don't drown the main
change, but in this case, the changes aren't cosmetic at all.
They don't sound bad, tho.  So please post them separately, with an
explanation for why they're right.

And please resend a new patch that only fixes the permanent-local part
of linum-mode, because I'm having a hard time figuring out which part
belongs to what.


        Stefan


> === modified file 'lisp/linum.el'
> --- trunk/lisp/linum.el	2010-01-13 08:35:10 +0000
> +++ patched/lisp/linum.el	2010-08-19 04:22:04 +0000
> @@ -38,6 +38,8 @@
>    "Functions run in each buffer before line numbering starts.")
 
>  (mapc #'make-variable-buffer-local '(linum-overlays linum-available))
> +(put 'linum-overlays  'permanent-local t)
> +(put 'linum-available 'permanent-local t)
 
>  (defgroup linum nil
>    "Show line numbers in the left margin."
> @@ -58,13 +60,6 @@
>    "Face for displaying line numbers in the display margin."
>    :group 'linum)
 
> -(defcustom linum-eager t
> -  "Whether line numbers should be updated after each command.
> -The conservative setting `nil' might miss some buffer changes,
> -and you have to scroll or press \\[recenter-top-bottom] to update the numbers."
> -  :group 'linum
> -  :type 'boolean)
> -
>  (defcustom linum-delay nil
>    "Delay updates to give Emacs a chance for other changes."
>    :group 'linum
> @@ -76,30 +71,29 @@
>    :lighter ""                           ; for desktop.el
>    (if linum-mode
>        (progn
> -        (if linum-eager
>              (add-hook 'post-command-hook (if linum-delay
>                                               'linum-schedule
> -                                           'linum-update-current) nil t)
> -          (add-hook 'after-change-functions 'linum-after-change nil t))
> +                                       'linum-update-current-buffer) nil t)
> +        (add-hook 'before-change-functions 'linum-before-change nil t)
> +        (add-hook 'after-change-functions 'linum-after-change nil t)
>          (add-hook 'window-scroll-functions 'linum-after-scroll nil t)
>          ;; Using both window-size-change-functions and
>          ;; window-configuration-change-hook seems redundant. --Stef
>          ;; (add-hook 'window-size-change-functions 'linum-after-size nil t)
> -        (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
>          (add-hook 'window-configuration-change-hook
> -                  ;; FIXME: If the buffer is shown in N windows, this
> -                  ;; will be called N times rather than once.  We should use
> -                  ;; something like linum-update-window instead.
> -                  'linum-update-current nil t)
> -        (linum-update-current))
> -    (remove-hook 'post-command-hook 'linum-update-current t)
> +                  ;; Update just the selected window
> +                  'linum-update-selected-window nil t)
> +        (setq linum-change-beg 1)
> +        (linum-update-current-buffer))
> +    (remove-hook 'post-command-hook 'linum-update-current-buffer t)
>      (remove-hook 'post-command-hook 'linum-schedule t)
>      ;; (remove-hook 'window-size-change-functions 'linum-after-size t)
>      (remove-hook 'window-scroll-functions 'linum-after-scroll t)
> +    (remove-hook 'before-change-functions 'linum-before-change t)
>      (remove-hook 'after-change-functions 'linum-after-change t)
> -    (remove-hook 'window-configuration-change-hook 'linum-update-current t)
> -    (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
> +    (remove-hook 'window-configuration-change-hook 'linum-update-selected-window t)
>      (linum-delete-overlays)))
> +(put 'linum-mode      'permanent-local t)
 
>  ;;;###autoload
>  (define-globalized-minor-mode global-linum-mode linum-mode linum-on)
> @@ -115,22 +109,34 @@
>    (dolist (w (get-buffer-window-list (current-buffer) nil t))
>      (set-window-margins w 0 (cdr (window-margins w)))))
 
> -(defun linum-update-current ()
> +(defun linum-update-current-buffer ()
>    "Update line numbers for the current buffer."
>    (linum-update (current-buffer)))
> +(put 'linum-update-current-buffer 'permanent-local-hook t)
 
>  (defun linum-update (buffer)
>    "Update line numbers for all windows displaying BUFFER."
>    (with-current-buffer buffer
> -    (when linum-mode
> +    (when (and linum-mode
> +               linum-change-beg)
>        (setq linum-available linum-overlays)
>        (setq linum-overlays nil)
>        (save-excursion
>          (mapc #'linum-update-window
>                (get-buffer-window-list buffer nil 'visible)))
>        (mapc #'delete-overlay linum-available)
> +      (setq linum-change-beg nil)
>        (setq linum-available nil))))
 
> +(defun linum-update-selected-window ()
> +  "Update line numbers for the selected window."
> +  (let ((here (window-point))
> +        ;; We might have scrolled or changed win config
> +        (linum-change-beg 1))
> +    (linum-update-window (selected-window))
> +    (goto-char here)))
> +(put 'linum-update-selected-window 'permanent-local-hook t)
> +
>  (defun linum-update-window (win)
>    "Update line numbers for the portion visible in window WIN."
>    (goto-char (window-start win))
> @@ -142,6 +148,7 @@
>                                        (count-lines (point-min) (point-max))))))
>                        (concat "%" (number-to-string w) "d")))))
>          (width 0))
> +    (when (<= linum-change-beg limit)
>      (run-hooks 'linum-before-numbering-hook)
>      ;; Create an overlay (or reuse an existing one) for each
>      ;; line visible in this window, if necessary.
> @@ -171,24 +178,40 @@
>        (let ((inhibit-point-motion-hooks t))
>          (forward-line))
>        (setq line (1+ line)))
> -    (set-window-margins win width (cdr (window-margins win)))))
> +      (set-window-margins win width (cdr (window-margins win))))))
> +
> +(defvar linum-change-beg nil
> +  "Position of change beginning, recorded after change.")
> +(make-variable-buffer-local 'linum-change-beg)
> +(put linum-change-beg 'permanent-local t)
> +
> +(defvar linum-changed-region-has-newline nil)
> +(defun linum-before-change (beg end)
> +  ;; Record new lines in changed region for check in after change function.
> +  (when (string-match-p "\n" (buffer-substring-no-properties beg end))
> +    (setq linum-changed-region-has-newline t)))
> +(put 'linum-before-change 'permanent-local-hook t)
 
>  (defun linum-after-change (beg end len)
> -  ;; update overlays on deletions, and after newlines are inserted
> -  (when (or (= beg end)
> -            (= end (point-max))
> +  ;; update overlays after newlines are delete or inserted
> +  (when (or linum-changed-region-has-newline
>              (string-match-p "\n" (buffer-substring-no-properties beg end)))
> -    (linum-update-current)))
> +    (setq linum-changed-region-has-newline nil)
> +    (setq linum-change-beg beg)))
> +(put 'linum-after-change 'permanent-local-hook t)
 
>  (defun linum-after-scroll (win start)
> -  (linum-update (window-buffer win)))
> +  (with-selected-window win
> +    (linum-update-selected-window)))
> +(put 'linum-after-scroll 'permanent-local-hook t)
 
>  ;; (defun linum-after-size (frame)
>  ;;   (linum-after-config))
 
>  (defun linum-schedule ()
>    ;; schedule an update; the delay gives Emacs a chance for display changes
> -  (run-with-idle-timer 0 nil #'linum-update-current))
> +  (run-with-idle-timer 0 nil #'linum-update-current-buffer))
> +(put 'linum-schedule 'permanent-local-hook t)
 
>  ;; (defun linum-after-config ()
>  ;;   (walk-windows (lambda (w) (linum-update (window-buffer w))) nil 'visible))





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 17:49:02 GMT) Full text and rfc822 format available.

Message #53 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 13:49:44 -0400
On Wed, Aug 18, 2010 at 3:20 AM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:

> It's relatively rare to use linum-mode and then to change major-mode.

Isn't that precisely the reason Lennart made the request?
E.g. that mumamo buffers _do_ change modes repeatedly?

Whatever, this doesn't address the stated concern that the overlays
will now have potential for persistence where there was none before.

> So (until proven otherwise) it's a non-issue.

OK.
FWIW I think this will come back to bite w/re redisplay once mumamo
related code starts exploiting the feature.
Witness the aggressive leeway Lennart has taken w/ his linum "patch"...

>        Stefan
>

--
/s_P\




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 18:49:02 GMT) Full text and rfc822 format available.

Message #56 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: bojohan <at> gnu.org (Johan Bockgård)
To: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 20:49:17 +0200
MON KEY <monkey <at> sandpframing.com> writes:

> I ask because of this comment here from linum.el:

Also, why doesn't linum-mode (nor anything else) use
`window-text-change-functions', since that hook was added specifically
to support linum?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 21:18:02 GMT) Full text and rfc822 format available.

Message #59 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 23:18:03 +0200
On Thu, Aug 19, 2010 at 7:49 PM, MON KEY <monkey <at> sandpframing.com> wrote:
>
> Whatever, this doesn't address the stated concern that the overlays
> will now have potential for persistence where there was none before.

I am sorry, but you have misunderstood this. And that is all I have
time to say about it. Try to figure out yourself.

> Witness the aggressive leeway Lennart has taken w/ his linum "patch"...

What is "leeway"?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 21:19:02 GMT) Full text and rfc822 format available.

Message #62 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Juanma Barranquero <lekktu <at> gmail.com>, 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 23:19:20 +0200
On Thu, Aug 19, 2010 at 4:45 PM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>
> I don't mind a few cosmetic changes as long as they don't drown the main
> change, but in this case, the changes aren't cosmetic at all.
> They don't sound bad, tho.  So please post them separately, with an
> explanation for why they're right.
>
> And please resend a new patch that only fixes the permanent-local part
> of linum-mode, because I'm having a hard time figuring out which part
> belongs to what.

Ah, sorry. I thought it would be easy for you to do that. I will try
to find time for it.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 21:23:01 GMT) Full text and rfc822 format available.

Message #65 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 23:23:29 +0200
On Thu, Aug 19, 2010 at 4:40 PM, Juanma Barranquero <lekktu <at> gmail.com> wrote:
> On Thu, Aug 19, 2010 at 16:00, Lennart Borgman
> <lennart.borgman <at> gmail.com> wrote:
>
>> It is still just for communication.
>
> ChangeLog entries help communicate intent.

I thought the intent would be obvious in this small amount of code,
but it looks like I am wrong.

>> Do they have to be committed separately?
>
> At the risk of repeating me thrice: if they are unrelated, yes, they
> should be committed separately.

I see. How do you yourself manage a situation like this? What happened is this:

- I found a problem for multi major mode use of linum.
- Looking at the code I found some other easy to see problems.

Normally in my own code I just fix all the issues I see on the fly so
to say. That is faster since I have already looked at the code then
and knows what to do. Later (which may be much later) I might forget
about exactly how to do it.

Do you try to keep multiple copies of the code with different patches
in each? Or what do you do?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 21:57:02 GMT) Full text and rfc822 format available.

Message #68 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Thu, 19 Aug 2010 23:57:10 +0200
On Thu, Aug 19, 2010 at 23:23, Lennart Borgman
<lennart.borgman <at> gmail.com> wrote:

> I thought the intent would be obvious in this small amount of code,
> but it looks like I am wrong.

Usually, changes are much clearer to the writer than to the reader :-)

> Do you try to keep multiple copies of the code with different patches
> in each? Or what do you do?

That depends. I don't develop on the trunk, but a branch, so if some
of the changes are trivial fixes or whatever, I move them to the trunk
and commit them right now (so one less thing to think about) and keep
the other changes in the branch while I refine them. Else, I commit
each change to my branch as separate commits, and then, when the time
comes to merge back to the trunk, I decide if they are related or not,
so I push them as a merge or separate commits.

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 22:21:02 GMT) Full text and rfc822 format available.

Message #71 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Fri, 20 Aug 2010 00:21:40 +0200
On Thu, Aug 19, 2010 at 11:57 PM, Juanma Barranquero <lekktu <at> gmail.com> wrote:
> On Thu, Aug 19, 2010 at 23:23, Lennart Borgman
> <lennart.borgman <at> gmail.com> wrote:
>
>> I thought the intent would be obvious in this small amount of code,
>> but it looks like I am wrong.
>
> Usually, changes are much clearer to the writer than to the reader :-)

Depends on who is writing and who is reading. I hoped they were
clearer to the reader ;-)

>> Do you try to keep multiple copies of the code with different patches
>> in each? Or what do you do?
>
> That depends. I don't develop on the trunk, but a branch, so if some
> of the changes are trivial fixes or whatever, I move them to the trunk
> and commit them right now (so one less thing to think about) and keep
> the other changes in the branch while I refine them. Else, I commit
> each change to my branch as separate commits, and then, when the time
> comes to merge back to the trunk, I decide if they are related or not,
> so I push them as a merge or separate commits.

Thansk, I think I understand the workflow, but I do not know how to do
this practically.

Let us say I first in this case write the parts for multi major modes.
I guess I then submit this to my local rep? How?

And how do I make a diff after that? Can I make the diff later on to
in a simple way?

After this I want to do the other changes to linum immediately so I
will not forget them. So I do that and submit them to my local rep. Or
should I do something else at this point?

And what if Stefan (or someone else) now says that the first part
needs some refinements and I should send a new patch? How can I handle
that now after I have submitted my first part to my local rep?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Thu, 19 Aug 2010 22:43:01 GMT) Full text and rfc822 format available.

Message #74 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: Juanma Barranquero <lekktu <at> gmail.com>, 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Fri, 20 Aug 2010 00:43:57 +0200
> Normally in my own code I just fix all the issues I see on the fly so
> to say. That is faster since I have already looked at the code then
> and knows what to do. Later (which may be much later) I might forget
> about exactly how to do it.

I have my own branch with a hodge-podge of changes in random order.
When I want to install a change from there to the trunk, I do a diff of
the relevant files and then pick the relevant parts and add
a ChangeLog message.

I usually take advantage of this opportunity to polish the change a bit
(which might mean to rewrite it completely in a different way, or just
add a comment, ...).  When I update my branch from trunk, I then get
"spurious conflicts", but they're easy to fix and usually having
a chance to revisit that code before committing it lets me improve
it significantly, so it's definitely worth the trouble.
Especially since it lets me (on the other side) make random changes to
my heart's content.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Fri, 20 Aug 2010 01:11:02 GMT) Full text and rfc822 format available.

Message #77 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Juanma Barranquero <lekktu <at> gmail.com>, 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Fri, 20 Aug 2010 03:11:21 +0200
[Message part 1 (text/plain, inline)]
On Fri, Aug 20, 2010 at 12:43 AM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>> Normally in my own code I just fix all the issues I see on the fly so
>> to say. That is faster since I have already looked at the code then
>> and knows what to do. Later (which may be much later) I might forget
>> about exactly how to do it.
>
> I have my own branch with a hodge-podge of changes in random order.
> When I want to install a change from there to the trunk, I do a diff of
> the relevant files and then pick the relevant parts and add
> a ChangeLog message.

Seems easiest, but I am not sure how to make the diff file. I just
edited the diff file I had. Does this work, i.e. how does the program
patch handle this?

I have attached a patch done this way for just making linum-mode per
buffer instead of per major mode.
[linum-multi-major-1.diff (application/octet-stream, attachment)]
[linum-multi-major-1.chlog (application/octet-stream, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Fri, 20 Aug 2010 09:07:01 GMT) Full text and rfc822 format available.

Message #80 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: lekktu <at> gmail.com, 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Fri, 20 Aug 2010 12:05:50 +0300
> From: Lennart Borgman <lennart.borgman <at> gmail.com>
> Date: Fri, 20 Aug 2010 00:21:40 +0200
> Cc: 6871 <at> debbugs.gnu.org
> 
> > That depends. I don't develop on the trunk, but a branch, so if some
> > of the changes are trivial fixes or whatever, I move them to the trunk
> > and commit them right now (so one less thing to think about) and keep
> > the other changes in the branch while I refine them. Else, I commit
> > each change to my branch as separate commits, and then, when the time
> > comes to merge back to the trunk, I decide if they are related or not,
> > so I push them as a merge or separate commits.
> 
> Thansk, I think I understand the workflow, but I do not know how to do
> this practically.
> 
> Let us say I first in this case write the parts for multi major modes.
> I guess I then submit this to my local rep? How?

You need to create a separate branch, with the "bzr branch" command.
Then you can commit there with "bzr ci".

Alternatively, you can use "bzr ci --local" in the bound branch, but
this is less recommended, since it requires you to be aware of local
commits that you didn't push to the remote repository.

> And how do I make a diff after that? Can I make the diff later on to
> in a simple way?

Ye, "bzr diff" supports versions.  E.g.,

  bzr diff -r101100..101101

will produce the diffs between the two named versions.

> After this I want to do the other changes to linum immediately so I
> will not forget them. So I do that and submit them to my local rep.

Yes.

> Or should I do something else at this point?

Nothing else is required.

> And what if Stefan (or someone else) now says that the first part
> needs some refinements and I should send a new patch? How can I handle
> that now after I have submitted my first part to my local rep?

You commit another change and use "bzr diff" as above, with a
different couple of revision numbers.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Fri, 20 Aug 2010 12:59:01 GMT) Full text and rfc822 format available.

Message #83 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: Juanma Barranquero <lekktu <at> gmail.com>, 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Fri, 20 Aug 2010 14:59:09 +0200
>>> Normally in my own code I just fix all the issues I see on the fly so
>>> to say. That is faster since I have already looked at the code then
>>> and knows what to do. Later (which may be much later) I might forget
>>> about exactly how to do it.
>> I have my own branch with a hodge-podge of changes in random order.
>> When I want to install a change from there to the trunk, I do a diff of
>> the relevant files and then pick the relevant parts and add
>> a ChangeLog message.
> Seems easiest, but I am not sure how to make the diff file.

By "I do a diff of the relevant files", I meant "bzr diff -rsubmit:
<files>", or rather C-u C-x v = s[TAB] RET RET.
By "pick the relevant parts", I meant:
- go to the *vc-diff* buffer
- M-x cd RET /my/checkout/of/the/trunk RET
- apply C-c C-a to the hunks I want to pick
- edit to clean up, improve, ...
- save the modified files.
- do C-x v = on the modified files, to see the patch I'm about to commit
  to trunk (or to send it via email).

> I just edited the diff file I had. Does this work,

Depends if you edited it well or not.

> i.e. how does the program patch handle this?

Again, depends if you edited it correctly or not.  Have you tried it?

> I have attached a patch done this way for just making linum-mode per
> buffer instead of per major mode.

Have you tried the patch and confirmed that it works and fixes
your problem?  I see it lacks the removal of change-major-mode-hook.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6871; Package emacs. (Sat, 19 Sep 2020 15:53:01 GMT) Full text and rfc822 format available.

Message #86 received at 6871 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6871 <at> debbugs.gnu.org
Subject: Re: bug#6871: Please make linum-mode per buffer, not per major mode
Date: Sat, 19 Sep 2020 17:52:03 +0200
Lennart Borgman <lennart.borgman <at> gmail.com> writes:

> Line numbers should work even in multi major mode buffers. Please add
> the following lines to linum.el:
>
> (put 'linum-overlays  'permanent-local t)
> (put 'linum-available 'permanent-local t)
> (put 'linum-mode      'permanent-local t)

This was ten years ago.  These days, `display-line-numbers-mode' does
pretty much everything linum-mode does, but better, so I think there's
probably no reason to implement this feature request, and I'm closing
this bug report.  (I've just skimmed the thread, though, so if there is
something here that should definitely be fixed, please respond to the
debbugs address and we'll reopen.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 19 Sep 2020 15:53:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 6871 <at> debbugs.gnu.org and Lennart Borgman <lennart.borgman <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 19 Sep 2020 15:53:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 18 Oct 2020 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 163 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.