users/chunyang: port.el: Add helm-port, new command

git-svn-id: https://svn.macports.org/repository/macports/users/chunyang@137701 d073be05-634f-4543-b044-5fe20cf6d1d6
This commit is contained in:
Chunyang Xu
2015-06-17 19:24:58 +00:00
parent 63dea2a433
commit bdbbb4e4a8
+21
View File
@@ -51,5 +51,26 @@ Letters do not insert themselves; instead, they are commands. "
(tabulated-list-print t)
(switch-to-buffer buf))))
;;;###autoload
(defun helm-port ()
(interactive)
(and
(require 'helm nil t)
(require 'subr-x nil t)
(helm :sources
(helm-build-sync-source "MacPorts"
:candidates (lambda ()
(mapcar
#'string-trim
(split-string
(shell-command-to-string "port -q installed requested")
"\n")))
:action '(("Go to home page" .
(lambda (candidate)
(when-let ((string candidate) (regexp " (active)")
(index (string-match regexp string)))
(setq candidate (substring string 0 index)))
(shell-command (concat "port gohome " candidate)))))))))
(provide 'port)
;;; port.el ends here