[Top][All Lists]

[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 <> 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

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)
  "Keymap for kodi-remote-keyboard-mode.")

(define-derived-mode kodi-remote-keyboard-mode special-mode 
  "Major mode for remote controlling kodi instance with keyboard commands
Key bindings:

(defun kodi-remote-keyboard ()
  "Open a `kodi-remote-keyboard-mode' buffer."
  (let* ((name "*kodi-remote-keyboard*")
         (buffer (get-buffer-create name)))
    (unless (eq buffer (current-buffer))
      (with-current-buffer buffer
        (let ((inhibit-read-only t))
          (insert (concat "Kodi Remote:\n"
        (switch-to-buffer-other-window buffer)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]