all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Making a read-only buffer writable
@ 2023-09-12  9:08 Heime
  2023-09-12 10:06 ` Philip Kaludercic
  2023-09-12 10:26 ` Yuri Khan
  0 siblings, 2 replies; 4+ messages in thread
From: Heime @ 2023-09-12  9:08 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Have been reading the documentation, any time one wants to write (insert) into a 
read-only buffer, one has to make it writable.  Doesn't matter when that time is. 
If it's read-only you need to make it writable to write into it. 

Then I wonder how it is possible for the following function 
to call  

(insert-button "[1]"

and

(insert " Graphic Organisation")

without calling 

(setq buffer-read-only nil)

first, just after  

(with-help-window (help-buffer)

-------------

(defun maces ()
  "Prints information about frames."
  (interactive)

  (with-help-window (help-buffer)

    (insert-button "[1]" 'action
      (lambda (button)
        (setq buffer-read-only nil)
        (insert "> Graphic Organisation \n\n")
        (setq buffer-read-only t)))
    (insert " Graphic Organisation") ))





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Making a read-only buffer writable
  2023-09-12  9:08 Making a read-only buffer writable Heime
@ 2023-09-12 10:06 ` Philip Kaludercic
  2023-09-12 10:26 ` Yuri Khan
  1 sibling, 0 replies; 4+ messages in thread
From: Philip Kaludercic @ 2023-09-12 10:06 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> Have been reading the documentation, any time one wants to write (insert) into a 
> read-only buffer, one has to make it writable.  Doesn't matter when that time is. 
> If it's read-only you need to make it writable to write into it. 
>
> Then I wonder how it is possible for the following function 
> to call  
>
> (insert-button "[1]"
>
> and
>
> (insert " Graphic Organisation")
>
> without calling 
>
> (setq buffer-read-only nil)
>
> first, just after  
>
> (with-help-window (help-buffer)
>
> -------------
>
> (defun maces ()
>   "Prints information about frames."
>   (interactive)
>
>   (with-help-window (help-buffer)
>
>     (insert-button "[1]" 'action
>       (lambda (button)
>         (setq buffer-read-only nil)
>         (insert "> Graphic Organisation \n\n")
>         (setq buffer-read-only t)))
>     (insert " Graphic Organisation") ))

The usual approach would be to do something like

(let ((inhibit-read-only t))
  (insert "> Graphic Organisation \n\n"))



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Making a read-only buffer writable
  2023-09-12  9:08 Making a read-only buffer writable Heime
  2023-09-12 10:06 ` Philip Kaludercic
@ 2023-09-12 10:26 ` Yuri Khan
  2023-09-12 10:52   ` Heime
  1 sibling, 1 reply; 4+ messages in thread
From: Yuri Khan @ 2023-09-12 10:26 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Tue, 12 Sept 2023 at 16:10, Heime <heimeborgia@protonmail.com> wrote:

> Then I wonder how it is possible for the following function
> to call
>
> (insert-button "[1]"
>
> without calling
>
> (setq buffer-read-only nil)
>
> first, just after
>
> (with-help-window (help-buffer)

Have you read the source for ‘with-help-window’? It arranges for
‘inhibit-read-only’ to be set to ‘t’ around the call to its body. Once
the body finishes, that temporary binding goes out of scope and
read-only is in effect again.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Making a read-only buffer writable
  2023-09-12 10:26 ` Yuri Khan
@ 2023-09-12 10:52   ` Heime
  0 siblings, 0 replies; 4+ messages in thread
From: Heime @ 2023-09-12 10:52 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Heime via Users list for the GNU Emacs text editor


------- Original Message -------
On Tuesday, September 12th, 2023 at 10:26 PM, Yuri Khan <yuri.v.khan@gmail.com> wrote:

> On Tue, 12 Sept 2023 at 16:10, Heime heimeborgia@protonmail.com wrote:
> 
> > Then I wonder how it is possible for the following function
> > to call
> > 
> > (insert-button "[1]"
> > 
> > without calling
> > 
> > (setq buffer-read-only nil)
> > 
> > first, just after
> > 
> > (with-help-window (help-buffer)
> 
> 
> Have you read the source for ‘with-help-window’? It arranges for
> ‘inhibit-read-only’ to be set to ‘t’ around the call to its body. Once
> the body finishes, that temporary binding goes out of scope and
> read-only is in effect again.

I have only read the Emacs Self Documentation with "C-h f".  It would be helpful
to include the detail mentioned in the documentation string of the function, that
'inhibit-read-only' to be set to 't' around the call to its body.  Otherwise, users 
cannot be blamed for concluding that 'with-help-window' uses a read-only buffer, 
and thusly have to reset 'inhibit-read-only'.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-12 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12  9:08 Making a read-only buffer writable Heime
2023-09-12 10:06 ` Philip Kaludercic
2023-09-12 10:26 ` Yuri Khan
2023-09-12 10:52   ` Heime

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.