help-gnu-emacs
[Top][All Lists]
Advanced

[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 13:41:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Stefan Huchler <address@hidden> writes:

> So did you understand what I wanna do? I can give you the real source
> code not the abstracted here:
>
>
> (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}"
>   (toggle-read-only)
>   (insert (concat "Kodi Remote:\n"
>                 (substitute-command-keys
>                  "\\{kodi-remote-keyboard-mode-map}") ))
>   )
>
> (defun kodi-remote-keyboard ()
>   "Open a `kodi-remote-keyboard-mode' buffer."
>   (interactive)
>   (let* ((name "*kodi-remote-keyboard*")
>          (buffer (or (get-buffer name)
>                      (generate-new-buffer name))))
>     (unless (eq buffer (current-buffer))
>       (with-current-buffer buffer
>         (unless (eq major-mode 'kodi-remote-keyboard-mode)
>           (condition-case e
>               (progn
>                 (kodi-remote-keyboard-mode)
>               )
>             (error
>              (kill-buffer buffer)
>              (signal (car e) (cdr e))))))
>       (switch-to-buffer-other-window buffer))))

FWIW, works perfectly here.  You should move the `insert' of the mode
definition, however, into `kodi-remote-keyboard', and instead of

   (toggle-read-only)

I think

   (setq buffer-read-only nil)

would be better.


Michael.



reply via email to

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