GNU bug report logs - #71370
30.0.50; Please un-obsolete buffer-substring as a generalized variable

Previous Next

Package: emacs;

Reported by: Adam Porter <adam <at> alphapapa.net>

Date: Wed, 5 Jun 2024 01:34:02 UTC

Severity: wishlist

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Andrea Corallo <acorallo <at> gnu.org>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, Adam Porter <adam <at> alphapapa.net>, Ihor Radchenko <yantar92 <at> posteo.net>, Stefan Monnier <monnier <at> iro.umontreal.ca>, 71370 <at> debbugs.gnu.org
Subject: bug#71370: 30.0.50; Please un-obsolete buffer-substring as a generalized variable
Date: Mon, 17 Feb 2025 18:54:30 +0000
Andrea Corallo <acorallo <at> gnu.org> writes:

> Ihor Radchenko <yantar92 <at> posteo.net> writes:
>
>> Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife
>> of text editors" <bug-gnu-emacs <at> gnu.org> 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.




This bug report was last modified 85 days ago.

Previous Next


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