in reply to
Post a journal entry to use.perl.org
This bit of elisp is something I use to post the contents of a buffer after editing it to my satisfaction. I'm posting it separately so that it doesn't interfere with the "Download Code" link for the Perl utility itself. It is not really complete, and certainly not perfect. Right now, you have to have the desired data in the region, I'd like for it to default to the whole buffer if the region isn't active (but there is no shell-command-on-buffer function in elisp, on the the region-oriented one).
When run, it will prompt you for your use.perl UID and password if those are not already available. It can be called non-interactively with those values, plus a yes/no setting for enabling comments, and the entry subject. The UID and password (as well as the location of the script that gets used) can be configured with the following global values:
- Set this to your use.perl.org user ID. The SOAP interface works on UID's, not text names.
- Set this to your password (if you so desire to). If this is not set, you will be prompted, and the elisp API routine does an annoying video-inversion trick when reading a password. The defun tries to set a variable to disable this, as per the elisp docs, but it has no effect. I have this set on my home desktop, but not on my laptop or other machines that are more easily accessed by others.
- Set this to the path to the commands itself (from the parent post), if (X)Emacs is not likely to find it otherwise. For safety's sake, I have this set, to the value:
(concat (getenv "HOME") "/bin/upj_post.pl")
(defun perl-journal-post-entry (&optional uid &optional passwd
&optional comment &optional subject)
"Post the contents of the the current region as a use.perl.org journ
(let* ((p-command (cond (perl-journal-command)
(p-uid (cond (uid)
(t (read-string "use.perl.org UID: "))))
(p-passwd (cond (passwd)
(t (read-passwd "use.perl.org Password: ")))
(p-comment (cond ((= comment "no") "no")
(p-subject (cond (subject)
(t (read-string "Entry subject: "))))
(command (format "%s -m %S -c %s -C %S"
(format "%s:%s" p-uid p-passwd))))
(shell-command-on-region (region-beginning) (region-end) command))