|
From: | Adam Porter |
Subject: | bug#71370: 30.0.50; Please un-obsolete buffer-substring as a generalized variable |
Date: | Thu, 27 Jun 2024 10:09:39 -0500 |
User-agent: | Mozilla Thunderbird |
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
[Prev in Thread] | Current Thread | [Next in Thread] |