helm - agregando helm-Mx a las fuentes de helm


7

Puedo agregar algunas fuentes adicionales a timones como este

(setq helm-mini-default-sources '(helm-source-buffers-list
                                  helm-source-recentf
                                  helm-source-dired-recent-dirs
                                  helm-chrome-source
                                  hgs/helm-c-source-stars
                                  hgs/helm-c-source-repos
                                  hgs/helm-c-source-search
                                  helm-source-buffer-not-found))

Lo último que necesito agregar a esto es helm-M-x. Solo necesito agregar todos los comandos a las fuentes predeterminadas. Con esto puedo invocar una sola función y puedo ir a cualquier cosa o puedo invocar cualquier comando.

Pero helm-M-xes una función y su código fuente no tiene ninguna fuente. ¿Alguna ayuda sobre cómo lograr esto?


¿Por qué sobre la creación de comandos Emacs fuente por ti mismo?
— xuchunyang

Respuestas:


4
(defvar helm-source-emacs-commands
  (helm-build-sync-source "Emacs commands"
    :candidates (lambda ()
                  (let ((cmds))
                    (mapatoms
                     (lambda (elt) (when (commandp elt) (push elt cmds))))
                    cmds))
    :coerce #'intern-soft
    :action #'command-execute)
  "A simple helm source for Emacs commands.")

;; Try it
(helm :sources helm-source-emacs-commands)

Traté de construir otra fuente como esta gist.github.com/ChillarAnand/23119413409f00b7e995#file-helm-el pero no funcionó como se esperaba.
— ChillarAnand 01 de

He probado el tuyo, funciona bien, pero solo por la historia de los comandos de Emacs, por lo que debes usar helm-M-xpara ejecutar algunos comandos para construir ese historial primero, porque el timón no guarda el historial de la sesión de forma predeterminada.
— xuchunyang

4

Basado en la respuesta de xuchunyang, pude agregar helm-M-xa las fuentes de timón.

(defvar helm-source-emacs-commands
  (helm-build-sync-source "Emacs commands"
    :candidates (lambda ()
                  (let ((cmds))
                    (mapatoms
                     (lambda (elt) (when (commandp elt) (push elt cmds))))
                    cmds))
    :coerce #'intern-soft
    :action #'command-execute)
  "A simple helm source for Emacs commands.")

(defvar helm-source-emacs-commands-history
  (helm-build-sync-source "Emacs commands history"
    :candidates (lambda ()
                  (let ((cmds))
                    (dolist (elem extended-command-history)
                      (push (intern elem) cmds))
                    cmds))
    :coerce #'intern-soft
    :action #'command-execute)
  "Emacs commands history")

(setq helm-mini-default-sources '(helm-source-emacs-commands-history
                                  helm-source-emacs-commands))

Genial, esto me ayuda mucho para helm-for-files.
— ReneFroger
Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.