Wednesday, July 30, 2014

Emacs ido-mode

Link.



Ido is part of Emacs, starting with release 22. You can get the latest version from the unofficial bzr mirror or git mirror. You may get a current version from the canonical emacs bzr repository at Savannah when it gains a web interface (BzrForEmacsDevs#toc6). Or you can get a very outdated version of it athttp://www.cua.dk/.

Overview of Ido

The ido.el package by KimStorm lets you interactively do things with buffers and files.
To activate, place this in your InitFile:
    (require ')
    (ido-mode t)
Then do
    M-x customize-group RET ido RET
and configure ido-mode. Another good setting to enable is ido-enable-flex-matching.

Using IDO

To switch between buffers, press “C-x b”, then:
  • type some characters appearing in the buffer name, RET to visit the buffer in the front the list.
  • use C-s (next) or C-r (previous) (or LEFT and RIGHT) to move through the list.
  • [Tab] display possible completion in a buffer (or visit the buffer if there is only one possible completion).
  • use C-f to switch to find file (with ido-mode) or C-b to fall back to switch to buffer (without ido-mode).
To find a file, press “C-x C-f”.
  • type some characters appearing in the file name, RET to choose the file or directory in the front of the list.
  • C-s (next) or C-r (previous) (or LEFT and RIGHT) to move through the whole list, and UP and DOWN to move through just the directories.
  • [Tab] - display possible completion in a buffer (or open the file or go down the directory if there is only one possible completion).
  • RET - type to go down inside the directory in front of the list.
  • [backspace] - go up to the parent directory.
  • // - go to the root directory.
  • ~/ - go to the home directory.
  • C-f - fall back to find file (without ido-mode) and C-b to switch to switch to buffer (with ido-mode)
  • C-d - enter Dired for this directory (used to be C-x C-d in older versions)
  • C-j - create a new file named with the text you entered (note: this is needed if the text you entered matches any existing files, because RET would open the first one in the list of matches)
To restrict the list after a first filtering:
  • type some characters appearing in the buffer/file name(say .cpp)
  • type C-SPC (C-@)
  • continue as normal with a list containing only the filtered names
Recently visited directories:
  • type M-p and M-n (or M-UP and M-DOWN) to change to previous/next directories from the history
  • M-s to search for a file matching your input
  • M-k to remove the current directory from the history
  • directories are added to the history by navigating inside them via RET
The documentation for these keys is available via
  • M-x describe-function RET ido-find-file RET
  • C-h f ido-find-file RET

Using Ido Programmatically

You can use Ido in your emacs-lisp programs. This is all you need:
  (setq mylist (list "red" "blue" "yellow" "clear" "i-dont-know"))
  (ido-completing-read "What, ... is your favorite color? " mylist)

Using IDO Select with ERC

Here is some code showing how to select an erc buffer using IDO features (including flex when enabled)
  (defun rgr/ido-erc-buffer()
  (interactive)
  (switch-to-buffer
   (ido-completing-read "Channel:" 
                        (save-excursion
                          (delq
                           nil
                           (mapcar (lambda (buf)
                                     ( (buffer-live-p buf)
                                       (with-current-buffer buf
                                         (and (eq major-mode 'erc-mode)
                                              (buffer-name buf)))))
                                   (buffer-list)))))))

  (global-set-key (kbd "C-c e") 'rgr/ido-erc-buffer)

Helper Function to Select Based on Mode

This is based on what RichardRiley provided. I extracted it out, so I can easily make one for erc, one for shell, … . – ajvargo
(defun ido-for-mode(prompt the-mode)
  (switch-to-buffer
   (ido-completing-read prompt
                        (save-excursion
                          (delq
                           nil
                           (mapcar (lambda (buf)
                                     ( (buffer-live-p buf)
                                       (with-current-buffer buf
                                         (and (eq major-mode the-mode)
                                              (buffer-name buf)))))
                                   (buffer-list)))))))

(defun ido-shell-buffer()
  (interactive)
  (ido-for-mode "Shell:" 'shell-mode))

(global-set-key (kbd "C-c s") 'ido-shell-buffer)

Limit to Current Major Mode

Further variation on RichardRiley’s and ajvargo’s examples: Limit ido to the current major mode, whatever that might be. – wgreenhouse
(defun wg/ido-for-this-mode
  ()
  (interactive)
  (
      ((-mode major-mode))
    (switch-to-buffer
     (ido-completing-read
      (format "Buffers of %s: " the-mode)
      (save-excursion
 (delq
  nil
  (mapcar
   (lambda
     (buf)
     (
  (buffer-live-p buf)
       (with-current-buffer buf
  (and
   (eq major-mode the-mode)
   (buffer-name buf)))))
   (buffer-list))))))))

(global-set-key (kbd "H-t") 'wg/ido-for-this-mode)
(global-set-key (kbd "C-c t") 'wg/ido-for-this-mode)

Mimicking an invocation of ido followed by some keys

I use ERC, and I wanted to bind something to the equivalent of “C-x b #”: that is, launching ido-switch-buffer and hitting a # so that ERC channels are given as options. However, it’s tough in general to write elisp or keyboard macros that run a command and start entering things into a minibuffer without finishing the prompt. For this special case, though, this elisp works:
    (ido-buffer-internal ido-default-buffer-method nil nil nil )

Miscellaneous Applications of Ido

M-x mode

    (global-set-key
     "\M-x"
     (lambda ()
       (interactive)
       (call-interactively
        (intern
         (ido-completing-read
          "M-x "
          (all-completions  obarray 'commandp))))))
You can also check out Smex. On top of a M-x Ido interface it features ranking heuristics and some other extras.
– hfwang, modified by nsq

Invoking Bookmarks From Ido

Did you ever want to use bookmarks from within ido? I just did a little mashup of bookmark and ido code, just M-C-b from your ido file selection. –AnselmHelbig
    (setq enable-recursive-minibuffers t)
    (define-key ido-file-dir-completion-map [(meta control ?b)] 'ido-goto-bookmark)
    (defun ido-goto-bookmark (bookmark)
      (interactive
       (list (bookmark-completing-read "Jump to bookmark"
           bookmark-current-bookmark)))
      (unless bookmark
        (error "No bookmark specified"))
      ( ((filename (bookmark-get-filename bookmark)))
        (ido-set-current-directory
         ( (file-directory-p filename)
             filename
           (file-name-directory filename)))
        (setq ido-exit        'refresh
              ido-text-init   ido-text
              ido-rotate-temp t)
        (exit-minibuffer)))
If you don’t want to set recursive minibuffers globally, you could also activate them locally in the above function using a let declaration.
The problem with this function is, if my bookmark is a directory, whose path I already started typing before realizing I could invoke it, the last path component will be appended to the bookmark path.
Eg. if I have a bookmark for path “/Users/gael/Documents/code/2012/my-super-project" and I had typed "/Users/gael/Docu" before invoking the bookmark, then IDO will display the path: "/Users/gael/Documents/code/2012/my-super-project/Docu” and I have to delete “Docu” by hand.
Here is a better way:
  (require 'bookmark)
  (setq enable-recursive-minibuffers t)
  (define-key ido-file-dir-completion-map [(meta control ?b)] 'ido-goto-bookmark)
  (defun ido-goto-bookmark (bookmark)
    (interactive
     (list (bookmark-completing-read "Jump to bookmark"
             bookmark-current-bookmark)))
    (unless bookmark
      (error "No bookmark specified"))
    ( ((filename (bookmark-get-filename bookmark)))
      ( (file-directory-p filename)
   (progn
     (ido-set-current-directory filename)
     (setq ido-text ))
        (progn
   (ido-set-current-directory (file-name-directory filename))))
      (setq ido-exit        'refresh
     ido-text-init   ido-text
     ido-rotate-temp t)
      (exit-minibuffer)))
--Gaël Deest
What about the following?
  (defun ido-bookmark-jump (bname)
    "*Switch to bookmark interactively using `'."
    (interactive (list (ido-completing-read "Bookmark: " (bookmark-all-names) nil t)))
    (bookmark-jump bname))

Complete find-tag using ido

  (defun my-ido-find-tag ()
    "Find a tag using ido"
    (interactive)
    (tags-completion-table)
    ( (tag-names)
      (mapatoms (lambda (x)
                  (push (prin1-to-string x t) tag-names))
                tags-completion-table)
      (find-tag (ido-completing-read "Tag: " tag-names))))

Find files in Tags File

From the screencast above:
    (defun ido-find-file-in-tag-files ()
      (interactive)
      (save-excursion
        ( ((enable-recursive-minibuffers t))
          (visit-tags-table-buffer))
        (find-file
         (expand-file-name
          (ido-completing-read
           "Project file: " (tags-table-files) nil t)))))
Selects among the files listed in the tags file. Similar to “find file in project” in TextMate; the tags file defines your project.
Philipp: Is there an equivalent command that supports TAGS generated by GNU gtags?
Icicles command ‘icicle-find-file-in-tag-table’ does this also. See Icicles - Tags File Projects.

Completing Imenu tags

Use ido to find any file from the project

If you define projects using project-root.el you can quickly find files that belong to the project. Useful as an alternative to bookmarks.
    (defun my-ido-project-files ()
      "Use ido to select a file from the project."
      (interactive)
      ( (my-project-root project-files tbl)
      (unless project-details (project-root-fetch))
      (setq my-project-root (cdr project-details))
      ;; get project files
      (setq project-files 
     (split-string 
      (shell-command-to-string 
       (concat "find "
        my-project-root
        " \\( -name \"*.svn\" -o -name \"*.git\" \\) -prune -o -type f -print | grep -E -v \"\.(pyc)$\""
        )) ))
      ;; populate hash table (display repr => path)
      (setq tbl (make-hash-table :test 'equal))
      ( (ido-list)
      (mapc (lambda (path)
       ;; format path for display in ido list
       (setq key (replace-regexp-in-string "\\(.*?\\)\\([/]+?\\)$" "\\2|\\1" path))
       ;; strip project root
       (setq key (replace-regexp-in-string my-project-root  key))
       ;; remove trailing | or /
       (setq key (replace-regexp-in-string "\\(|\\|/\\)$"  key))
       (puthash key path tbl)
       (push key ido-list)
       )
     project-files
     )
      (find-file (gethash (ido-completing-read "project-files: " ido-list) tbl)))))
    ;; bind to a key for quick access
    (define-key global-map [f6] 'my-ido-project-files)
--fas

Make Ido complete almost anything (except the stuff where it shouldn't)

    (defvar ido-enable-replace-completing-read t
      "If t, use ido-completing-read instead of completing-read if possible.
    
    Set it to nil using let in around-advice for functions where the
    original completing-read is required.  For example, if a function
    foo absolutely must use the original completing-read, define some
    advice like this:
    
    (defadvice  (around original-completing-read-only activate)
      ( (ido-enable-replace-completing-read) ad-do-it))")
    
    ;; Replace completing-read wherever possible, unless directed otherwise
    (defadvice completing-read
      (around use-ido-when-possible activate)
      ( (or (not ido-enable-replace-completing-read) ; Manual override disable ido
              (and (boundp 'ido-cur-list)
                   ido-cur-list)) ; Avoid infinite loop from ido calling this
          ad-do-it
        ( ((allcomp (all-completions  collection predicate)))
          ( allcomp
              (setq ad-return-value
                    (ido-completing-read prompt
                                   allcomp
                                   nil require-match initial-input hist def))
            ad-do-it))))

Problem using advice to reset to completing-read

1. Incompatible Libraries
2. I like using ido for (almost) everything a lot but it gets slow for a long list of possible completions (e.g. for describe-function).
Using the defadvice as described does not work for me? Is it just me or is this a bug? TIA – sebhofer
Fixed. It seems in version >=23, ido-cur-list is always bound and you need to check it as well. – LeWang
I found ido-completing-read to interfere when using dired mode buffers (e.g., renaming files). To turn it off:
    (add-hook 'dired-mode-hook
              '(lambda () (setq ido-enable-replace-completing-read nil)))
Fixed: use local varible
    (add-hook 'dired-mode-hook
              '(lambda ()
                 (set (make-local-variable 'ido-enable-replace-completing-read) nil)))
– Shihpin

Use ido in ibuffer

ibuffer mode doesn’t come with an option to use ido-find-file, so here’s a simple adaptation of ibuffer-find-file that uses ido instead of read-file:
(defun ibuffer-ido-find-file (file &optional wildcards)
  "Like `ido-find-file', but default to the directory of the buffer at point."
  (interactive
   ( ((default-directory
           ( ((buf (ibuffer-current-buffer)))
             ( (buffer-live-p buf)
                 (with-current-buffer buf
                   default-directory)
               default-directory))))
     (list (ido-read-file-name "Find file: " default-directory) t)))
  (find-file file wildcards))
To use this, if you’ve already (require 'ibuffer)’d, (define-key ibuffer-mode-map "\C-x\C-f" 'ibuffer-ido-find-file) should work, if you haven’t required it do
(add-hook 'ibuffer-mode-hook
          (lambda ()
            (define-key ibuffer-mode-map "\C-x\C-f"
              'ibuffer-ido-find-file)))
– new definition of ibuffer-ido-find-file by TreyHarris to suppress wrong type argument errors that could happen in some circumstances.

ido-ubiquitous

The ido ubiquitous module allows you set up to use ido with almost anything that uses completion. For example in ‘C-h f’. Extremely useful. Although for ‘M-x’ there is the improved Smex package. It is now maintained by Ryan Thompson:

ido-ubiquitous compile-log issue

If ido-ubiquitous 1.6 is used in emacs 24.3, there will always be a compile-log buffer warning:
    .emacs.d/elpa/ido-ubiquitous-20121214.2145/ido-ubiquitous.elc:Warning:
        reference to free variable `ido-cur-item'
    .emacs.d/elpa/ido-ubiquitous-20121214.2145/ido-ubiquitous.elc:Warning:
        reference to free variable `ido-default-item'
    .emacs.d/elpa/ido-ubiquitous-20121214.2145/ido-ubiquitous.elc:Warning:
        reference to free variable `ido-cur-list'
Just add the following three defvars to get around this problem:
    (defvar ido-cur-item nil)
    (defvar ido-default-item nil)
    (defvar ido-cur-list nil)

ido-at-point

If you want to have ido-style completion-at-point (the default in-buffer completion), check out the ido-at-point package. It replaces the standard completions buffer on M-tab with ido prompt.

Ido Hacks (modifying Ido's behavior)

Better flex (fuzzy) matching for Ido

There are at least two options:
flx-ido. This does fuzzy matching based on intelligent sorting of the list along with nice highlighting. It doesn’t match out-of-order characters though, unlike:
ido-better-flex implements just another fuzzy matching algorithm, unlike default Ido flex, it allows you to match candidates even if you type a character that is before the previously matched input.

Display Completions Vertically

It’s a lot easier to scan long path names if they’re displayed vertically, instead of horizontally. Run this to achieve just that:
This can be achieved by installing package ido-vertical-mode, which (presumably), does the following, below.
  ;; Display ido results vertically, rather than horizontally
  (setq ido-decorations (quote ("\n-> "   "\n   ..."   " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")))
  (defun ido-disable-line-truncation () (set (make-local-variable 'truncate-lines) nil))
  (add-hook 'ido-minibuffer-setup-hook 'ido-disable-line-truncation)
  (defun ido-define-keys () ;; C-n/p is more intuitive in vertical layout
    (define-key ido-completion-map (kbd "C-n") 'ido-next-match)
    (define-key ido-completion-map (kbd "C-p") 'ido-prev-match))
  (add-hook 'ido-setup-hook 'ido-define-keys)

Control-TAB buffer switching with Ido

nXhtml tweaks Ido to do ControlTABbufferCycling combined with Ido’s normal buffer switching.

Sort files by mtime

Why would anyone want an alphabetically sorted list? You can save keystrokes if the most recently modified files are at the front:
  ; sort ido filelist by mtime instead of alphabetically
  (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))))
If you want to ensure ‘.’ is not buried by this, change the final lambda as follows (or equivalent):
    (lambda (x) (and (string-match-p "^\\.." x) x))
Depending on the type of entities (e.g. file names) in the list and your current context, it can often be more convenient to sort alphabetically. It all depends. For files and directories, this is why we have different sort orders in DiredMode(see, e.g., DiredSortMenu).
On my system (Debian squeeze), there are “files” in the root directory ending in a colon for which applying file-attributes to them invokes tramp, and tramp hangs with “Tramp: Waiting for prompts from remote shell”. Changing the sort predicate in the above code to the following seems to work:
    (lambda (a b)
      ( ((a-tramp-file-p (string-match-p ":\\'" a))
            (b-tramp-file-p (string-match-p ":\\'" b)))
        (
         ((and a-tramp-file-p b-tramp-file-p)
          (string< a b))
         (a-tramp-file-p nil)
         (b-tramp-file-p t)
         (t (time-less-p
             (sixth (file-attributes (concat ido-current-directory b)))
             (sixth (file-attributes (concat ido-current-directory a))))))))
See also SortOrder.

A better (IMHO) ido-edit-input function

In order to be more consistent with the normal find-file HCI, to which I am really really used (and, by the waym with the way command shells do completion), I changed slighlty the behaviour of the backspace and C-e keys in ‘file mode :
  (defun ido-my-edit-input () "bla" (interactive)
    (setq ido-current-directory 
          (concat (abbreviate-file-name ido-current-directory) ido-text ))
    (setq ido-text )
    (ido-edit-input)
    )
  
  (defun ido-my-keys ()
    "Add my keybindings for ido."
    ( (eq ido-cur-item 'file)
      (define-key ido-mode-map (kbd "ESC DEL") 'ido-delete-backward-updir)
      (define-key ido-mode-map (kbd "C-e") 'ido-my-edit-input)
      (define-key ido-mode-map (kbd "<backspace>") 'ido-my-edit-input)
     ))
Maybe this is useless with recent versions of emacs/ido, but here I’m forced to use emacs 21, so I downloaded ido 1.56 from cua.dk (see above) and it works like a charm. My only difficulty was that I had to comment this line in ido-read-internal, and i don’t really know what kind of wizardry I am trying to cheat here.
   ;;(process-environment (cons "HOME=/" process-environment)) 
– Gyom

Invoke any command using ido in other window / split window, deciding after the fact instead of before

This makes ido-find-file-other-window, ido-switch-buffer-other-window, et. al obsolete. It’s a much better abstraction, and I believe it should become apart of ido mode, because any command that uses ido-completing-read can benefit from it without any additional effort, including textmate.el’s textmate-goto-symbol.

Make RET easier to use with ido-find-file

Both SPC and RET in ido-find-file cause ido to descend directories. C-j can be used to select a matched directory name, but if used after typing a prefix, it creates a new file of that name. What I need is a binding between the two: where RET immediately selects whatever directory is shown in the minibuffer -- or has been partially selected – while SPC or / can be used to keep descending. Doing things required a hack, as there is no customization to achieve this. Here is the code for your .emacs. – JohnWiegley
  (defun ido-smart-select-text ()
    "Select the current completed item.  Do NOT descend into directories."
    (interactive)
    ( (and (or (not ido-require-match)
                   ( (memq ido-require-match
                             '(confirm confirm-after-completion))
                       ( (or (eq ido-cur-item 'dir)
                               (eq last-command this-command))
                           t
                         (setq ido-show-confirm-message t)
                         nil))
                   (ido-existing-item-p))
               (not ido-incomplete-regexp))
      ( ido-current-directory
        (setq ido-exit 'takeprompt)
        (unless (and ido-text (= 0 (length ido-text)))
          ( ((match (ido-name (car ido-matches))))
            (throw '
                   (setq ido-selected
                         ( match
                             (replace-regexp-in-string "/\\'"  match)
                           ido-text)
                         ido-text ido-selected
                         ido-final-text ido-text)))))
      (exit-minibuffer)))
  
  (eval-after-load "ido"
    '(define-key ido-common-completion-map "\C-m" 'ido-smart-select-text))

ido-hacks.el

Misc collection of ido changes, including making it behave better with dired’s copying and renaming commands (such as putting directory as first option).
Emacs 23 and lower: http://www0.fh-trier.de/~politza/emacs/ido-hacks.el.gz An Emacs 24 compatible version is available at https://github.com/scottjad/ido-hacks

Multi-select

Simple function that can be used to select multiple items using ido-completing-read by injecting a “sentinel” value into the possible choices and reading in a loop until the user chooses the sentinel value. The selected choices are returned in a list.
– mgalgs

ido-preview

Two functions, that allow to view current item contents in a temporary buffer and window(clearing surrounding windows, but it’s safe). Content is either file contents, buffer contents or function description.
Content can also be second list’s element, that must be string:
  (ido-completing-read "What, ... is your favorite color? "
    (list
      (list "red" "Red is #ff0000")
      (list "blue" "Blue is #0000ff")
      "yellow"
      "clear"
      (list "i-dont-know" "So why do you think my ido-preview will ever know it?")))

Icicles and Ido

Icicles is similar to Ido in some ways, and the two are sometimes confused. In Icicles, you use the same minibuffer interface for files, buffers, commands – everything (even keys). Like Ido, Icicles offers cycling and several kinds of completion matching (regexp, substring, 5 kinds of fuzzy, prefix).
Unlike Ido, in Icicles you can:
  • Compose match patterns (e.g. regexps), applying them one after the other to narrow down choices (like ‘grep’ piping) – progressive completion.
  • Perform actions on multiple candidates on the fly – see multi-commands.
  • Manipulate (union, intersection, diff, complement) and save sets of candidates and reuse them later.
  • Access bookmarks on the fly: a file bookmark when you use ‘C-x C-f’, an Infobookmark when you use ‘g’ to go to an Info node, etc.
  • Change the completion sort order on the fly.
You cannot use Icicles and Ido together – they use the minibuffer differently. You can, however, use Icicles and IswitchB together. (IswitchB provides buffer-switching similar to Ido, but it does not provide Ido’s file visiting.) And you can make Icicles behave more like Ido, if you prefer that interaction – see Icicles - Ido and IswitchB.

Ido History

Quote from the history section of ido.el:
Since I discovered StephenEglen’s excellent iswitchb package, I just couldn’t live without it, but once being addicted to switching buffers with a minimum of keystrokes, I soon found that opening files in the old-fashioned way was just too slow - so I decided to write a package which could open files with the same speed and ease as iswitchb could switch buffers.
I originally wrote a separate ifindf.el package based on a copy of iswitchb.el, which did for opening files what iswitchb did for switching buffers. Along the way, I corrected a few errors in ifindf which could have found its way back into iswitchb, but since most of the functionality of the two package was practically identical, I decided that the proper thing to do was to merge my ifindf package back into iswitchb.
This is basically what ido (interactively do) is all about; but I found it awkward to merge my changes into the “iswitchb-” namespace, so I invented a common “ido-” namespace for the merged packages.

Preventing auto-searches unless called explicitly

   ;; a better solution
   (setq ido-auto-merge-work-directories-length -1)
   ;; disable auto searching for files unless called explicitly
   (setq ido-auto-merge-delay-time 99999)
   (define-key ido-file-dir-completion-map (kbd "C-c C-s") 
      (lambda() 
        (interactive)
        (ido-initiate-auto-merge (current-buffer))))
I’m not sure where to add this so I’m just putting it here for people who may find a problem with ido-mode. I’ve used iswitchb for a while, but when I would try ido, things just didn’t work, I couldn’t select files, directories, or even go to the next item in the list. What I found was that my customization of MComplete mode was overriding the ido mode such that C-s, etc. weren’t calling ido functions, but mcomplete functions. All I had to do to get ido to work like I would expect was to turn off mcomplete-mode in my customizations. I hope this helps someone - MattSavoie?
After C-x C-f in ido-mode, M-r doesn’t work as expected. With the default find-file, you can regexp search for recently opened files. With ido, the file names do show up in ido-work-file-list but I always get a ‘no earlier matching history item’ when searching for a history item.
Issuing a M-f or M-d (wide find while at the ido find file prompt) inside a directory with “spaces” doesn’t match anything. Issuing the command a level above matches everything but doesn’t traverse the directory with “spaces”. The space isn’t the first character.

A Hint About "Too Big"

Once upon a time, I created a lot of files in a given directory. When I later tried to open a file in that directory with C-x C-f (ido-find-file), not surprisingly, it displayed [Too Big], rather than showing me a list of files in that directory.
But after I deleted all those files, it still said [Too Big]. Even after rebooting Emacs!
I eventually realized that the directory itself was Too Big – Unix directories get bigger as you add files, but, oddly, don’t get smaller when you delete those files – and so I needed to ensmallen it. I did that by creating a new directory “frotz”, and in the old, too-big directory, doing something like find . -mindepth 1 -maxdepth 1 -exec mv {} frotz ';'. That moved everything from the old directory to the new. Then I deleted the old directory, and renamed the new one to the old one’s name. Voila.
You could call this “garbage-collecting” a directory.

Alternatively, you can change the value of ido-max-directory-size:
 (setq ido-max-directory-size 100000)
--JasonDunsmore?

Wish list

truename files

it would be nice if ido could truename files. ido blows away the truenaming of files that i had set up with ffap. It can be very confusing to open a symlink and have the buffer name be the name of the symlink. I fixed this in ffap with the following code, but I don’t know where to fix it in ido since it does not seem to have a finder variable.
  ;;finding file keeps buffer name as symlink name.  all the truename vars do
  ;;not fix.  this does.  this should use before advice changing filename?
  (defun alpha-find-file-truename (filename &optional codesys)
    "used for ffap."
    (interactive "FFile name (will be truenamed): ")
    (find-file (file-truename filename) codesys))
  (setf ffap-file-finder 'alpha-find-file-truename)
  ;;here are variables.  they are insufficient for getting the ;;truename.  in emacs 22, you only get truename if you
  ;;already had the original file in a buffer.  it is as if these
  ;;variables are simply ignored.  there are no other variables.
  (setf find-file-compare-truenames t)    ;xemacs
  (setf find-file-existing-other-name t)  ;emacs and xemacs alias for ffct
  ;;find-file-use-truenames seems to default to t in xemacs but not in emacs.
  ;;why can't they compare inode for hard links and what happens if these are nil?
  (setf find-file-visit-truename t)
--gambarimasu

bury buffer

Sometimes I think it would be convenient to be able to bury buffer. I can use bury-buffer command, and it works with standard emacs C-xb, but ido seems to ignore it. Is there a way to bury buffer in ido? – KonstantinAntipin

zsh style completion

I find ido-find-file too intrusive, I would prefer something that ressembles my menu completion in zsh. It would run the regular find-file, and switch to ido when I press TAB twice. From there I could select my item with the arrows and RET then the minibuffer would return to find-file mode.
The relevant zsh config is here:http://zshwiki.org/home/examples/compquickstart – DenisMartinez?

ido and ibus

I have a number of files named in Chinese. In the standard find-file I can use ibus to enter their names, or part of their names. This doesn’t work with ido-find-file. – Bernard Hurley
You might get some help here, but this sounds like a bug. Please use ‘M-x report-emacs-bug’, providing a recipe from emacs -Q. – DrewAdams
Done!! – Bernard Hurley

Searching for unicode characters with IsearchPlus when IdoUbiquitous is enabled.

In Emacs 24.2.1, and maybe other versions, if you use IsearchPlus with Ido Ubiquitous enabled, you find that you can’t search for unicode charaters and if you try an error is generated. In Emacs 24.2.1 the solution is to disable Ido’s advice around ‘completing-read’ when ‘isearchp-read-unicode-char’ is called. This can be done by putting:
(ido-ubiquitous-disable-in isearchp-read-unicode-char)
in your .emacs file. When I first did this, I evaluated the form interactively and it didn’t seem to fix the problem - I don’t know why - but it worked next time I started up Emacs. – Bernard Hurley

Grouping files by directories.

It will be very helpful, especially when browsing code, to be able to group files by directories (so that we get some sort of tree representation) in the ibuffer mode.

No comments:

Post a Comment