Questions tagged [read-only-mode]

37 questions
9
votes
2 answers

Make buffer read-only on a per-file basis

I know I can set something like -*- mode: read-only-mode -*- inside a commentary and Emacs will open the corresponding file as read-only. My problem is that I still want to read files that include such a line with the org-mode major mode; Emacs…
shackra
  • 2,702
  • 18
  • 47
9
votes
2 answers

Flush all output in shell buffer (and *Messages* too)

Is there any easy way to flush all output in the shell buffer? Since recently (I believe Emacs 24.4 already has this) *shell* buffers aren't editable, they behave similar to how typical terminal would behave, i.e. only allowing you to append text at…
wvxvw
  • 11,222
  • 2
  • 30
  • 55
7
votes
1 answer

View a buffer in read-only mode in a window while editing it in another window

A buffer can be made write-protected by toggling the read-only mode via M-x toggle-read-only. Is there a way to make a buffer read-only in a window, while editing it in another window?
AlQuemist
  • 175
  • 6
7
votes
2 answers

how to open all files from specific path as read-only buffer

I am looking for a way to open all files from $MYPATH (for instance) as read-only buffer by default. And all rest of the files should be opened as normal buffer (I mean, not read-only buffer). Does anyone know how to do this? Cheers. - A still naive…
StupidKris
  • 109
  • 5
7
votes
2 answers

Is there a hook that runs for all read only buffers

I want to enable show-trailing-whitespace for editable file and disable show-trailing-whitespace for read only files. I've tried (defun my/read-only-whitespace () (setq-local show-trailing-whitespace (not buffer-read-only))) (setq-default…
Moyamo
  • 388
  • 2
  • 7
7
votes
1 answer

How to make a specific read-only buffer writable?

The readonly status of the current buffer can be toggled with (read-only-mode) or pressing C-x C-q but I intend to make a buffer which is not current, writable. The below is what I am using (with-current-buffer (get-buffer-create "*some*") …
myTerminal
  • 417
  • 1
  • 5
  • 15
6
votes
3 answers

How to exit read-only mode

I have a buffer in read-only mode. Killing the buffer and reopening it does not do the job while restarting emacs does. How to exit the read-only mode without restarting emacs?
Viesturs
  • 805
  • 8
  • 19
5
votes
1 answer

Open some files with read-only mode

I want some files to be read-only when I open them. Maybe using some kind of header would work? Parsing the extension would work too but I want to apply to, for example, some ".txt" files so is not very good to apply this rule to all "txt" files.
hhaamm
  • 305
  • 1
  • 5
4
votes
1 answer

Is there a hook that runs when exiting read-only-mode?

I'd like to set some things (e.g., cursor shape) when in read-only-mode. That part is easy enough with (add-hook 'read-only-mode-hook (lambda() (setq-local cursor-type 'box))) Then I'd like to switch it back when exiting…
Ista
  • 1,148
  • 8
  • 12
3
votes
1 answer

Is it possible to modify the emacs buffer with read-only text?

I am new to emacs lisp and emacs itself, coming from vim. I have seen such a nice feature in the idea: This is a mutable buffer with read-only text hints: type of a variable and a argument name in the print function. I'd like to implement such…
VP.
  • 187
  • 1
  • 9
3
votes
1 answer

How can I edit read-only text after pasting?

I want to create a buffer where some parts are editable, but others are not. I'm using the read-only string property to do this, e.g.: (with-current-buffer (get-buffer-create "*scratch-demo*") (insert ";; you can edit me\n") (insert (propertize …
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59
2
votes
0 answers

How to make ansi-term output read only?

When using ansi-term in line mode emacs lets you edit the buffer arbitrarily, not just after the last prompt. I'm trying to make it read only so I stop fudging with command output. The problem is all the solutions I've come up with also prevent me…
Joseph Garvin
  • 2,061
  • 8
  • 21
2
votes
1 answer

Cannot edit ".gitignore" due to strange errors and read-only switched on

A new error has occurred with a recent upgrade to Emacs 27.1. I'm trying to edit .gitignore and get the following error: *ERROR*: Unlocking file: Invalid argument, /.gitignore To check this is not an error in an initialisation file, I…
user23791
2
votes
1 answer

How to set key binding for read-only-mode? in order to simplify cursor movement

moving point command: next-line, previous-line, forward-char, backward-char, etc. How to omit Ctrl key in read-only-mode? How can I combine with read-only-mode-hook to automatically enable keybind when opening a file with read-only permissions?
dongli si
  • 63
  • 8
2
votes
3 answers

How can I copy text from read only buffer?

When read the org mode manual to provide support for the raised question. The contents in read-only buffer is causally need to be copied as reference here. Take the Org Capture Template as an example, Tried to copy to the above region to this…
Alice
  • 219
  • 1
  • 7
1
2 3