/[emacs]/emacs/lisp/ido.el
ViewVC logotype

Diff of /emacs/lisp/ido.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by kfstorm, Sun Jan 12 22:27:17 2003 UTC revision 1.20 by kfstorm, Mon Jan 13 22:56:53 2003 UTC
# Line 416  This allows the current directory to be Line 416  This allows the current directory to be
416    :group 'ido)    :group 'ido)
417    
418  (defcustom ido-ignore-directories-merge nil  (defcustom ido-ignore-directories-merge nil
419    "*List of regexps or functions matching directory path names to ignore during merge.    "*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  Directory names matched by one of the regexps in this list are not inserted
421  in merged file and directory lists."  in merged file and directory lists."
422    :type '(repeat (choice regexp function))    :type '(repeat (choice regexp function))
423    :group 'ido)    :group 'ido)
# Line 511  non-negletable amount of time; setting t Line 511  non-negletable amount of time; setting t
511    :type 'integer    :type 'integer
512    :group 'ido)    :group 'ido)
513    
514  (defcustom ido-max-prompt-path 0.35  (defcustom ido-max-prompt-width 0.35
515    "*Non-zero means that the prompt string be limited to than number of characters.    "*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."  If value is a floating point number, it specifies a fraction of the frame width."
517    :type '(choice    :type '(choice
# Line 533  If value is a floating point number, it Line 533  If value is a floating point number, it
533    :group 'ido)    :group 'ido)
534    
535  (defcustom ido-enable-last-directory-history t  (defcustom ido-enable-last-directory-history t
536    "*Non-nil means that `ido' will remember latest selected directory paths.    "*Non-nil means that `ido' will remember latest selected directory names.
537  See `ido-last-directory-list' and `ido-save-directory-list-file'."  See `ido-last-directory-list' and `ido-save-directory-list-file'."
538    :type 'boolean    :type 'boolean
539    :group 'ido)    :group 'ido)
# Line 547  See `ido-work-directory-list' and `ido-s Line 547  See `ido-work-directory-list' and `ido-s
547    
548  (defcustom ido-work-directory-list-ignore-regexps nil  (defcustom ido-work-directory-list-ignore-regexps nil
549    "*List of regexps matching directories which should not be recorded.    "*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  Directory names matched by one of the regexps in this list are not inserted in
551  the `ido-work-directory-list' list."  the `ido-work-directory-list' list."
552    :type '(repeat regexp)    :type '(repeat regexp)
553    :group 'ido)    :group 'ido)
# Line 555  the `ido-work-directory-list' list." Line 555  the `ido-work-directory-list' list."
555    
556  (defcustom ido-enable-tramp-completion t  (defcustom ido-enable-tramp-completion t
557    "*Non-nil means that ido shall perform tramp method and server name completion.    "*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."  A tramp file name uses the following syntax: /method:user@host:filename."
559    :type 'boolean    :type 'boolean
560    :group 'ido)    :group 'ido)
561    
562  (defcustom ido-record-ftp-work-directories t  (defcustom ido-record-ftp-work-directories t
563    "*Non-nil means that ftp paths are recorded in work directory list."    "*Non-nil means that remote directories are recorded in work directory list."
564    :type 'boolean    :type 'boolean
565    :group 'ido)    :group 'ido)
566    
567  (defcustom ido-merge-ftp-work-directories nil  (defcustom ido-merge-ftp-work-directories nil
568    "*Nil means that ftp paths in work directory list are ignored during merge."    "*Nil means that remote directories in work directory list are ignored during merge."
569    :type 'boolean    :type 'boolean
570    :group 'ido)    :group 'ido)
571    
# Line 735  Each function on the list may modify the Line 735  Each function on the list may modify the
735    :type 'hook    :type 'hook
736    :group 'ido)    :group 'ido)
737    
738  (defcustom ido-make-file-prompt-hook nil  (defcustom ido-rewrite-file-prompt-functions nil
739    "*List of functions to run when the find-file prompt is created.    "*List of functions to run when the find-file prompt is created.
740  Each function on the list may modify the following dynamically bound  Each function on the list may modify the following dynamically bound
741  variables:  variables:
742    path   - the (abbreviated) directory path    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    max-width - the max width of the resulting dirname; set to nil to inhibit truncation
744    prompt - the basic prompt (e.g. \"Find File: \")    prompt - the basic prompt (e.g. \"Find File: \")
745    literal - the string shown if doing `literal' find; set to nil to omit    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    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    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:  The following variables are available, but should not be changed:
749    ido-current-directory - the unabbreviated directory path    ido-current-directory - the unabbreviated directory name
750    item - equals 'file or 'dir depending on the current mode."    item - equals 'file or 'dir depending on the current mode."
751    :type 'hook    :type 'hook
752    :group 'ido)    :group 'ido)
753    
754  (defvar ido-rewrite-prompt-path-rules nil  (defvar ido-rewrite-file-prompt-rules nil
755    "*Alist of rewriting rules for file paths.    "*Alist of rewriting rules for directory names in ido prompts.
756  A list of elements of the form (FROM . TO) or (FROM . FUNC),  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  meaning to rewrite the directory name if matched by FROM by either
758  substituting the matched string by TO or calling the function  substituting the matched string by TO or calling the function FUNC
759  FUNC with the current path as its only argument and using the  with the current directory name as its only argument and using the
760  return value as the new path.  In addition, each FUNC may  return value as the new directory name.  In addition, each FUNC may
761  also modify the dynamic variables described for the  also modify the dynamic variables described for the variable
762  variable `ido-make-file-prompt-hook'.")  `ido-rewrite-file-prompt-functions'.")
763    
764  (defcustom ido-completion-buffer "*Ido Completions*"  (defcustom ido-completion-buffer "*Ido Completions*"
765    "*Name of completion buffer used by ido.    "*Name of completion buffer used by ido.
# Line 804  Must be set before enabling ido mode." Line 804  Must be set before enabling ido mode."
804    :group 'ido)    :group 'ido)
805    
806  (defcustom ido-read-file-name-as-directory-commands '()  (defcustom ido-read-file-name-as-directory-commands '()
807    "List of commands which uses read-file-name to read a directory path.    "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  When `ido-everywhere' is non-nil, the commands in this list will read
809  the directory using ido-read-directory-name."  the directory using ido-read-directory-name."
810    :type '(repeat symbol)    :type '(repeat symbol)
# Line 831  the file name using normal read-file-nam Line 831  the file name using normal read-file-nam
831    "History of buffers selected using `ido-switch-buffer'.")    "History of buffers selected using `ido-switch-buffer'.")
832    
833  (defvar ido-last-directory-list nil  (defvar ido-last-directory-list nil
834    "List of last selected directory paths.    "List of last selected directory names.
835  See `ido-enable-last-directory-history' for details.")  See `ido-enable-last-directory-history' for details.")
836    
837  (defvar ido-work-directory-list nil  (defvar ido-work-directory-list nil
838    "List of actual working directory paths.    "List of actual working directory names.
839  The current directory is inserted at the front of this list whenever a  The current directory is inserted at the front of this list whenever a
840  file is opened with ido-find-file and family.")  file is opened with ido-find-file and family.")
841    
842  (defvar ido-work-file-list nil  (defvar ido-work-file-list nil
843    "List of actual work file names.    "List of actual work file names.
844  The current file name (sans path) is inserted at the front of this list  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.")  whenever a file is opened with ido-find-file and family.")
846    
847  (defvar ido-dir-file-cache nil  (defvar ido-dir-file-cache nil
# Line 1394  This function also adds a hook to the mi Line 1394  This function also adds a hook to the mi
1394    ;; Make the prompt for ido-read-internal    ;; Make the prompt for ido-read-internal
1395    (cond    (cond
1396     ((and (memq item '(file dir)) ido-current-directory)     ((and (memq item '(file dir)) ido-current-directory)
1397      (let ((path (abbreviate-file-name ido-current-directory))      (let ((dirname (abbreviate-file-name ido-current-directory))
1398            (max-width (if (and ido-max-prompt-path (floatp ido-max-prompt-path))            (max-width (if (and ido-max-prompt-width (floatp ido-max-prompt-width))
1399                           (floor (* (frame-width) ido-max-prompt-path))                           (floor (* (frame-width) ido-max-prompt-width))
1400                         ido-max-prompt-path))                         ido-max-prompt-width))
1401            (literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) "))            (literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) "))
1402            (vc-off (and ido-saved-vc-mt (not vc-master-templates) "[-VC] "))            (vc-off (and ido-saved-vc-mt (not vc-master-templates) "[-VC] "))
1403            (prefix nil)            (prefix nil)
1404            (rule ido-rewrite-prompt-path-rules))            (rule ido-rewrite-file-prompt-rules))
1405        (let ((case-fold-search nil))        (let ((case-fold-search nil))
1406          (while rule          (while rule
1407            (if (and (consp (car rule))            (if (and (consp (car rule))
1408                     (string-match (car (car rule)) path))                     (string-match (car (car rule)) dirname))
1409                (setq path                (setq dirname
1410                      (if (stringp (cdr (car rule)))                      (if (stringp (cdr (car rule)))
1411                          (replace-match (cdr (car rule)) t nil path)                          (replace-match (cdr (car rule)) t nil dirname)
1412                        (funcall (cdr (car rule)) path))))                        (funcall (cdr (car rule)) dirname))))
1413            (setq rule (cdr rule))))            (setq rule (cdr rule))))
1414        (run-hooks 'ido-make-file-prompt-hook)        (run-hooks 'ido-rewrite-file-prompt-functions)
1415        (concat prompt        (concat prompt
1416                ; (if ido-process-ignore-lists "" "&")                ; (if ido-process-ignore-lists "" "&")
1417                (or literal "")                (or literal "")
1418                (or vc-off  "")                (or vc-off  "")
1419                (or prefix "")                (or prefix "")
1420                (let ((l (length path)))                (let ((l (length dirname)))
1421                  (if (and max-width (> max-width 0) (> l max-width))                  (if (and max-width (> max-width 0) (> l max-width))
1422                      (let* ((s (substring path (- max-width)))                      (let* ((s (substring dirname (- max-width)))
1423                             (i (string-match "/" s)))                             (i (string-match "/" s)))
1424                        (concat "..." (if i (substring s i) s)))                        (concat "..." (if i (substring s i) s)))
1425                    path)))))                    dirname)))))
1426     (t prompt)))     (t prompt)))
1427    
1428  ;; Here is very briefly how ido-find-file works:  ;; Here is very briefly how ido-find-file works:
# Line 1723  If INITIAL is non-nil, it specifies the Line 1723  If INITIAL is non-nil, it specifies the
1723      ido-selected))      ido-selected))
1724    
1725  (defun ido-edit-input ()  (defun ido-edit-input ()
1726    "Edit ido path and input string. Terminate by RET."    "Edit absolute file name entered so far with ido; terminate by RET."
1727    (interactive)    (interactive)
1728    (setq ido-text-init ido-text)    (setq ido-text-init ido-text)
1729    (setq ido-exit 'edit)    (setq ido-exit 'edit)
# Line 1884  If INITIAL is non-nil, it specifies the Line 1884  If INITIAL is non-nil, it specifies the
1884                (if (eq method 'dired)                (if (eq method 'dired)
1885                    (dired-goto-file (expand-file-name file))))                    (dired-goto-file (expand-file-name file))))
1886               ((string-match "[[*?]" filename)               ((string-match "[[*?]" filename)
1887                (setq  path (concat ido-current-directory filename))                (setq path (concat ido-current-directory filename))
1888                (ido-record-command method path)                (ido-record-command method path)
1889                (ido-record-work-directory)                (ido-record-work-directory)
1890                (funcall method path))                (funcall method path))
# Line 1958  If INITIAL is non-nil, it specifies the Line 1958  If INITIAL is non-nil, it specifies the
1958             (string-match "[$]" ido-text))             (string-match "[$]" ido-text))
1959        (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text))))        (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text))))
1960          (if (not (file-exists-p (file-name-directory evar)))          (if (not (file-exists-p (file-name-directory evar)))
1961              (message "Expansion generates non-existing directory path")              (message "Expansion generates non-existing directory.")
1962            (if (file-directory-p evar)            (if (file-directory-p evar)
1963                (ido-set-current-directory evar)                (ido-set-current-directory evar)
1964              (let ((d (or (file-name-directory evar) "/"))              (let ((d (or (file-name-directory evar) "/"))
# Line 2319  If repeated, insert text from buffer ins Line 2319  If repeated, insert text from buffer ins
2319        (exit-minibuffer))))        (exit-minibuffer))))
2320        
2321  (defun ido-copy-current-word (all)  (defun ido-copy-current-word (all)
2322    "Insert current word (file name or path) from current buffer."    "Insert current word (file or directory name) from current buffer."
2323    (interactive "P")    (interactive "P")
2324    (let ((word (save-excursion    (let ((word (save-excursion
2325                  (set-buffer ido-entry-buffer)                  (set-buffer ido-entry-buffer)
# Line 2494  for first matching file." Line 2494  for first matching file."
2494      res))      res))
2495    
2496  (defun ido-flatten-merged-list (items)  (defun ido-flatten-merged-list (items)
2497    ;; Create a list of path names based on a merged directory list.    ;; Create a list of directory names based on a merged directory list.
2498    (let (res)    (let (res)
2499      (while items      (while items
2500        (let* ((item (car items))        (let* ((item (car items))
# Line 3220  If no buffer or file is found, prompt fo Line 3220  If no buffer or file is found, prompt fo
3220  matches all files.  If there is only one match, select that file.  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  If there is no common suffix, show a list of all matching files
3222  in a separate window.  in a separate window.
3223  \\[ido-edit-input] Edit input string (including path).  \\[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.  \\[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.  \\[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.  \\[ido-forget-work-directory] removes current directory from the work directory history.

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26