ido.el 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. (ido-mode 1)
  2. (setq ido-enable-flex-matching t)
  3. (setq ido-everywhere t)
  4. (setq ido-use-filename-at-point 'guess)
  5. (setq ido-create-new-buffer 'always)
  6. (setq ido-file-extensions-order
  7. '(".org" ".txt" ".py" ".emacs" ".xml" ".el" ".ini" ".cfg" ".cnf"))
  8. ; Ignore object files
  9. (setq ido-ignore-extensions t)
  10. ;; Maybe we can disable tramp stuff via this?
  11. ;(setq ido-work-directory-list-ignore-regexps
  12. ; Always open in the same window
  13. (setq ido-default-buffer-method 'selected-window)
  14. ;;;;;;;;;;;;;;
  15. ;; imenu & ido
  16. ;;;;;;;;;;;;;;
  17. ; Thanks emacswiki.org!
  18. (defun ido-goto-symbol (&optional symbol-list)
  19. "Refresh imenu and jump to a place in the buffer using Ido."
  20. (interactive)
  21. (unless (featurep 'imenu)
  22. (require 'imenu nil t))
  23. (cond
  24. ((not symbol-list)
  25. (let ((ido-mode ido-mode)
  26. (ido-enable-flex-matching
  27. (if (boundp 'ido-enable-flex-matching)
  28. ido-enable-flex-matching t))
  29. name-and-pos symbol-names position)
  30. (unless ido-mode
  31. (ido-mode 1)
  32. (setq ido-enable-flex-matching t))
  33. (while (progn
  34. (imenu--cleanup)
  35. (setq imenu--index-alist nil)
  36. (ido-goto-symbol (imenu--make-index-alist))
  37. (setq selected-symbol
  38. (ido-completing-read "Symbol? " symbol-names))
  39. (string= (car imenu--rescan-item) selected-symbol)))
  40. (unless (and (boundp 'mark-active) mark-active)
  41. (push-mark nil t nil))
  42. (setq position (cdr (assoc selected-symbol name-and-pos)))
  43. (cond
  44. ((overlayp position)
  45. (goto-char (overlay-start position)))
  46. (t
  47. (goto-char position)))))
  48. ((listp symbol-list)
  49. (dolist (symbol symbol-list)
  50. (let (name position)
  51. (cond
  52. ((and (listp symbol) (imenu--subalist-p symbol))
  53. (ido-goto-symbol symbol))
  54. ((listp symbol)
  55. (setq name (car symbol))
  56. (setq position (cdr symbol)))
  57. ((stringp symbol)
  58. (setq name symbol)
  59. (setq position
  60. (get-text-property 1 'org-imenu-marker symbol))))
  61. (unless (or (null position) (null name)
  62. (string= (car imenu--rescan-item) name))
  63. (add-to-list 'symbol-names name)
  64. (add-to-list 'name-and-pos (cons name position))))))))
  65. (global-set-key (kbd "\C-ci") 'ido-goto-symbol)
  66. ;;Aditional
  67. (setq ido-max-prospects 200)
  68. (require 'ido-recentf-open)
  69. (recentf-mode 1)
  70. (global-set-key (kbd "C-x C-r") 'ido-recentf-open)
  71. ;; Fix Warning
  72. (defvar ido-cur-item nil)
  73. (defvar ido-default-item nil)
  74. (defvar ido-cur-list nil)
  75. (defvar predicate nil)
  76. (defvar inherit-input-method nil)
  77. ;; Use ido everywhere
  78. (require 'ido-ubiquitous)
  79. (ido-ubiquitous-mode 1)
  80. (require 'ido-vertical-mode)
  81. (ido-vertical-mode)
  82. ;; Fix ido-ubiquitous for newer packages
  83. (defmacro ido-ubiquitous-use-new-completing-read (cmd package)
  84. `(eval-after-load ,package
  85. '(defadvice ,cmd (around ido-ubiquitous-new activate)
  86. (let ((ido-ubiquitous-enable-compatibility nil))
  87. ad-do-it))))
  88. (ido-ubiquitous-use-new-completing-read webjump 'webjump)
  89. (ido-ubiquitous-use-new-completing-read yas/expand 'yasnippet)
  90. (ido-ubiquitous-use-new-completing-read yas/visit-snippet-file 'yasnippet)