8b5b2b90ac77

Merge
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 07 Sep 2020 20:57:39 -0400
parents b7b95cfbb342 (current diff) 5e6b2fd0a0e1 (diff)
children a7f0e08891c8
branches/tags (none)
files stumpwmrc

Changes

--- a/bin/doc	Mon Sep 07 20:57:15 2020 -0400
+++ b/bin/doc	Mon Sep 07 20:57:39 2020 -0400
@@ -5,7 +5,7 @@
 LANG=$1
 shift
 
-if test "$LANG" -eq "go"; then
+if test "$LANG" = "go"; then
     LANG=golang
 fi
 
--- a/fish/functions/ep.fish	Mon Sep 07 20:57:15 2020 -0400
+++ b/fish/functions/ep.fish	Mon Sep 07 20:57:39 2020 -0400
@@ -6,7 +6,6 @@
         make
         cat README.markdown | sed -En 'H; /^## [0-9]{4}-[0-9]{2}-[0-9]{2}/h; ${g;p;}' | tail +3 > ~/.plan
         git cm 'Update' -a
-        git push origin master
     case '*'
         hg pull -u
         nvim README.markdown
--- a/lisp/pick.lisp	Mon Sep 07 20:57:15 2020 -0400
+++ b/lisp/pick.lisp	Mon Sep 07 20:57:39 2020 -0400
@@ -32,20 +32,33 @@
               ((matchesp line '("y" "yes")) (return t))
               ((matchesp line '("n" "no" "")) (return nil)))))
 
-(defun filter (choices)
+(defun filter-many (choices)
   (loop
     :with width = (1+ (reduce #'max choices :key #'length :initial-value 0))
     :for choice :in choices
     :when (prompt "~A~vA[yN] " choice (- width (length choice)) #\space)
     :collect choice))
 
+(defun filter-one (choices)
+  (loop :for choice :in choices
+        :for i :from 0
+        :do (format *interactive-output* "~36R) ~A~%" i choice)
+        :collect choice)
+  (let ((i (parse-integer (read-line *interactive-input*) :radix 36)))
+    (if (or (minusp i) (>= i (length choices)))
+      (error "Bad choice ~d" i)
+      (list (elt choices i)))))
+
 (defun output (results)
   (loop :for (r . remaining) :on results
         :do (write-string r)
         :when remaining :do (write-string *separator*)))
 
-(defun run (choices)
-  (output (filter choices)))
+(defun run-many (choices)
+  (output (filter-many choices)))
+
+(defun run-one (choices)
+  (output (filter-one choices)))
 
 
 ;;;; User Interface -----------------------------------------------------------
@@ -86,6 +99,22 @@
     :short #\0
     :reduce (constantly (string #\nul))))
 
+(defparameter *option-one*
+  (adopt:make-option 'one
+    :help "Pick a single line instead of picking one-by-one."
+    :long "one"
+    :short #\o
+    :reduce (constantly t)
+    :initial-value nil))
+
+(defparameter *option-many*
+  (adopt:make-option 'many
+    :result-key 'one
+    :help "Pick multiple lines, asking one-by-one (the default)."
+    :long "many"
+    :short #\O
+    :reduce (constantly nil)))
+
 
 (adopt:define-string *help-text*
   "pick displays its arguments one-by-one on standard error and prompts you ~
@@ -97,6 +126,11 @@
    arguments are present prevents something like 'pick `ls -1 | grep foo`' from ~
    silently hanging forever if no files match.~@
    ~@
+   Using the --one argument changes the behaviour of pick.  Instead of ~
+   picking several lines from the input by asking one-by-one, all of the lines ~
+   are presented at once and the user is prompted to pick one of them with ~
+   a prefix.
+   ~@
    This version was inspired by the pick program described in 'The UNIX ~
    Programming Environment'.")
 
@@ -110,7 +144,9 @@
     :contents (list *option-help*
                     *option-version*
                     *option-separator*
-                    *option-null*)))
+                    *option-null*
+                    *option-one*
+                    *option-many*)))
 
 
 (defun toplevel ()
@@ -120,11 +156,15 @@
               ((gethash 'version options) (write-line *version*) (adopt:exit)))
         (with-open-file (*interactive-input* "/dev/tty" :direction :input)
           (let ((*separator* (gethash 'separator options))
-                (*interactive-output* *error-output*))
-            (run (mapcan (lambda (arg)
-                           (if (string= "-" arg)
-                             (read-lines *standard-input*)
-                             (list arg)))
-                         arguments)))))
+                (*interactive-output* *error-output*)
+                (arguments (mapcan (lambda (arg)
+                                     (if (string= "-" arg)
+                                       (read-lines *standard-input*)
+                                       (list arg)))
+                                   arguments)))
+            (funcall (if (gethash 'one options)
+                       #'run-one
+                       #'run-many)
+                     arguments))))
     (error (c) (adopt:print-error-and-exit c))))
 
--- a/stumpwmrc	Mon Sep 07 20:57:15 2020 -0400
+++ b/stumpwmrc	Mon Sep 07 20:57:39 2020 -0400
@@ -1,6 +1,6 @@
 (in-package :stumpwm-user)
 
-(ql:quickload '(:losh :split-sequence :alexandria :parse-number) :silent t)
+(ql:quickload '(:losh :split-sequence :alexandria :parse-number :str :cl-ppcre) :silent t)
 (use-package :losh)
 
 
@@ -18,8 +18,9 @@
       *window-format* "(%n%m%20t)"
       *window-name-source* :title
       *maximum-completions* 20
-      *shell-program* "/home/sjl/src/dotfiles/bin/bash-dammit")
-
+      *shell-program* "/home/sjl/src/dotfiles/bin/bash-dammit"
+      losh:*pbcopy-command* "/home/sjl/src/dotfiles/bin/pbcopy"
+      losh:*pbpaste-command* "/home/sjl/src/dotfiles/bin/pbpaste")
 
 
 ;;;; Utils --------------------------------------------------------------------
@@ -425,6 +426,15 @@
   (run-shell-command "pbeecopy")
   (message "Copied the entire Bee Movie script to clipboard."))
 
+(defcommand urlize-jira-issue () ()
+  (let ((issue (str:trim (pbpaste))))
+    (if (ppcre:scan "^[A-Z0-9]+-\\d+$" issue)
+      (let* ((endpoint (str:trim (run-shell-command "grep endpoint .jira.d/config.yml | sed -e 's/.*: //'" t)))
+             (url (format nil "~A/browse/~A" endpoint issue)))
+        (pbcopy url)
+        (message "Copied ~A to the clipboard." url))
+      (message "Clipboard does not look like a JIRA issue."))))
+
 
 ;;;; Applications -------------------------------------------------------------
 (defcommand spotify () ()
@@ -528,7 +538,7 @@
 (define-top-keys ;; clipboard
   ("H-u" "generate-random-uuid")
   ("H-U" "bee-movie-script")
-  )
+  ("M-H-u" "urlize-jira-issue"))
 
 (define-top-keys ;; movement
   ("H-h" "move-focus* left")
--- a/vim/custom-dictionary.utf-8.add	Mon Sep 07 20:57:15 2020 -0400
+++ b/vim/custom-dictionary.utf-8.add	Mon Sep 07 20:57:39 2020 -0400
@@ -309,4 +309,5 @@
 deduplicating
 passlist
 golang
+lifecycle
 unapplied
--- a/vim/vimrc	Mon Sep 07 20:57:15 2020 -0400
+++ b/vim/vimrc	Mon Sep 07 20:57:39 2020 -0400
@@ -1504,6 +1504,8 @@
     au FileType go iabbrev <buffer> erstr if err != nil {<cr>return "", err<esc>jA
     au FileType go iabbrev <buffer> ererr if err != nil {<cr>return err<esc>jA
     au FileType go iabbrev <buffer> erpan if err != nil {<cr>panic(err)<esc>jA
+
+    au FileType gohtmltmpl setlocal shiftwidth=4
 augroup END
 
 " }}}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/weechat/python/autoload/sanitize_jira.py	Mon Sep 07 20:57:39 2020 -0400
@@ -0,0 +1,30 @@
+import re, weechat, subprocess
+
+SCRIPT_NAME = 'sanitize_jira'
+SCRIPT_AUTHOR = 'Steve Losh <steve@stevelosh.com>'
+SCRIPT_VERSION = '0.0.1'
+SCRIPT_LICENSE = 'MIT'
+SCRIPT_DESC = 'clean up the garbage jirabot sends to channels into something readable'
+
+weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '')
+
+weechat.hook_line('*', '', 'nick_Jira_Cloud', 'sanitize_jira', '')
+
+first_line_re = re.compile(
+    r'(?P<link>https://[^/]+/browse/[^?]+)[?]atlOrigin=[^ ]+ [(](?P<title>.+)[)]'
+)
+
+detail_line_re = re.compile(
+    r'''Status: \x1a\x01[*](?P<status>[^*]+)[*]\x1b\x01.*Type: \x1a\x01[*](?P<type>[^*]+)[*]\x1b\x01.*Assignee: \x1a\x01[*](?P<assignee>[^*]+)[*]\x1b\x01.*Priority: \x1a\x01[*](?P<priority>[^*]+)[*]\x1b\x01'''
+)
+
+def sanitize_jira(data, line):
+    m = first_line_re.search(line['message'])
+    if m:
+        return {'message': '%s | %s' % (m.group('title'), m.group('link'))}
+
+    m = detail_line_re.search(line['message'])
+    if m:
+        return {'message': '%s / %s / %s' % (m.group('type'), m.group('status'), m.group('assignee'))}
+
+    return {}