# HG changeset patch # User Steve Losh # Date 1599526659 14400 # Node ID 8b5b2b90ac77e04666b26009fbb9daa5e0d6e5ff # Parent b7b95cfbb3429500cf4fed5843076fb444d7feae# Parent 5e6b2fd0a0e1afcc40e3d69463381d258ba9d2f0 Merge diff -r b7b95cfbb342 -r 8b5b2b90ac77 bin/doc --- 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 diff -r b7b95cfbb342 -r 8b5b2b90ac77 fish/functions/ep.fish --- 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 diff -r b7b95cfbb342 -r 8b5b2b90ac77 lisp/pick.lisp --- 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)))) diff -r b7b95cfbb342 -r 8b5b2b90ac77 stumpwmrc --- 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") diff -r b7b95cfbb342 -r 8b5b2b90ac77 vim/custom-dictionary.utf-8.add --- 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 diff -r b7b95cfbb342 -r 8b5b2b90ac77 vim/vimrc --- 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 erstr if err != nil {return "", errjA au FileType go iabbrev ererr if err != nil {return errjA au FileType go iabbrev erpan if err != nil {panic(err)jA + + au FileType gohtmltmpl setlocal shiftwidth=4 augroup END " }}} diff -r b7b95cfbb342 -r 8b5b2b90ac77 weechat/python/autoload/sanitize_jira.py --- /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 ' +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'(?Phttps://[^/]+/browse/[^?]+)[?]atlOrigin=[^ ]+ [(](?P.+)[)]' +) + +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 {}