-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmustafa-util-func.el
61 lines (51 loc) · 2.39 KB
/
mustafa-util-func.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
;;; Misc. utility functions
(defun m-expand-prog-path (program)
"Returns full PROGRAM path"
(if (or (eq system-type 'gnu/linux) (eq system-type 'darwin))
(let ((path (shell-command-to-string (format "which %s" program))))
(if (not (= (length path) 0)) (substring path 0 -1)))
nil)) ; return nothing for windows for now
(defun ido-imenu ()
"Update the imenu index and then use ido to select a symbol to navigate to."
(interactive)
(require 'imenu)
(imenu--make-index-alist)
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
(let ((name nil) (position nil))
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(addsymbols symbol))
((listp symbol)
(setq name (car symbol))
(setq position (cdr symbol)))
((stringp symbol)
(setq name symbol)
(setq position (get-text-property 1 'org-imenu-marker symbol))))
(unless (or (null position) (null name))
(add-to-list 'symbol-names name)
(add-to-list 'name-and-pos (cons name position))))))))
(addsymbols imenu--index-alist))
(let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
(position (cdr (assoc selected-symbol name-and-pos))))
(goto-char position))))
(defun m-ido-find-tag ()
(interactive)
(visit-tags-table-buffer)
(tags-completion-table)
(let (tag-names)
(mapc (lambda (x)
(unless (integerp x)
(push (prin1-to-string x t) tag-names)))
tags-completion-table)
(find-tag (ido-completing-read "Tag? " tag-names))))
(defun m-paredit-mode-binding (mode-type)
(require 'paredit)
(define-key mode-type (kbd "(") 'paredit-open-parenthesis)
(define-key mode-type (kbd ")") 'paredit-close-parenthesis)
(define-key mode-type (kbd "\"") 'paredit-doublequote)
(define-key mode-type (kbd "[") 'paredit-open-square)
(define-key mode-type (kbd "]") 'paredit-close-square))