[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: special-mode buffer changes to fundamental when modified
From: |
Michael Heerdegen |
Subject: |
Re: special-mode buffer changes to fundamental when modified |
Date: |
Sun, 23 Oct 2016 18:24:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Stefan Huchler <stefan.huchler@mail.de> writes:
> condition-case: Buffer is read-only: #<killed buffer>
Well, your code behaved differently depending on whether the buffer
already existed or not.
> Can you post a exact source you used that did work? maybe my emacs
> setup is messed up somehow.
Ok, I used the excerpt you posted and edited it very slightly. There
was indeed a problem: `special-mode', from which your mode derived,
makes the buffer read-only. So I suggest to bind `inhibit-read-only' to
ignore the read-only flag, since I assume you want the buffer to stay
read-only.
This is the slightly edited example, that indeed works as expected (and
for every call the same):
#+begin_src emacs-lisp
(defvar kodi-remote-keyboard-mode-map
(let ((map (make-sparse-keymap))
;; (menu-map (make-sparse-keymap))
)
(define-key map (kbd "-") #'kodi-remote-volume-decrease)
(define-key map (kbd "<tab>") #'kodi-remote-toggle-fullscreen)
map)
"Keymap for kodi-remote-keyboard-mode.")
(define-derived-mode kodi-remote-keyboard-mode special-mode
"kodi-remote-keyboard"
"Major mode for remote controlling kodi instance with keyboard commands
Key bindings:
\\{kodi-remote-keyboard-mode-map}")
(defun kodi-remote-keyboard ()
"Open a `kodi-remote-keyboard-mode' buffer."
(interactive)
(let* ((name "*kodi-remote-keyboard*")
(buffer (get-buffer-create name)))
(unless (eq buffer (current-buffer))
(with-current-buffer buffer
(let ((inhibit-read-only t))
(erase-buffer)
(kodi-remote-keyboard-mode)
(insert (concat "Kodi Remote:\n"
(substitute-command-keys
"\\{kodi-remote-keyboard-mode-map}"))))
(switch-to-buffer-other-window buffer)))))
#+end_src
HTH,
Michael.
- special-mode buffer changes to fundamental when modified, Stefan Huchler, 2016/10/20
- Re: special-mode buffer changes to fundamental when modified, Michael Heerdegen, 2016/10/20
- Re: special-mode buffer changes to fundamental when modified, Stefan Huchler, 2016/10/20
- Re: special-mode buffer changes to fundamental when modified, Michael Heerdegen, 2016/10/21
- Re: special-mode buffer changes to fundamental when modified, Stefan Huchler, 2016/10/22
- Re: special-mode buffer changes to fundamental when modified, Michael Heerdegen, 2016/10/23
- Re: special-mode buffer changes to fundamental when modified, Stefan Huchler, 2016/10/23
- Re: special-mode buffer changes to fundamental when modified,
Michael Heerdegen <=
- Re: special-mode buffer changes to fundamental when modified, Stefan Huchler, 2016/10/23
- Re: special-mode buffer changes to fundamental when modified, Michael Heerdegen, 2016/10/27