Subject: Re: bug#71370: 30.0.50; Please un-obsolete buffer-substring as a generalized variable

From: Stefan Kangas <[email-masked]>
Date: Mon, 17 Feb 2025 18:54:30 +0000

Andrea Corallo <[email-masked]> writes:

> Ihor Radchenko <[email-masked]> writes:
>
>> Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife
>> of text editors" <[email-masked]> writes:
>>
>>> Any arguments why this gv is different from the others that had been
>>> deprecated?
>>
>> It is one of the commonly used gvs.
>> https://github.com/search?q=%22%28setf+%28buffer-substring%22&type=code
>> gives 500+ hits (and it is not all forks of one or two popular packages)
>
> Interesting, I took the time to apply your methodology to all GV
> obsoleted by the same commit and this is the result:
>
> | GV                           | file occurrences |
> |                              |        in github |
> |------------------------------+------------------|
> | buffer-file-name             |                5 |
> | buffer-modified-p            |                7 |
> | buffer-name                  |               48 |
> | buffer-string                |              142 |
> | buffer-substring             |              512 |
> | current-buffer               |              234 |
> | current-column               |                3 |
> | current-global-map           |                0 |
> | current-input-mode           |                0 |
> | current-local-map            |                0 |
> | current-window-configuration |                0 |
> | default-file-modes           |                0 |
> | current-window-configuration |                0 |
> | default-file-modes           |                0 |
> | documentation-property       |                8 |
> | frame-height                 |               38 |
> | frame-visible-p              |                0 |
> | global-key-binding           |                3 |
> | local-key-binding            |                0 |
> | mark                         |                4 |
> | mark-marker                  |                0 |
> | marker-position              |               16 |
> | mouse-position               |                7 |
> | point                        |               32 |
> | point-marker                 |                0 |
> | point-max                    |                0 |
> | point-min                    |               40 |
> | read-mouse-position          |                0 |
> | screen-height                |                4 |
> | screen-width                 |               15 |
> | selected-window              |                4 |
> | selected-screen              |                0 |
> | selected-frame               |                0 |
> | standard-case-table          |                0 |
> | syntax-table                 |                0 |
> | visited-file-modtime         |                0 |
> | window-height                |               13 |
> | window-width                 |                9 |
> | x-get-secondary-selection    |                0 |
>
> While some of them are rarely/not used some others looks quite popular.
> This is an indication that the popular ones are probably a good
> abstraction or they are just convenient.
>
> I don't know what would be the risk of un-obsoleting the popular ones
> now, but if is not possible I think we should consider doing it for the
> next release cycle.

Can we make a decision about this now?

The most popular ones seem to be these:

> | buffer-name                  |               48 |
> | buffer-string                |              142 |
> | buffer-substring             |              512 |
> | current-buffer               |              234 |
> | frame-height                 |               38 |

Testing like this:

(setf (buffer-name) "test")
(setf (buffer-string) "foo")
(setf (buffer-substring 0 3) "hello")
(setf (current-buffer) "somebuffer")
(setf (frame-height) 20)

I get these warnings:

 Warning: ‘buffer-name’ is an obsolete generalized variable; use
    ‘rename-buffer’ instead.
 Warning: ‘buffer-string’ is an obsolete generalized variable.
 Warning: ‘current-buffer’ is an obsolete generalized variable; use
    ‘set-buffer’ instead.
 Warning: ‘frame-height’ is an obsolete generalized variable; use
    ‘set-frame-height’ instead.
 Warning: ‘buffer-substring’ is an obsolete generalized variable.

So only `buffer-string' and `buffer-substring' seem to lack alternative
functions that could be used instead.