[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9054: 24.0.50; show source in other window
From: |
Juri Linkov |
Subject: |
bug#9054: 24.0.50; show source in other window |
Date: |
Tue, 03 May 2022 20:25:00 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
>> BTW, I can't find a discussion about scratch-buffer, so I'll ask here:
>> when I accidentally delete the *scratch* buffer, the first thing I do is
>> 'C-x b *scratch* RET' and discover an empty buffer. I wonder would it help
>> to add a '("\*scratch\*\\'" . scratch-buffer) to 'auto-mode-alist'
>> that will recreate it after switching to a new buffer with this name?
>
> Hm... that seems quite attractive, but also somewhat surprising. I
> mean, `C-x b foo.c RET' doesn't put the resulting buffer in C mode.
I get C mode after `C-x b foo.c RET' due to such customization:
```
(setq-default major-mode (lambda ()
(if buffer-file-name
(fundamental-mode)
(let ((buffer-file-name (buffer-name)))
(set-auto-mode)))))
```
> On the other hand, the *scratch* buffer is slightly special, so perhaps
> this would be helpful for users. The reason I added the
> `scratch-buffer' command is that I remember a number of users saying
> that they'd accidentally killed the buffer, and couldn't find a way to
> get it back to how it was working (because typing `M-x
> lisp-interaction-mode' is a pretty obscure thing to say).
>
> So perhaps it would be helpful to do what you say.
Now I tried again to switch to the deleted *scratch* buffer to recreate it,
and it activated the correct mode. This is because switch-to-buffer
uses set-buffer-major-mode that has special handling for *scratch*:
if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0)
function = find_symbol_value (intern ("initial-major-mode"));