-
Notifications
You must be signed in to change notification settings - Fork 1
/
ido.el
4816 lines (4308 loc) · 167 KB
/
ido.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; ido.el --- interactively do things with buffers and files
;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
;; Author: Kim F. Storm <[email protected]>
;; Based on: iswitchb by Stephen Eglen <[email protected]>
;; Keywords: extensions convenience
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Ido - interactive do - switches between buffers and opens files and
;; directories with a minimum of keystrokes. It is a superset of
;; iswitchb, the interactive buffer switching package by Stephen Eglen.
;; Interactive substring matching
;; ------------------------------
;;
;; As you type in a substring, the list of buffers or files currently
;; matching the substring are displayed as you type. The list is
;; ordered so that the most recent buffers or files visited come at
;; the start of the list.
;;
;; The buffer or file at the start of the list will be the one visited
;; when you press RETURN. By typing more of the substring, the list is
;; narrowed down so that gradually the buffer or file you want will be
;; at the top of the list. Alternatively, you can use C-s and C-r (or
;; the right and left arrow keys) to rotate buffer or file names in the
;; list until the one you want is at the top of the list.
;;
;; Completion is also available so that you can see what is common to
;; all of the matching buffers or files as you type.
;;
;; Example:
;;
;; If I have two buffers called "123456" and "123", with "123456" the
;; most recent, when I use ido-switch-buffer, I first of all get
;; presented with the list of all the buffers
;;
;; Buffer: {123456 | 123}
;;
;; If I then press 2:
;; Buffer: 2[3]{123456 | 123}
;;
;; The list in {...} are the matching buffers, most recent first
;; (buffers visible in the current frame are put at the end of the
;; list by default). At any time I can select the item at the head of
;; the list by pressing RET. I can also put the first element at the
;; end of the list by pressing C-s or [right], or bring the last
;; element to the head of the list by pressing C-r or [left].
;;
;; The item in [...] indicates what can be added to my input by
;; pressing TAB. In this case, I will get "3" added to my input.
;; So, I press TAB:
;; Buffer: 23{123456 | 123}
;;
;; At this point, I still have two matching buffers.
;; If I want the first buffer in the list, I simply press RET. If I
;; wanted the second in the list, I could press C-s to move it to the
;; top of the list and then RET to select it.
;;
;; However, if I type 4, I only have one match left:
;; Buffer: 234[123456]
;;
;; Since there is only one matching buffer left, it is given in [] and
;; it is shown in the `ido-only-match' face (ForestGreen). I can now
;; press TAB or RET to go to that buffer.
;;
;; If I want to create a new buffer named "234", I press C-j instead of
;; TAB or RET.
;;
;; If instead, I type "a":
;; Buffer: 234a [No match]
;; There are no matching buffers. If I press RET or TAB, I can be
;; prompted to create a new buffer called "234a".
;;
;; Of course, where this function comes in really useful is when you
;; can specify the buffer using only a few keystrokes. In the above
;; example, the quickest way to get to the "123456" file would be
;; just to type 4 and then RET (assuming there isn't any newer buffer
;; with 4 in its name).
;; Likewise, if you use C-x C-f (ido-find-file), the list of files and
;; directories in the current directory is provided in the same
;; fashion as the buffers above. The files and directories are
;; normally sorted in alphabetical order, but the most recently
;; visited directory is placed first to speed up navigating to
;; directories that you have visited recently.
;;
;; In addition to scrolling through the list using [right] and [left],
;; you can use [up] and [down] to quickly scroll the list to the next
;; or previous subdirectory.
;;
;; To go down into a subdirectory, and continue the file selection on
;; the files in that directory, simply move the directory to the head
;; of the list and hit RET.
;;
;; To go up to the parent directory, delete any partial file name
;; already specified (e.g. using [backspace]) and hit [backspace].
;;
;; To go to the root directory (on the current drive), enter two
;; slashes. On MS-DOS or Windows, to select the root of another
;; drive, enter X:/ where X is the drive letter. You can also visit
;; files on other hosts using the ange-ftp notations `/host:' and
;; `/user@host:'. See the variable `ido-slow-ftp-hosts' if you want
;; to inhibit the ido substring matching for ftp access.
;;
;; If for some reason you cannot specify the proper file using
;; ido-find-file, you can press C-f to enter the normal find-file.
;; You can also press C-b to drop into ido-switch-buffer.
;; See the doc string of ido-switch-buffer and ido-find-file for full
;; keybindings and features.
;; (describe-function 'ido-find-file)
;; Hidden buffers and files
;; ------------------------
;;
;; Normally, ido does not include hidden buffers (whose name starts
;; with a space) and hidden files and directories (whose name starts
;; with `.') in the list of possible completions. However, if the
;; substring you enter does not match any of the visible buffers or
;; files, ido will automatically look for completions among the hidden
;; buffers or files.
;;
;; You can toggle display of the hidden buffers and files with C-a.
;; Additional functionality
;; ------------------------
;;
;; After C-x b, the buffer at the head of the list can be killed by
;; pressing C-k. If the buffer needs saving, you will be queried
;; before the buffer is killed.
;;
;; Likewise, after C-x C-f, you can delete (i.e. physically remove)
;; the file at the head of the list with C-k. You will always be
;; asked for confirmation before the file is deleted.
;;
;; If you enter C-x b to switch to a buffer visiting a given file, and
;; you find that the file you are after is not in any buffer, you can
;; press C-f to immediately drop into ido-find-file. And you can
;; switch back to buffer selection with C-b.
;; Prefix matching
;; ---------------
;;
;; The standard way of completion with Unix-shells and Emacs is to insert a
;; PREFIX and then hitting TAB (or another completion key). Cause of this
;; behavior has become second nature to a lot of emacs users `ido' offers in
;; addition to the default substring-matching-method (look above) also the
;; prefix-matching-method. The kind of matching is the only difference to
;; the description of the substring-matching above.
;;
;; You can toggle prefix matching with C-p.
;;
;; Example:
;;
;; If you have again two Buffers "123456" and "123" then hitting "2" does
;; not match because "2" is not a PREFIX in any of the buffer-names.
;; Flexible matching
;; -----------------
;;
;; If you set ido-enable-flex-matching, ido will do a more flexible
;; matching (unless regexp matching is active) to find possible matches
;; among the available buffer or file names if no matches are found using
;; the normal prefix or substring matching.
;;
;; The flexible matching implies that any item which simply contains all
;; of the entered characters in the specified sequence will match.
;;
;; Example:
;;
;; If you have four files "alpha", "beta", "gamma", and "delta",
;; entering "aa" will match "alpha" and "gamma", while "ea" matches
;; "beta" and "delta". If prefix matching is also active, "aa" only
;; matches "alpha", while "ea" does not match any files.
;; Regexp matching
;; ---------------
;;
;; There is limited provision for regexp matching within ido,
;; enabled through `ido-enable-regexp' (toggle with C-t).
;; This allows you to type `[ch]$' for example and see all file names
;; ending in `c' or `h'.
;;
;; Note: ido-style completion is inhibited when you enable regexp matching.
;; Customization
;; -------------
;;
;; Customize the `ido' group to change the `ido' functionality.
;;
;; To modify the keybindings, use the ido-setup-hook. For example:
;;(add-hook 'ido-setup-hook 'ido-my-keys)
;;
;;(defun ido-my-keys ()
;; "Add my keybindings for ido."
;; (define-key ido-completion-map " " 'ido-next-match)
;; )
;; Seeing all the matching buffers or files
;; ----------------------------------------
;;
;; If you have many matching files, they may not all fit onto one
;; line of the minibuffer. Normally, the minibuffer window will grow
;; to show you more of the matching files (depending on the setting
;; of the variables `resize-mini-windows' and `max-mini-window-height').
;; If you want ido to behave differently from the default minibuffer
;; resizing behavior, set the variable `ido-max-window-height'.
;;
;; Also, to improve the responsiveness of ido, the maximum number of
;; matching items is limited to 12, but you can increase or removed
;; this limit via the `ido-max-prospects' variable.
;; To see a full list of all matching buffers in a separate buffer,
;; hit ? or press TAB when there are no further completions to the
;; substring. Repeated TAB presses will scroll you through this
;; separate buffer.
;; Changing the list of files
;; --------------------------
;; By default, the list of current files is most recent first,
;; oldest last, with the exception that the files visible in the
;; current frame are put at the end of the list. A hook exists to
;; allow other functions to order the list. For example, if you add:
;;
;; (add-hook 'ido-make-buffer-list-hook 'ido-summary-buffers-to-end)
;;
;; then all files matching "Summary" are moved to the end of the
;; list. (I find this handy for keeping the INBOX Summary and so on
;; out of the way.) It also moves files matching "output\*$" to the
;; end of the list (these are created by AUCTeX when compiling.)
;; Other functions could be made available which alter the list of
;; matching files (either deleting or rearranging elements.)
;; Highlighting
;; ------------
;; The highlighting of matching items is controlled via ido-use-faces.
;; The faces used are ido-first-match, ido-only-match and
;; ido-subdir.
;; Coloring of the matching item was suggested by
;; Carsten Dominik ([email protected]).
;; Replacement for read-buffer and read-file-name
;; ----------------------------------------------
;; ido-read-buffer and ido-read-file-name have been written to be drop
;; in replacements for the normal buffer and file name reading
;; functions `read-buffer' and `read-file-name'.
;; To use ido for all buffer and file selections in Emacs, customize the
;; variable `ido-everywhere'.
;; Using ido-like behavior in other lisp packages
;; -----------------------------------------------
;; If you don't want to rely on the `ido-everywhere' functionality,
;; ido-read-buffer, ido-read-file-name, and ido-read-directory-name
;; can be used by other packages to read a buffer name, a file name,
;; or a directory name in the `ido' way.
;;; Acknowledgments
;; Infinite amounts of gratitude goes to Stephen Eglen <[email protected]>
;; who wrote iswitch-buffer mode - from which I ripped off 99% of the code
;; for ido-switch-buffer and found the inspiration for ido-find-file.
;; The ido package would never have existed without his work.
;; Also thanks to Klaus Berndl, Rohit Namjoshi, Robert Fenk, Alex
;; Schroeder, Bill Benedetto, Stephen Eglen, and many others for bug
;; fixes and improvements.
;;; History
;; Since I discovered Stephen Eglen'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.
;;
;; This version is based on ido.el version 1.57 released on
;; gnu.emacs.sources adapted for emacs 22.1 to use command remapping
;; and optionally hooking the read-buffer and read-file-name functions.
;;
;; Prefix matching was added by Klaus Berndl <[email protected]> based on
;; an idea of Yuji Minejima <[email protected]> and his mcomplete-package.
;;; Code:
(defvar recentf-list)
;;; User Variables
;;
;; These are some things you might want to change.
(defun ido-fractionp (n)
(and (numberp n) (> n 0.0) (<= n 1.0)))
(defgroup ido nil
"Switch between files using substrings."
:group 'extensions
:group 'convenience
:version "22.1"
:link '(emacs-commentary-link :tag "Commentary" "ido.el")
:link '(emacs-library-link :tag "Lisp File" "ido.el"))
;;;###autoload
(defcustom ido-mode nil
"Determines for which functional group \(buffer and files) ido behavior
should be enabled. The following values are possible:
- `buffer': Turn only on ido buffer behavior \(switching, killing,
displaying...)
- `file': Turn only on ido file behavior \(finding, writing, inserting...)
- `both': Turn on ido buffer and file behavior.
- `nil': Turn off any ido switching.
Setting this variable directly does not take effect;
use either \\[customize] or the function `ido-mode'."
:set #'(lambda (_symbol value)
(ido-mode value))
:initialize 'custom-initialize-default
:require 'ido
:link '(emacs-commentary-link "ido.el")
:set-after '(ido-save-directory-list-file
;; This will clear ido-unc-hosts-cache, so set it
;; before loading history file.
ido-unc-hosts)
:type '(choice (const :tag "Turn on only buffer" buffer)
(const :tag "Turn on only file" file)
(const :tag "Turn on both buffer and file" both)
(const :tag "Switch off all" nil))
:group 'ido)
(defcustom ido-case-fold case-fold-search
"Non-nil if searching of buffer and file names should ignore case."
:type 'boolean
:group 'ido)
(defcustom ido-ignore-buffers
'("\\` ")
"List of regexps or functions matching buffer names to ignore.
For example, traditional behavior is not to list buffers whose names begin
with a space, for which the regexp is `\\` '. See the source file for
example functions that filter buffer names."
:type '(repeat (choice regexp function))
:group 'ido)
(defcustom ido-ignore-files
'("\\`CVS/" "\\`#" "\\`.#" "\\`\\.\\./" "\\`\\./")
"List of regexps or functions matching file names to ignore.
For example, traditional behavior is not to list files whose names begin
with a #, for which the regexp is `\\`#'. See the source file for
example functions that filter filenames."
:type '(repeat (choice regexp function))
:group 'ido)
(defcustom ido-ignore-extensions t
"Non-nil means ignore files in `completion-ignored-extensions' list."
:type 'boolean
:group 'ido)
(defcustom ido-show-dot-for-dired nil
"Non-nil means to always put . as the first item in file name lists.
This allows the current directory to be opened immediately with `dired'."
:type 'boolean
:group 'ido)
(defcustom ido-file-extensions-order nil
"List of file extensions specifying preferred order of file selections.
Each element is either a string with `.' as the first char, an empty
string matching files without extension, or t which is the default order
for files with an unlisted file extension."
:type '(repeat (choice string
(const :tag "Default order" t)))
:group 'ido)
(defcustom ido-ignore-directories
'("\\`CVS/" "\\`\\.\\./" "\\`\\./")
"List of regexps or functions matching sub-directory names to ignore."
:type '(repeat (choice regexp function))
:group 'ido)
(defcustom ido-ignore-directories-merge nil
"List of regexps or functions matching directory names to ignore during merge.
Directory names matched by one of the regexps in this list are not inserted
in merged file and directory lists."
:type '(repeat (choice regexp function))
:group 'ido)
;; Examples for setting the value of ido-ignore-buffers
;;(defun ido-ignore-c-mode (name)
;; "Ignore all c mode buffers -- example function for ido."
;; (with-current-buffer name
;; (derived-mode-p 'c-mode)))
;;
;;(setq ido-ignore-buffers '("^ " ido-ignore-c-mode))
;; Examples for setting the value of ido-ignore-files
;;(setq ido-ignore-files '("^ " "\\.c\\'" "\\.h\\'"))
(defcustom ido-default-file-method 'raise-frame
"How to visit a new file when using `ido-find-file'.
Possible values:
`selected-window' Show new file in selected window
`other-window' Show new file in another window (same frame)
`display' Display file in another window without selecting to it
`other-frame' Show new file in another frame
`maybe-frame' If a file is visible in another frame, prompt to ask if you
you want to see the file in the same window of the current
frame or in the other frame
`raise-frame' If a file is visible in another frame, raise that
frame; otherwise, visit the file in the same window"
:type '(choice (const :tag "Visit in selected window" selected-window)
(const :tag "Visit in other window" other-window)
(const :tag "Display (no select) in other window" display)
(const :tag "Visit in other frame" other-frame)
(const :tag "Ask to visit in other frame" maybe-frame)
(const :tag "Raise frame if already visited" raise-frame))
:group 'ido)
(defcustom ido-default-buffer-method 'raise-frame
"How to switch to new buffer when using `ido-switch-buffer'.
See `ido-default-file-method' for details."
:type '(choice (const :tag "Show in selected window" selected-window)
(const :tag "Show in other window" other-window)
(const :tag "Display (no select) in other window" display)
(const :tag "Show in other frame" other-frame)
(const :tag "Ask to show in other frame" maybe-frame)
(const :tag "Raise frame if already shown" raise-frame))
:group 'ido)
(defcustom ido-enable-flex-matching nil
"Non-nil means that `ido' will do flexible string matching.
Flexible matching means that if the entered string does not
match any item, any item containing the entered characters
in the given sequence will match."
:type 'boolean
:group 'ido)
(defcustom ido-enable-regexp nil
"Non-nil means that `ido' will do regexp matching.
Value can be toggled within `ido' using `ido-toggle-regexp'."
:type 'boolean
:group 'ido)
(defcustom ido-enable-prefix nil
"Non-nil means only match if the entered text is a prefix of file name.
This behavior is like the standard Emacs completion.
If nil, match if the entered text is an arbitrary substring.
Value can be toggled within `ido' using `ido-toggle-prefix'."
:type 'boolean
:group 'ido)
(defcustom ido-enable-dot-prefix nil
"Non-nil means to match leading dot as prefix.
I.e. hidden files and buffers will match only if you type a dot
as first char even if `ido-enable-prefix' is nil."
:type 'boolean
:group 'ido)
;; See http://debbugs.gnu.org/2042 for more info.
(defcustom ido-buffer-disable-smart-matches t
"Non-nil means not to re-order matches for buffer switching.
By default, ido arranges matches in the following order:
full-matches > suffix matches > prefix matches > remaining matches
which can get in the way for buffer switching."
:version "24.3"
:type 'boolean
:group 'ido)
(defcustom ido-confirm-unique-completion nil
"Non-nil means that even a unique completion must be confirmed.
This means that \\[ido-complete] must always be followed by \\[ido-exit-minibuffer]
even when there is only one unique completion."
:type 'boolean
:group 'ido)
(defcustom ido-cannot-complete-command 'ido-completion-help
"Command run when `ido-complete' can't complete any more.
The most useful values are `ido-completion-help', which pops up a
window with completion alternatives, or `ido-next-match' or
`ido-prev-match', which cycle the buffer list."
:type 'function
:group 'ido)
(defcustom ido-record-commands t
"Non-nil means that `ido' will record commands in command history.
Note that the non-ido equivalent command is recorded."
:type 'boolean
:group 'ido)
(defcustom ido-max-prospects 12
"Non-zero means that the prospect list will be limited to that number of items.
For a long list of prospects, building the full list for the minibuffer can take a
non-negligible amount of time; setting this variable reduces that time."
:type 'integer
:group 'ido)
(defcustom ido-max-file-prompt-width 0.35
"Non-zero means that the prompt string be limited to that number of characters.
If value is a floating point number, it specifies a fraction of the frame width."
:type '(choice
(integer :tag "Characters" :value 20)
(restricted-sexp :tag "Fraction of frame width"
:value 0.35
:match-alternatives (ido-fractionp)))
:group 'ido)
(defcustom ido-max-window-height nil
"Non-nil specifies a value to override `max-mini-window-height'."
:type '(choice
(const :tag "Don't override" nil)
(integer :tag "Number of lines" :value 1)
(restricted-sexp
:tag "Fraction of window height"
:value 0.25
:match-alternatives (ido-fractionp)))
:group 'ido)
(defcustom ido-enable-last-directory-history t
"Non-nil means that `ido' will remember latest selected directory names.
See `ido-last-directory-list' and `ido-save-directory-list-file'."
:type 'boolean
:group 'ido)
(defcustom ido-max-work-directory-list 50
"Maximum number of working directories to record.
This is the list of directories where files have most recently been opened.
See `ido-work-directory-list' and `ido-save-directory-list-file'."
:type 'integer
:group 'ido)
(defcustom ido-work-directory-list-ignore-regexps nil
"List of regexps matching directories which should not be recorded.
Directory names matched by one of the regexps in this list are not inserted in
the `ido-work-directory-list' list."
:type '(repeat regexp)
:group 'ido)
(defcustom ido-use-filename-at-point nil
"Non-nil means that ido shall look for a filename at point.
May use `ffap-guesser' to guess whether text at point is a filename.
If found, use that as the starting point for filename selection."
:type '(choice
(const :tag "Disabled" nil)
(const :tag "Guess filename" guess)
(other :tag "Use literal filename" t))
:group 'ido)
(defcustom ido-use-url-at-point nil
"Non-nil means that ido shall look for a URL at point.
If found, call `find-file-at-point' to visit it."
:type 'boolean
:group 'ido)
(defcustom ido-enable-tramp-completion t
"Non-nil means that ido shall perform tramp method and server name completion.
A tramp file name uses the following syntax: /method:user@host:filename."
:type 'boolean
:group 'ido)
(defcustom ido-record-ftp-work-directories t
"Non-nil means record ftp file names in the work directory list."
:type 'boolean
:group 'ido)
(defcustom ido-merge-ftp-work-directories nil
"If nil, merging ignores ftp file names in the work directory list."
:type 'boolean
:group 'ido)
(defcustom ido-cache-ftp-work-directory-time 1.0
"Maximum time to cache contents of an ftp directory (in hours).
Use C-l in prompt to refresh list.
If zero, ftp directories are not cached."
:type 'number
:group 'ido)
(defcustom ido-slow-ftp-hosts nil
"List of slow ftp hosts where ido prompting should not be used.
If an ftp host is on this list, ido automatically switches to the non-ido
equivalent function, e.g. `find-file' rather than `ido-find-file'."
:type '(repeat string)
:group 'ido)
(defcustom ido-slow-ftp-host-regexps nil
"List of regexps matching slow ftp hosts (see `ido-slow-ftp-hosts')."
:type '(repeat regexp)
:group 'ido)
(defvar ido-unc-hosts-cache t
"Cached value from `ido-unc-hosts' function.")
(defcustom ido-unc-hosts nil
"List of known UNC host names to complete after initial //.
If value is a function, that function is called to search network for
hosts on first use of UNC path."
:type '(choice (repeat :tag "List of UNC host names" string)
(function-item :tag "Use `NET VIEW'"
:value ido-unc-hosts-net-view)
(function :tag "Your own function"))
:set #'(lambda (symbol value)
(set symbol value)
(setq ido-unc-hosts-cache t))
:group 'ido)
(defcustom ido-downcase-unc-hosts t
"Non-nil if UNC host names should be downcased."
:type 'boolean
:group 'ido)
(defcustom ido-ignore-unc-host-regexps nil
"List of regexps matching UNC hosts to ignore.
Case is ignored if `ido-downcase-unc-hosts' is set."
:type '(repeat regexp)
:group 'ido)
(defcustom ido-cache-unc-host-shares-time 8.0
"Maximum time to cache shares of an UNC host (in hours).
Use C-l in prompt to refresh list.
If zero, UNC host shares are not cached."
:type 'number
:group 'ido)
(defcustom ido-max-work-file-list 10
"Maximum number of names of recently opened files to record.
This is the list of the file names (sans directory) which have most recently
been opened. See `ido-work-file-list' and `ido-save-directory-list-file'."
:type 'integer
:group 'ido)
(defcustom ido-work-directory-match-only t
"Non-nil means to skip non-matching directories in the directory history.
When some text is already entered at the `ido-find-file' prompt, using
\\[ido-prev-work-directory] or \\[ido-next-work-directory] will skip directories
without any matching entries."
:type 'boolean
:group 'ido)
(defcustom ido-auto-merge-work-directories-length 0
"Automatically switch to merged work directories during file name input.
The value is number of characters to type before switching to merged mode.
If zero, the switch happens when no matches are found in the current directory.
Automatic merging is disabled if the value is negative."
:type 'integer
:group 'ido)
(defcustom ido-auto-merge-delay-time 0.70
"Delay in seconds to wait for more input before doing auto merge."
:type 'number
:group 'ido)
(defcustom ido-auto-merge-inhibit-characters-regexp "[][*?~]"
"Regexp matching characters which should inhibit automatic merging.
When a (partial) file name matches this regexp, merging is inhibited."
:type 'regexp
:group 'ido)
(defcustom ido-merged-indicator "^"
"The string appended to first choice if it has multiple directory choices."
:type 'string
:group 'ido)
(defcustom ido-max-dir-file-cache 100
"Maximum number of working directories to be cached.
This is the size of the cache of `file-name-all-completions' results.
Each cache entry is time stamped with the modification time of the
directory. Some systems, like Windows, have unreliable directory
modification times, so you may choose to disable caching on such
systems, or explicitly refresh the cache contents using the command
`ido-reread-directory' command (C-l) in the minibuffer.
See also `ido-dir-file-cache' and `ido-save-directory-list-file'."
:type 'integer
:group 'ido)
(defcustom ido-max-directory-size nil
"Maximum size (in bytes) for directories to use ido completion.
If you enter a directory with a size larger than this size, ido will
not provide the normal completion. To show the completions, use C-a."
:type '(choice (const :tag "No limit" nil)
(integer :tag "Size in bytes" 30000))
:group 'ido)
(defcustom ido-rotate-file-list-default nil
"Non-nil means that `ido' will always rotate file list to get default in front."
:type 'boolean
:group 'ido)
(defcustom ido-enter-matching-directory 'only
"Additional methods to enter sub-directory of first/only matching item.
If value is 'first, enter first matching sub-directory when typing a slash.
If value is 'only, typing a slash only enters the sub-directory if it is
the only matching item.
If value is t, automatically enter a sub-directory when it is the only
matching item, even without typing a slash."
:type '(choice (const :tag "Never" nil)
(const :tag "Slash enters first directory" first)
(const :tag "Slash enters first and only directory" only)
(other :tag "Always enter unique directory" t))
:group 'ido)
(defcustom ido-create-new-buffer 'prompt
"Specify whether a new buffer is created if no buffer matches substring.
Choices are 'always to create new buffers unconditionally, 'prompt to
ask user whether to create buffer, or 'never to never create new buffer."
:type '(choice (const always)
(const prompt)
(const never))
:group 'ido)
(defcustom ido-setup-hook nil
"Hook run after the ido variables and keymap have been setup.
The dynamic variable `ido-cur-item' contains the current type of item that
is read by ido; possible values are file, dir, buffer, and list.
Additional keys can be defined in `ido-completion-map'."
:type 'hook
:group 'ido)
(defcustom ido-separator nil
"String used by ido to separate the alternatives in the minibuffer.
Obsolete. Set 3rd element of `ido-decorations' instead."
:type '(choice string (const nil))
:group 'ido)
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")
"List of strings used by ido to display the alternatives in the minibuffer.
There are 11 elements in this list:
1st and 2nd elements are used as brackets around the prospect list,
3rd element is the separator between prospects (ignored if `ido-separator' is set),
4th element is the string inserted at the end of a truncated list of prospects,
5th and 6th elements are used as brackets around the common match string which
can be completed using TAB,
7th element is the string displayed when there are no matches, and
8th element is displayed if there is a single match (and faces are not used),
9th element is displayed when the current directory is non-readable,
10th element is displayed when directory exceeds `ido-max-directory-size',
11th element is displayed to confirm creating new file or buffer."
:type '(repeat string)
:group 'ido)
(defcustom ido-use-virtual-buffers nil
"If non-nil, refer to past buffers as well as existing ones.
Essentially it works as follows: Say you are visiting a file and
the buffer gets cleaned up by midnight.el. Later, you want to
switch to that buffer, but find it's no longer open. With
virtual buffers enabled, the buffer name stays in the buffer
list (using the `ido-virtual' face, and always at the end), and if
you select it, it opens the file back up again. This allows you
to think less about whether recently opened files are still open
or not. Most of the time you can quit Emacs, restart, and then
switch to a file buffer that was previously open as if it still
were.
This feature relies upon the `recentf' package, which will be
enabled if this variable is configured to a non-nil value."
:version "24.1"
:type 'boolean
:group 'ido)
(defcustom ido-use-faces t
"Non-nil means use ido faces to highlighting first match, only match and
subdirs in the alternatives."
:type 'boolean
:group 'ido)
(defface ido-first-match '((t :weight bold))
"Face used by ido for highlighting first match."
:group 'ido)
(defface ido-only-match '((((class color))
:foreground "ForestGreen")
(t :slant italic))
"Face used by ido for highlighting only match."
:group 'ido)
(defface ido-subdir '((((min-colors 88) (class color))
:foreground "red1")
(((class color))
:foreground "red")
(t :underline t))
"Face used by ido for highlighting subdirs in the alternatives."
:group 'ido)
(defface ido-virtual '((t :inherit font-lock-builtin-face))
"Face used by ido for matching virtual buffer names."
:version "24.1"
:group 'ido)
(defface ido-indicator '((((min-colors 88) (class color))
:foreground "yellow1" :background "red1" :width condensed)
(((class color))
:foreground "yellow" :background "red" :width condensed)
(t :inverse-video t))
"Face used by ido for highlighting its indicators."
:group 'ido)
(defface ido-incomplete-regexp
'((t :inherit font-lock-warning-face))
"Ido face for indicating incomplete regexps."
:group 'ido)
(defcustom ido-make-file-list-hook nil
"List of functions to run when the list of matching files is created.
Each function on the list may modify the dynamically bound variable
`ido-temp-list' which contains the current list of matching files."
:type 'hook
:group 'ido)
(defcustom ido-make-dir-list-hook nil
"List of functions to run when the list of matching directories is created.
Each function on the list may modify the dynamically bound variable
`ido-temp-list' which contains the current list of matching directories."
:type 'hook
:group 'ido)
(defcustom ido-make-buffer-list-hook nil
"List of functions to run when the list of matching buffers is created.
Each function on the list may modify the dynamically bound variable
`ido-temp-list' which contains the current list of matching buffer names."
:type 'hook
:group 'ido)
(defcustom ido-rewrite-file-prompt-functions nil
"List of functions to run when the find-file prompt is created.
Each function on the list may modify the following dynamically bound
variables:
dirname - the (abbreviated) directory name
to be modified by the hook functions
max-width - the max width of the resulting dirname; nil means no limit
prompt - the basic prompt (e.g. \"Find File: \")
literal - the string shown if doing \"literal\" find; set to nil to omit
vc-off - the string shown if version control is inhibited; set to nil to omit
prefix - either nil or a fixed prefix for the dirname
The following variables are available, but should not be changed:
`ido-current-directory' - the unabbreviated directory name
item - equals `file' or `dir' depending on the current mode."
:type 'hook
:group 'ido)
(defvar ido-rewrite-file-prompt-rules nil
"Alist of rewriting rules for directory names in ido prompts.
A list of elements of the form (FROM . TO) or (FROM . FUNC), each
meaning to rewrite the directory name if matched by FROM by either
substituting the matched string by TO or calling the function FUNC
with the current directory name as its only argument and using the
return value as the new directory name. In addition, each FUNC may
also modify the dynamic variables described for the variable
`ido-rewrite-file-prompt-functions'.")
(defcustom ido-completion-buffer "*Ido Completions*"
"Name of completion buffer used by ido.
Set to nil to disable completion buffers popping up."
:type 'string
:group 'ido)
(defcustom ido-completion-buffer-all-completions nil
"Non-nil means to show all completions in completion buffer.
Otherwise, only the current list of matches is shown."
:type 'boolean
:group 'ido)
(defcustom ido-all-frames 'visible
"Argument to pass to `walk-windows' when Ido is finding buffers.
See documentation of `walk-windows' for useful values."
:type '(choice (const :tag "Selected frame only" nil)
(const :tag "All existing frames" t)
(const :tag "All visible frames" visible)
(const :tag "All frames on this terminal" 0))
:group 'ido)
(defcustom ido-minibuffer-setup-hook nil
"Ido-specific customization of minibuffer setup.
This hook is run during minibuffer setup if `ido' is active.
It is intended for use in customizing ido for interoperation
with other packages. For instance:
\(add-hook 'ido-minibuffer-setup-hook
\(function
\(lambda ()
\(make-local-variable 'max-mini-window-height)
\(setq max-mini-window-height 3))))
will constrain Emacs to a maximum minibuffer height of 3 lines when
ido is running. Copied from `icomplete-minibuffer-setup-hook'."
:type 'hook
:group 'ido)
(defcustom ido-save-directory-list-file (convert-standard-filename "~/.ido.last")
"File in which the ido state is saved between invocations.
Variables stored are: `ido-last-directory-list', `ido-work-directory-list',
`ido-work-file-list', and `ido-dir-file-cache'.
Must be set before enabling ido mode."
:type 'string
:group 'ido)
(defcustom ido-read-file-name-as-directory-commands '()
"List of commands which uses `read-file-name' to read a directory name.
When `ido-everywhere' is non-nil, the commands in this list will read
the directory using `ido-read-directory-name'."
:type '(repeat symbol)
:group 'ido)
(defcustom ido-read-file-name-non-ido '()
"List of commands which shall not read file names the ido way.
When `ido-everywhere' is non-nil, the commands in this list will read
the file name using normal `read-file-name' style."
:type '(repeat symbol)
:group 'ido)
(defcustom ido-before-fallback-functions '()
"List of functions to call before calling a fallback command.
The fallback command is passed as an argument to the functions."
:type 'hook
:group 'ido)
;;; Internal Variables
;; Persistent variables
(defvar ido-completion-map nil
"Currently active keymap for ido commands.")
(defvar ido-common-completion-map nil
"Keymap for all ido commands.")
(defvar ido-file-completion-map nil
"Keymap for ido file commands.")
(defvar ido-file-dir-completion-map nil
"Keymap for ido file and directory commands.")
(defvar ido-buffer-completion-map nil
"Keymap for ido buffer commands.")
(defvar ido-file-history nil
"History of files selected using `ido-find-file'.")
(defvar ido-buffer-history nil
"History of buffers selected using `ido-switch-buffer'.")
(defvar ido-last-directory-list nil
"List of last selected directory names.
See `ido-enable-last-directory-history' for details.")
(defvar ido-work-directory-list nil
"List of actual working directory names.
The current directory is inserted at the front of this list whenever a
file is opened with `ido-find-file' and family.")
(defvar ido-work-file-list nil
"List of actual work file names.
Opening a file with `ido-find-file' and similar functions
inserts the current file name (relative to its containing directory)
at the front of this list.")
(defvar ido-dir-file-cache nil
"List of `file-name-all-completions' results.
Each element in the list is of the form (DIR (MTIME) FILE...).")