erc fixes
[dot-emacs] / ian-notes.org
1 #+title: My Personal Init Customization
2 #+OPTIONS: toc:nil num:nil ^:nil
3
4 * python disabled due to long load time
5 todo: get smart-operator to work
6 todo, checkout https://github.com/python-rope/ropemacs refactoring python,
7 todo, try py-autopep8, autoformatter
8 todo, check out some python linting stuff. pychecker is one, others are in *packages*
9 todo, finish reading through python-mode.el functions
10 ;; todo, figure out multi-line input in shell mode
11
12
13 usefull m-x commands:
14 m-x py-describe-mode: doc for mode which is extensive
15 m-x py-sort-imports
16 m-x py-guess-indent-offset: setup indent for code i didn't write
17
18 possibly usefull commands:
19 found via looking through python-mode.el, quit like 1/4 through, cuz its tedious, last spot was at:
20 (defun py-comment-region (beg end &optional arg)
21 after finding py-describe-mode, it seemed to do a good job of documenting all the most important stuff
22
23 py-switch-to-python
24 python-shell-completion-complete-or-indent may be usefull to get completion working in the shell
25 py-insert-default-shebang
26 py-electric-*
27 py-indent-line-outmost
28 py-newline-and-close-block
29 py-indent-and-forward (indent line, move to next)
30 py-fill-*
31 py-which-function (for showing in the modeline)
32 py-help-at-point
33 py-execute-import-or-reload
34 py-execute-def-or-class
35 various pdb functions
36
37
38 installing jedi
39 #+begin_src sh :tangle no
40 pi python-pip
41 s pip install jedi virtualenv
42 #+end_src
43 then do m-x jedi:install-server
44
45
46
47 disabled because it takes 152 ms to load,
48 and I don't know how to do it conditioally
49 #+begin_src emacs-lisp :tangle no
50
51 ;; change from default python3 to be compatibile with Pywikibot
52 (setq py-shell-name "/usr/bin/python")
53 (require 'python-mode)
54
55 (setq py-autopep8-options '("--max-line-length=110"))
56
57 (defun py-execute-block-or-clause-create-shell ()
58 (interactive)
59 (cond ((get-buffer "*Python*")
60 (py--execute-prepare "block-or-clause")
61 (py-execute-block-or-clause)
62 (call-interactively 'next-line))
63 (t
64 (py-shell)
65 ;; py-shell starts the shell but not display the buffer on the first run
66 ;; subsequent runs, it does. I grabbed this command from inside to
67 ;; do just the relevant part from the second run, as a hack.
68 ;; todo: report a bug on this
69 (py--shell-manage-windows py-buffer-name))))
70 (setq py-tab-shifts-region-p t)
71 (setq py-tab-indents-region-p t)
72
73 (defun py-run ()
74 "default action to run the current buffer"
75 (basic-save-buffer)
76 (py-execute-buffer))
77
78
79 (add-hook 'python-mode-hook
80 (lambda ()
81 (setq run-fun 'py-run)
82 (define-key python-mode-map (kbd "C-M-a") nil)
83 (define-key python-mode-map (kbd "C-M-d") nil)
84 (define-key python-mode-map (kbd "C-M-e") nil)
85 (define-key python-mode-map (kbd "C-M-h") nil)
86 (define-key python-mode-map (kbd "C-M-i") nil)
87 (define-key python-mode-map (kbd "C-M-u") nil)
88 (define-key python-mode-map (kbd "C-M-x") nil)
89 (define-key python-mode-map (kbd "<tab>") 'indent-for-tab-command)
90 (define-key python-mode-map (kbd "C-j") nil)
91 (define-key python-mode-map (kbd "<C-backspace>") nil)
92 ;;(define-key python-mode-map (kbd "C-(") (lambda () (interactive) (basic-save-buffer) (py-execute-buffer)))
93 ;; fix default return bindings
94 (define-key python-mode-map (kbd "C-j") nil)
95 (define-key python-mode-map (kbd "RET") nil)
96 (define-key python-mode-map (kbd "<return>") 'py-newline-and-indent)
97 (define-key python-mode-map (kbd "<M-tab>") 'py-indent-line)
98 (define-key python-mode-map (kbd "C-M-(") 'py-shift-left)
99 (define-key python-mode-map (kbd "C-M-)") 'py-shift-right)
100 (define-key python-mode-map (kbd "<home>") 'py-beginning-of-line)
101 (define-key python-mode-map (kbd "<end>") 'py-end-of-line)
102 (define-key python-mode-map (kbd "C-t") 'py-execute-block-or-clause-create-shell)
103 (define-key python-mode-map (kbd "<S-delete>") 'py-ian-execute-line-or-region)
104 ;; python mode adds these to this list, which is normally empty.
105 ;; it makes my send-python function not reuse an existing python shell window
106 ;; there are other ways to override this, but I don't know of any other value of
107 ;; having this set.
108 (setq same-window-buffer-names (delete "*Python*" same-window-buffer-names))
109 (setq same-window-buffer-names (delete "*IPython*" same-window-buffer-names))))
110
111 ;; i dunno, why, but this didn't work:
112 ;; and we can't eval-after-load cuz it is part of the greater python mode file
113 (add-hook 'py-shell-hook
114 (lambda ()
115 (define-key py-shell-map "\r" nil)
116 (define-key py-shell-map (kbd "<return>") 'comint-send-input)
117 (define-key py-shell-map (kbd "C-t") 'py-shell-toggle-arrow-keys)
118 (define-key py-shell-map "\C-d" nil)
119 (define-key py-shell-map (kbd "<up>") 'my-comint-previous-input)
120 (define-key py-shell-map (kbd "<down>") 'my-comint-next-input)))
121
122
123 (defun py-ian-execute-line-or-region ()
124 (interactive)
125 (cond ((get-buffer "*Python*")
126 (if mark-active
127 (py-execute-region)
128 (py-execute-statement))
129 (call-interactively 'next-line))
130 (t (py-shell))))
131
132 ;; http://tkf.github.io/emacs-jedi/latest/
133 (add-hook 'python-mode-hook 'jedi:setup)
134 (setq jedi:complete-on-dot t)
135
136 (defun py-shell-toggle-arrow-keys ()
137 (interactive)
138 (toggle-arrow-keys py-shell-map))
139
140 #+end_src
141
142
143 ;; py-shell window stuff
144 ;; it splits the window if the shell is in a different frame
145 ;; which seems to be a bug, but it can be fixed with this option
146 ;; (setq py-keep-windows-configuration 'force)
147 ;; however, with py-execute-block-or-clause, if the shell is in a different frame,
148 ;; you get errors "buffer is read only", when the point is near the beginning of a command
149 ;; todo: test with emacs -Q and file a bug
150 ;; if you execute py-execute-... without a python shell open,
151 ;; it starts one, doesn't display it, and subsequent py-execute commands
152 ;; give error "buffer is read only"
153 ;; these functions fix / improve these problems
154
155
156 ** initial python-mode setup
157
158 python-mode seems to be the most canonical package, based on
159 https://docs.python.org/devguide/emacs.html
160 much more feature rich than the emacs built in one.
161
162 getting it, it wants you to setup an account on launchpad by default,
163 there is some way to get anonymous bzr access, but google didn't answer it right away,
164 so fuck it, ill go the happy path.
165
166 based on error messages,
167 add public ssh key to https://launchpad.net/people/+me
168 bzr launchpad-login iank
169 cd ~/.emacs.d/src/
170 bzr branch lp:python-mode
171
172 add lines from INSTALL to init
173
174
175 ** background on packages
176 jedi appears most popular based on github stats
177 pysmell appears dead
178 ac-python appears dead
179 https://github.com/proofit404/anaconda-mode seems to be kicking along
180
181
182 ** misc notes:
183
184 python-mode has a TON of functions that are just aliases or verbatim wrappers of other functions.
185 also has undocumented/unused vars all around. it is quite annoying.
186
187 the dedicated argument to py-shell does nothing,
188 and py-dedicated-shell just sets that, so it is a waste
189
190
191 ** background on sending to python shell
192
193 using the builtin python execute shell functions, sending one line doesn't really work well.
194 The bulit in functions don't wait for further input if a block is not closed.
195 And doing a copy/paste thing gets messed up because of indents.
196 With some hacking, I could probably do copy/paste and remove indents, only to a
197 certain level if we have entered a block and are waiting to finish it.
198 But just doing the builtin execute block is a decent work around.
199
200
201 Here is the scrapped function for single line built in sending to shell.
202
203
204 (setq w32-enable-num-lock nil)
205 (global-set-key (kbd "<num_lock>") 'left-char)
206
207
208 (defun sqlup-find-correct-keywords ()
209 "If emacs is handling the logic for syntax highlighting of SQL keywords, then we piggyback on top of that logic. If not, we use an sql-mode function to create a list of regular expressions and use that."
210 (mapcar 'car (sql-add-product-keywords sql-product '())))
211
212
213 largest subarray sum, array of pos and neg ints.
214
215 * disabled but saved for documentation purposes
216 :PROPERTIES:
217 :header-args: :tangle no
218 :END:
219
220 ** ido keybinds
221 *** C-j
222 ido-find-file create file
223 *** //]
224 ido goto root
225 *** C-k]
226 ido kill buffer/file
227 *** C-d]
228 ido open dired buffer
229 *** M-d]
230 ido search within all subdirectories
231 *** M-m]
232 ido create subdirectory
233 *** M-s]
234 ido search recently used directories
235 *** M-n/p]
236 ido next/previous recently used directory
237 *** C-s]
238 **** TODO implement this keybind, normally ctrl-space
239 ido use current pattern and start a new one
240
241
242 ** indent settings for git's perl code
243 don't have a way to set this automatically or a good place to put this
244 #+begin_src emacs-lisp
245 (setq
246 perl-indent-level 8
247 perl-continued-statement-offset 8
248 perl-continued-brace-offset -8
249 perl-brace-offset 0
250 perl-brace-imaginary-offset 0
251 indent-tabs-mode t
252 )
253 #+end_src
254 ** org mode website
255
256 #+begin_src emacs-lisp
257 ;; use org-publish-current-project with a project file open
258 (setq org-publish-project-alist
259 '(("org"
260 :base-directory "/a/h/src"
261 :publishing-directory "/a/h/output"
262 :base-extension "org"
263 ;;:publishing-function org-org-publish-to-org
264 :publishing-function org-html-publish-to-html
265 :preserve-breaks t
266 :html-postamble "Everything here is <a rel=\"license\"
267 href=\"http://creativecommons.org/licenses/by-sa/4.0/\"><img
268 alt=\"Creative Commons License\" style=\"border-width:0\"
269 src=\"http://i.creativecommons.org/l/by-sa/4.0/80x15.png\" /></a>"
270 :html-head "<link rel=\"stylesheet\"
271 href=\"style.css\"
272 type=\"text/css\"/>"
273 :htmlized-source t)
274 ("othersrc"
275 :base-directory "/a/h/src"
276 :base-extension "css\\|el\\|"
277 :publishing-directory "/a/h/output"
278 :publishing-function org-publish-attachment)
279 ("other"
280 :base-directory "/a/h/other"
281 :base-extension ".*"
282 :publishing-directory "/a/h/output"
283 :publishing-function org-publish-attachment)))
284 ;; default is xhtml-strict. don't really care, but this is more common
285 (setq org-html-doctype "html4-strict")
286
287 ;; this is needed for worg
288 ;; todo: for my own site, I need to define the css in a separate file
289 ;; in order to use this setting. see the variable help for info
290 (setq org-export-htmlize-output-type t)
291
292
293 #+end_src
294
295 ** bash-completion
296 #+begin_src emacs-lisp
297 ;; this eventually gets set in
298 ;; comint-dynamic-complete-functions
299 ;; (car comint-dynamic-complete-functions)
300 (autoload 'bash-completion-dynamic-complete "bash-completion"
301 "BASH completion hook")
302 (add-hook 'shell-dynamic-complete-functions
303 'bash-completion-dynamic-complete)
304
305 ;; this appears useless, but was in the recommended init code
306 (add-hook 'shell-command-complete-functions
307 'bash-completion-dynamic-complete)
308
309 (defun ac-rlc-setup-sources ()
310 "Add me to shell-mode-hook!"
311 (setq ac-sources '(ac-source-shell)))
312 (add-hook 'shell-mode-hook 'ac-rlc-setup-sources)
313
314 #+end_src
315
316 ** misc stuff
317 It is an awesome mode for keyboard navigation.
318 However, using the mouse takes less thought and works as well
319
320 #+begin_src emacs-lisp
321
322
323 ;; whitespace-mode config. minimal for bad whitespace
324 ;(setq whitespace-line-column 80) ; for style of lines-tail, but I have it disabled
325 (setq whitespace-style '(face tabs empty trailing))
326 ;to enable whitespace mode
327 (whitespace-mode +1)
328
329
330
331 (defun org-set-mark-command (arg)
332 "Do set-mark-command and then org-show-context if the point
333 moves to invisible text."
334 (interactive "P")
335 (let ((initial-point (point)))
336 (setq this-command 'set-mark-command)
337 (set-mark-command (arg))
338 (if (and (not (= (point) initial-point))
339 (or (outline-invisible-p) (org-invisible-p2)))
340 (org-show-context 'mark-goto))))
341
342 (defun org-exchange-point-and-mark (&optional arg)
343 (interactive "P")
344 (let ((initial-point (point)))
345 (exchange-point-and-mark)
346 (if (and (not (= (point) initial-point))
347 (or (outline-invisible-p) (org-invisible-p2)))
348 (org-show-context 'mark-goto))))
349
350
351 (defun toggle-mode-line ()
352 "Toggle mode line on and off."
353 (interactive)
354 (if mode-line-format
355 (progn (setq my-saved-mode-line-format mode-line-format)
356 (setq mode-line-format nil))
357 (setq mode-line-format my-saved-mode-line-format))
358 (force-mode-line-update))
359 (toggle-mode-line)
360 (global-set-key (kbd "M-m") 'toggle-mode-line)
361 (add-hook 'after-change-major-mode-hook
362 (lambda () (setq my-saved-mode-line-format mode-line-format)
363 (setq mode-line-format nil)))
364
365
366 #+end_src
367
368 ** Copy mode-line to the top
369 #+begin_src emacs-lisp
370 ;; Copy mode-line to the top
371 (setq-default header-line-format mode-line-format
372 mode-line-format nil)
373 ;; copied the mode-line theme into the header theme, else it is unreadable
374 ;; this goes after loading the theme
375 (let ((class '((class color) (min-colors 89))))
376 (custom-theme-set-faces
377 'leuven
378 `(header-line ((,class (:box (:line-width 1 :color "#1A2F54") :foreground "#85CEEB" :background "#335EA8"))))))
379
380 #+end_src
381
382 ** tab bindings for when I wanted to make tab be for search
383 #+begin_src emacs-lisp
384
385 (define-key emacs-lisp-mode-map (kbd "<tab>") nil)
386 (define-key button-buffer-map "\t" nil)
387 (define-key button-buffer-map (kbd "f") 'forward-button)
388 (define-key Info-mode-map "\t" nil)
389 (define-key widget-keymap "\t" nil)
390 (define-key widget-keymap (kbd "<tab>") nil)
391
392 (add-hook 'compilation-mode-hook (lambda ()
393 (define-key compilation-mode-map (kbd "<tab>") nil)
394 (define-key compilation-mode-map "\t" nil)))
395
396 ;; unbind c-i for yas. it already separately binds <tab>
397 (add-hook 'yas-minor-mode-hook (lambda ()
398 (define-key yas-minor-mode-map "\t" nil)))
399
400 (add-hook 'haskell-interactive-mode-hook
401 (lambda ()
402 (define-key haskell-interactive-mode-map "\t" nil)
403 (define-key haskell-interactive-mode-map (kbd "<tab>") 'haskell-interactive-mode-tab)))
404
405 (define-key minibuffer-local-must-match-map "\t" nil)
406 (define-key minibuffer-local-must-match-map (kbd "<tab>") 'minibuffer-complete)
407 (define-key minibuffer-local-completion-map (kbd "<tab>") 'minibuffer-complete)
408 (define-key minibuffer-local-completion-map "\t" 'minibuffer-complete)
409
410 (add-hook 'ido-setup-hook
411 (lambda()
412 (define-key ido-completion-map (kbd "<tab>") 'ido-complete)
413 (define-key ido-completion-map "\t" nil)))
414
415 #+end_src
416
417 ** kill buffer and window
418 #+begin_src emacs-lisp
419 (defun kill-buffer-and-window ()
420 "Close the current window and kill the buffer it's visiting."
421 (interactive)
422 (progn
423 (kill-buffer)
424 (delete-window)))
425 #+end_src
426 ** sending multiple commands to a comint buffer
427 without waiting for commands to finish is unreliable.
428 seems like 1 in 100 times, an invisible command to restore prompt didn't work
429 #+begin_src emacs-lisp
430 (setq shell-unset-prompt "unset PROMPT_COMMAND; unset PS1")
431 (setq shell-set-prompt "PROMPT_COMMAND=prompt_command")
432
433 (if (boundp 'shell-unset-prompt)
434 (send-invisible-string proc shell-unset-prompt))
435 (if (boundp 'shell-set-prompt)
436 (send-invisible-string proc shell-set-prompt))
437
438
439 (defun send-invisible-string (proc string)
440 "Like send-invisible, but non-interactive"
441 (comint-snapshot-last-prompt)
442 (funcall comint-input-sender proc string))
443
444 #+end_src
445
446
447
448
449 ** org-mode auto-complete source
450
451 todo, someday take a look at this. it is broken.
452
453 ;(defvar ac-source-eshell-pcomplete
454 ; '((candidates . (pcomplete-completions))))
455 ;(defun ac-complete-eshell-pcomplete ()
456 ; (interactive)
457 ; (auto-complete '(ac-source-eshell-pcomplete)))
458
459 ;(add-hook 'org-mode-hook (lambda () (setq ac-sources (cons 'ac-source-eshell-pcomplete ac-sources))))
460 ;(add-to-list 'ac-modes 'eshell-mode)
461
462
463 ** gnus nice unicode
464
465
466 this looks nice, but it lags gnus just a bit
467 #+begin_src emacs-lisp
468
469 (defun gnus-pretty-chars-setup ()
470 (when window-system
471 (setq gnus-sum-thread-tree-indent " "
472 gnus-sum-thread-tree-root "● "
473 gnus-sum-thread-tree-false-root "◯ "
474 gnus-sum-thread-tree-single-indent "◎ "
475 gnus-sum-thread-tree-leaf-with-other "├─► "
476 gnus-sum-thread-tree-vertical "│"
477 gnus-sum-thread-tree-single-leaf "╰─► ")))
478 ;; dunno why, but this didn't work just setting on startup
479 (add-hook 'gnus-startup-hook 'gnus-pretty-chars-setup)
480
481 #+end_src
482
483 ** misc
484 #+begin_src emacs-lisp
485
486 ;; this makes more ergonomic sense, since our eyes are mostly on the left,
487 ;; but after using it a while, it's too much cognitive dissonance that
488 ;; every other program has it on the right
489 ;;(set-scroll-bar-mode 'left)
490
491
492
493 ; todo, is this require things necessary?
494 ; (require 'flyspell)
495
496
497
498 ; whenever M-tab is completion, swap it with tab
499 ;(define-key emacs-lisp-mode-map (kbd "<tab>") 'completion-at-point)
500 ;(define-key emacs-lisp-mode-map (kbd "C-M-i") 'indent-for-tab-command)
501 ;(define-key lisp-interaction-mode-map (kbd "<tab>") 'completion-at-point)
502 ;(define-key lisp-interaction-mode-map (kbd "C-M-i") 'indent-for-tab-command)
503 ;the global tab keyind. for some reason this totally screws up mini-buffer tab.
504 ; disabled until I actually find myself using this, and find a fix for the above problem
505 ;(global-set-key (kbd "<tab>") 'complete-symbol)
506
507
508 ; todo, make my custom overlays have an underline if they are
509 ; overriding a paren matching overlay
510 ; make right click set the mark
511 ; make search tab do completion instead of meta-tab
512 ; in isearch, move C-y to C-v
513 ; in isearch, move c-s to c-f
514
515 ; some testing to figure out the underlining when paren highlight conflicts
516 ; (let ((extra-overlays (overlays-at (1+ end-point))))
517 ; (when extra-overlays (print extra-overlays)))
518
519
520
521
522 ; commented out because it messes up yank-pop.
523 ; todo, fix it someday
524 ; make yank linewise if it ends in a newline
525 ;(defadvice yank (before linewise-yank-advice activate)
526 ; (let ((arg (ad-get-arg 0)))
527 ; (when (string-match "\n[ \t]*$" (current-kill (cond
528 ;; ((listp arg) 0)
529 ;; ((eq arg '-) -2)
530 ;; (t (1- arg))) t))
531 ;; (move-beginning-of-line nil))))
532
533
534
535 ; todo, look into augmenting auto-complete with hippie expand.
536 ; starter kit has some hippie expand settings to look into:
537 ; (when (boundp 'hippie-expand-try-functions-list)
538 ; (delete 'try-expand-line hippie-expand-try-functions-list)
539 ; (delete 'try-expand-list hippie-expand-try-functions-list))
540
541
542 ;; hippie expand is dabbrev expand on steroids
543 ;(setq hippie-expand-try-functions-list '(try-expand-dabbrev
544 ; try-expand-dabbrev-all-buffers
545 ; try-expand-dabbrev-from-kill
546 ; try-complete-file-name-partially
547 ; try-complete-file-name
548 ; try-expand-all-abbrevs
549 ; try-expand-list
550 ; try-expand-line
551 ; try-complete-lisp-symbol-partially
552 ; try-complete-lisp-symbol))
553 ;; use hippie-expand instead of dabbrev
554 ;(global-set-key (kbd "M-/") 'hippie-expand)
555
556
557 ; commented because i haven't had time to check it out yet
558 ;; shorter aliases for ack-and-a-half commands
559 ;(defalias 'ack 'ack-and-a-half)
560 ;(defalias 'ack-same 'ack-and-a-half-same)
561 ;(defalias 'ack-find-file 'ack-and-a-half-find-file)
562 ;(defalias 'ack-find-file-same 'ack-and-a-half-find-file-same)
563
564
565
566
567 ; todo. take a look at fixing this
568 ;delete-old-versions t ; fix description in http://www.emacswiki.org/emacs/ForceBackups
569
570
571
572
573 ;; prelude uses paredit mode.
574 ;; paredit has some useful stuff but also annoying stuff.
575 ;; if I ever do a ton of lisp coding, I should look into it
576
577
578
579
580
581
582 ; random notes and example code
583
584
585 ; usefull thing
586 ;(map 'list #'list tabSwapKeys (reverse (getBinds tabSwapKeys)))
587
588 ; example of getting keymap info
589 ;(car (car (minor-mode-key-binding (kbd "C-/") t)))
590 ;(cdr (car (minor-mode-key-binding (kbd "C-/") t)))
591 ;(global-key-binding (kbd "C-M-i") t)
592 ;(minor-mode-key-binding (kbd "<tab>") t)
593 ;(local-key-binding (kbd "C-M-i") t)
594 ;(current-minor-mode-maps)
595 ;(cdr (assq 'undo-tree-mode minor-mode-map-alist))
596
597
598 ; center on incremental search, instead of being at top or bottom of screen.
599 ; i'm hoping that setting Isearch Allow Scroll is good enough to fix this annoyance
600 ;from http://stackoverflow.com/questions/11052678/emacs-combine-iseach-forward-and-recenter-top-bottom
601
602 ;example of constant definition of an overlay and propreries
603 ;(defface mouse-flash-position '((t (:background "Yellow")))
604 ; "*Face used to highlight mouse position temporarily."
605 ; :group 'mouse)
606 ;(defface mouse-flash-position '((t (:background "Yellow")))
607 ; "*Face used to highlight mouse position temporarily."
608 ; :group 'mouse)
609 ;(defconst mouse-flash-posn-overlay
610 ; ;; Create and immediately delete, to get "overlay in no buffer".
611 ; (let ((ol (make-overlay (point-min) (point-max))))
612 ; ;(delete-overlay ol)
613 ; ;(overlay-put ol 'face 'mouse-flash-position)
614 ; (overlay-put ol 'mouse-face 'mouse-flash-position)
615 ; (overlay-put ol 'priority 1000000)
616 ; ol)
617 ; "Overlay to highlight current mouse position.")
618
619
620 ;tip, put the last interactive command as elisp on the kill ring:
621 ;C-x <ESC> <ESC> C-a C-k C-g
622
623 ; example of overlay testing
624 ;(setq foo (make-overlay 2 3 nil t nil))
625 ;(setq foo2 (make-overlay 3 4 nil t nil))
626 ;(overlay-put foo 'face '(:background "red3" :foreground "black"))
627 ;(overlay-put foo2 'face '(:background "red1" :foreground "black"))
628 ;(overlay-put foo 'face 'visible-mark-face)
629 ;(overlay-put foo 'face visible-mark-face2)
630
631
632 #+end_src
633
634
635 ** SQL
636
637 disabled, as I haven't used it in a long time. I think it was good for learning some sql stuff.
638 #+begin_src emacs-lisp :tangle no
639 (require 'sqlup-mode)
640 (add-hook 'sql-mode-hook 'sqlup-mode)
641 (add-hook 'sql-interactive-mode-hook 'sqlup-mode)
642
643 (setq sql-product 'postgres)
644 #+end_src
645
646
647 ** icomplete
648 #+begin_src emacs-lisp
649 ;; without this, on partial completion return would exit the minibuffer, and i had to
650 ;; keep typing out letters do a full completion before pressing enter.
651 ;; super annoying. So I picked ctrl-j as a free key to put exit,
652 ;; but in practice, I would just use ctrl-g to quit. Anyways,
653 ;; ivy is doing all the minibuffer stuff, so removed this as it's
654 ;; unused, so it can't cause any problems in future
655 (when (boundp 'icomplete-minibuffer-map)
656 (define-key icomplete-minibuffer-map (kbd "C-j") 'exit-minibuffer)
657 (define-key icomplete-minibuffer-map (kbd "<return>")
658 'minibuffer-force-complete-and-exit))
659
660
661 #+end_src
662
663 ** java eclim
664
665 based on https://github.com/senny/emacs-eclim
666
667
668 eclim: eclipse completion, searching, validation, etc inside emacs
669 install:
670 cd ~/opt
671 git clone git://github.com/ervandew/eclim.git
672 cd eclim
673 pi ant
674 ant -Declipse.home=/a/opt/eclipse
675
676
677 currently makes emacs hang a bunch. dunno why. just using eclipse instead
678 #+begin_src emacs-lisp :tangle no
679 (require 'eclim)
680 (global-eclim-mode)
681
682 ;; just do java
683 (setq eclim-accepted-file-regexps
684 '("\\.java"))
685
686 (custom-set-variables
687 '(eclim-eclipse-dirs '("/a/opt/eclipse"))
688 '(eclim-executable "/a/opt/eclipse/eclim"))
689
690 (setq help-at-pt-display-when-idle t)
691 (setq help-at-pt-timer-delay 0.1)
692 (help-at-pt-set-timer)
693
694 ;; dunno if this line is needed
695 (require 'eclimd)
696 (setq eclimd-default-workspace "/a/bin/eclipse-workspace")
697
698 ;;add the emacs-eclim source
699 (require 'ac-emacs-eclim-source)
700 (add-hook 'java-mode-hook 'ac-emacs-eclim-java-setup)
701
702 #+end_src
703
704 #+RESULTS:
705 | ac-emacs-eclim-java-setup |
706
707
708
709 * broken & disabled mouse stuff
710
711 all mouse stuff disabled till i have time to figure it out again.
712 #+begin_src emacs-lisp :tangle no
713 (defun xterm-mouse-translate-1 (&optional extension)
714 (save-excursion
715 (let* ((event (xterm-mouse-event extension))
716 (ev-command (nth 0 event))
717 (ev-data (nth 1 event))
718 (ev-where (nth 1 ev-data))
719 (vec (vector event))
720 (is-down (string-match "down-" (symbol-name ev-command))))
721
722 (cond
723 ((null event) nil) ;Unknown/bogus byte sequence!
724 (is-down
725 (setf (terminal-parameter nil 'xterm-mouse-last-down) event)
726 vec)
727 (t
728 (let* ((down (terminal-parameter nil 'xterm-mouse-last-down))
729 (down-data (nth 1 down))
730 (down-where (nth 1 down-data)))
731 (setf (terminal-parameter nil 'xterm-mouse-last-down) nil)
732 (cond
733 ((null down)
734 ;; This is an "up-only" event. Pretend there was an up-event
735 ;; right before and keep the up-event for later.
736 (push event unread-command-events)
737 (vector (cons (intern (replace-regexp-in-string
738 "\\`\\([ACMHSs]-\\)*" "\\&down-"
739 (symbol-name ev-command) t))
740 (cdr event))))
741 ((equal ev-where down-where) vec)
742 (t
743 (let ((drag (if (symbolp ev-where)
744 0 ;FIXME: Why?!?
745 (list (intern (replace-regexp-in-string
746 "\\`\\([ACMHSs]-\\)*" "\\&drag-"
747 (symbol-name ev-command) t))
748 down-data ev-data))))
749 (if (null track-mouse)
750 (vector drag)
751 (push drag unread-command-events)
752 (vector (list 'mouse-movement ev-data))))))))))))
753
754 #+end_src
755
756
757 ** cursor highlight
758 disabled until fixed
759 #+begin_src emacs-lisp :tangle no
760 (defun mouse-follow-cursor ()
761 ;(if (not (equal this-command last-command)) (print this-command))
762 ;debug
763 ; (print this-command)
764 (when (and this-command (not (string= this-command "show-pointer")))
765 (let* ((pos (posn-col-row (posn-at-point)))
766 (x (1+ (car pos))) ; no idea why this is off by 1
767 (y (cdr pos)))
768 (setq ignore-mouse-visibility t)
769 (set-mouse-position (selected-frame) x y))
770 ;(sleep-for 0 100)
771 (frame-make-pointer-invisible)))
772
773 ; (when this-command
774 ; (if (string= this-command "show-pointer")
775 ; (frame-make-pointer-visible)
776 ;))
777
778
779
780 (defun show-pointer ()
781 (interactive)
782 (if ignore-mouse-visibility
783 (setq ignore-mouse-visibility nil)
784 ; (print "visible")
785 (frame-make-pointer-visible)))
786
787 (setq ignore-mouse-visibility t)
788 ; disabled
789 ; (global-set-key (kbd "<mouse-movement>") 'show-pointer)
790
791 ; (add-hook 'post-command-hook 'mouse-follow-cursor t)
792
793
794 ; status. working, except that all scroll wheel actions send a mouse-movement command before doing their actual command, which makes the pointer flicker.
795 ; this is just an artifact of xbindkeys. when i do my own mouse chip, it will fix this.
796
797 ; we could set track-mouse to nil, then do the command, then set it back. i like that idea a bit better.
798 ; we could do the same thing in the other case of ignore-mouse-visibility.
799
800 ; there are also other issues, it doesn't work with changing buffers on a split screen.
801 ; i think a good idea along with this would be for the cursor to follow the mouse all the time.
802 ; i have done code for that in my mouse 1 function,
803 ; i just need to read it again and try it out.
804
805
806
807
808 ; this does not take care of scrolling,
809 ; a post-command hook function below does,
810 ; but it breaks when the frame is split.
811 ; the bug is specifically in mouse-pixel-position
812 ; todo, fix this eventually
813 (defun mouse-highlight-event (event)
814 (interactive "e")
815 (when (or (not event) (mouse-movement-p event)
816 (memq (car-safe event) '(switch-frame select-window)))
817 (let ((pos (posn-point (event-end event))))
818 (if (eq (overlay-buffer mouse-hi-ov) (current-buffer))
819 (move-overlay mouse-hi-ov pos (1+ pos))
820 (delete-overlay mouse-hi-ov)
821 (setq mouse-hi-ov
822 (make-overlay pos (1+ pos)))
823 (overlay-put mouse-hi-ov
824 'insert-in-front-hooks (list 'mouse-hi-modification))
825 (overlay-put mouse-hi-ov 'priority 1001))
826 (cond ((save-excursion (goto-char pos) (eolp))
827 (overlay-put mouse-hi-ov 'face nil)
828 (overlay-put mouse-hi-ov 'before-string
829 (propertize
830 " "
831 'cursor t
832 'face 'mouse-cursor-face)))
833 (t
834 (overlay-put mouse-hi-ov 'face 'mouse-cursor-face)
835 (overlay-put mouse-hi-ov 'before-string nil))))))
836
837
838 ; overlay changed hook function
839 (defun mouse-hi-modification (ov timing beginning end &optional length)
840 "Make an overlay of length 1 not expand when text is inserted at the front."
841 (when timing
842 (let ((start (overlay-start ov)))
843 (move-overlay ov start (1+ start)))))
844
845
846
847
848 (defun mouse-hi-command-hook ()
849 ; not sure if I need to deal with case of a nil mouse position in some unforseen situation.
850 (let ((x-y (cdr (mouse-pixel-position))))
851 (when (wholenump (car x-y))
852 (let ((pos (posn-point (posn-at-x-y (car x-y) (cdr x-y) nil t))))
853 (when pos
854 (if (eq (overlay-buffer mouse-hi-ov) (current-buffer))
855 (move-overlay mouse-hi-ov pos (1+ pos))
856 (delete-overlay mouse-hi-ov)
857 (setq mouse-hi-ov
858 (make-overlay pos (1+ pos)))
859
860 (overlay-put mouse-hi-ov 'priority 1001))
861 (cond ((save-excursion (goto-char pos) (eolp))
862
863 (overlay-put mouse-hi-ov 'face nil)
864 (overlay-put mouse-hi-ov 'before-string
865 (propertize
866 " "
867 'cursor t
868 'face 'mouse-cursor-face)))
869 (t
870 (overlay-put mouse-hi-ov 'face 'mouse-cursor-face)
871 (overlay-put mouse-hi-ov 'before-string nil))))))))
872 ; (pcase-let ((`(,_ ,x . ,y) (mouse-pixel-position)))
873 ; (posn-point (posn-at-x-y x y)))))
874 ; equivalent of above to find pos. todo, learn about the above syntax
875
876 (setq mouse-hi-ov (make-overlay 1 1))
877 (delete-overlay mouse-hi-ov)
878 ; initialized overlay
879 ; temporarily set to nil instead of t because it is broken and
880 ; also has a bug that makes emacs not remember the column when
881 ; doing up and down movements.
882 ; it also messes up yas/insert-snippet, dunno why.
883 ; i should test out whether it is something in the post-command hook
884 ; (setq track-mouse t)
885 ;(add-hook 'post-command-hook 'mouse-hi-command-hook)
886
887 ;(mouse-hi-command-hook)
888 ;(setq debug-on-error nil)
889
890 #+end_src
891 ** mouse 1 drag func
892
893 disabled as it breaks in newer emacs versions with this error, when
894 clicking on info links
895
896 "and: Symbol's function definition is void: mouse--remap-link-click-p"
897
898 #+begin_src emacs-lisp :tangle no
899
900 ; Copied from mouse.el and modified.
901 ; my modifications have comments prefaced by "ian"
902 (defun mouse-drag-track (start-event &optional
903 do-mouse-drag-region-post-process)
904 "Track mouse drags by highlighting area between point and cursor.
905 The region will be defined with mark and point.
906 DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by
907 `mouse-drag-region'."
908 (mouse-minibuffer-check start-event)
909 (setq mouse-selection-click-count-buffer (current-buffer))
910 ; ian. removed as unneeded since I don't use TMM
911 ;(deactivate-mark)
912 (let* ((scroll-margin 0) ; Avoid margin scrolling (Bug#9541).
913 (original-window (selected-window))
914 ;; We've recorded what we needed from the current buffer and
915 ;; window, now let's jump to the place of the event, where things
916 ;; are happening.
917 (_ (mouse-set-point start-event))
918 (echo-keystrokes 0)
919 (start-posn (event-start start-event))
920 (start-point (posn-point start-posn))
921 (start-window (posn-window start-posn))
922 (start-window-start (window-start start-window))
923 (start-hscroll (window-hscroll start-window))
924 (bounds (window-edges start-window))
925 (make-cursor-line-fully-visible nil)
926 (top (nth 1 bounds))
927 (bottom (if (window-minibuffer-p start-window)
928 (nth 3 bounds)
929 ;; Don't count the mode line.
930 (1- (nth 3 bounds))))
931 (on-link (and mouse-1-click-follows-link
932 ;; Use start-point before the intangibility
933 ;; treatment, in case we click on a link inside
934 ;; intangible text.
935 (mouse-on-link-p start-posn)))
936 (click-count (1- (event-click-count start-event)))
937 (remap-double-click (and on-link
938 (eq mouse-1-click-follows-link 'double)
939 (= click-count 1)))
940 ;; Suppress automatic hscrolling, because that is a nuisance
941 ;; when setting point near the right fringe (but see below).
942 (auto-hscroll-mode-saved auto-hscroll-mode)
943 (auto-hscroll-mode nil)
944 moved-off-start event end end-point)
945
946 (setq mouse-selection-click-count click-count)
947 ;; In case the down click is in the middle of some intangible text,
948 ;; use the end of that text, and put it in START-POINT.
949 (if (< (point) start-point)
950 (goto-char start-point))
951 (setq start-point (point))
952 (if remap-double-click
953 (setq click-count 0))
954
955 ;; Activate the region, using `mouse-start-end' to determine where
956 ;; to put point and mark (e.g., double-click will select a word).
957 (setq transient-mark-mode
958 (if (eq transient-mark-mode 'lambda)
959 '(only)
960 (cons 'only transient-mark-mode)))
961 (delete-overlay mouse-hi-ov) ; ian, added this.
962
963 (let ((range (mouse-start-end start-point start-point click-count)))
964 (push-mark (nth 0 range) t t)
965 (goto-char (nth 1 range)))
966
967 ;; Track the mouse until we get a non-movement event.
968 (track-mouse
969 (while (progn
970 (setq event (read-event))
971 (or (mouse-movement-p event)
972 (memq (car-safe event) '(switch-frame select-window))))
973 (unless (memq (car-safe event) '(switch-frame select-window))
974 ;; Automatic hscrolling did not occur during the call to
975 ;; `read-event'; but if the user subsequently drags the
976 ;; mouse, go ahead and hscroll.
977 (let ((auto-hscroll-mode auto-hscroll-mode-saved))
978 (redisplay))
979 (setq end (event-end event)
980 end-point (posn-point end))
981 ;; Note whether the mouse has left the starting position.
982 (unless (eq end-point start-point)
983 (setq moved-off-start t))
984 (if (and (eq (posn-window end) start-window)
985 (integer-or-marker-p end-point))
986 (mouse--drag-set-mark-and-point start-point
987 end-point click-count)
988 (let ((mouse-row (cdr (cdr (mouse-position)))))
989 (cond
990 ((null mouse-row))
991 ((< mouse-row top)
992 (mouse-scroll-subr start-window (- mouse-row top)
993 nil start-point))
994 ((>= mouse-row bottom)
995 (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
996 nil start-point))))))
997 (visible-mark-move-overlays))) ; ian, added this
998
999
1000 ;; Handle the terminating event if possible.
1001 (when (consp event)
1002 ;; Ensure that point is on the end of the last event.
1003 (when (and (setq end-point (posn-point (event-end event)))
1004 (eq (posn-window end) start-window)
1005 (integer-or-marker-p end-point)
1006 (/= start-point end-point))
1007 (mouse--drag-set-mark-and-point start-point
1008 end-point click-count))
1009
1010 ;; Find its binding.
1011 (let* ((fun (key-binding (vector (car event))))
1012 (do-multi-click (and (> (event-click-count event) 0)
1013 (functionp fun)
1014 (not (memq fun '(mouse-set-point
1015 mouse-set-region))))))
1016 (if (and (/= (mark) (point))
1017 (not do-multi-click))
1018
1019 ;; If point has moved, finish the drag.
1020 (let* (last-command this-command)
1021 (and mouse-drag-copy-region
1022 do-mouse-drag-region-post-process
1023 (let (deactivate-mark)
1024 (copy-region-as-kill (mark) (point)))))
1025
1026 ;; Otherwise, run binding of terminating up-event.
1027 (if do-multi-click
1028 (goto-char start-point)
1029 (deactivate-mark)
1030 (unless moved-off-start
1031 ;; ian: poping the mark is a poor choice of behavior.
1032 ;; we should delete the mark instead.
1033 ;; The first way I found to delete it is to pop it first
1034 (pop-mark)
1035 (setq mark-ring (nbutlast mark-ring))))
1036
1037 (when (and (functionp fun)
1038 (= start-hscroll (window-hscroll start-window))
1039 ;; Don't run the up-event handler if the window
1040 ;; start changed in a redisplay after the
1041 ;; mouse-set-point for the down-mouse event at
1042 ;; the beginning of this function. When the
1043 ;; window start has changed, the up-mouse event
1044 ;; contains a different position due to the new
1045 ;; window contents, and point is set again.
1046 (or end-point
1047 (= (window-start start-window)
1048 start-window-start)))
1049
1050 (when (and on-link
1051 (= start-point (point))
1052 (mouse--remap-link-click-p start-event event))
1053
1054 ;; If we rebind to mouse-2, reselect previous selected
1055 ;; window, so that the mouse-2 event runs in the same
1056 ;; situation as if user had clicked it directly. Fixes
1057 ;; the bug reported by juri@jurta.org on 2005-12-27.
1058 (if (or (vectorp on-link) (stringp on-link))
1059 (setq event (aref on-link 0))
1060 (select-window original-window)
1061 (setcar event 'mouse-2)
1062 ;; If this mouse click has never been done by the
1063 ;; user, it doesn't have the necessary property to be
1064 ;; interpreted correctly.
1065 (put 'mouse-2 'event-kind 'mouse-click)))
1066 (push event unread-command-events)))))))
1067 #+end_src
1068
1069 ** mouse 3
1070 #+begin_src emacs-lisp :tangle no
1071
1072
1073 (defun mouse3-range-mark (start click click-count)
1074 (let* ((range (mouse-start-end start click click-count))
1075 (beg (nth 0 range))
1076 (end (nth 1 range)))
1077 (cond ((<= click start)
1078 (set-mark beg))
1079 (t
1080 (set-mark end))))
1081 (visible-mark-move-overlays))
1082
1083
1084 (defun mouse3-set-mark (event)
1085 "in development"
1086 (interactive "e")
1087 (mouse-minibuffer-check event)
1088 ;; Use event-end in case called from mouse-drag-region.
1089 ;; If EVENT is a click, event-end and event-start give same value.
1090 (set-mark (posn-point (event-end event)))
1091 (visible-mark-move-overlays))
1092
1093
1094 (defun mouse3-func (start-event)
1095 "in development"
1096 (interactive "e")
1097
1098 (run-hooks 'mouse-leave-buffer-hook)
1099
1100 (mouse-minibuffer-check start-event)
1101 (setq mouse-selection-click-count-buffer (current-buffer))
1102 (push-mark (posn-point (event-end start-event)))
1103
1104 (let* ((scroll-margin 0) ; Avoid margin scrolling (Bug#9541).
1105 (original-window (selected-window))
1106 ;; We've recorded what we needed from the current buffer and
1107 ;; window, now let's jump to the place of the event, where things
1108 ;; are happening.
1109 ;(_ (mouse-set-point start-event)) ; ian: commented, replaced
1110 (echo-keystrokes 0)
1111 (start-posn (event-start start-event))
1112 (start-point (posn-point start-posn))
1113 (start-window (posn-window start-posn))
1114 (start-window-start (window-start start-window))
1115 (start-hscroll (window-hscroll start-window))
1116 (bounds (window-edges start-window))
1117 (make-cursor-line-fully-visible nil)
1118 (top (nth 1 bounds))
1119 (bottom (if (window-minibuffer-p start-window)
1120 (nth 3 bounds)
1121 ;; Don't count the mode line.
1122 (1- (nth 3 bounds))))
1123 (click-count (1- (event-click-count start-event)))
1124 ;; Suppress automatic hscrolling, because that is a nuisance
1125 ;; when setting point near the right fringe (but see below).
1126 (auto-hscroll-mode-saved auto-hscroll-mode)
1127 (auto-hscroll-mode nil)
1128 moved-off-start event end end-point)
1129
1130 (setq mouse-selection-click-count click-count)
1131 ;; In case the down click is in the middle of some intangible text,
1132 ;; use the end of that text, and put it in START-POINT.
1133 (if (< (mark) start-point) ; ian: change point to the mark
1134 (set-mark start-point)
1135 (visible-mark-move-overlays))
1136 (setq start-point (mark))
1137
1138 (delete-overlay mouse-hi-ov) ; ian, added this.
1139
1140 ;; Activate the region, using `mouse-start-end' to determine where
1141 ;; to put point and mark (e.g., double-click will select a word).
1142 (let ((range (mouse-start-end start-point start-point click-count)))
1143 (set-mark (nth 1 range)))
1144 (visible-mark-move-overlays)
1145
1146
1147 ;; Track the mouse until we get a non-movement event.
1148 (track-mouse
1149
1150 (while (progn
1151 (setq event (read-event))
1152 (or (mouse-movement-p event)
1153 (memq (car-safe event) '(switch-frame select-window))))
1154 (unless (memq (car-safe event) '(switch-frame select-window))
1155
1156 ;; Automatic hscrolling did not occur during the call to
1157 ;; `read-event'; but if the user subsequently drags the
1158 ;; mouse, go ahead and hscroll.
1159 (let ((auto-hscroll-mode auto-hscroll-mode-saved))
1160 (redisplay))
1161 (setq end (event-end event)
1162 end-point (posn-point end))
1163 ;; Note whether the mouse has left the starting position.
1164
1165 (unless (eq end-point start-point)
1166 (setq moved-off-start t))
1167 (if (and (eq (posn-window end) start-window)
1168 (integer-or-marker-p end-point))
1169 (mouse3-range-mark start-point end-point click-count); ian, set mark
1170
1171 ; do scrolling if needed
1172 (let ((mouse-row (cdr (cdr (mouse-position)))))
1173 (cond
1174 ((null mouse-row))
1175 ((< mouse-row top)
1176 (mouse-scroll-subr start-window (- mouse-row top)
1177 nil start-point))
1178 ((>= mouse-row bottom)
1179 (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
1180 nil start-point))))))))
1181
1182 ;; Handle the terminating event if possible.
1183 (when (consp event)
1184 ;; Ensure that point is on the end of the last event.
1185 (when (and (setq end-point (posn-point (event-end event)))
1186 (eq (posn-window end) start-window)
1187 (integer-or-marker-p end-point)
1188 (/= start-point end-point))
1189 ;(mouse--drag-set-mark-and-point start-point ; ian, set mark
1190 ;end-point click-count))
1191 (mouse3-range-mark start-point end-point click-count)); ian, set mark
1192
1193 ;; Find its binding.
1194 (let* ((fun (key-binding (vector (car event))))
1195 (do-multi-click (and (> (event-click-count event) 0)
1196 (functionp fun)
1197 (not (memq fun '(mouse3-set-mark))))))
1198 (if (and (/= end-point start-point)
1199 (not do-multi-click))
1200
1201 ;; If point has moved, finish the drag.
1202 (let* (last-command this-command)
1203 (and mouse-drag-copy-region
1204 do-mouse-drag-region-post-process
1205 (let (deactivate-mark)
1206 (copy-region-as-kill (mark) (point)))))
1207
1208 ;; Otherwise, run binding of terminating up-event.
1209 (when do-multi-click
1210 (set-mark start-point)) ; ian, change this. why?
1211 (visible-mark-move-overlays)
1212
1213
1214 (when (and (functionp fun)
1215 (= start-hscroll (window-hscroll start-window))
1216 ;; Don't run the up-event handler if the window
1217 ;; start changed in a redisplay after the
1218 ;; mouse-set-point for the down-mouse event at
1219 ;; the beginning of this function. When the
1220 ;; window start has changed, the up-mouse event
1221 ;; contains a different position due to the new
1222 ;; window contents, and point is set again.
1223 (or end-point
1224 (= (window-start start-window)
1225 start-window-start)))
1226
1227 (push event unread-command-events)))))))
1228
1229 #+end_src
1230
1231
1232
1233
1234
1235 * disabled planning to fix
1236 ** speedbar
1237 (sr-speedbar-close)
1238 (sr-speedbar-open)
1239
1240 #+begin_src emacs-lisp :tangle no
1241 (require 'sr-speedbar)
1242 (setq speedbar-hide-button-brackets-flag t ;; didn't notice a diff
1243 speedbar-file-unshown-regexp "flycheck-.*"
1244 sr-speedbar-width 40
1245 sr-speedbar-width-x 40
1246 sr-speedbar-auto-refresh nil
1247 sr-speedbar-skip-other-window-p t
1248 sr-speedbar-right-side nil
1249 speedbar-hide-button-brackets-flag nil)
1250 #+end_src
1251
1252 * TODO investigate modes i had installed, but removed due to not using:
1253 inf-ruby
1254 jedi
1255 key-chord
1256 paredit
1257 python-info
1258 rust-mode
1259 python-mode
1260 tabulated-list
1261 python-environment
1262 popup
1263 transient
1264 lv
1265 outorg
1266 ac-haskell-process
1267 ghc
1268
1269 * TODO in init.el, use (expand-file-name "myinit.el" init-dir) instead of ~/.emacs.d
1270 so it could be relocated
1271 * TODO fix auto save to be reliable and not rely on idle time
1272 sometimes emacs or computer stays busy and idle never comes
1273 * TODO try out which key mode
1274 * TODO make installed emacs package declarative
1275 * TODO see if there are more cool functions in sh-script
1276 like sh-cd-here, and bind that to a key
1277 * TODO assign a key to append-next-kill
1278 * TODO keybinds to remember
1279
1280 keys worth memorizing
1281
1282 c-2
1283 c-m-3
1284
1285 s-return
1286
1287 in isearch, C-o
1288 isearch-occur
1289
1290 org, C-c / t
1291 make just todo items visible
1292
1293 C-mouse-1
1294 buffer list menu
1295
1296 C-up/down
1297 move up/down fast
1298
1299 M-right-scroll
1300 forward/back sexp
1301
1302 C-M-right-scroll
1303 scroll
1304
1305 C-S-scroll
1306 change text size
1307
1308 how to control+left scroll on kinesis
1309 right shift = control
1310
1311 C-left-scroll
1312 forward/backward word
1313
1314 C-M-d
1315 swap buffers across windows
1316
1317 shell-cd-to-file
1318 M-2
1319
1320 * TODO add simpler keybind for make-frame-command
1321 current one is C-x 5 2.
1322
1323 * TODO learn some more ivy mode stuff
1324 * TODO declarative package installations,
1325 with documentation.
1326 * TODO shell mode reverse search hides 2nd+ line of multi-line result
1327 * TODO figure out browsing files with broken nfs mount
1328 causes emacs to freeze until I kill -9 it.
1329 * TODO make a keybind to print var under cursor
1330 and actually, putting the start of it in th emodeline might be cool
1331 * TODO make recent files save periodically,
1332 normally it just saves on exit, but half the time I don't exit cleanly
1333 so they don't get saved, because I leave emacs running until it crashes
1334 * TODO fix undo tree outside visible buffer bug
1335 * TODO c-<delete> in shell mode should send over
1336 previous line if current line is empty
1337 * TODO make c-m-s be just a control key for easier use
1338 * TODO try out avy mode for laptop
1339 i used to have ace jump mode, but google says avy is better.
1340 * TODO bind a in group mode of gnus to c-u a,
1341 also, make a default for number of articles
1342 * TODO make auto-complete be on by default in sql-mode
1343 * TODO make an easy bind for open previous buffer
1344 * TODO i think my autosave for sudo-edit might be too fast
1345 it sometimes leaves #_asdfjasdf files littered
1346 * TODO readline-compleste doesn't work when you cat a file without a newline,
1347 and so the prompt is messed up. not sure exactly what needs to be in end, or if its anything
1348 * TODO figure out how to paste a path into find file
1349 probably have to use the old kind of find file
1350 * TODO readline-complete doesn't escape special chars in filenames
1351 * TODO readline-complete dev
1352
1353
1354
1355 ** misc fixes
1356
1357 bad code, the comment this relates to was removed, but not the comment
1358 /* If waiting for this channel, arrange to return as
1359 soon as no more input to be processed. No more
1360 waiting. */
1361
1362
1363 (status_notify): New arg WAIT_PROC. this is unused, this is a bug.
1364 The change in status_notify's return is just passing more information
1365 from what it did already. No changes at all inside this function.
1366
1367 * TODO consider whether to bind indent-for-tab-command
1368 I removed it from m-tab for terminal compatibility.
1369 It's the default tab command, which yasnippet replaces.
1370 * TODO readline-complete: remove the hardcoded rlc-no-readline-hook
1371 * TODO isearch doesn't automatically wrap in info
1372 * TODO look into fixing shell mode reverse search
1373 and why auto-complete dies
1374 caveat is that it doesn't work well with certain unusual prompts, for example if $/# is not used at the end
1375 see if we can load history, or reverse search with history commands
1376 * TODO keybinds for s-delete/tab etc
1377 * TODO fix bbdb info packaging in melpa
1378 * TODO figure out why my emacs startup script doesn't work from dmenu
1379 * TODO post idea to make customize group show function var names so we can read doc strings
1380 * TODO report/fix bug that kill-whole-line doesn't work right with append kill
1381 * TODO make bash keybind for copy paste interoperate with x windows
1382 * TODO fix org stderr redirection
1383 make this produce output of "ok"
1384 #+begin_src sh
1385 echo ok >&2
1386
1387 #+end_src
1388 * TODO make ido keybinds better
1389 * TODO fix indenting in org
1390
1391 (defun my-org-indent-region (start end)
1392 "Indent region."
1393 (interactive "r")
1394 (save-excursion
1395 (let ((line-end (org-current-line end)))
1396 (goto-char start)
1397 (while (< (org-current-line) line-end)
1398 (cond ((org-in-src-block-p) (org-babel-do-in-edit-buffer (indent-according-to-mode)))
1399 (t (call-interactively 'org-indent-line)))
1400 (move-beginning-of-line 2)))))
1401
1402
1403
1404 org-indent-region is broken for source blocks
1405 the above function works, but has several problems.
1406 first: it should not have separate logic from org-indent-line
1407 second: it runs way too slow, mainly the command
1408 (org-babel-do-in-edit-buffer (indent-according-to-mode)))
1409
1410
1411 * TODO figure out newline in prompt shell issue
1412 setting this before readline-complete is loaded allows completion to work,
1413 but auto-completion still fails. Need to debug readline-complete to figure this out.
1414 (setq shell-prompt-pattern "^[^#$%>]*[#$]\n")
1415 * TODO setup bind for find tag / lisp function at point
1416
1417 * TODO org-delete-char should also work for the delete/backspace keys!
1418 fix and send patch
1419
1420 * TODO checkout projectile / graphene's project settings
1421
1422 * TODO check up on recent changes to 3rd party default configs
1423 - last checked apr 24
1424 https://github.com/eschulte/emacs24-starter-kit/commits/master
1425
1426 last checked mayish
1427 https://github.com/bbatsov/prelude
1428 - redefined mouse functions from this file
1429
1430 * TODO figure out how to setup emacs to format text nicely like thunderbird
1431 * TODO it appears impossible make C-[ not be the same as escape
1432 * TODO movement within info buffer after opening a link doesn't cancel isearch
1433 leads to many frustrations
1434 * TODO fix org resolve clock message. it is innacurate
1435 i is not the same, becuase it does not make org realize there is an active clock
1436
1437 * TODO add apropos commands to help prefix, from
1438 http://stackoverflow.com/questions/3124844/what-are-your-favorite-global-key-bindings-in-emacs
1439 * TODO my autosave goes into an endless prompting loop
1440 when running save buffer, and the buffer has been changed
1441 outside of emacs
1442 * TODO smart peren does not see ?\\) as a valid paren
1443
1444 * TODO why does org-end-of-line not go all the way to the end on a closed headline?
1445 * TODO org makes random ... things, and delete right before them does ctrl-i
1446 * TODO try mark word, which might be a useful keybind
1447 * TODO fix org-cycle: it assumes which key it is bound to for its last alternative
1448 * TODO checkout lisp-complete-symbol to augment auto-complete
1449 * TODO emacs keylogger to optimize key binds
1450 * TODO remap/investigate find tag, find tag at point
1451 * TODO set key to cycle buffers by mode, example below
1452
1453 (defun cycle-buffer-by-mode (p-mode)
1454 "Cycle buffers by mode name"
1455 (interactive)
1456 (dolist (buffer (buffer-list))
1457 (with-current-buffer buffer
1458 (when (buffer-live-p buffer)
1459 (if (string-match p-mode mode-name) ;(regexp-quote p-mode)
1460 (setq switch2buffer buffer)))))
1461 (when (boundp 'switch2buffer)
1462 (switch-to-buffer switch2buffer)))
1463
1464 And I have bound this to my F9 key
1465
1466 (global-set-key [f9] '(lambda () (interactive) (cycle-buffer-by-mode "Shell$")))
1467
1468 * TODO test out usefulness of forward/back sexp in different languages
1469
1470 * TODO major mode settings to check out in future
1471 ** emacs24 starter kit
1472 - Nxhtml -- utilities for web development
1473 [[http://ourcomments.org/Emacs/nXhtml/doc/nxhtml.html][Nxhtml]] is a large package of utilities for web development and for
1474 embedding multiple major modes in a single buffer.
1475
1476 Nxhtml is not installed in this version of the starter-kit by default,
1477 for information on installing nxhtml see [[http://www.emacswiki.org/emacs/NxhtmlMode][EmacsWiki-Nxhtml]].
1478
1479 web-mode is competing package and actively developed, so i'm using that instead
1480
1481
1482 (dolist (package '(yaml-mode js2-mode))
1483 (unless (package-installed-p package)
1484
1485 - Associate modes with file extensions
1486
1487 (add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . diff-mode))
1488 (add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
1489 (require 'yaml-mode)
1490 (add-to-list 'auto-mode-alist '("\\.ya?ml$" . yaml-mode))
1491 (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
1492 (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
1493 (add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js2-mode))
1494 ;; (add-to-list 'auto-mode-alist '("\\.xml$" . nxml-mode))
1495
1496 - clojure in starter-kit-lisp.org
1497
1498 - others = gnus, js, publish, perl, python, perl, ruby
1499 they each have their own starter kit file.
1500
1501 - snippets for various modes other than org-mode
1502
1503 * TODO update yasnippet documentation
1504 yas expand key customization is rediculously hard to figure out
1505 and completely undocumented
1506 * TODO fix org source indenting, send patch
1507 * TODO check out bundling aka compiling yasnippet
1508 * TODO try xml/html mode url func
1509
1510 (defun view-url ()
1511 "Open a new buffer containing the contents of URL."
1512 (interactive)
1513 (let* ((default (thing-at-point-url-at-point))
1514 (url (read-from-minibfer "URL: " default)))
1515 (switch-to-buffer (url-retrieve-synchronously url))
1516 (rename-buffer url t)
1517 ;; TODO: switch to nxml/nxhtml mode
1518 (cond ((search-forward "<?xml" nil t) (xml-mode))
1519 ((search-forward "<html" nil t) (html-mode)))))
1520
1521 * TODO flyspell-buffer automatically
1522
1523 * TODO respond to ediff thread
1524 * TODO fix horizontal mouse resizing
1525 resizing a window horizontally with the mouse should be allowed in more places
1526
1527 * TODO try using / making abbreviations
1528
1529 * TODO move over to ivy, ditch ido
1530
1531 * key binds. keep at end of file
1532 this should come at the end because it depends on key maps being
1533 created in earlier sections.
1534
1535 ** emacs keys notes
1536 commands not needed in ido mode and their replacement in ido mode
1537 spell check fix -> use current pattern and start new one
1538 narrow -> create subdirectory
1539 org-cycle -> M-s search recently used directory
1540 vert split Window -> create file instead of select match
1541 delete-other-windows -> open dired buffer
1542 delete current window -> delete buffer/file
1543 find file -> search within all subdirectories
1544
1545 forward/back error
1546
1547 buffer select -> toggle find file / buffer
1548 up/down -> next/previous history
1549 forward/back -> ido-forward/back
1550
1551
1552 right keyboard attributes: movement, involve typing words
1553 left keyboard attributes: non-typing universal non-movement
1554
1555
1556
1557
1558 todo
1559 fix global unpop mark ring
1560 setup helm
1561 learn cedet and projectile and helm
1562 setup key for pop-global-mark
1563 try out C-M-\ indent region
1564 set quoted insert to some obscure keybind
1565 make currently overrided M-u uppercase word into something obscure
1566 remember mode
1567 bind shell-command to something better
1568 investigate tags
1569 investigate keys in isearch mode and find file mode
1570 try out occur. M-s o
1571 investigate programming modes. M-g n/b next/previous error. gdb?
1572 investigate org mode keys
1573 learn version control
1574 learn mail
1575 check out imenu
1576 bind capitalize-word to something obscure
1577 sentance/paragraph movement/marking should be swapped with sexp/paren movement based on mode
1578 bind fill-paragraph to something obscure
1579 setup linewise paste
1580 install magit (git control)
1581 magpie expansion provides a completion key for acronym expansion based on buffer text
1582 learn ediff
1583 universal google
1584 figure out auto-indent
1585 learn eshell and prelude settings for it
1586 combine register prefix and c-x prefix
1587 note: remember to think of mouse & foot pedals
1588 commands to change: select other window: C-x o.
1589
1590 ** named commands
1591 *** gdb
1592 gdb-many-windows
1593 *** tramp sudo
1594 /ssh:host|sudo:host:
1595 when in the same session, you can then do:
1596 /sudo:root@host:
1597
1598 *** org insert table row
1599 [org-shiftmetadown/up]
1600 *** toggle line continuation / truncation / wrap
1601 toggle-truncate-lines
1602 *** auto-save on/off
1603 my-as-on/my-as-off
1604 *** toggle menu bar
1605 menu-bar-mode
1606 *** show abbreviations
1607 list-abbrevs
1608
1609 *** rename-file-and-buffer
1610 *** ediff-buffers
1611 *** refill-mode
1612 automatically balance a paragraph with newlines
1613 *** executable-make-buffer-file-executable-if-script-p
1614 make a script executable
1615 *** (setq lazy-highlight-cleanup nil)
1616 keep search highlight on after search is done
1617 *** auto-revert-tail-mode
1618 tail a file
1619 *** what-line
1620 *** linum-mode
1621 line numbers
1622
1623 *** sgml-pretty-print
1624 format xml in nxml-mode
1625 *** visual-line-mode
1626 toggle word wrap.
1627 ** compound commands
1628 *** C-xc
1629 exit0
1630 *** C-x s
1631 save file
1632 *** C-x e
1633 eval last sexp
1634 *** C-c -
1635 [org insert table horizontal line or create list]
1636 *** C-x tab
1637 indent/dedent region
1638
1639 *** C-x *
1640 [calc-dispatch]
1641 *** C-x =
1642 [point information]
1643 *** C-x d
1644 [dired]
1645 *** C-xb
1646 [ibuffer]
1647
1648 *** C-x r c
1649 rectangular clear, replace area with whitespace
1650 ** gnus
1651 searching overview.
1652 3 types:
1653 ingroup searching
1654 nnir searching with notmuch, specific group (not sure if it can do multiple)
1655 search all groups with mairix
1656 *** a]
1657 compose new message
1658 *** C-c C-c]
1659 send message
1660 *** s]
1661 save newsrc file, alterations to groups.
1662 *** g]
1663 gnus refresh / get new
1664 *** m]
1665 gnus new message
1666 *** F]
1667 gnus quoted reply all
1668 *** e]
1669 gnus draft edit message
1670 *** delete]
1671 gnus delete draft
1672 #+begin_src emacs-lisp
1673 (add-hook 'gnus-startup-hook
1674 (lambda ()
1675 (define-key gnus-summary-mode-map (kbd "<delete>") 'gnus-summary-delete-article)))
1676 #+end_src
1677
1678 *** b]
1679 mairix search
1680 #+begin_src emacs-lisp
1681 (add-hook 'gnus-startup-hook
1682 (lambda ()
1683 (define-key gnus-group-mode-map "b" 'nnmairix-search)
1684 (define-key gnus-summary-mode-map "b" 'nnmairix-search)))
1685 #+end_src
1686 *** B m]
1687 move message, or messages in region
1688 *** #]
1689 mark article, move with B m
1690 *** B delete]
1691 gnus delete draft
1692 *** / plus x a / b]
1693 search current group (or see info manual for more groups),
1694 using the gnus native search (its slow, do a notmuch or mairix search instead)
1695 x= extra (ie. to)
1696 todo; send in patch to make author search to in sent folder
1697 a = author
1698 / = subject
1699 b = body
1700 see C-h m for a full list
1701 *** G G ]
1702 do a nnir notmuch search, for the group on the current line
1703 *** A T ]
1704 jump to thread from nnir group
1705
1706 *** marks]
1707 ! = saved for later
1708 E = expired
1709 M-& apply process mark to a non-process mark command
1710 *** S D e]
1711 edit as new
1712 *** T k / C-M-k
1713 maybe rebind this to a shorter keybind, like del
1714 gnus-summary-kill-thread
1715 ** message mode
1716 *** C-ck]
1717 discard message
1718 ** notmuch
1719 *** space]
1720 notmuch advance to next message/thread
1721
1722 ** readline / bash / .inputrc
1723 *** C-m
1724 [--------]
1725 terminal crap, duplicate of enter
1726
1727 ** isearch
1728 *** C-w
1729 paste word/char under cursor into isearch
1730 *** M-n/p
1731 next/previous isearch history
1732 *** C-o
1733 *** m-r
1734
1735 ** icomplete
1736 *** C-. C-,
1737 icomplete-forward/backward-completions
1738
1739 ** info
1740 *** [, ]
1741 forward / previous node, descend/ascend tree as needed
1742 *** x
1743 Info-follow-nearest-node
1744
1745 m, f, n, p or ^ command, depending on where you click.
1746 ** auto-complete
1747 *** S-return
1748 select next completion candidate
1749 ac-expand
1750 ** agenda
1751 *** t]
1752 agenda cycle todo state
1753 ** org
1754 *** C-c / t]
1755 make just todo items visible
1756 *** S-<tab>
1757 org-shifttab global visibility cycle / move table cell
1758 *** C-cs]
1759 schedule todo item
1760 *** C-cx p]
1761 org set property
1762 *** C-c -]
1763 org insert horizontal line
1764 *** C-cq]
1765 org tag
1766 ** calc
1767 i'd like to drill these sometime when I have space in my head, or I
1768 plan to use calc.
1769 *** space
1770 [enter input to the stack, or duplicate top stack item]
1771 *** C-M-i
1772 [cycle 3 elements on stack]
1773 *** tab
1774 [cycle 2 elements on stack]
1775 *** n
1776 [negate]
1777 *** _
1778 [begin negative number]
1779 *** /
1780 [reciprocal]
1781 *** x
1782 [calc named command]
1783 *** M-delete
1784 [delete 2nd from top of stack]
1785 *** C-u [-]0-9
1786 [0=whole stack, 1-9=that many, -1-9=that element]
1787 *** delete
1788 [remove from the top of the stack]
1789 *** '
1790 [algebraic mode. infix expressions are calculated when input to the stack]
1791 *** m a
1792 [auto algebraic mode]
1793 *** $,$$,$$$
1794 [top x of stack reference]
1795 *** s s/t/r/u
1796 [store to variable: store, top, retrieve, unstore. the quick variables 0-9 don't need s prefix]
1797 *** U/D
1798 [undo/redo]
1799 *** t p/n/]/y
1800 [trail prev/next/end/yankh]
1801 *** `
1802 [calc edit mode, to edit the top of stack]
1803
1804 * keybind tables
1805
1806 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1807 | left primary | C- | M- | C-M- | C-S- |
1808 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1809 | 2 | copy-symbol | shell-cd-to-file | --- | |
1810 | 3 | dot-mode-execute | | recenter-top-bottom | |
1811 | q | mode specific | org-archive-... | quoted-insert | |
1812 | w | find-file | org-clock-in | | |
1813 | e | copy-line | org-clock-in-last | | |
1814 | r | isearch-backward | org-clock-out | | |
1815 | a | copy-all | | | |
1816 | s | C-x prefix | | split-window-vertically | |
1817 | d | C-c prefix | | swap buffer | |
1818 | f | kill-whole-line | print-var-at-point | kill rest of line | |
1819 | g | other-window / cancel | abort-recursive-edit | gnus | |
1820 | z | undo-tree-undo | | | |
1821 | x | kill-region | append-next-kill | append-next-kill | |
1822 | c | copy | org-capture | copy-to-register | |
1823 | v | yank | insert-register | yank pop | |
1824 | b | delete-other-windows | search back symbol | isearch-current-symbol | |
1825 | tab | --- | indent line | | |
1826 | delete | kill-symbol | | kill-sexp | |
1827 | left-arrow | backward-symbol | | org-shiftup | |
1828 | right-arrow | forward-symbol | | org-shiftdown | |
1829 | backspace | backward-kill-symbol | | backward-kill-sexp | |
1830 | f7 | | | | |
1831 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1832 | right primary | C- | M- | C-M- | C-S- |
1833 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1834 | * | split-window-horizontally | | calc-dispatch | |
1835 | 9 | delete-window-or-exit | kill-buffer-and-window | kill client buffer | |
1836 | u | universal-argument | | search-keybind | |
1837 | i | | | query-replace-regexp | |
1838 | o | occur | | counsel-imenu | |
1839 | p | move-mouse-to-point | | delete-horizontal-space | |
1840 | j | pop-to-mark | previous-error | register prefix | |
1841 | k | jump to register | next-error | man | |
1842 | l | ivy-switch-buffer | | cursor top bottom mid | |
1843 | ; | comment-dwim | comment-dwim | comment line | |
1844 | m | | | recursive grep | |
1845 | , | counsel-find-file | | find-file-in-project | |
1846 | . | recentf-ido-find-file | | - | |
1847 | / | join lines | | copy-variable | |
1848 | 8 | calc-embedded-word | | | |
1849 | up-arrow | back defun/headline | | | winner undo |
1850 | down-arrow | forward dfun/headline | | toggle-mark-activation | smex-major-mode |
1851 | lbracket | ---- | | scroll-right | |
1852 | rbracket | fill-paragraph | | scroll-left | |
1853 | return | newline next line | newline plain | | |
1854 | space | org-edit-special | | spell check word | |
1855 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1856 | left secondary | C- | M- | C-M- | C-S- |
1857 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1858 | = | | | | |
1859 | 1 | | | | |
1860 | 4 | | | widen | |
1861 | 5 | | | | |
1862 | tab-key | query-replace | | | |
1863 | t | org change todo state | | org insert timestamp | |
1864 | home | start of buffer | | | |
1865 | end | end of buffer | | | |
1866 | f9 | | | | |
1867 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1868 | right secondary | C- | M- | C-M- | C-S- |
1869 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1870 | 6 | | | insert-small-copyright | save-buffers-kill-emacs |
1871 | 7 | | | insert-full-copyright | |
1872 | 0 | text-scale-reset | | insert-apache | |
1873 | - | | | org-edit-src-exit | |
1874 | y | undo-tree-redo | | | |
1875 | \ | sr-speedbar-toggle | | mark-defun | |
1876 | h | help-prefix | | | |
1877 | ' | eval-expression | | | |
1878 | n | unpop-to-mark-command | | narrow-to-region | |
1879 | rshift | | | | |
1880 | escape | find-tag | | | |
1881 |-----------------+---------------------------+------------------------+-------------------------+-------------------------|
1882
1883 * keybind notes
1884 todo:
1885
1886
1887 common keys, which would be better off doing swaps than rebinds:
1888 c-x prefix -> c-s
1889 c-c prefix -> c-d
1890 yank c-y -> c-c
1891 search c-s -> kp-add
1892 kill line c-k -> c-f
1893 undo c-_ -> c-z
1894 set-mark-command c-@ -> kp-enter
1895 quoted-insert c-q -> c-m-q
1896 recenter-top-bottom c-l -> c-m-3
1897 kill-region c-w -> c-x
1898
1899 commands to make less accessible
1900 narrow-to-defun/subtree -> M-2 maybe
1901 occur
1902
1903 command to make more accessible, ...
1904
1905 * TESTING / DEVELOPMENT AREA
1906
1907 (defun comint-send-string (process string)
1908 "Like `process-send-string', but also does extra bookkeeping for Comint mode."
1909 (if process
1910 (with-current-buffer (if (processp process)
1911 (process-buffer process)
1912 (get-buffer process))
1913 (comint-snapshot-last-prompt))
1914 (comint-snapshot-last-prompt))
1915 (process-send-string process string))