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