rejeep/prodigy.el — pull request #48 by tomterl (2014-03-19 17:01:08+00:00)
Title: Let property functions access the current service.

Here I go again :)

Property functions are encapsulated in a `prodigy-with-service`
environment, storing the current service in `*prodigy-service-with*`.

Motivation:

Instead of

(prodigy-define-tag
:name 'ssh-tunnel
:command "ssh"
:cwd (getenv "HOME")
:ready-message "debug1: Entering interactive session.")

(prodigy-define-service
:name "name"
:tags '(ssh-tunnel)
:args (lambda ()
(tom/build-tunnel-args
:localport "23232"
:tunnel-ip "192.168.32.66"
:tunnel-port "22"
:user "tomterl"
:host "tunnelhost"
:port "tunnelport"))

I can write

(prodigy-define-tag
:name 'ssh-tunnel
:command "ssh"
:cwd (getenv "HOME")
:args (lambda ()
(tom/build-tunnel-args
(getf *prodigy-service-with* :tunnel)))
:ready-message "debug1: Entering interactive session.")

(prodigy-define-service
:name "name"
:tags '(ssh-tunnel)
:tunnel (list
:localport "23232"
:tunnel-ip "192.168.32.66"
:tunnel-port "22"
:user "tomterl"
:host "tunnelhost"
:port "tunnelport"))

In both cases with the simple

(defun tom/build-tunnel-args (args)
"Assemble the ssh tunnel argument list."
`("-v" ;; allows us to parse for the ready message
"-N" ;; don't start an interactive shell remotely
"-L" ,(concat (getf args :localport) ;; the tunnel spec
":"
(getf args :tunnel-ip)
":"
(getf args :tunnel-port))
"-l" ,(getf args :user) ;; the username
"-p" ,(getf args :port) ;; the remote port
,(getf args :host))) ;; the remote host

as helper.

What do you think? Too ugly? Edge case? Braindead?