all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Stefan Huchler <stefan.huchler@mail.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: special-mode buffer changes to fundamental when modified
Date: Sun, 23 Oct 2016 18:24:53 +0200	[thread overview]
Message-ID: <87bmybkp7u.fsf@web.de> (raw)
In-Reply-To: <87lgxfusra.fsf@jupiter.lan> (Stefan Huchler's message of "Sun, 23 Oct 2016 14:58:17 +0200")

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.




  reply	other threads:[~2016-10-23 16:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20  2:25 special-mode buffer changes to fundamental when modified Stefan Huchler
2016-10-20 15:33 ` Michael Heerdegen
2016-10-20 16:34   ` Stefan Huchler
2016-10-21 10:58     ` Michael Heerdegen
2016-10-22  0:15       ` Stefan Huchler
2016-10-23 11:41         ` Michael Heerdegen
2016-10-23 12:58           ` Stefan Huchler
2016-10-23 16:24             ` Michael Heerdegen [this message]
2016-10-23 16:47               ` Stefan Huchler
2016-10-27 16:59                 ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bmybkp7u.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=stefan.huchler@mail.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.