all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* New text property: `inhibit-read-only'
@ 2014-11-16 22:45 Lars Magne Ingebrigtsen
  2014-11-17  4:30 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 2014-11-16 22:45 UTC (permalink / raw)
  To: emacs-devel

As previously discussed (like a year or two ago), we have certain modes
that basically have read-only buffers, but that need certain bits to be
writable.

eww is one of them -- we need to write things into search fields and the
like.

So I've just implemented an `inhibit-read-only' text property and pushed
it.  I'm sure there are cases that I haven't covered yet, so please give
it a whirl and let me know where I forgot to add checks.

This is a test snippet:

(progn
  (pop-to-buffer "*test*")
  (insert "This is a test This is a test\nThis is a test This is a test")
  (put-text-property 10 20 'inhibit-read-only t)
  (put-text-property 10 20 'face '(:background "red"))
  (setq buffer-read-only t))

The red text should be editable.

Commands like `C-k' and stuff don't really work in this particular
scenario, but I don't things that's necessarily a bug.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* Re: New text property: `inhibit-read-only'
  2014-11-16 22:45 New text property: `inhibit-read-only' Lars Magne Ingebrigtsen
@ 2014-11-17  4:30 ` Stefan Monnier
  2014-11-17  7:47   ` Lars Brinkhoff
  2014-11-17 10:20   ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Monnier @ 2014-11-17  4:30 UTC (permalink / raw)
  To: emacs-devel

> As previously discussed (like a year or two ago), we have certain modes
> that basically have read-only buffers, but that need certain bits to be
> writable.

Right, like Custom buffers.

> eww is one of them -- we need to write things into search fields and the
> like.

> So I've just implemented an `inhibit-read-only' text property and pushed
> it.

What is different that the solution used in Custom buffers can't be used
or doesn't work well in eww?


        Stefan



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

* Re: New text property: `inhibit-read-only'
  2014-11-17  4:30 ` Stefan Monnier
@ 2014-11-17  7:47   ` Lars Brinkhoff
  2014-11-17 10:20   ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Brinkhoff @ 2014-11-17  7:47 UTC (permalink / raw)
  To: emacs-devel

Larsi wrote:
>> So I've just implemented an `inhibit-read-only' text property and
>> pushed it.

That's exactly what I was looking for the other week!  (When I didn't
find it, my workaround was to set the read-only text property to t
everywhere except for the writable bits.)

Stefan Monnier wrote:
> What is different that the solution used in Custom buffers can't be
> used or doesn't work well in eww?

That solution being:  The buffer is writable, but uses a keymap with
self-insert-command remapped to signal an error.  Ecxept for editable
fields, which use another keymap.  Right?




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

* Re: New text property: `inhibit-read-only'
  2014-11-17  4:30 ` Stefan Monnier
  2014-11-17  7:47   ` Lars Brinkhoff
@ 2014-11-17 10:20   ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 2014-11-17 10:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> What is different that the solution used in Custom buffers can't be used
> or doesn't work well in eww?

Custom buffers uses a bewildering number of hooks, bindings and
... mysteries to achieve this pretty trivial thing.  It binds all
inserting commands to `Custom-no-edit' (and then has an overlay over the
text input bits that has a different keymap).

To inhibit deletions, it uses

(add-hook 'before-change-functions 'widget-before-change nil t)

that checks stuff in some contexts

Debugger entered--Lisp error: (text-read-only "Attempt to change text outside editable field")
  signal(text-read-only ("Attempt to change text outside editable field"))
  widget-before-change(3 6)
  delete-region(3 6)

Hm.  After that backtrace I'm now able to delete text in the Custom
buffer.

Anyway, with a new buffer `C-k' again fails as it should with

Debugger entered--Lisp error: (text-read-only #<buffer *Customize Apropos*>)
  signal(text-read-only (#<buffer *Customize Apropos*>))
  kill-region(124 126 region)

but I'm not quite sure how that's set up.

And and.

It just seems ridiculous to me that all modes that need this simple
thing (a read-only buffer with some bits that are editable) would have
to jump through all these vaguely defined hoops.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

end of thread, other threads:[~2014-11-17 10:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-16 22:45 New text property: `inhibit-read-only' Lars Magne Ingebrigtsen
2014-11-17  4:30 ` Stefan Monnier
2014-11-17  7:47   ` Lars Brinkhoff
2014-11-17 10:20   ` Lars Magne Ingebrigtsen

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.