Difference between revisions of "Ido"

From WikEmacs
Jump to navigation Jump to search
(propse better package)
 
(27 intermediate revisions by 9 users not shown)
Line 1: Line 1:
'''Ido''' is a wonderful mode which does wonderful things.
+
{{Package
 +
|name=Ido
 +
|author = Kim F. Storm
 +
|description=Interactive Do [[MiniBuffer]] Enhancement
 +
|source=http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/ido.el
 +
|maintainer=[[FSF]]
 +
|in_emacs=yes
 +
|Development status=active
 +
}}
  
<!-----DONT REMOVE ANYTHING FROM THIS TEMPLATE ------------------------------>
+
'''Ido''' - Interactively do things is a very convenient way to find files and switch buffers.
<!-----FEW MONTHS, YEARS FROM WE CAN DELETE STUFF. NOT NOW ------------------>
 
<!-----YOU DON"T WANT WIKEMACS TO BE ANOTHER EMACSWIKI RIGHT ------------------>
 
<!-----PLEASE BE PATIENT AND CO-OPERATE FOR GREATER GOOD ------------------>
 
  
 +
== Basic setup ==
  
 +
<source lang="lisp">
 +
(ido-mode)
 +
(ido-everywhere 1)
 +
</source>
  
<!------------------------------------------------------------------------->
+
== Helpful keybindings ==
 
 
= Basic setup =
 
 
 
Install these third party libraries or read this section before proceeding.
 
  
= Helpful keybindings =
+
; {{Keys|C-s}}
 +
: Move to next ido suggestion.
  
; {{Keys|C-x C-c}}
+
; {{Keys|C-r}}
: Quit Emacs.
+
: Move to previous ido suggestion.
  
; {{CommandKeys|C-x C-s|save-buffer}}
+
; {{Keys|C-f}}
: Save buffer.
+
: Temporarily revert to the default find-file behavior. Handy if [[ido]] won't behave as you'd like.
 
 
<!------------------------------------------------------------------------->
 
= Common Customization =
 
<!-- Customization common to all platforms goes here -->
 
 
 
== Customization 1 ==
 
<source lang="lisp">
 
(message "This stuff will go in your .emacs")
 
</source>
 
 
 
== Customization 2 ==
 
<source lang="lisp">
 
(message "You can also do this customization")
 
</source>
 
  
 +
; {{Keys|C-j}}
 +
: Accept the provided text as is, instead of selecting the currently proposed completion.
  
<!------------------------------------------------------------------------->
+
== Common Customization ==
  
= [[GNU/Linux]] =
+
=== Enable Fuzzy Matching ===
<!-- Customization/Notes specific to GNU/Linux goes here -->
 
== GNU/Linux Notes 1 ==
 
== GNU/Linux Notes 2 ==
 
  
<!------------------------------------------------------------------------->
+
<syntaxhighlight lang="lisp">
 +
(setq ido-enable-flex-matching t)
 +
</syntaxhighlight>
  
= [[OS X]] =
+
=== Ignore Case ===
<!-- Customization/Notes specific to OS X goes here -->
 
== OS X Notes 1 ==
 
== OS X Notes 2 ==
 
  
<!------------------------------------------------------------------------->
+
{{Snippet|(setq ido-case-fold t)}}
  
= [[Windows]] =
+
=== Virtual Buffers ===
<!-- Customization/Notes specific to Windows goes here -->
 
Windows users be aware of this.
 
== Windows Notes 1 ==
 
== Windows Notes 2 ==
 
  
<!------------------------------------------------------------------------->
+
If [[Recentf]] is enabled, you can use {{CommandKeys|C-x b|ido-switch-buffer}} to visit recently closed files by enabling virtual buffers:
 +
{{Snippet|(setq ido-use-virtual-buffers t)}}
  
= [[Emacs-24]] =
+
=== Prevent Auto-Merge ===
<!-- Customization/Notes specific to Emacs-24 -->
 
<!-- Recent revision should come first. This way important information stays at top  -->
 
  
Emacs-24 specific notes.
+
Ido's default behavior when there is no matching file in the current directory is to look in recent working directories. If you prefer to limit {{CommandKeys|C-x C-f|ido-find-file}} to the current directory you can disable this ''auto-merge'' behavior:
 +
{{Snippet|(setq ido-auto-merge-work-directories-length -1) ;; disable auto-merge}}
  
== Emacs-24 specific notes 1 ==
+
You can still look in other working directories explicitly with {{Keys|M-s|ido-merge-work-directories}}.
== Emacs-24 specific notes 2 ==
 
  
<!------------------------------------------------------------------------->
+
=== Directory Caching on Windows ===
  
= [[Emacs-23]] =
+
On [[Windows]] operating systems it can be unreliable to cache directory listings: the directory may not appear to be modified even though files have been added or removed. Ido caches directory listings by default, which may cause confusion on Windows. You can disable caching:
<!-- Customization/Notes specific to Emacs-22 -->
 
Emacs-23 is not as great as Emacs-24. You will have these problems and you can workaround it this way.
 
== Emacs-23 specific notes 1 ==
 
== Emacs-23 specific notes 2 ==
 
  
<!------------------------------------------------------------------------->
+
<syntaxhighlight lang="lisp">
 +
(when (equal system-type 'windows-nt)
 +
  (setq ido-max-dir-file-cache 0)) ; caching unreliable
 +
</syntaxhighlight>
  
= [[Emacs-22]] =
+
=== Specifying sort-order ===
<!-- Customization/Notes specific to Emacs-22 -->
+
If you'd like to tweak the default file sorting, like making [[Org]]-files appear first, tell [[ido]] which files to give a higher sort priority:
 +
<syntaxhighlight lang="lisp">
 +
(setq ido-file-extensions-order '(".org" ".txt" ".py" ".emacs" ".xml" ".el"
 +
  ".ini" ".cfg" ".conf"))
 +
</syntaxhighlight>
  
Seriously...Why are you even looking at this? You suck.  Your Emacs sucks.  Your organization sucks.
+
=== Sort by mtime instead of alphabetically ===
  
== Emacs-24 specific notes 1 ==
+
If you prefer to sort ido filelist by mtime instead of alphabetically use the package [https://github.com/pkkm/ido-sort-mtime ido-sort-mtime] (available in MELPA), which is more reliable than the script below. Which breaks on TRAMP files or if you enter //, etc:
== Emacs-24 specific notes 2 ==
 
  
<!------------------------------------------------------------------------->
+
<syntaxhighlight lang="lisp">
 +
(add-hook 'ido-make-file-list-hook 'ido-sort-mtime)
 +
(add-hook 'ido-make-dir-list-hook 'ido-sort-mtime)
 +
(defun ido-sort-mtime ()
 +
  (setq ido-temp-list
 +
        (sort ido-temp-list
 +
              (lambda (a b)
 +
                (time-less-p
 +
                (sixth (file-attributes (concat ido-current-directory b)))
 +
                (sixth (file-attributes (concat ido-current-directory a)))))))
 +
  (ido-to-end  ;; move . files to end (again)
 +
  (delq nil (mapcar
 +
              (lambda (x) (and (char-equal (string-to-char x) ?.) x))
 +
              ido-temp-list))))
 +
</syntaxhighlight>
  
= Recommended Reading =
 
<!-- Only internal links. DO NOT insert EXTERNAL LINKS -->
 
* [[Internal Link1]]
 
* [[Internal Link2]]
 
  
<!------------------------------------------------------------------------->
+
== See Also ==
  
= Project Pages =
+
[[Helm]]
* [http://bazaar.canonical.com/en/ Bazaar]
 
* [http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html Bzr Users Guide]
 
  
<!------------------------------------------------------------------------->
+
[[Smex]], a M-x enhancement
  
= Tutorial Pages =
+
== External Links ==
;[http://wiki.bazaar.canonical.com/EmacsTips Emacs as commit message editor] 
 
:Tips for setting up Emacs as Bazaar commit editor.
 
  
<!------------------------------------------------------------------------->
+
[http://www.masteringemacs.org/articles/2010/10/10/introduction-to-ido-mode/ Introduction to Ido Mode]
<!-- Add categories based on user-level (beginner etc), user-role (programming, emacs contributor etc), platform (windows, linux etc) or work flow (text editing, document authoring etc)  -->
 
  
 
[[Category:Completion]]
 
[[Category:Completion]]
 +
[[Category:Built-in Package]]
 +
[[Category:MiniBuffer]]
 +
[[Category:Convenience]]
 +
[[Category:Minor Mode]]
 +
[[Category:Buffer Navigation]]
 +
[[Category:Popular Package]]

Latest revision as of 15:04, 29 May 2015

Ido
Description Interactive Do MiniBuffer Enhancement
Author Kim F. Storm
Maintainer FSF
Source http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/ido.el
Part of Emacs yes

Ido - Interactively do things is a very convenient way to find files and switch buffers.

Basic setup

(ido-mode)
(ido-everywhere 1)

Helpful keybindings

[C-s]
Move to next ido suggestion.
[C-r]
Move to previous ido suggestion.
[C-f]
Temporarily revert to the default find-file behavior. Handy if ido won't behave as you'd like.
[C-j]
Accept the provided text as is, instead of selecting the currently proposed completion.

Common Customization

Enable Fuzzy Matching

(setq ido-enable-flex-matching t)

Ignore Case

(setq ido-case-fold t)

Virtual Buffers

If Recentf is enabled, you can use [C-x b] (or M-x ido-switch-buffer) to visit recently closed files by enabling virtual buffers:

(setq ido-use-virtual-buffers t)

Prevent Auto-Merge

Ido's default behavior when there is no matching file in the current directory is to look in recent working directories. If you prefer to limit [C-x C-f] (or M-x ido-find-file) to the current directory you can disable this auto-merge behavior:

(setq ido-auto-merge-work-directories-length -1) ;; disable auto-merge

You can still look in other working directories explicitly with [M-s].

Directory Caching on Windows

On Windows operating systems it can be unreliable to cache directory listings: the directory may not appear to be modified even though files have been added or removed. Ido caches directory listings by default, which may cause confusion on Windows. You can disable caching:

(when (equal system-type 'windows-nt)
  (setq ido-max-dir-file-cache 0)) ; caching unreliable

Specifying sort-order

If you'd like to tweak the default file sorting, like making Org-files appear first, tell ido which files to give a higher sort priority:

(setq ido-file-extensions-order '(".org" ".txt" ".py" ".emacs" ".xml" ".el"
				  ".ini" ".cfg" ".conf"))

Sort by mtime instead of alphabetically

If you prefer to sort ido filelist by mtime instead of alphabetically use the package ido-sort-mtime (available in MELPA), which is more reliable than the script below. Which breaks on TRAMP files or if you enter //, etc:

(add-hook 'ido-make-file-list-hook 'ido-sort-mtime)
(add-hook 'ido-make-dir-list-hook 'ido-sort-mtime)
(defun ido-sort-mtime ()
  (setq ido-temp-list
        (sort ido-temp-list
              (lambda (a b)
                (time-less-p
                 (sixth (file-attributes (concat ido-current-directory b)))
                 (sixth (file-attributes (concat ido-current-directory a)))))))
  (ido-to-end  ;; move . files to end (again)
   (delq nil (mapcar
              (lambda (x) (and (char-equal (string-to-char x) ?.) x))
              ido-temp-list))))


See Also

Helm

Smex, a M-x enhancement

External Links

Introduction to Ido Mode