annotate .elisp/settings/50.localfuncs.el @ 125:15bcc3e0afeb

Function for selecting text inside of a quote pair.
author Augie Fackler <durin42@gmail.com>
date Thu, 09 Jul 2009 13:25:06 -0500
parents 2ae20e96f6c0
children 34b698771af9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 )