1

I am using multi-term and would like to create a helm source which displays all my open terminals. There is a list of all terminal buffers called "multi-term-buffer-list", but I can't get this list into the candidates for the helm source. I tried several combinations along these lines:

(setq some-helm-source
  '((name . "Terminal Buffers")
    (candidates . multi-term-buffer-list)))

(helm :sources '(some-helm-source))

Does anyone know how to do this?

  • Try (helm :sources 'some-helm-source). Have you seen the wiki? – Tianxiang Xiong Apr 12 '16 at 13:44
  • The result is the same. It opens the helm buffer, but there are no candidates to choose from. The problem seems to be getting the candidates from the multi-term-buffer-list into the helm source. – MMock Apr 12 '16 at 14:24
  • I think the problem is that Helm sources need to be a list of strings, while multi-term-buffer-list is a list of buffers. – Tianxiang Xiong Apr 13 '16 at 0:13
2

First, check out the wiki on developing for Helm. If you find anything unclear, be sure to create an issue and explain it clearly so others can benefit!

I don't use multi-term, but it seems that the problem is that multi-term-buffer-list returns a list of buffers. Helm needs a list of strings to display.

What you need is a list of candidates of the form (display . candidate), where display is a string to display and candidate is the actual object (in this case, a process) to take actions on.

Here is a minimal example:

(helm :sources
      (helm-build-sync-source "Multi-term buffers"
        :candidates (mapcar (lambda (buffer)
                              (cons (buffer-name buffer) buffer))
                            multi-term-buffer-list)
        :action '(("Switch to buffer" . switch-to-buffer))))                     
  • multi-term-buffer-list is a variable not a function – xuchunyang Apr 13 '16 at 3:05
  • Edited my answer. – Tianxiang Xiong Apr 13 '16 at 4:11
1

Actually I ended up using a slightly different solution. Doing it like it was shown in the answer in this post I get a terminal list with additional information about the terminals.

(defclass my-helm-source-terminal-buffers-class (helm-source-buffers)
   ((candidates :initform
               (lambda ()
                 (mapcar 'buffer-name multi-term-buffer-list)))))

(setq my-helm-source-terminal-buffers-list
      (helm-make-source "Terminals" 'my-helm-source-terminal-buffers-class))

(defun my-helm-terminal-buffers ()
  (interactive)
  (helm :sources 'my-helm-source-terminal-buffers-list
        :buffer "*helm terminals*"))

I really need to learn emacs lisp, at the moment I have no clue what I am really doing...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.