Mercurial > dotfiles
annotate .elisp/settings/50.localfuncs.el @ 129:1286c27cf0c0
Need to use paths default instead of the outdated svn url now.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Thu, 23 Jul 2009 10:23:52 -0500 |
parents | 34b698771af9 |
children | e30655eb7050 |
rev | line source |
---|---|
89
f34d90569fdc
Add a file for local functions not yet extracted into a module. Includes a function to run pyflakes on the current buffer.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 (defun pyflakes-this-buffer () |
f34d90569fdc
Add a file for local functions not yet extracted into a module. Includes a function to run pyflakes on the current buffer.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 (interactive) |
91
075b45c5aecc
cd to the file dir before running pyflakes to make output less verbose.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
3 (compilation-start (concat "cd " |
075b45c5aecc
cd to the file dir before running pyflakes to make output less verbose.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
4 (file-name-directory buffer-file-name) |
96
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
5 "; pyflakes " (file-name-nondirectory |
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
6 buffer-file-name)) |
91
075b45c5aecc
cd to the file dir before running pyflakes to make output less verbose.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
7 nil |
075b45c5aecc
cd to the file dir before running pyflakes to make output less verbose.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
8 (lambda (mode) "*pyflakes*"))) |
96
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
9 |
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
10 |
98
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
11 (defun ido-imenu () |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
12 "Update the imenu index and then use ido to select a symbol to navigate to. |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
13 Symbols matching the text at point are put first in the completion list." |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
14 (interactive) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
15 (imenu--make-index-alist) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
16 (let ((name-and-pos '()) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
17 (symbol-names '())) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
18 (flet ((addsymbols (symbol-list) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
19 (when (listp symbol-list) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
20 (dolist (symbol symbol-list) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
21 (let ((name nil) (position nil)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
22 (cond |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
23 ((and (listp symbol) (imenu--subalist-p symbol)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
24 (addsymbols symbol)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
25 |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
26 ((listp symbol) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
27 (setq name (car symbol)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
28 (setq position (cdr symbol))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
29 |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
30 ((stringp symbol) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
31 (setq name symbol) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
32 (setq position (get-text-property 1 'org-imenu-marker symbol)))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
33 |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
34 (unless (or (null position) (null name)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
35 (add-to-list 'symbol-names name) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
36 (add-to-list 'name-and-pos (cons name position)))))))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
37 (addsymbols imenu--index-alist)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
38 ;; If there are matching symbols at point, put them at the beginning of `symbol-names'. |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
39 (let ((symbol-at-point (thing-at-point 'symbol))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
40 (when symbol-at-point |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
41 (let* ((regexp (concat (regexp-quote symbol-at-point) "$")) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
42 (matching-symbols (delq nil (mapcar (lambda (symbol) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
43 (if (string-match regexp symbol) symbol)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
44 symbol-names)))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
45 (when matching-symbols |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
46 (sort matching-symbols (lambda (a b) (> (length a) (length b)))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
47 (mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names)))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
48 matching-symbols))))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
49 (let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names)) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
50 (position (cdr (assoc selected-symbol name-and-pos)))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
51 (goto-char position)))) |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
52 |
8aa70b521063
Jump-to-function trick with IDO.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
53 |
96
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
54 (defun fullscreen () |
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
55 (interactive) |
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
56 (set-frame-parameter nil 'fullscreen |
0eabfd7a8ffa
Add a fullscreen function, cleanup.
Augie Fackler <durin42@gmail.com>
parents:
91
diff
changeset
|
57 (if (frame-parameter nil 'fullscreen) nil 'fullboth))) |
117
67bfc48b2a61
Function for removing a file from Mercurial.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
58 |
67bfc48b2a61
Function for removing a file from Mercurial.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
59 |
67bfc48b2a61
Function for removing a file from Mercurial.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
60 (defun hg-rm-this-file () |
67bfc48b2a61
Function for removing a file from Mercurial.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
61 (interactive) |
124
2ae20e96f6c0
Should really shell quote this arg.
Augie Fackler <durin42@gmail.com>
parents:
117
diff
changeset
|
62 (shell-command-to-string (concat "hg rm " (shell-quote-argument buffer-file-name)))) |
125
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
63 |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
64 ;; Lifted from http://code.google.com/p/ergoemacs/ |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
65 (defun select-text-in-quote () |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
66 "Select text between the nearest left and right delimiters. |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
67 Delimiters are paired characters: ()[]<>«»“”‘’「」, including \"\"." |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
68 (interactive) |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
69 (let (b1 b2) |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
70 (skip-chars-backward "^<>(“{[「«\"‘") |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
71 (setq b1 (point)) |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
72 (skip-chars-forward "^<>)”}]」»\"’") |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
73 (setq b2 (point)) |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
74 (set-mark b1) |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
75 ) |
15bcc3e0afeb
Function for selecting text inside of a quote pair.
Augie Fackler <durin42@gmail.com>
parents:
124
diff
changeset
|
76 ) |
126 | 77 |
78 ;; Most of this was extracted from show-paren-function in paren.el from an emacs 23 nightly | |
79 ;; Also, it seems like this really ought to be builtin, but I can't find it. | |
80 (defun bounce-to-other-paren () | |
81 (interactive) | |
82 (let ((oldpos (point)) | |
83 (dir (cond ((eq (syntax-class (syntax-after (1- (point)))) 5) -1) | |
84 ((eq (syntax-class (syntax-after (point))) 4) 1))) | |
85 pos mismatch face) | |
86 ;; | |
87 ;; Find the other end of the sexp. | |
88 (when dir | |
89 (save-excursion | |
90 (save-restriction | |
91 ;; Determine the range within which to look for a match. | |
92 (when blink-matching-paren-distance | |
93 (narrow-to-region | |
94 (max (point-min) (- (point) blink-matching-paren-distance)) | |
95 (min (point-max) (+ (point) blink-matching-paren-distance)))) | |
96 ;; Scan across one sexp within that range. | |
97 ;; Errors or nil mean there is a mismatch. | |
98 (condition-case () | |
99 (setq pos (scan-sexps (point) dir)) | |
100 (error (setq pos t mismatch t))) | |
101 ;; Move back the other way and verify we get back to the | |
102 ;; starting point. If not, these two parens don't really match. | |
103 ;; Maybe the one at point is escaped and doesn't really count. | |
104 (when (integerp pos) | |
105 (unless (condition-case () | |
106 (eq (point) (scan-sexps pos (- dir))) | |
107 (error nil)) | |
108 (setq pos nil))) | |
109 ))) | |
110 ;; Highlight the other end of the sexp, or unhighlight if none. | |
111 (if (and pos (integerp pos)) | |
112 (goto-char pos) | |
113 (message "No matching other paren found.") | |
114 ))) |