all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 71370@debbugs.gnu.org
Subject: bug#71370: 30.0.50; Please un-obsolete buffer-substring as a generalized variable
Date: Thu, 27 Jun 2024 10:09:39 -0500	[thread overview]
Message-ID: <1ea7303f-5e8f-4ff6-ab1a-5a97412c291b@alphapapa.net> (raw)
In-Reply-To: <87iky4zedz.fsf@web.de>

Hi Michael,

On 6/19/24 18:44, Michael Heerdegen wrote:
> Adam Porter <adam@alphapapa.net> writes:
> 
>> ┌────
>> │ (let ((inhibit-read-only t))
>> │   (setf (buffer-substring (oref (magit-current-section) start)
>> │                           (oref (magit-current-section) end))
>> │         "foobar\n"))
>> └────
>>
>> Otherwise, one would have to use `delete-region' and then `insert',
>> which is more cumbersome and error-prone.
> 
> I guess alternatively you could define a helper function and make that
> `setf'able, like
> 
> #+begin_src emacs-lisp
> (defalias 'magit-buffer-substring #'buffer-substring)
> (gv-define-simple-setter magit-buffer-substring
>                           cl--set-buffer-substring)
> #+end_src

One could, but it would seem tedious and wasteful to have do that across 
tens or hundreds of Elisp packages that use this setter and have for years.

The minor ambiguities you point out in one of your later messages are 
fair to note; however, they aren't new, and they don't appear to have 
discouraged use of this form in practice.  On the contrary, the form 
appears to be widely useful and understood easily enough.

Given that Emacs is full of idiosyncrasies which are much more impactful 
and challenging to understand, I'd think that it would be sufficient to 
document this one in the Elisp manual, like others are.  I'd certainly 
rather do that than deprive users of this useful, simple idiom which is 
already widely used.

--Adam





      parent reply	other threads:[~2024-06-27 15:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  1:33 bug#71370: 30.0.50; Please un-obsolete buffer-substring as a generalized variable Adam Porter
2024-06-05 11:52 ` Eli Zaretskii
2024-06-05 12:09   ` Ihor Radchenko
2024-06-05 14:16   ` Adam Porter
2024-06-05 14:58     ` Eli Zaretskii
2024-06-05 17:35       ` Adam Porter
2024-06-19 23:44 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-20  4:05   ` Adam Porter
2024-06-20 15:33     ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-20 15:46       ` Ihor Radchenko
2024-06-21  8:55         ` Andrea Corallo
2024-06-21 22:52           ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-22  6:05             ` Ihor Radchenko
2024-06-22  8:16               ` Eli Zaretskii
2024-06-22  8:39                 ` Ihor Radchenko
2024-06-22  9:45                   ` Eli Zaretskii
2024-06-22  7:13             ` Eli Zaretskii
2024-06-27 15:09   ` Adam Porter [this message]

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

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

  git send-email \
    --in-reply-to=1ea7303f-5e8f-4ff6-ab1a-5a97412c291b@alphapapa.net \
    --to=adam@alphapapa.net \
    --cc=71370@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.