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: Stefan Huchler
Subject: Re: special-mode buffer changes to fundamental when modified
Date: Sat, 22 Oct 2016 02:15:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> Ok, then please tell us a bit more about what you want to achieve, and
> what the mode you want to define is supposed to do.

Well, I am the author of kodi-remote.el it startet as some functions to
send a video/youtube url to kodi and start music party-mode. But
recently I startet to implement a whole remote for emacs.

Basicly the idea is to have keyboard mode so you can control a kodi
instance like you would have connected the keyboard direct on the
machine that runs kodi.

On top of that I have a kodi series mode that shows me at the moment the
unseen stuff and lets me start a video.

There I have other problems like getting the refresh functionality to
work at the moment it only kind of refreshes if I restart the mode, and
even that not really consistent.

But that is another problem, but a similar one, cause its also about
such special mode buffers (there I use tabulated mode).

In the end I would want, if that makes sense have one major
kodi-remote-buffer as start-point, and the other modes as sub-buffers.

For this thread I was targeting the keyboard mode, functional wise it
does what it should do, it sends kodi commands according to the keys you
press.

But I cant make this a empty special buffer, then most people would have
no idea what to do if they start this mode/function. So I thought lets
display the keybbindings for now.

In the end maybe I dont know what would be best, a mouse interface, I
dont know. But to get some sort of version out there I thought
displaying the keybindings and a header line would be ok.

Its just a bit much, trying to gasp emacs internals, elisp, the json-api
from kodi and designing a good interface so I have to have milestones between
that. Also the current patch will be huge anyway, so I am not trying to
get all right, but have something a user can get around if he is a bit
interested in such software.

In the end there could be some minor modes, there could be youtube-eww
integration etc, (I use it to send youtube-urls from other browsers like
conkeror and qutebrowser with something like that:

 var cmd = '/usr/bin/emacsclient -e "(kodi-remote-play-video-url
 \\"{}\\")"'

and

hint links spawn emacsclient -e "(kodi-remote-play-video-url \"{hint-url}\")"
    y

because I am to lazy to write for each browser a own youtube-plugin, but
thats maybe to much detail now.

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


That should be the relevant part.

greetings

Stefan




reply via email to

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