Mercurial > emacs
comparison lisp/ido.el @ 49208:5a945cb7d742
(ido-ignore-directories-merge): Doc fix.
(ido-max-prompt-width): Renamed from ido-max-prompt-path.
(ido-enable-last-directory-history): Doc fix.
(ido-work-directory-list-ignore-regexps): Doc fix.
(ido-enable-tramp-completion): Doc fix.
(ido-record-ftp-work-directories): Doc fix.
(ido-merge-ftp-work-directories): Doc fix.
(ido-rewrite-file-prompt-functions): Renamed from
ido-make-file-prompt-hook. Directory name is now in dynamic
variable `dirname' (instead of `path').
(ido-rewrite-file-prompt-rules): Renamed from
ido-rewrite-prompt-path-rules.
(ido-read-file-name-as-directory-commands): Doc fix.
(ido-last-directory-list): Doc fix.
(ido-work-directory-list): Doc fix.
(ido-work-file-list): Doc fix.
(ido-make-prompt): Directory name now in `dirname' var.
(ido-edit-input): Doc fix.
(ido-complete): Fix error message.
(ido-copy-current-word): Doc fix.
(ido-find-file): Doc fix.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Mon, 13 Jan 2003 22:56:53 +0000 |
parents | b76c3354f4e7 |
children | 93a6625a2ef3 |
comparison
equal
deleted
inserted
replaced
49207:0064f690e77d | 49208:5a945cb7d742 |
---|---|
414 "*List of regexps or functions matching sub-directory names to ignore." | 414 "*List of regexps or functions matching sub-directory names to ignore." |
415 :type '(repeat (choice regexp function)) | 415 :type '(repeat (choice regexp function)) |
416 :group 'ido) | 416 :group 'ido) |
417 | 417 |
418 (defcustom ido-ignore-directories-merge nil | 418 (defcustom ido-ignore-directories-merge nil |
419 "*List of regexps or functions matching directory path names to ignore during merge. | 419 "*List of regexps or functions matching directory names to ignore during merge. |
420 Directory paths matched by one of the regexps in this list are not inserted | 420 Directory names matched by one of the regexps in this list are not inserted |
421 in merged file and directory lists." | 421 in merged file and directory lists." |
422 :type '(repeat (choice regexp function)) | 422 :type '(repeat (choice regexp function)) |
423 :group 'ido) | 423 :group 'ido) |
424 | 424 |
425 ;;; Examples for setting the value of ido-ignore-buffers | 425 ;;; Examples for setting the value of ido-ignore-buffers |
509 For a long list of prospects, building the full list for the minibuffer can take a | 509 For a long list of prospects, building the full list for the minibuffer can take a |
510 non-negletable amount of time; setting this variable reduces that time." | 510 non-negletable amount of time; setting this variable reduces that time." |
511 :type 'integer | 511 :type 'integer |
512 :group 'ido) | 512 :group 'ido) |
513 | 513 |
514 (defcustom ido-max-prompt-path 0.35 | 514 (defcustom ido-max-prompt-width 0.35 |
515 "*Non-zero means that the prompt string be limited to than number of characters. | 515 "*Non-zero means that the prompt string be limited to than number of characters. |
516 If value is a floating point number, it specifies a fraction of the frame width." | 516 If value is a floating point number, it specifies a fraction of the frame width." |
517 :type '(choice | 517 :type '(choice |
518 (integer :tag "Characters" :value 20) | 518 (integer :tag "Characters" :value 20) |
519 (restricted-sexp :tag "Fraction of frame width" | 519 (restricted-sexp :tag "Fraction of frame width" |
531 :value 0.25 | 531 :value 0.25 |
532 :match-alternatives (ido-fractionp))) | 532 :match-alternatives (ido-fractionp))) |
533 :group 'ido) | 533 :group 'ido) |
534 | 534 |
535 (defcustom ido-enable-last-directory-history t | 535 (defcustom ido-enable-last-directory-history t |
536 "*Non-nil means that `ido' will remember latest selected directory paths. | 536 "*Non-nil means that `ido' will remember latest selected directory names. |
537 See `ido-last-directory-list' and `ido-save-directory-list-file'." | 537 See `ido-last-directory-list' and `ido-save-directory-list-file'." |
538 :type 'boolean | 538 :type 'boolean |
539 :group 'ido) | 539 :group 'ido) |
540 | 540 |
541 (defcustom ido-max-work-directory-list 50 | 541 (defcustom ido-max-work-directory-list 50 |
545 :type 'integer | 545 :type 'integer |
546 :group 'ido) | 546 :group 'ido) |
547 | 547 |
548 (defcustom ido-work-directory-list-ignore-regexps nil | 548 (defcustom ido-work-directory-list-ignore-regexps nil |
549 "*List of regexps matching directories which should not be recorded. | 549 "*List of regexps matching directories which should not be recorded. |
550 Directory paths matched by one of the regexps in this list are not inserted in | 550 Directory names matched by one of the regexps in this list are not inserted in |
551 the `ido-work-directory-list' list." | 551 the `ido-work-directory-list' list." |
552 :type '(repeat regexp) | 552 :type '(repeat regexp) |
553 :group 'ido) | 553 :group 'ido) |
554 | 554 |
555 | 555 |
556 (defcustom ido-enable-tramp-completion t | 556 (defcustom ido-enable-tramp-completion t |
557 "*Non-nil means that ido shall perform tramp method and server name completion. | 557 "*Non-nil means that ido shall perform tramp method and server name completion. |
558 A tramp file name uses the following syntax: /method:user@host:path." | 558 A tramp file name uses the following syntax: /method:user@host:filename." |
559 :type 'boolean | 559 :type 'boolean |
560 :group 'ido) | 560 :group 'ido) |
561 | 561 |
562 (defcustom ido-record-ftp-work-directories t | 562 (defcustom ido-record-ftp-work-directories t |
563 "*Non-nil means that ftp paths are recorded in work directory list." | 563 "*Non-nil means that remote directories are recorded in work directory list." |
564 :type 'boolean | 564 :type 'boolean |
565 :group 'ido) | 565 :group 'ido) |
566 | 566 |
567 (defcustom ido-merge-ftp-work-directories nil | 567 (defcustom ido-merge-ftp-work-directories nil |
568 "*Nil means that ftp paths in work directory list are ignored during merge." | 568 "*Nil means that remote directories in work directory list are ignored during merge." |
569 :type 'boolean | 569 :type 'boolean |
570 :group 'ido) | 570 :group 'ido) |
571 | 571 |
572 (defcustom ido-cache-ftp-work-directory-time 1.0 | 572 (defcustom ido-cache-ftp-work-directory-time 1.0 |
573 "*Maximum time to cache contents of an ftp directory (in hours). | 573 "*Maximum time to cache contents of an ftp directory (in hours). |
733 Each function on the list may modify the dynamically bound variable | 733 Each function on the list may modify the dynamically bound variable |
734 `ido-temp-list' which contains the current list of matching buffer names." | 734 `ido-temp-list' which contains the current list of matching buffer names." |
735 :type 'hook | 735 :type 'hook |
736 :group 'ido) | 736 :group 'ido) |
737 | 737 |
738 (defcustom ido-make-file-prompt-hook nil | 738 (defcustom ido-rewrite-file-prompt-functions nil |
739 "*List of functions to run when the find-file prompt is created. | 739 "*List of functions to run when the find-file prompt is created. |
740 Each function on the list may modify the following dynamically bound | 740 Each function on the list may modify the following dynamically bound |
741 variables: | 741 variables: |
742 path - the (abbreviated) directory path | 742 dirname - the (abbreviated) directory name to be modified by the hook functions |
743 max-width - the max width of the path; set to nil to inhibit truncation | 743 max-width - the max width of the resulting dirname; set to nil to inhibit truncation |
744 prompt - the basic prompt (e.g. \"Find File: \") | 744 prompt - the basic prompt (e.g. \"Find File: \") |
745 literal - the string shown if doing `literal' find; set to nil to omit | 745 literal - the string shown if doing `literal' find; set to nil to omit |
746 vc-off - the string shown if version control is inhibited; set to nit to omit | 746 vc-off - the string shown if version control is inhibited; set to nit to omit |
747 prefix - normally nil, but may be set to a fixed prefix for the path | 747 prefix - normally nil, but may be set to a fixed prefix for the dirname |
748 The following variables are available, but should not be changed: | 748 The following variables are available, but should not be changed: |
749 ido-current-directory - the unabbreviated directory path | 749 ido-current-directory - the unabbreviated directory name |
750 item - equals 'file or 'dir depending on the current mode." | 750 item - equals 'file or 'dir depending on the current mode." |
751 :type 'hook | 751 :type 'hook |
752 :group 'ido) | 752 :group 'ido) |
753 | 753 |
754 (defvar ido-rewrite-prompt-path-rules nil | 754 (defvar ido-rewrite-file-prompt-rules nil |
755 "*Alist of rewriting rules for file paths. | 755 "*Alist of rewriting rules for directory names in ido prompts. |
756 A list of elements of the form (FROM . TO) or (FROM . FUNC), | 756 A list of elements of the form (FROM . TO) or (FROM . FUNC), each |
757 each meaning to rewrite the path if matched by FROM by either | 757 meaning to rewrite the directory name if matched by FROM by either |
758 substituting the matched string by TO or calling the function | 758 substituting the matched string by TO or calling the function FUNC |
759 FUNC with the current path as its only argument and using the | 759 with the current directory name as its only argument and using the |
760 return value as the new path. In addition, each FUNC may | 760 return value as the new directory name. In addition, each FUNC may |
761 also modify the dynamic variables described for the | 761 also modify the dynamic variables described for the variable |
762 variable `ido-make-file-prompt-hook'.") | 762 `ido-rewrite-file-prompt-functions'.") |
763 | 763 |
764 (defcustom ido-completion-buffer "*Ido Completions*" | 764 (defcustom ido-completion-buffer "*Ido Completions*" |
765 "*Name of completion buffer used by ido. | 765 "*Name of completion buffer used by ido. |
766 Set to nil to disable completion buffers popping up." | 766 Set to nil to disable completion buffers popping up." |
767 :type 'string | 767 :type 'string |
802 Must be set before enabling ido mode." | 802 Must be set before enabling ido mode." |
803 :type 'string | 803 :type 'string |
804 :group 'ido) | 804 :group 'ido) |
805 | 805 |
806 (defcustom ido-read-file-name-as-directory-commands '() | 806 (defcustom ido-read-file-name-as-directory-commands '() |
807 "List of commands which uses read-file-name to read a directory path. | 807 "List of commands which uses read-file-name to read a directory name. |
808 When `ido-everywhere' is non-nil, the commands in this list will read | 808 When `ido-everywhere' is non-nil, the commands in this list will read |
809 the directory using ido-read-directory-name." | 809 the directory using ido-read-directory-name." |
810 :type '(repeat symbol) | 810 :type '(repeat symbol) |
811 :group 'ido) | 811 :group 'ido) |
812 | 812 |
829 | 829 |
830 (defvar ido-buffer-history nil | 830 (defvar ido-buffer-history nil |
831 "History of buffers selected using `ido-switch-buffer'.") | 831 "History of buffers selected using `ido-switch-buffer'.") |
832 | 832 |
833 (defvar ido-last-directory-list nil | 833 (defvar ido-last-directory-list nil |
834 "List of last selected directory paths. | 834 "List of last selected directory names. |
835 See `ido-enable-last-directory-history' for details.") | 835 See `ido-enable-last-directory-history' for details.") |
836 | 836 |
837 (defvar ido-work-directory-list nil | 837 (defvar ido-work-directory-list nil |
838 "List of actual working directory paths. | 838 "List of actual working directory names. |
839 The current directory is inserted at the front of this list whenever a | 839 The current directory is inserted at the front of this list whenever a |
840 file is opened with ido-find-file and family.") | 840 file is opened with ido-find-file and family.") |
841 | 841 |
842 (defvar ido-work-file-list nil | 842 (defvar ido-work-file-list nil |
843 "List of actual work file names. | 843 "List of actual work file names. |
844 The current file name (sans path) is inserted at the front of this list | 844 The current file name (sans directory) is inserted at the front of this list |
845 whenever a file is opened with ido-find-file and family.") | 845 whenever a file is opened with ido-find-file and family.") |
846 | 846 |
847 (defvar ido-dir-file-cache nil | 847 (defvar ido-dir-file-cache nil |
848 "List of file-name-all-completions results. | 848 "List of file-name-all-completions results. |
849 Each element in the list is of the form (dir (mtime) file...).") | 849 Each element in the list is of the form (dir (mtime) file...).") |
1392 | 1392 |
1393 (defun ido-make-prompt (item prompt) | 1393 (defun ido-make-prompt (item prompt) |
1394 ;; Make the prompt for ido-read-internal | 1394 ;; Make the prompt for ido-read-internal |
1395 (cond | 1395 (cond |
1396 ((and (memq item '(file dir)) ido-current-directory) | 1396 ((and (memq item '(file dir)) ido-current-directory) |
1397 (let ((path (abbreviate-file-name ido-current-directory)) | 1397 (let ((dirname (abbreviate-file-name ido-current-directory)) |
1398 (max-width (if (and ido-max-prompt-path (floatp ido-max-prompt-path)) | 1398 (max-width (if (and ido-max-prompt-width (floatp ido-max-prompt-width)) |
1399 (floor (* (frame-width) ido-max-prompt-path)) | 1399 (floor (* (frame-width) ido-max-prompt-width)) |
1400 ido-max-prompt-path)) | 1400 ido-max-prompt-width)) |
1401 (literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) ")) | 1401 (literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) ")) |
1402 (vc-off (and ido-saved-vc-mt (not vc-master-templates) "[-VC] ")) | 1402 (vc-off (and ido-saved-vc-mt (not vc-master-templates) "[-VC] ")) |
1403 (prefix nil) | 1403 (prefix nil) |
1404 (rule ido-rewrite-prompt-path-rules)) | 1404 (rule ido-rewrite-file-prompt-rules)) |
1405 (let ((case-fold-search nil)) | 1405 (let ((case-fold-search nil)) |
1406 (while rule | 1406 (while rule |
1407 (if (and (consp (car rule)) | 1407 (if (and (consp (car rule)) |
1408 (string-match (car (car rule)) path)) | 1408 (string-match (car (car rule)) dirname)) |
1409 (setq path | 1409 (setq dirname |
1410 (if (stringp (cdr (car rule))) | 1410 (if (stringp (cdr (car rule))) |
1411 (replace-match (cdr (car rule)) t nil path) | 1411 (replace-match (cdr (car rule)) t nil dirname) |
1412 (funcall (cdr (car rule)) path)))) | 1412 (funcall (cdr (car rule)) dirname)))) |
1413 (setq rule (cdr rule)))) | 1413 (setq rule (cdr rule)))) |
1414 (run-hooks 'ido-make-file-prompt-hook) | 1414 (run-hooks 'ido-rewrite-file-prompt-functions) |
1415 (concat prompt | 1415 (concat prompt |
1416 ; (if ido-process-ignore-lists "" "&") | 1416 ; (if ido-process-ignore-lists "" "&") |
1417 (or literal "") | 1417 (or literal "") |
1418 (or vc-off "") | 1418 (or vc-off "") |
1419 (or prefix "") | 1419 (or prefix "") |
1420 (let ((l (length path))) | 1420 (let ((l (length dirname))) |
1421 (if (and max-width (> max-width 0) (> l max-width)) | 1421 (if (and max-width (> max-width 0) (> l max-width)) |
1422 (let* ((s (substring path (- max-width))) | 1422 (let* ((s (substring dirname (- max-width))) |
1423 (i (string-match "/" s))) | 1423 (i (string-match "/" s))) |
1424 (concat "..." (if i (substring s i) s))) | 1424 (concat "..." (if i (substring s i) s))) |
1425 path))))) | 1425 dirname))))) |
1426 (t prompt))) | 1426 (t prompt))) |
1427 | 1427 |
1428 ;; Here is very briefly how ido-find-file works: | 1428 ;; Here is very briefly how ido-find-file works: |
1429 ;; | 1429 ;; |
1430 ;; (ido-find-file) | 1430 ;; (ido-find-file) |
1721 (t | 1721 (t |
1722 (setq done t)))))) | 1722 (setq done t)))))) |
1723 ido-selected)) | 1723 ido-selected)) |
1724 | 1724 |
1725 (defun ido-edit-input () | 1725 (defun ido-edit-input () |
1726 "Edit ido path and input string. Terminate by RET." | 1726 "Edit absolute file name entered so far with ido; terminate by RET." |
1727 (interactive) | 1727 (interactive) |
1728 (setq ido-text-init ido-text) | 1728 (setq ido-text-init ido-text) |
1729 (setq ido-exit 'edit) | 1729 (setq ido-exit 'edit) |
1730 (exit-minibuffer)) | 1730 (exit-minibuffer)) |
1731 | 1731 |
1882 (ido-record-work-directory) | 1882 (ido-record-work-directory) |
1883 (funcall method ido-current-directory) | 1883 (funcall method ido-current-directory) |
1884 (if (eq method 'dired) | 1884 (if (eq method 'dired) |
1885 (dired-goto-file (expand-file-name file)))) | 1885 (dired-goto-file (expand-file-name file)))) |
1886 ((string-match "[[*?]" filename) | 1886 ((string-match "[[*?]" filename) |
1887 (setq path (concat ido-current-directory filename)) | 1887 (setq path (concat ido-current-directory filename)) |
1888 (ido-record-command method path) | 1888 (ido-record-command method path) |
1889 (ido-record-work-directory) | 1889 (ido-record-work-directory) |
1890 (funcall method path)) | 1890 (funcall method path)) |
1891 ((y-or-n-p (format "Directory %s does not exist. Create it " filename)) | 1891 ((y-or-n-p (format "Directory %s does not exist. Create it " filename)) |
1892 (ido-record-command method path) | 1892 (ido-record-command method path) |
1956 (cond | 1956 (cond |
1957 ((and (memq ido-cur-item '(file dir)) | 1957 ((and (memq ido-cur-item '(file dir)) |
1958 (string-match "[$]" ido-text)) | 1958 (string-match "[$]" ido-text)) |
1959 (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text)))) | 1959 (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text)))) |
1960 (if (not (file-exists-p (file-name-directory evar))) | 1960 (if (not (file-exists-p (file-name-directory evar))) |
1961 (message "Expansion generates non-existing directory path") | 1961 (message "Expansion generates non-existing directory.") |
1962 (if (file-directory-p evar) | 1962 (if (file-directory-p evar) |
1963 (ido-set-current-directory evar) | 1963 (ido-set-current-directory evar) |
1964 (let ((d (or (file-name-directory evar) "/")) | 1964 (let ((d (or (file-name-directory evar) "/")) |
1965 (f (file-name-nondirectory evar))) | 1965 (f (file-name-nondirectory evar))) |
1966 (when (file-directory-p d) | 1966 (when (file-directory-p d) |
2317 (setq ido-exit 'refresh | 2317 (setq ido-exit 'refresh |
2318 ido-try-merged-list nil) | 2318 ido-try-merged-list nil) |
2319 (exit-minibuffer)))) | 2319 (exit-minibuffer)))) |
2320 | 2320 |
2321 (defun ido-copy-current-word (all) | 2321 (defun ido-copy-current-word (all) |
2322 "Insert current word (file name or path) from current buffer." | 2322 "Insert current word (file or directory name) from current buffer." |
2323 (interactive "P") | 2323 (interactive "P") |
2324 (let ((word (save-excursion | 2324 (let ((word (save-excursion |
2325 (set-buffer ido-entry-buffer) | 2325 (set-buffer ido-entry-buffer) |
2326 (let ((p (point)) start-line end-line start-name name) | 2326 (let ((p (point)) start-line end-line start-name name) |
2327 (beginning-of-line) | 2327 (beginning-of-line) |
2492 f (file-name-nondirectory path) | 2492 f (file-name-nondirectory path) |
2493 res (cons (cons (if finddir (ido-final-slash f t) f) d) res)))) | 2493 res (cons (cons (if finddir (ido-final-slash f t) f) d) res)))) |
2494 res)) | 2494 res)) |
2495 | 2495 |
2496 (defun ido-flatten-merged-list (items) | 2496 (defun ido-flatten-merged-list (items) |
2497 ;; Create a list of path names based on a merged directory list. | 2497 ;; Create a list of directory names based on a merged directory list. |
2498 (let (res) | 2498 (let (res) |
2499 (while items | 2499 (while items |
2500 (let* ((item (car items)) | 2500 (let* ((item (car items)) |
2501 (file (car item)) | 2501 (file (car item)) |
2502 (dirs (cdr item))) | 2502 (dirs (cdr item))) |
3218 \\[ido-prev-match] Put the last element at the start of the list. | 3218 \\[ido-prev-match] Put the last element at the start of the list. |
3219 \\[ido-complete] Complete a common suffix to the current string that | 3219 \\[ido-complete] Complete a common suffix to the current string that |
3220 matches all files. If there is only one match, select that file. | 3220 matches all files. If there is only one match, select that file. |
3221 If there is no common suffix, show a list of all matching files | 3221 If there is no common suffix, show a list of all matching files |
3222 in a separate window. | 3222 in a separate window. |
3223 \\[ido-edit-input] Edit input string (including path). | 3223 \\[ido-edit-input] Edit input string (including directory). |
3224 \\[ido-prev-work-directory] or \\[ido-next-work-directory] go to previous/next directory in work directory history. | 3224 \\[ido-prev-work-directory] or \\[ido-next-work-directory] go to previous/next directory in work directory history. |
3225 \\[ido-merge-work-directories] search for file in the work directory history. | 3225 \\[ido-merge-work-directories] search for file in the work directory history. |
3226 \\[ido-forget-work-directory] removes current directory from the work directory history. | 3226 \\[ido-forget-work-directory] removes current directory from the work directory history. |
3227 \\[ido-prev-work-file] or \\[ido-next-work-file] cycle through the work file history. | 3227 \\[ido-prev-work-file] or \\[ido-next-work-file] cycle through the work file history. |
3228 \\[ido-wide-find-file] and \\[ido-wide-find-dir] prompts and uses find to locate files or directories. | 3228 \\[ido-wide-find-file] and \\[ido-wide-find-dir] prompts and uses find to locate files or directories. |