Add convenience function for updating #sxemacs topic version string.
authorSteve Youngs <steve@sxemacs.org>
Mon, 15 Jun 2015 00:24:09 +0000 (10:24 +1000)
committerSteve Youngs <steve@sxemacs.org>
Mon, 15 Jun 2015 00:24:09 +0000 (10:24 +1000)
* 16-riece-sy.el (sy-riece-get-sxemacs-topic-version):
New. Returns the "version" section of #sxemacs topic.

* 16-riece-sy.el (sy-riece-sxemacs-topic-version-update): New.
Updates the "version" section of the #sxemacs topic.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
16-riece-sy.el

index 82fc4d0..086e36b 100644 (file)
@@ -5,7 +5,7 @@
 ;;     Author: Steve Youngs <steve@sxemacs.org>
 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
 ;;    Created: <2007-12-02>
-;; Time-stamp: <Friday May 15, 2015 21:44:46 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
@@ -557,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.
@@ -626,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)
@@ -641,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)