[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Whats the idiomatic way to erase a buffer?
From: |
Mario Lang |
Subject: |
Re: Whats the idiomatic way to erase a buffer? |
Date: |
Tue, 10 Dec 2019 18:47:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> (defun my-func (name)
>> (with-current-buffer (get-buffer-create name)
>> (let ((inhibit-read-only t))
>> (erase-buffer))
>
> That look OK.
>
>> When I bury the buffer with 'q' and create the same
>> buffer, 'q' now complains:
>>
>> Text is read-only: "Attempt to change text outside editable field"
>
> I think you want to M-x toggle-debug-on-error RET, then reproduce the
> bug so we can see the backtrace which will hopefully clarify what's
> going on.
It is not an error I'm afraid.
First time around, C-h k q gives me
q runs the command bury-buffer (found in sclang-scdoc-mode-map)
but the second time around I get
q runs the command self-insert-command (found in global-map)
However, major-mode evalutes to sclang-scdoc-mode in both cases.
And sclang-scdoc-mode is defined as:
(defvar sclang-scdoc-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map widget-browse-mode-map)
(define-key map (kbd "C-c C-f") #'sclang-scdoc-find-schelp)
(define-key map (kbd "C-c C-h") #'sclang-find-scdoc)
(define-key map (kbd "C-c C-s") #'sclang-main-stop)
(define-key map (kbd "C-c C-w") #'sclang-switch-to-workspace)
(define-key map (kbd "C-M-x") 'sclang-eval-defun)
map))
(define-derived-mode sclang-scdoc-mode widget-browse-mode "SCDoc"
"Major mode for displaying SuperCollider Documentation."
(sclang-init-document)
(sclang-make-document))
> It may be that the buffer has overlays that survive the erasure (as
> 0-length overlays) and then re-grow as text is inserted.
Since I am using `widget-create' a lot, that might be a possibility.
How do I eliminate overlays in a buffer?
--
CYa,
⡍⠁⠗⠊⠕