all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Clearning a keymap completely
@ 2016-09-04 21:40 Narendra Joshi
  2016-09-04 22:27 ` Søren Pilgård
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Narendra Joshi @ 2016-09-04 21:40 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

I need to remove all the self-insert commands in a buffer. I want to
be able to insert text into the buffer through emacs lisp but don't
want the user to be able to insert text. How can this be done?

Best,
Narendra Joshi



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

* Re: Clearning a keymap completely
  2016-09-04 21:40 Clearning a keymap completely Narendra Joshi
@ 2016-09-04 22:27 ` Søren Pilgård
  2016-09-05  3:54 ` Yuri Khan
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Søren Pilgård @ 2016-09-04 22:27 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: help-gnu-emacs@gnu.org

On Sun, Sep 4, 2016 at 11:40 PM, Narendra Joshi <narendraj9@gmail.com> wrote:
> I need to remove all the self-insert commands in a buffer. I want to
> be able to insert text into the buffer through emacs lisp but don't
> want the user to be able to insert text. How can this be done?
>
That is now how you want to solve it.
Instead look into the buffer-read-only and inhibit-read-only variables [0].
You can let bind them to temporarily edit the buffer from your code.
Messing with all the keybindings is not the way to go.

[0] https://www.gnu.org/software/emacs/manual/html_node/elisp/Read-Only-Buffers.html



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

* Re: Clearning a keymap completely
  2016-09-04 21:40 Clearning a keymap completely Narendra Joshi
  2016-09-04 22:27 ` Søren Pilgård
@ 2016-09-05  3:54 ` Yuri Khan
  2016-09-05  4:03 ` John Mastro
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Yuri Khan @ 2016-09-05  3:54 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: help-gnu-emacs@gnu.org

On Mon, Sep 5, 2016 at 4:40 AM, Narendra Joshi <narendraj9@gmail.com> wrote:

> I need to remove all the self-insert commands in a buffer. I want to
> be able to insert text into the buffer through emacs lisp but don't
> want the user to be able to insert text. How can this be done?

Easiest is to set (read-only-mode 1). (insert "foo") still works but
self-insert-command tells the user “Buffer is read-only”.



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

* Re: Clearning a keymap completely
  2016-09-04 21:40 Clearning a keymap completely Narendra Joshi
  2016-09-04 22:27 ` Søren Pilgård
  2016-09-05  3:54 ` Yuri Khan
@ 2016-09-05  4:03 ` John Mastro
  2016-09-05  6:27   ` Narendra Joshi
  2016-09-05  7:27 ` Marcin Borkowski
  2016-09-06 12:53 ` Stefan Monnier
  4 siblings, 1 reply; 9+ messages in thread
From: John Mastro @ 2016-09-05  4:03 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org; +Cc: Narendra Joshi

> Narendra Joshi <narendraj9@gmail.com> wrote:
> 
> I need to remove all the self-insert commands in a buffer. I want to
> be able to insert text into the buffer through emacs lisp but don't
> want the user to be able to insert text. How can this be done?

Just make the buffer read only, and then let-bind inhibit-read-only
to t where necessary in your Lisp. 

https://www.gnu.org/software/emacs/manual/html_node/elisp/Read-Only-Buffers.html

Hope that helps

        John


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

* Re: Clearning a keymap completely
  2016-09-05  4:03 ` John Mastro
@ 2016-09-05  6:27   ` Narendra Joshi
  0 siblings, 0 replies; 9+ messages in thread
From: Narendra Joshi @ 2016-09-05  6:27 UTC (permalink / raw)
  To: John Mastro; +Cc: help-gnu-emacs@gnu.org

Thanks! Let binding inhibit-read-only worked.

On Mon, Sep 5, 2016 at 9:33 AM, John Mastro <john.b.mastro@gmail.com> wrote:
>> Narendra Joshi <narendraj9@gmail.com> wrote:
>>
>> I need to remove all the self-insert commands in a buffer. I want to
>> be able to insert text into the buffer through emacs lisp but don't
>> want the user to be able to insert text. How can this be done?
>
> Just make the buffer read only, and then let-bind inhibit-read-only
> to t where necessary in your Lisp.
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Read-Only-Buffers.html
>
> Hope that helps
>
>         John



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

* Re: Clearning a keymap completely
  2016-09-04 21:40 Clearning a keymap completely Narendra Joshi
                   ` (2 preceding siblings ...)
  2016-09-05  4:03 ` John Mastro
@ 2016-09-05  7:27 ` Marcin Borkowski
  2016-09-06 12:53 ` Stefan Monnier
  4 siblings, 0 replies; 9+ messages in thread
From: Marcin Borkowski @ 2016-09-05  7:27 UTC (permalink / raw)
  To: Narendra Joshi; +Cc: help-gnu-emacs@gnu.org


On 2016-09-04, at 23:40, Narendra Joshi <narendraj9@gmail.com> wrote:

> I need to remove all the self-insert commands in a buffer. I want to
> be able to insert text into the buffer through emacs lisp but don't
> want the user to be able to insert text. How can this be done?

Also, you may want to make a mode derived from special-mode.

> Best,
> Narendra Joshi

Hth,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: Clearning a keymap completely
  2016-09-04 21:40 Clearning a keymap completely Narendra Joshi
                   ` (3 preceding siblings ...)
  2016-09-05  7:27 ` Marcin Borkowski
@ 2016-09-06 12:53 ` Stefan Monnier
  4 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2016-09-06 12:53 UTC (permalink / raw)
  To: help-gnu-emacs

> I need to remove all the self-insert commands in a buffer.  I want to
> be able to insert text into the buffer through emacs lisp but don't
> want the user to be able to insert text.  How can this be done?

The traditional way to do that is with suppress-keymap or by deriving
from special-mode.


        Stefan




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

* Re: Clearning a keymap completely
       [not found] <mailman.1893.1473362103.22741.help-gnu-emacs@gnu.org>
@ 2016-09-09  8:41 ` Ralf Fassel
  2016-09-09  9:04 ` Joost Kremers
  1 sibling, 0 replies; 9+ messages in thread
From: Ralf Fassel @ 2016-09-09  8:41 UTC (permalink / raw)
  To: help-gnu-emacs

* Narendra Joshi <narendraj9@gmail.com>
| I need to remove all the self-insert commands in a buffer. I want to
| be able to insert text into the buffer through emacs lisp but don't
| want the user to be able to insert text. How can this be done?

Set the buffer to read-only?

R'


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

* Re: Clearning a keymap completely
       [not found] <mailman.1893.1473362103.22741.help-gnu-emacs@gnu.org>
  2016-09-09  8:41 ` Ralf Fassel
@ 2016-09-09  9:04 ` Joost Kremers
  1 sibling, 0 replies; 9+ messages in thread
From: Joost Kremers @ 2016-09-09  9:04 UTC (permalink / raw)
  To: help-gnu-emacs

Narendra Joshi wrote:
> I need to remove all the self-insert commands in a buffer. I want to
> be able to insert text into the buffer through emacs lisp but don't
> want the user to be able to insert text. How can this be done?

Easiest way is to set the buffer to read-only, then whenever you want to
insert text programmatically, do:

```
(let ((inhibit-read-only t))
  (insert-text)
  ...)
```

You can of course use a keymap that binds every normal key to `nil`, but
you'll have to install it in such a way that it actually overrides all
other keymaps in that buffer. You'd have to read up on keymaps in the
Elisp manual to learn how to do that.



-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

end of thread, other threads:[~2016-09-09  9:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-04 21:40 Clearning a keymap completely Narendra Joshi
2016-09-04 22:27 ` Søren Pilgård
2016-09-05  3:54 ` Yuri Khan
2016-09-05  4:03 ` John Mastro
2016-09-05  6:27   ` Narendra Joshi
2016-09-05  7:27 ` Marcin Borkowski
2016-09-06 12:53 ` Stefan Monnier
     [not found] <mailman.1893.1473362103.22741.help-gnu-emacs@gnu.org>
2016-09-09  8:41 ` Ralf Fassel
2016-09-09  9:04 ` Joost Kremers

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.