comparison .elisp/settings/50.localfuncs.el @ 98:8aa70b521063

Jump-to-function trick with IDO.
author Augie Fackler <durin42@gmail.com>
date Thu, 30 Apr 2009 13:48:22 -0500
parents 0eabfd7a8ffa
children 67bfc48b2a61
comparison
equal deleted inserted replaced
97:5f7b673008b5 98:8aa70b521063
6 buffer-file-name)) 6 buffer-file-name))
7 nil 7 nil
8 (lambda (mode) "*pyflakes*"))) 8 (lambda (mode) "*pyflakes*")))
9 9
10 10
11 (defun ido-imenu ()
12 "Update the imenu index and then use ido to select a symbol to navigate to.
13 Symbols matching the text at point are put first in the completion list."
14 (interactive)
15 (imenu--make-index-alist)
16 (let ((name-and-pos '())
17 (symbol-names '()))
18 (flet ((addsymbols (symbol-list)
19 (when (listp symbol-list)
20 (dolist (symbol symbol-list)
21 (let ((name nil) (position nil))
22 (cond
23 ((and (listp symbol) (imenu--subalist-p symbol))
24 (addsymbols symbol))
25
26 ((listp symbol)
27 (setq name (car symbol))
28 (setq position (cdr symbol)))
29
30 ((stringp symbol)
31 (setq name symbol)
32 (setq position (get-text-property 1 'org-imenu-marker symbol))))
33
34 (unless (or (null position) (null name))
35 (add-to-list 'symbol-names name)
36 (add-to-list 'name-and-pos (cons name position))))))))
37 (addsymbols imenu--index-alist))
38 ;; If there are matching symbols at point, put them at the beginning of `symbol-names'.
39 (let ((symbol-at-point (thing-at-point 'symbol)))
40 (when symbol-at-point
41 (let* ((regexp (concat (regexp-quote symbol-at-point) "$"))
42 (matching-symbols (delq nil (mapcar (lambda (symbol)
43 (if (string-match regexp symbol) symbol))
44 symbol-names))))
45 (when matching-symbols
46 (sort matching-symbols (lambda (a b) (> (length a) (length b))))
47 (mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names))))
48 matching-symbols)))))
49 (let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
50 (position (cdr (assoc selected-symbol name-and-pos))))
51 (goto-char position))))
52
53
11 (defun fullscreen () 54 (defun fullscreen ()
12 (interactive) 55 (interactive)
13 (set-frame-parameter nil 'fullscreen 56 (set-frame-parameter nil 'fullscreen
14 (if (frame-parameter nil 'fullscreen) nil 'fullboth))) 57 (if (frame-parameter nil 'fullscreen) nil 'fullboth)))