Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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:

perl-journal-uid
Set this to your use.perl.org user ID. The SOAP interface works on UID's, not text names.
perl-journal-passwd
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.
perl-journal-command
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")

The code:

(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 +al entry." (interactive) (make-local-variable 'perl-journal-uid) (make-local-variable 'perl-journal-passwd) (make-local-variable 'perl-journal-command) (make-local-variable 'passwd-invert-frame-when-keyboard-grabbed) (let* ((p-command (cond (perl-journal-command) (t "upj_post.pl"))) (p-uid (cond (uid) (perl-journal-uid) (t (read-string "use.perl.org UID: ")))) (p-passwd (cond (passwd) (perl-journal-passwd) (t (read-passwd "use.perl.org Password: "))) +) (p-comment (cond ((= comment "no") "no") (t "yes"))) (p-subject (cond (subject) (t (read-string "Entry subject: ")))) (passwd-invert-frame-when-keyboard-grabbed nil) (command (format "%s -m %S -c %s -C %S" p-command p-subject p-comment (format "%s:%s" p-uid p-passwd)))) (shell-command-on-region (region-beginning) (region-end) command)) +)

--rjray


In reply to (X)Emacs client by rjray
in thread Post a journal entry to use.perl.org by rjray

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (10)
    As of 2014-09-23 11:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (219 votes), past polls