Update howm settings, and work-around a howm/lisp-initd issue.
[syinit] / 16-riece-sy.el
index 01e06f0..086e36b 100644 (file)
@@ -1,11 +1,11 @@
 ;; 16-riece-sy.el --- Riece (IRC) Settings   -*- Emacs-Lisp -*-
 
-;; Copyright (C) 2007 - 2012 Steve Youngs
+;; Copyright (C) 2007 - 2013 Steve Youngs
 
 ;;     Author: Steve Youngs <steve@sxemacs.org>
 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
 ;;    Created: <2007-12-02>
-;; Time-stamp: <Monday Jun 18, 2012 09:41:00 steve>
+;; Time-stamp: <Monday Jun 15, 2015 10:22:22 steve>
 ;;   Download: <http://bastard.steveyoungs.com/~steve/SXEmacs/inits/>
 ;;   HTMLised: <http://bastard.steveyoungs.com/~steve/SXEmacs/htmlinits/16-riece-sy.html>
 ;;   Git Repo: git clone http://git.sxemacs.org/syinit
 ;; Misc setq's
 (setq riece-alias-percent-hack-mask "*.net"
       riece-biff-check-channels '("#sxemacs"
-                                 "#harmattan"
-                                 "#meego"
-                                 "#n9"
                                  "#emchat"
-                                 ;"#xwem"
-                                 ;"#fresse"
                                  "#xemacs")
       riece-channel-buffer-mode t
+      riece-ctlseq-colors
+           '("white" "black" "blue" "green" "red" "brown"
+             "purple" "orange" "yellow" "lightgreen" "darkcyan"
+             "cyan" "lightblue" "HotPink" "grey35" "grey")
       riece-default-channel-binding nil
       riece-default-coding-system 'binary
+      riece-desktop-notify-always t
       riece-gather-channel-modes t
+      riece-hide-list '(joins parts quits)
       riece-ignore-discard-message nil
-      riece-keywords '("JackaLX" "jackalx" "Eicq" "eicq" "EMchat" "emchat"
-                      "SXEmacs" "sxemacs" "XWEM" "xwem" "XLIB" "xlib" "tla"
-                      "arch" "xtla" "XEtla" "xetla" "eMoney" "emoney"
-                      "JackaLX_N9" "jackalx_n9")
+      riece-keywords
+      '("Bastard" "EMchat" "eMoney" "Gnus" "LFS" "LinuxFromScratch"
+       "Linux From Scratch" "PgSQL" "PostgreSQL" "postgres" "Riece"
+       "SteveYoungs" "SXEmacs" "XEmacs" "systemd" "xwem")
       riece-layout '"bottom-right"
       riece-retry-with-new-nickname t
       riece-server-alist
       '(("irc.sxemacs.org" :host "irc.sxemacs.org")
-       ("irc.au.freenode.net" :host "irc.au.freenode.net")
-       ("azimov.freenode.net" :host "azimov.freenode.net")
-       ("brin.freenode.net" :host "brin.freenode.net")
-       ("irc.freenode.org" :host "irc.freenode.org")
        ("irc.freenode.net" :host "irc.freenode.net")
-       ("kornbluth.freenode.net" :host "kornbluth.freenode.net")
-       ("orwell.freenode.net" :host "orwell.freenode.net")
-       ("calvino.freenode.net" :host "calvino.freenode.net")
-       ("wells.freenode.net" :host "wells.freenode.net")
-       ("zelazny.freenode.net" :host "zelazny.freenode.net")
-       ("anthony.freenode.net" :host "anthony.freenode.net")
+       ("irc.au.freenode.net" :host "irc.au.freenode.net")
        ("irc.nac.net" :host "irc.nac.net")
        ("irc.efnet.org" :host "irc.efnet.org")
        ("irc.efnet.net" :host "irc.efnet.net"))
@@ -147,7 +139,7 @@ those gaps."
 With prefix arg, also /join."
   (interactive "sMemoserv: ")
   (when current-prefix-arg
-    (riece-command-join ["MemoServ" ""]))
+    (riece-command-join (list ["MemoServ" ""])))
   (riece-send-string (format "MEMOSERV %s\r\n" command)))
 
 (defun sy-riece-command-chanserv (command)
@@ -156,7 +148,7 @@ With prefix arg, also /join."
 With prefix arg, also /join."
   (interactive "sChanserv: ")
   (when current-prefix-arg
-    (riece-command-join ["ChanServ" ""]))
+    (riece-command-join (list ["ChanServ" ""])))
   (riece-send-string (format "CHANSERV %s\r\n" command)))
 
 (defun sy-riece-command-nickserv (command)
@@ -165,17 +157,21 @@ With prefix arg, also /join."
 With prefix arg, also /join."
   (interactive "sNickserv: ")
   (when current-prefix-arg
-    (riece-command-join ["NickServ" ""]))
+    (riece-command-join (list ["NickServ" ""])))
   (riece-send-string (format "NICKSERV %s\r\n" command)))
 
+;; Seems to not exist anymore. :-(
 (defun sy-riece-command-seenserv (command)
   "Send COMMAND, a string, to SEENSERV.
 
+SeenServ doesn't actually exist anymore, so this sends `info nick' to
+NickServ which gives us the same info.
+
 With prefix arg, also /join."
-  (interactive "sSeenserv: ")
+  (interactive "sLast saw who (nick): ")
   (when current-prefix-arg
-    (riece-command-join ["SeenServ" ""]))
-  (riece-send-string (format "SEENSERV %s\r\n" command)))
+    (riece-command-join (list ["NickServ" ""])))
+  (riece-send-string (format "NICKSERV info %s\r\n" command)))
 
 (defun sy-riece-command-quick-op ()
   "Request Ops from ChanServ in the current channel."
@@ -246,15 +242,10 @@ Optional prefix arg, UNBAN removes the ban."
 
 With non-nil optional prefix arg, NOTICE, send it as a notice."
   (interactive "P")
-  (let ((song (if **mpd-var-Title*
-                 (format "%s --- [%s]"
-                         **mpd-var-Title*
-                         **mpd-var-Artist*)
-               "The Sounds of Silence --- [Marcel Marceau]")))
-    (riece-command-send-message (format "NP: %s" song) 
-                               (if current-prefix-arg
-                                   'notice
-                                 nil))))
+  (riece-command-send-message
+   (format "NP: %s" (mpd-now-playing)) 
+   (and current-prefix-arg
+       'notice)))
 
 (defun sy-riece-say-all-purpose (&optional notice)
   "Send the all-purpose answer to everything."
@@ -566,7 +557,12 @@ See `riece-me:command-complete-user'."
 
 (add-hook 'riece-command-mode-hook
          #'(lambda ()
-             (local-set-key [iso-left-tab] #'sy-riece-complete-user-backwards)))
+             ;; Define a few keys here so they don't have the `C-c' prefix
+             (local-set-key [iso-left-tab] #'sy-riece-complete-user-backwards)
+             (local-set-key [(super next)] #'riece-command-user-list-scroll-up)
+             (local-set-key [(super prior)] #'riece-command-user-list-scroll-down)
+             (local-set-key [(hyper next)] #'riece-command-scroll-up)
+             (local-set-key [(hyper prior)] #'riece-command-scroll-down)))
 
 (defun riece-me:command-complete-user (&optional reverse)
   "Like `riece-command-complete-user' but restrict to current chan.
@@ -635,6 +631,32 @@ biff list."
     (message "Channel: %s added to riece-biff channel list."
             (riece-identity-prefix riece-current-channel))))
 
+(defun sy-riece-get-sxemacs-topic-version ()
+  "Return the \"version\" section of #sxemacs topic."
+  (let* ((topic (riece-with-server-buffer
+                   (riece-identity-server riece-current-channel)
+                 (riece-channel-get-topic "#sxemacs")))
+        (ver (third (split-string-by-char topic ?\ ))))
+    ver))
+
+(defun sy-riece-sxemacs-topic-version-update (&optional newver)
+  "*Updates the \"version\" section of #sxemacs topic with NEWVER.
+With a prefix arg, prompt for the new version string."
+  (interactive "P")
+  (let* ((oldver (sy-riece-get-sxemacs-topic-version))
+        (gitver (substring (shell-command-to-string
+                            "( cd ${SXEWD}; git describe master )")
+                           0 -1))
+        (newver (or (and current-prefix-arg
+                         (read-string "New Version: "
+                                      sxemacs-git-version nil
+                                      sxemacs-git-version))
+                    gitver))
+       (chan (riece-identity-prefix riece-current-channel)))
+    (unless (string= chan "#sxemacs")
+      (error 'invalid-argument "Wrong channel" chan))
+    (riece-command-send-message
+     (format ",topic change 1 s/%s/%s/" oldver newver) nil)))
 
 ;; Define keys for those functions.
 (define-key riece-command-map (kbd "C-c C") #'sy-riece-clear-unread-chans)
@@ -650,6 +672,7 @@ biff list."
 (define-key riece-command-map (kbd "C-c b") #'sy-riece-add-rem-biff-channel)
 (define-key riece-command-map (kbd "C-c ?") #'sy-riece-think)
 (define-key riece-command-map (kbd "C-c R") #'sy-riece-reverse)
+(define-key riece-command-map (kbd "C-c T") #'sy-riece-sxemacs-topic-version-update)
 (define-key riece-command-map (kbd "C-c U") #'sy-riece-sxe-uptime)
 (define-key riece-command-map [a] #'sy-riece-say-all-purpose)
 
@@ -666,7 +689,8 @@ connect to."
   (let ((riece-server (if current-prefix-arg
                          nil
                        "irc.sxemacs.org")))
-    (setq riece-frame (new-frame '((name . "RieceFrame"))))
+    (setq riece-frame (new-frame '((name . "RieceFrame")
+                                  (width . 110))))
     (select-frame riece-frame)
     (call-interactively 'riece)
     (focus-frame riece-frame)))
@@ -686,25 +710,14 @@ connect to."
 (defvar sy-riece-startup-channel-list
   '("#sxemacs"
     "#emchat"
-    ;"#xwem"
-    ;"#fresse"
     "#xemacs"
-    "#emacs"
-    "#harmattan"
-    "#meego"
-    "#n9"
-    "#e"
-    "#pulseaudio"
-    "#latex"
-    ;"#iptables"
-    ;"#netfilter"
-    "#postgresql"
-    "##c"
-    ;"##kernel"
-    ;"#linux-kernel"
-    ;"#glibc"
-    ;"#gcc"
-    "#zsh")
+    ;"#emacs"
+    ;"#postgresql"
+    ;"#avahi"
+    "#systemd"
+    ; No kdbus chan "#kdbus"
+    "#zsh"
+    )
   "List of channels to join after logging in and identifying to nickserv.")
 
 ;; Set up channel coding systems
@@ -714,7 +727,7 @@ connect to."
 ;; hate this crap? --SY.
 (mapcar
  #'(lambda (chan)
-     (if (string-match #r"#\(sxemacs\|e\(mchat\|icq\)\|xwem\|fresse\)" chan)
+     (if (string-match #r"#\(sxemacs\|emchat\)" chan)
         (push (cons chan 'iso-8859-1) riece-channel-coding-system-alist)
        (push (cons chan 'utf-8) riece-channel-coding-system-alist)))
  sy-riece-startup-channel-list)
@@ -734,10 +747,11 @@ connect to."
          (riece-command-join-channel identity (nth 1 entry)))
       (setq channel-list (cdr channel-list))))
   (riece-send-string "PRIVMSG ChanServ :op #sxemacs\r\n")
-  (riece-send-string "PRIVMSG ChanServ :op #emchat\r\n"))
-  ;(riece-send-string "PRIVMSG ChanServ :op #xwem\r\n")
-  ;(riece-send-string "PRIVMSG ChanServ :op #fresse\r\n")
-  ;(riece-send-string "PRIVMSG ChanServ :op #xemacs\r\n"))
+  (riece-send-string "PRIVMSG ChanServ :op #emchat\r\n")
+  (riece-send-string "PRIVMSG ChanServ :op #xemacs\r\n")
+  (riece-send-string
+   (format "PRIVMSG SXEbot :identify SteveYoungs %s\r\n"
+          (getenv "BOTPASSWD"))))
 
 (add-hook 'riece-after-login-hook #'sy-riece-login)
 
@@ -745,16 +759,23 @@ connect to."
 ;; running to completion) I use this to finish the job
 (defun sy-riece-cleanup-login ()
   (interactive)
-  (riece-command-switch-to-channel-by-number 2)
-  (riece-part-channel riece-current-channel)
-  ;(riece-part-channel ["MemoServ" ""])
-  (riece-part-channel ["ChanServ" ""])
-  (riece-part-channel ["NickServ" ""])
-  (sy-riece-relist-chans-clear-blanks)
-  (riece-command-switch-to-channel-by-number 1))
-
+  (let ((metachans
+        #r".*\.freenode\.net\|\(Chan\|Nick\|Memo\|Seen\)Serv\|SXEbot"))
+    (mapcar
+     #'(lambda (chan-vect)
+        (mapcar
+         #'(lambda (chan)
+             (and (string-match metachans chan)
+                  (riece-part-channel chan-vect)))
+         chan-vect))
+     riece-current-channels)
+    (sy-riece-relist-chans-clear-blanks)
+    (riece-command-switch-to-channel-by-number 1)))
+
+;; CANNOT get this to work from the hook.  I suspect it is a
+;; networking/async/timing thing.  I have it bound to a key
+;; seq... `C-c C-c l', a PITA though.
 ;(add-hook 'riece-after-login-hook #'sy-riece-cleanup-login 'append)
-
 (define-key riece-command-map (kbd "C-c l") 'sy-riece-cleanup-login)
 
 ;; Automatically clear Riece Biff indicator by switching to the right