* Can't figure out how to create a tabulated-list-mode with visible
@ 2016-10-09 16:08 Stefan Huchler
2016-10-11 1:30 ` Michael Heerdegen
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Huchler @ 2016-10-09 16:08 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I tried to upgrade my few kodi-remote functions to a basic major
mode. Primary to control kodi like you would do with a usb-keyboard but
over network within emacs.
So the basic stuff works so far, you can navigate start/pause/stop
delete a selected file and some stuff like that, with the standard
keyboard configuration.
https://github.com/spiderbit/kodi-remote.el
(its also in melpa)
the problem is, that in this form it only creates a empty special buffer,
which provides the right keybindings and forwards them to the kodi
instance but doesnt show anything.
I am not shure how you can print something into that read-only buffer, I
then thought next logical step besides a remote-keyboard would be to
list movies and series and stuff like that, and tabulated-list-mode
would make probably sense for that.
I looked into the code of other tabulated list modes like transmission
or proced, but they are pretty complex.
So I looked up the official documentation and tried to make a minimal
implementation that displays anything, but I did not succeed the buffer
stays empty, here my attempt:
(define-derived-mode kodi-remote-mode tabulated-list-mode "kodi-remote"
"Major mode for remote controlling kodi instance
Key bindings:
\\{kodi-remote-mode-map}"
;; :group '
;; (setq-local line-move-visual nil)
(setq tabulated-list-format [("choice" nil t)])
(setq tabulated-list-entries (nil ["Series"]))
(tabulated-list-init-header)
(tabulated-list-print)
)
;;;###autoload
(defun kodi-remote ()
"Open a `kodi-remote-mode' buffer."
(interactive)
(let* ((name "*kodi-remote*")
(buffer (or (get-buffer name)
(generate-new-buffer name))))
(unless (eq buffer (current-buffer))
(with-current-buffer buffer
(unless (eq major-mode 'kodi-remote-mode)
(condition-case e
(progn
(kodi-remote-mode)
)
(error
(kill-buffer buffer)
(signal (car e) (cdr e))))))
(switch-to-buffer-other-window buffer))))
what did I miss?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't figure out how to create a tabulated-list-mode with visible
2016-10-09 16:08 Can't figure out how to create a tabulated-list-mode with visible Stefan Huchler
@ 2016-10-11 1:30 ` Michael Heerdegen
2016-10-12 1:38 ` Stefan Huchler
0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2016-10-11 1:30 UTC (permalink / raw)
To: Stefan Huchler; +Cc: help-gnu-emacs
Hello Stefan,
> (define-derived-mode kodi-remote-mode tabulated-list-mode "kodi-remote"
> "Major mode for remote controlling kodi instance
> Key bindings:
> \\{kodi-remote-mode-map}"
> ;; :group '
> ;; (setq-local line-move-visual nil)
> (setq tabulated-list-format [("choice" nil t)])
> (setq tabulated-list-entries (nil ["Series"]))
> (tabulated-list-init-header)
> (tabulated-list-print)
> )
I've never used `tabulated-list-mode' mode, and I just had a very quick
look at your example code.
There is something wrong with the tabulated-list-* assignments. First,
the assignment expression to `tabulated-list-entries' is missing a quote
before the given list, so your code raises an error. Secondly, the
assigned values don't seem to fit the required format. I guess it
should more or less look like this (dunno if it makes sense for your
example, but at least, it makes "something happen" here):
#+begin_src emacs-lisp
(define-derived-mode kodi-remote-mode tabulated-list-mode "kodi-remote"
(setq tabulated-list-format [("choice" 10 t)])
(setq tabulated-list-entries '((nil ["Series"])))
(tabulated-list-init-header)
(tabulated-list-print))
#+end_src
HTH,
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't figure out how to create a tabulated-list-mode with visible
2016-10-11 1:30 ` Michael Heerdegen
@ 2016-10-12 1:38 ` Stefan Huchler
2016-10-12 9:28 ` Michael Heerdegen
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Huchler @ 2016-10-12 1:38 UTC (permalink / raw)
To: help-gnu-emacs
Hello Michael,
that helped me a lot, was exactly what I wanted to do at least as
startpoint. :)
Michael Heerdegen <michael_heerdegen@web.de> writes:
> There is something wrong with the tabulated-list-* assignments. First,
> the assignment expression to `tabulated-list-entries' is missing a quote
> before the given list, so your code raises an error.
I think it didnt just did silently nothing, but could be wrong :).
Hmm yes I am a lisp beginner I still strugle with the different lists
and even somethimes have problems to understand the concepts behind it,
and what is a good/efficiant/clean way to code. :)
>Entries displayed in the current Tabulated List buffer.
>This should be either a function, or a list.
>If a list, each element has the form (ID [DESC1 ... DESCN]),
Well I guess I misread the description. Each has the form, so the
additional parenthesis makes sense, but why is a ' needed for entries
but not for format?
Because its "either a function or a list, and
therefor it tries to execute the function of nil". So whenever I read
such sentence I have to quote? Or do vectors get quoted / not evaluated
in general?
> Secondly, the
> assigned values don't seem to fit the required format. I guess it
> should more or less look like this (dunno if it makes sense for your
> example, but at least, it makes "something happen" here):
>
> #+begin_src emacs-lisp
> (define-derived-mode kodi-remote-mode tabulated-list-mode "kodi-remote"
> (setq tabulated-list-format [("choice" 10 t)])
> (setq tabulated-list-entries '((nil ["Series"])))
> (tabulated-list-init-header)
> (tabulated-list-print))
> #+end_src
Yes it works and making "something happen" was exactly my goal :)
greetings
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't figure out how to create a tabulated-list-mode with visible
2016-10-12 1:38 ` Stefan Huchler
@ 2016-10-12 9:28 ` Michael Heerdegen
0 siblings, 0 replies; 4+ messages in thread
From: Michael Heerdegen @ 2016-10-12 9:28 UTC (permalink / raw)
To: Stefan Huchler; +Cc: help-gnu-emacs
Stefan Huchler <stefan.huchler@mail.de> writes:
> Well I guess I misread the description. Each has the form, so the
> additional parenthesis makes sense, but why is a ' needed for entries
> but not for format?
Good question! One might assume that () and [] are quite symmetric, but
there are important differences.
Lisp programs are written as lists (and not as vectors). If you want a
list constant (at a position that is evaluated), you need to quote the
list to prevent evaluation, otherwise it would be interpreted as code.
OTOH, the syntax for vectors, [element...], is only used to describe
vectors. Vectors are self-evaluating objects, so you don't need to
quote. It wouldn't harm OTOH, but I guess it would look quite strange
to most people.
Regards,
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-12 9:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-09 16:08 Can't figure out how to create a tabulated-list-mode with visible Stefan Huchler
2016-10-11 1:30 ` Michael Heerdegen
2016-10-12 1:38 ` Stefan Huchler
2016-10-12 9:28 ` Michael Heerdegen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).