Updates to google-query.el, linux-kernel.el, and lj.el
[slh] / lj.el
diff --git a/lj.el b/lj.el
index 6ab5286..8994d04 100644 (file)
--- a/lj.el
+++ b/lj.el
@@ -1,6 +1,6 @@
 ;; lj.el --- LiveJournal meets SXEmacs   -*- Emacs-Lisp -*-
 
-;; Copyright (C) 2008 - 2011 Steve Youngs
+;; Copyright (C) 2008 - 2014 Steve Youngs
 
 ;; Author:     Steve Youngs <steve@sxemacs.org>
 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
 ;;        plus the first letter or two of the next tag you wanna use
 ;;        after the last inserted tag.
 ;;
-;;; Twitter: (broken, don't use)
-;;
-;;    This is currently broken because twitter turned off Basic Auth
-;;
-;;    You can optionally post the subject header of your blog entry as
-;;    a status update to Twitter, along with a URL to the entry on
-;;    livejournal.com.  To do so, you must set...
-;;
-;;        `lj-twitter-flag'
-;;        `lj-twitter-username'
-;;        `lj-twitter-password'
-;;
-;;    The down side to this is that your twitter username and password
-;;    are stored in clear text.  I'll work on a way to make that safer
-;;    later.
-;;
 ;;    Have fun with it!
 
 ;;; Todo:
 ;;      choose different qotd's after one has been selected.  Also, be
 ;;      able to view older qotd's.
 ;;
-;;    o Rewrite the twitter code to use OAuth.
 ;;
 
 ;;; Bugs:
 ;;
 
 ;;; Version:
-(defconst lj-version 1.30
+(defconst lj-version 1.31
   "Version number of SXEmacs/LJ.")
 
 ;;; Code:
   :link '(url-link "http://www.livejournal.com/")
   :group 'hypermedia)
 
-(defgroup lj-twitter nil
-  "LiveJournal meets Twitter"
-  :prefix "lj-twitter-"
-  :link '(url-link "http://www.livejournal.com/")
-  :link '(url-link "http://twitter.com/")
-  :group 'lj)
-
 (defun lj-customise-faces ()
   "Customise the lj.el faces."
   (interactive)
@@ -312,18 +288,7 @@ XHTML 1.0 Transitional if you plan to validate before posting."
   "The default LJ userpic keyword.")
 
 ;; See mpd.el in the same repo as lj.el
-(defvar **mpd-var-Title* nil)
-(defvar **mpd-var-Artist* nil)
-(defun lj-music-mpd ()
-  "Return the current song title/artist from mpd."
-  (let ((song (if **mpd-var-Title*
-                 (format "%s --- [%s]"
-                         **mpd-var-Title*
-                         **mpd-var-Artist*)
-               "The Sounds of Silence --- [Marcel Marceau]")))
-    song))
-
-(defcustom lj-music (and (featurep 'mpd) #'lj-music-mpd)
+(defcustom lj-music (and (featurep 'mpd) #'mpd-now-playing)
   "*A function to retrieve current song for LJ music header.
 This function should return a formatted string, or nil."
   :type 'function
@@ -407,26 +372,6 @@ Set to nil to disable."
   :type 'hook
   :group 'lj)
 
-(defcustom lj-twitter-flag nil
-  "*Non-nil means to update your twitter status.
-
-The subject header and a URL to the last blog entry is posted to
-twitter as a status update if this is set."
-  :type 'boolean
-  :group 'lj-twitter)
-
-(defcustom lj-twitter-username (user-login-name)
-  "*Your twitter username."
-  :type 'string
-  :group 'lj-twitter)
-
-;;; FIXME: Can we store this in something OTHER than plain text.  Do
-;;; we even need it at all with OAuth?
-(defcustom lj-twitter-password "secret"
-  "*Your twitter password."
-  :type 'string
-  :group 'lj-twitter)
-
 (defconst lj-clientversion
   (concat (when (featurep 'sxemacs) "S")
          "XEmacs-"
@@ -2625,7 +2570,7 @@ The value returned is that same as from `encode-time'."
         (btime (apply #'encode-btime (lj-parse-time-string timestr))))
     (btime-to-time btime)))
 
-(defun lj-twitter-compress-url (url)
+(defun lj-compress-url (url)
   "Compress URL using tinyurl.com."
   (with-temp-buffer
     (mm-url-insert
@@ -2633,47 +2578,6 @@ The value returned is that same as from `encode-time'."
             (lj-hexify-string url t)))
     (buffer-string)))
 
-(defun lj-twitter-sentinel (process status)
-  "Sentinel for `lj-twitter-update-status' PROCESS STATUS."
-  (if (equal status "finished\n")
-      (message "Sending to Twitter...done")
-    (message "Sending to Twitter...failed: %s"
-            (substring status 0 (1- (length status))))))
-
-;;; FIXME: Twitter no longer supports Basic Auth, so must rewrite this
-;;; using OAuth.
-(defun lj-twitter-update-status (user pass status url)
-  "Update twitter status.
-
-Argument USER is your twitter username.
-Argument PASS is your twitter password.
-Argument STATUS is the subject header from your LJ post.
-Argument URL is the URL to the post on livejournal.com."
-  (let* ((userpass (format "%s:%s" user pass))
-        (turl (lj-twitter-compress-url url))
-        (twit (concat "status="
-                      (lj-hexify-string
-                       (concat status "  See: " turl) t)))
-        (twiturl "http://twitter.com/statuses/update.json")
-        proc)
-    (if (<= (length twit) 147)         ; twitter's max + "status="
-       (progn
-         (setq proc
-               (apply #'start-process
-                      "LJcurl" nil "curl"
-                      (list "-u" userpass
-                            "-d" twit
-                            "-s" twiturl
-                            "-H" "X-Twitter-Client: SXEmacs_LJ"
-                            "-H" (format "X-Twitter-Client-Version: %s"
-                                         lj-version)
-                            "-H" (concat
-                                  "X-Twitter-Client-URL: "
-                                  "http://www.sxemacs.org/~steve/lj/lj.xml")
-                            "-d" "source=lj.el")))
-         (set-process-sentinel proc #'lj-twitter-sentinel))
-      (warn "LJ subject too long for Twitter"))))
-
 (defun lj-check-limits (bodlen sublen taglen muslen loclen)
   "Make sure we don't exceed any LJ size limits.
 
@@ -2763,10 +2667,6 @@ With two prefix args, also set a \"date out of order\" flag."
         (lj-archive-post (lj-header-content "fcc")))
     (and lj-bcc-address
         (lj-send-bcc subject security tags comm mood music location body))
-;;; FIXME: twitter updates are broken, needs OAuth
-;;    (and lj-twitter-flag
-;;      (lj-twitter-update-status lj-twitter-username lj-twitter-password
-;;                                subject lj-last-url))
     ;; If there is a itemid don't delete the draft because it is our
     ;; archive copy
     (when (zerop (length itemid))