From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: special-mode buffer changes to fundamental when modified Date: Sun, 23 Oct 2016 18:24:53 +0200 Message-ID: <87bmybkp7u.fsf@web.de> References: <87wph3n4d7.fsf@jupiter.lan> <87twc79gsa.fsf@web.de> <87eg3bhtcm.fsf@jupiter.lan> <87wph2j7e3.fsf@web.de> <877f911bnm.fsf@jupiter.lan> <87lgxfl2bf.fsf@web.de> <87lgxfusra.fsf@jupiter.lan> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1477239940 11474 195.159.176.226 (23 Oct 2016 16:25:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Oct 2016 16:25:40 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Stefan Huchler Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 23 18:25:36 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byLaR-0001IA-3a for geh-help-gnu-emacs@m.gmane.org; Sun, 23 Oct 2016 18:25:27 +0200 Original-Received: from localhost ([::1]:41680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byLaT-0002cM-Gd for geh-help-gnu-emacs@m.gmane.org; Sun, 23 Oct 2016 12:25:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byLa3-0002c5-9Y for help-gnu-emacs@gnu.org; Sun, 23 Oct 2016 12:25:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byLa0-0001W7-4S for help-gnu-emacs@gnu.org; Sun, 23 Oct 2016 12:25:03 -0400 Original-Received: from mout.web.de ([212.227.17.12]:65264) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byLZz-0001Vx-RM for help-gnu-emacs@gnu.org; Sun, 23 Oct 2016 12:25:00 -0400 Original-Received: from drachen.dragon ([90.186.1.126]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MLxwG-1bzT6L0pga-007m2y; Sun, 23 Oct 2016 18:24:57 +0200 In-Reply-To: <87lgxfusra.fsf@jupiter.lan> (Stefan Huchler's message of "Sun, 23 Oct 2016 14:58:17 +0200") X-Provags-ID: V03:K0:BxFTZyyIsUwKRrurwMvTmzBKANXS8rajAwGiJ88vJYB6Wo9wyQO AGKJlEj6KYaNIlTPHVYJJukc4MbbzzysLRhTojz/SQJmwMfJ8EO5wIpuy0FcP+DfkN1JU9g bPgPYjdOfhp1Zbcay+VGsUHptFJEetn8D/+4sSclrBwrRTwYVIALEp+iYwmCJC4+DBxG93X h6iKxRZUwKJ1J/qVnCIng== X-UI-Out-Filterresults: notjunk:1;V01:K0:j6WeB9Aoljw=:ZrJkDL71H28L001m533Qfr 7oYqr6pltyuUfKAhOdADT+EKmHHqHZSkBPjpNwdY+3tiW9xMJvVD6doLv29izi7UuZ2Y57ygj 8lGOce9GWZ0SpVec3v3cLgvQSz4GEhmM/ZGNrEmLjKJp9rp97meNJVgPM3FRdj1rsrfNlgwwJ AmKwTpDiwwaDgrQuBZWnNhY8askM0ff08pUXydmQjkiqCLsKxMh6GrL5nOuT3M/9RsPG9c34Y l0habhOpDEPGRRRRt7KR1I6BRdOkZMZ6us66MKkrZ7z+Sb6LKcY8AuSP42m0hHNZ1TBKobKEP c9yT0hqSJ4gg4bvyelf1z/kmNlEuJN6izBIc/AAUWIfx3Z7NTz9CFoD61NZZb+VDLZab7l/TW /rs1sYcAoYfyTInKlZvhSkE5R4PiTbez0uacko4nf5chqXSsc1FA3xP3biLuES+R6ONp9IQE9 GW8mo09OL0KrBGq0xHhlFofb+ida1XWyJp7rzG5YurGH5KPr/uJRiDbSCcsAL7+OcfservuP5 u7iX0koIUmy24sChbKmp4nEgFD2JAZ6Z3Vdr8e+SspKfOeFEEemwxlC94fZTw8dK2Qp8ah4Nv CqxpLaX67lk8rXapjXgG9mepW4w070zsFXh2l6M7JQ0hVae+CzUK5WWhm/hwoNYreE0XIlEub mZprswHSNmOgZSFiCa5F+G/oGyuLNmiJpSopXVUgzKRkCFLdl89YYtBza4y5k+YNqq7X1/Bjl FsdB6uYt+zI8sxLMTiveX2+umEYadrPW1BEIKooCMUEDSRAAAjH8drCB4kxGz1bypauuPITl X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111603 Archived-At: Stefan Huchler writes: > condition-case: Buffer is read-only: # 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 "") #'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.