git.fiddlerwoaroof.com
Browse code

Various changes

* Emacs:
- org-mode tweaks
- cider tweaks
- save file on C-c C-k
- persist repl history
- make sure the (comment section is last
- add pastebin command
- have lisp-mode highlight [] and {} correctly
- add fwoar to skeleton package names

* Lispworks
- add script to save a console image

* OSX
- update emacsclient applescript

* vim
- add work vimrc that uses dein instead of Neobundle

* zsh
- minor tweaks to git config
- minor dependency tweaks

Ed Langley authored on 10/01/2019 06:21:25
Showing 9 changed files
... ...
@@ -48,6 +48,7 @@
48 48
         org-default-notes-file (concat org-directory "/scratch.org")
49 49
         org-refile-use-outline-path 'file
50 50
         org-outline-path-complete-in-steps nil
51
+        org-log-done 'time
51 52
         org-capture-templates '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
52 53
                                  "* TODO %?\n  %i\n  %a")
53 54
                                 ("j" "Journal" entry (file+olp+datetree "~/org/journal.org")
... ...
@@ -205,7 +206,8 @@ With a prefix ARG invalidates the cache first."
205 206
   (modify-syntax-entry ?- "w" clojure-mode-syntax-table)
206 207
   (modify-syntax-entry ?~ "w" clojure-mode-syntax-table)
207 208
   (modify-syntax-entry ?. "w" clojure-mode-syntax-table)
208
-  (setq cider-save-file-on-load t)
209
+  (setq cider-save-file-on-load t
210
+        cider-repl-history-file "~/.emacs.d/cider-history.clj")
209 211
 
210 212
   ;; https://github.com/clojure-emacs/cider/issues/2435
211 213
   (defun cider--gather-session-params (session)
... ...
@@ -333,6 +335,48 @@ With a prefix ARG invalidates the cache first."
333 335
 
334 336
 (setq org-agenda-files '("~/org/notes.org"))
335 337
 
338
+(load-file custom-file)
339
+
340
+(defun read-sexps-in-file (fn)
341
+  (with-temp-buffer
342
+    (save-excursion
343
+      (insert "(")
344
+      (insert-file fn)
345
+      (goto-char (point-max))
346
+      (insert "\n)"))
347
+    (read (current-buffer))))
348
+
349
+(use-package circe
350
+  :config
351
+  (setq circe-server-buffer-name "{host}:{port}"
352
+        circe-reduce-lurker-spam t
353
+        circe-network-options (read-sexps-in-file "~/.circe-info")))
354
+
355
+(defvar url-pattern (car (read-sexps-in-file "~/.pastebin-name")))
356
+(defun pastebin-buffer ()
357
+  (interactive)
358
+  (let* ((extension (file-name-extension (buffer-name)))
359
+         (htmlized-buffer (htmlize-buffer)))
360
+    (with-current-buffer htmlized-buffer
361
+      (let ((result-name-hash (sha1 (current-buffer))))
362
+        (write-file (format url-pattern result-name-hash extension))
363
+        (message "Wrote file to: %s.%s.html" result-name-hash extension)))))
364
+
365
+(defun delete-mru-window ()
366
+  (interactive)
367
+  (delete-window
368
+   (get-mru-window nil nil t)))
369
+(define-key evil-motion-state-map (kbd "C-w C-o") 'delete-mru-window)
370
+(define-key evil-motion-state-map (kbd "C-w C-w") 'evil-window-mru)
371
+
372
+(defvar passwords ())
373
+(defun get-passwd (id prompt)
374
+  (let ((val (assoc id passwords)))
375
+    (cdr
376
+     (if val val
377
+       (car (push (cons id (read-passwd prompt))
378
+                  passwords))))))
379
+
336 380
 ;;;;; junk drawer ....
337 381
 
338 382
 (comment
... ...
@@ -393,34 +437,3 @@ With a prefix ARG invalidates the cache first."
393 437
    (setq org-brain-visualize-default-choices 'all)
394 438
    (setq org-brain-title-max-length 12)))
395 439
 
396
-(load-file custom-file)
397
-
398
-(defun read-sexps-in-file (fn)
399
-  (with-temp-buffer
400
-   (save-excursion
401
-     (insert-string "(")
402
-     (insert-file fn)
403
-     (goto-char (point-max))
404
-     (insert-string "\n)"))
405
-   (read (current-buffer))))
406
-
407
-(use-package circe
408
-  :config
409
-  (setq circe-server-buffer-name "{host}:{port}"
410
-        circe-reduce-lurker-spam t
411
-        circe-network-options (read-sexps-in-file "~/.circe-info")))
412
-
413
-(defun delete-mru-window ()
414
-  (interactive)
415
-  (delete-window
416
-   (get-mru-window nil nil t)))
417
-(define-key evil-motion-state-map (kbd "C-w C-o") 'delete-mru-window)
418
-(define-key evil-motion-state-map (kbd "C-w C-w") 'evil-window-mru)
419
-
420
-(defvar passwords ())
421
-(defun get-passwd (id prompt)
422
-  (let ((val (assoc id passwords)))
423
-    (cdr
424
-     (if val val
425
-       (car (push (cons id (read-passwd prompt))
426
-                  passwords))))))
... ...
@@ -49,6 +49,11 @@
49 49
 (modify-syntax-entry ?~ "w" lisp-mode-syntax-table)
50 50
 (modify-syntax-entry ?. "w" lisp-mode-syntax-table)
51 51
 
52
+(modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table)
53
+(modify-syntax-entry ?\] ")[" lisp-mode-syntax-table)
54
+(modify-syntax-entry ?\{ "(}" lisp-mode-syntax-table)
55
+(modify-syntax-entry ?\} "){" lisp-mode-syntax-table)
56
+
52 57
 (setq shr-inhibit-images t
53 58
       shr-use-fonts nil)
54 59
 
... ...
@@ -94,15 +94,16 @@ REVERSE - Jump to previous position in skeleton"
94 94
   "Insert a defpackage template"
95 95
   (skeleton-read "Package Name: "
96 96
                  (if v1
97
-                     (file-name-sans-extension
98
-                      (file-name-nondirectory
99
-                       (buffer-file-name)))))
97
+                     (concat "fwoar."
98
+                             (file-name-sans-extension
99
+                              (file-name-nondirectory
100
+                               (buffer-file-name))))))
100 101
   '(setq v1 (bobp))
101 102
   "(defpackage :" @ str "
102 103
   (:use :cl "  _ @ - ")
103 104
   (:export " @  "))
104 105
 (in-package :" str ")" \n
105
-@)
106
+  @)
106 107
 
107 108
 
108 109
 (define-skeleton skel-defsystem
... ...
@@ -37,12 +37,13 @@
37 37
     (evil-insert 1)))
38 38
 
39 39
 (defun create-system-files ()
40
-    (interactive)
40
+  (interactive)
41
+  (save-excursion
41 42
     (mapcar (lambda (it) (save-buffer (find-file (format "%s.lisp" (cadr it)))))
42 43
             (getf (cddar (read-from-string
43 44
                           (buffer-substring (point)
44 45
                                             (mark))))
45
-                  :components)))
46
+                  :components))))
46 47
 
47 48
 (defmacro comment (&rest _))
48 49
 
49 50
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+;;; to run, do something like:
2
+;;;  <path_to_lispworks>/lispworks-7-1-0-amd64-darwin -build ~/git_repos/dotfiles/lispworks/saveimg.lisp
3
+(in-package "CL-USER")
4
+(load-all-patches)
5
+(let ((out-name (format nil "~~/bin/lw-console-~a" 
6
+                        (lisp-implementation-version))))
7
+  (save-image out-name 
8
+              :console t
9
+              :multiprocessing t
10
+              :environment nil))
... ...
@@ -1,10 +1,21 @@
1 1
 #!/usr/bin/osascript
2 2
 on run argv
3 3
   set currentApp to my getCurrentApp()
4
-  do shell script "/usr/local/bin/emacsclient -c " & (item 1 of argv)
5
-  activate application currentApp
4
+  do shell script "/usr/local/bin/emacsclient -c '" & (item 1 of argv) & "'"
5
+  do shell script "open '/Volumes/" & currentApp & "'"
6 6
 end run
7 7
 
8 8
 to getCurrentApp()
9
-  return (path to frontmost application as text)
9
+  return replace_chars((path to frontmost application as text), ":", "/")
10 10
 end getCurrentApp
11
+
12
+on replace_chars(this_text, search_string, replacement_string)
13
+ set AppleScript's text item delimiters to the search_string
14
+ set the item_list to every text item of this_text
15
+ set AppleScript's text item delimiters to the replacement_string
16
+ set this_text to the item_list as string
17
+ set AppleScript's text item delimiters to ""
18
+ return this_text
19
+end replace_chars
20
+
21
+
11 22
new file mode 100644
... ...
@@ -0,0 +1,224 @@
1
+"dein Scripts-----------------------------
2
+if &compatible
3
+  set nocompatible               " Be iMproved
4
+endif
5
+
6
+" Required:
7
+set runtimepath+=$HOME/.vim/repos/github.com/Shougo/dein.vim
8
+
9
+let vim_config_directory=$HOME.'/.vim'
10
+" Required:
11
+if dein#load_state(vim_config_directory)
12
+  call dein#begin(vim_config_directory)
13
+
14
+  " Let dein manage dein
15
+  " Required:
16
+  call dein#add(vim_config_directory.'/repos/github.com/Shougo/dein.vim')
17
+
18
+  call dein#add('LnL7/vim-nix')
19
+  call dein#add('Shougo/vimproc', {'build': 'make'})
20
+  call dein#add('Shougo/unite-outline')
21
+  call dein#add('Shougo/unite.vim')
22
+  call dein#add('Shougo/vimfiler.vim')
23
+  call dein#add('altercation/vim-colors-solarized')
24
+  call dein#add('christoomey/vim-tmux-navigator')
25
+  call dein#add('dbakker/vim-paragraph-motion')
26
+  call dein#add('editorconfig/editorconfig-vim')
27
+  call dein#add('jceb/vim-editqf')
28
+  call dein#add('kien/rainbow_parentheses.vim')
29
+  call dein#add('kovisoft/slimv')
30
+  call dein#add('mattn/emmet-vim')
31
+  call dein#add('scrooloose/nerdcommenter')
32
+  call dein#add('scrooloose/nerdtree')
33
+  call dein#add('scrooloose/syntastic')
34
+  call dein#add('sjl/gundo.vim.git')
35
+  call dein#add('terryma/vim-multiple-cursors')
36
+  call dein#add('tpope/vim-fireplace')
37
+  call dein#add('tpope/vim-fugitive')
38
+  call dein#add('tpope/vim-repeat')
39
+  call dein#add('tpope/vim-surround')
40
+  call dein#add('tsukkee/unite-tag')
41
+  call dein#add('vim-airline/vim-airline')
42
+  call dein#add('vim-airline/vim-airline-themes')
43
+  call dein#add('vim-scripts/matchit.zip')
44
+  call dein#add('vim-voom/VOoM')
45
+  call dein#add('jnurmine/zenburn')
46
+
47
+
48
+  " Required:
49
+  call dein#end()
50
+  call dein#save_state()
51
+endif
52
+
53
+" Required:
54
+filetype plugin indent on
55
+syntax enable
56
+
57
+" If you want to install not installed plugins on startup.
58
+if dein#check_install()
59
+  call dein#install()
60
+endif
61
+"End dein Scripts-------------------------
62
+
63
+let g:airline_theme="murmur"
64
+let maplocalleader=','
65
+
66
+filetype indent on
67
+
68
+"Enable support for Color xterm
69
+:if has("terminfo")
70
+:  set t_Co=8
71
+:  set t_Sf=^[[3%p1%dm
72
+:  set t_Sb=^[[4%p1%dm
73
+:else
74
+:  set  t_Co=8
75
+:  set t_Sf=^[[3%dm
76
+:  set t_Sb=^[[4%dm
77
+:endif
78
+
79
+set ignorecase
80
+set smartcase
81
+set nu
82
+set expandtab
83
+set tabstop=3
84
+set softtabstop=2
85
+set smarttab
86
+set shiftwidth=2
87
+set incsearch
88
+set scrolloff=4
89
+set wildmode=list:longest
90
+set autoread
91
+set background=dark
92
+set pastetoggle=<F12>
93
+set undodir=~/.vim/undodir
94
+set undofile
95
+set undolevels=10000
96
+set undoreload=100000
97
+set foldlevel=9
98
+set hidden
99
+set laststatus=2
100
+set splitbelow
101
+set splitright
102
+set grepprg=grep\ -nH\ $*
103
+set modelines=1      " CVE-2007-2438
104
+set backspace=2      " more powerful backspacing
105
+
106
+syntax enable
107
+colorscheme zenburn
108
+
109
+function! Checkft()
110
+  if &filetype==""
111
+    filetype detect
112
+  endif
113
+endfunction
114
+
115
+autocmd! BufNewFile * silent! 0r ~/.vim/skel/tmpl.%:e
116
+autocmd bufwritepost * call Checkft()
117
+
118
+autocmd FileType markdown set linebreak tw=110 noexpandtab nosmartindent autoindent spelllang=en spell
119
+
120
+nnoremap <C-h> <C-W>h
121
+nnoremap <C-j> <C-W><C-J>
122
+nnoremap <C-k> <C-W><C-K>
123
+nnoremap <C-l> <C-W><C-L>
124
+inoremap <F2> ^O:set nonumber! foldcolumn=0<CR>
125
+
126
+map <BS> dh
127
+
128
+if filereadable(".vim.custom")
129
+    so .vim.custom
130
+endif
131
+
132
+call unite#custom#source('file,file/new,buffer,file_rec','matchers','matcher_fuzzy')
133
+
134
+autocmd FileType unite call s:unite_my_settings()
135
+function! s:unite_my_settings()
136
+  " Overwrite settings.
137
+  let b:SuperTabDisabled=1
138
+  imap <buffer><expr> <C-v>     unite#do_action('vsplit')
139
+  imap <buffer><expr> <C-s>     unite#do_action('split')
140
+  imap <buffer>  <Tab>     <Plug>(unite_complete)
141
+  imap <buffer> <C-j>   <Plug>(unite_select_next_line)
142
+  imap <buffer> <Down>   <Plug>(unite_select_next_line)
143
+  imap <buffer> <C-k>   <Plug>(unite_select_previous_line)
144
+  imap <buffer> <Up>   <Plug>(unite_select_previous_line)
145
+
146
+  " exit with esc
147
+  nmap <buffer> <ESC> <Plug>(unite_exit)
148
+
149
+  " exit with ctrl-c
150
+  imap <buffer> <c-c> <Plug>(unite_exit)
151
+  nmap <buffer> <c-c> <Plug>(unite_exit)
152
+endfunction
153
+
154
+if executable('ag')
155
+  let g:unite_source_file_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', '""', '--ignore', '''.sass-cache''']
156
+  "https://github.com/ggreer/the_silver_searcher
157
+  "Use ag in unite grep source.
158
+  let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', '', '--ignore', '.git', '--ignore', '.sass-cache']
159
+  let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', '', '--ignore', '.git', '--ignore', '.sass-cache']
160
+  let g:unite_source_grep_command = 'ag'
161
+  let g:unite_source_grep_default_opts =
162
+        \ '--line-numbers --nocolor --nogroup --hidden --ignore ' .
163
+        \ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'' ' .
164
+        \ '--ignore ''**/*.pyc'''
165
+  let g:unite_source_grep_recursive_opt = ''
166
+elseif executable('ack-grep')
167
+  let g:unite_source_grep_command = 'ack-grep'
168
+  " Match whole word only. This might/might not be a good idea
169
+  let g:unite_source_grep_default_opts = '--no-heading --no-color -a -H'
170
+  "let g:unite_source_grep_default_opts = '--no-heading --no-color -a -w'
171
+  let g:unite_source_grep_default_opts = '--exclude ''\.(git|svn|hg|bzr)'''
172
+  let g:unite_source_grep_recursive_opt = ''
173
+elseif executable('ack')
174
+  let g:unite_source_grep_command = 'ack'
175
+  let g:unite_source_grep_default_opts = '--no-heading --no-color -a -w'
176
+  let g:unite_source_grep_default_opts = '--exclude ''\.(git|svn|hg|bzr)'''
177
+  let g:unite_source_grep_recursive_opt = ''
178
+endif
179
+
180
+nmap <F2> :set nu!<CR>
181
+imap <F2> <C-o>:set nu!<CR>
182
+
183
+nnoremap [unite] <Nop>
184
+nmap <space> [unite]
185
+
186
+nmap                 [unite]s :<C-u>Unite -auto-preview grep:.<C-m>
187
+nmap                 [unite]o :<C-u>Unite outline -start-insert<C-m>
188
+nmap                 [unite]f :<C-u>Unite file_rec/async -start-insert<C-m>
189
+nmap                 [unite]F :<C-u>Unite file -start-insert<C-m>
190
+nmap                 [unite]g :<C-u>Unite file_rec/git -start-insert<C-m>
191
+nmap                 [unite]j :<C-u>Unite buffer -start-insert<C-m>
192
+nmap                 [unite]k :<C-u>Unite tab:no-current<C-m>
193
+
194
+nmap                 [unite]t :NERDTreeToggle<CR>
195
+nmap                 [unite]u :GundoToggle<CR>
196
+"nmap                 [unite]r :!vagrant rsync<CR>
197
+nmap                 [unite]h :set hlsearch!<CR>
198
+nmap                 [unite]l :set list!<CR>
199
+nmap <silent> <expr> [unite]z FS_ToggleFoldAroundSearch({'context':2})
200
+nmap          <expr> [unite]x FS_ToggleFoldAroundSearch({'context':0})
201
+nmap                 [unite]w :let @/='\<<C-r><C-w>\>'<CR>:set hlsearch<CR>
202
+nmap                 [unite]r :s/<C-r><C-w>/<C-r>=input('replacement? ').'/g'<CR>
203
+nmap                 [unite]R :%s/<C-r><C-w>/<C-r>=input('replacement? ').'/g'<CR>
204
+
205
+nmap                 <C-x>o <C-w><C-w>
206
+
207
+autocmd BufRead,BufNewFile *.css,*.scss,*.less setlocal foldmethod=marker foldmarker={,}
208
+
209
+command -nargs=+ Gadd Git add <q-args>
210
+
211
+if &term =~ '^\(xterm\)\|\(screen\)'
212
+  " solid underscore
213
+  let &t_SI .= "\<Esc>[3 q"
214
+  " solid block
215
+  let &t_EI .= "\<Esc>[2 q"
216
+  " 1 or 0 -> blinking block
217
+  " 3 -> blinking underscore
218
+  " Recent versions of xterm (282 or above) also support
219
+  " 5 -> blinking vertical bar
220
+  " 6 -> solid vertical bar
221
+endif
222
+set timeoutlen=1000 ttimeoutlen=0
223
+
224
+command FwoarSc ':let g:syntastic_sh_shellcheck_tail = " -x"'
... ...
@@ -52,7 +52,8 @@ git-pff() {
52 52
 }
53 53
 
54 54
 git-root() {
55
-  git rev-parse --show-toplevel
55
+  rootpath="$(git rev-parse --show-toplevel)"
56
+  echo "$rootpath/$1"
56 57
 }
57 58
 
58 59
 git-ag() {
... ...
@@ -68,9 +69,14 @@ git-graph() {
68 69
   git log --graph --format=oneline --decorate "$@"
69 70
 }
70 71
 alias gl=git-graph
71
-alias git-l=git-graph
72
-alias git-hist=git-graph
73
-alias g=git
72
+
73
+git-find-tag() {
74
+  git log --format=oneline --all |
75
+    gawk -vtofind="$*" -vFS=$'[ ]+|:[ ]*' \
76
+         'tolower($2) == "code" {$2=$2" "$3; for (i=3;i<NF;i++) $i=$(i+1); $NF=""} \
77
+          {code=$2; hash=$1; for (i=1;i<=NF-2;i++) $i=$(i+2); NF=NF-2} \
78
+          code ~ tofind {print code": "hash" "$0}'
79
+}
74 80
 
75 81
 git-messages() {
76 82
   if [[ -d .git ]]; then
... ...
@@ -1,6 +1,7 @@
1 1
 #:depends-on:todo
2 2
 #:depends-on:key-bindings
3 3
 #:depends-on:named-directories
4
+#:depends-on:aliases
4 5
 
5 6
 cat <<'EOP'
6 7
              :