553 |
:group 'ido) |
:group 'ido) |
554 |
|
|
555 |
|
|
556 |
|
(defcustom ido-use-filename-at-point nil |
557 |
|
"*Non-nil means that ido shall look for a filename at point. |
558 |
|
If found, use that as the starting point for filename selection." |
559 |
|
:type 'boolean |
560 |
|
:group 'ido) |
561 |
|
|
562 |
|
|
563 |
|
(defcustom ido-use-url-at-point nil |
564 |
|
"*Non-nil means that ido shall look for a URL at point. |
565 |
|
If found, call `find-file-at-point' to visit it." |
566 |
|
:type 'boolean |
567 |
|
:group 'ido) |
568 |
|
|
569 |
|
|
570 |
(defcustom ido-enable-tramp-completion t |
(defcustom ido-enable-tramp-completion t |
571 |
"*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. |
572 |
A tramp file name uses the following syntax: /method:user@host:filename." |
A tramp file name uses the following syntax: /method:user@host:filename." |
968 |
;; Value is a list (ido-text dir cur-list ignored-list matches). |
;; Value is a list (ido-text dir cur-list ignored-list matches). |
969 |
(defvar ido-pre-merge-state) |
(defvar ido-pre-merge-state) |
970 |
|
|
971 |
;; Original value of vc-master-templates for use in ido-toggle-vc. |
;; Original value of vc-handled-backends for use in ido-toggle-vc. |
972 |
(defvar ido-saved-vc-mt) |
(defvar ido-saved-vc-hb) |
973 |
|
|
974 |
;; Stores temporary state of literal find file. |
;; Stores temporary state of literal find file. |
975 |
(defvar ido-find-literal) |
(defvar ido-find-literal) |
1386 |
(fix-it (concat dir "/")) |
(fix-it (concat dir "/")) |
1387 |
(t nil))) |
(t nil))) |
1388 |
|
|
1389 |
|
(defun ido-no-final-slash (s) |
1390 |
|
;; Remove optional final slash from string S |
1391 |
|
(let ((l (1- (length s)))) |
1392 |
|
(if (and (> l 0) (eq (aref s l) ?/)) |
1393 |
|
(substring s 0 l) |
1394 |
|
s))) |
1395 |
|
|
1396 |
(defun ido-set-current-directory (dir &optional subdir no-merge) |
(defun ido-set-current-directory (dir &optional subdir no-merge) |
1397 |
;; Set ido's current directory to DIR or DIR/SUBDIR |
;; Set ido's current directory to DIR or DIR/SUBDIR |
1398 |
(setq dir (ido-final-slash dir t)) |
(setq dir (ido-final-slash dir t)) |
1429 |
(floor (* (frame-width) ido-max-file-prompt-width)) |
(floor (* (frame-width) ido-max-file-prompt-width)) |
1430 |
ido-max-file-prompt-width)) |
ido-max-file-prompt-width)) |
1431 |
(literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) ")) |
(literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) ")) |
1432 |
(vc-off (and ido-saved-vc-mt (not vc-master-templates) "[-VC] ")) |
(vc-off (and ido-saved-vc-hb (not vc-handled-backends) "[-VC] ")) |
1433 |
(prefix nil) |
(prefix nil) |
1434 |
(rule ido-rewrite-file-prompt-rules)) |
(rule ido-rewrite-file-prompt-rules)) |
1435 |
(let ((case-fold-search nil)) |
(let ((case-fold-search nil)) |
1853 |
|
|
1854 |
(defun ido-file-internal (method &optional fallback default prompt item initial) |
(defun ido-file-internal (method &optional fallback default prompt item initial) |
1855 |
;; Internal function for ido-find-file and friends |
;; Internal function for ido-find-file and friends |
1856 |
|
(unless item |
1857 |
|
(setq item 'file)) |
1858 |
(let ((ido-current-directory (expand-file-name (or default default-directory))) |
(let ((ido-current-directory (expand-file-name (or default default-directory))) |
1859 |
filename) |
filename) |
1860 |
|
|
1861 |
(if (or (not ido-mode) (ido-is-slow-ftp-host)) |
(cond |
1862 |
(setq filename t |
((or (not ido-mode) (ido-is-slow-ftp-host)) |
1863 |
ido-exit 'fallback)) |
(setq filename t |
1864 |
|
ido-exit 'fallback)) |
1865 |
|
|
1866 |
|
((and (eq item 'file) |
1867 |
|
(or ido-use-url-at-point ido-use-filename-at-point)) |
1868 |
|
(let (fn d) |
1869 |
|
(require 'ffap) |
1870 |
|
;; Duplicate code from ffap-guesser as we want different behaviour for files and URLs. |
1871 |
|
(cond |
1872 |
|
((and ido-use-url-at-point |
1873 |
|
ffap-url-regexp |
1874 |
|
(ffap-fixup-url (or (ffap-url-at-point) |
1875 |
|
(ffap-gopher-at-point)))) |
1876 |
|
(setq ido-exit 'ffap |
1877 |
|
filename t)) |
1878 |
|
|
1879 |
|
((and ido-use-filename-at-point |
1880 |
|
(setq fn (ffap-string-at-point)) |
1881 |
|
(not (string-match "^http:/" fn)) |
1882 |
|
(setq d (file-name-directory fn)) |
1883 |
|
(file-directory-p d)) |
1884 |
|
(setq ido-current-directory d) |
1885 |
|
(setq initial (file-name-nondirectory fn))))))) |
1886 |
|
|
1887 |
(let (ido-saved-vc-mt |
(let (ido-saved-vc-hb |
1888 |
(vc-master-templates (and (boundp 'vc-master-templates) vc-master-templates)) |
(vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) |
1889 |
(ido-work-directory-index -1) |
(ido-work-directory-index -1) |
1890 |
(ido-work-file-index -1) |
(ido-work-file-index -1) |
1891 |
(ido-find-literal nil)) |
(ido-find-literal nil)) |
1892 |
|
|
1893 |
(unless filename |
(unless filename |
1894 |
(setq ido-saved-vc-mt vc-master-templates) |
(setq ido-saved-vc-hb vc-handled-backends) |
1895 |
(setq filename (ido-read-internal (or item 'file) |
(setq filename (ido-read-internal item |
1896 |
(or prompt "Find file: ") |
(or prompt "Find file: ") |
1897 |
'ido-file-history nil nil initial))) |
'ido-file-history nil nil initial))) |
1898 |
|
|
1913 |
((eq ido-exit 'dired) |
((eq ido-exit 'dired) |
1914 |
(dired (concat ido-current-directory (or ido-text "")))) |
(dired (concat ido-current-directory (or ido-text "")))) |
1915 |
|
|
1916 |
|
((eq ido-exit 'ffap) |
1917 |
|
(find-file-at-point)) |
1918 |
|
|
1919 |
((eq method 'alt-file) |
((eq method 'alt-file) |
1920 |
(ido-record-work-file filename) |
(ido-record-work-file filename) |
1921 |
(setq default-directory ido-current-directory) |
(setq default-directory ido-current-directory) |
2135 |
(interactive) |
(interactive) |
2136 |
(if (and ido-mode (eq ido-cur-item 'file)) |
(if (and ido-mode (eq ido-cur-item 'file)) |
2137 |
(progn |
(progn |
2138 |
(setq vc-master-templates |
(setq vc-handled-backends |
2139 |
(if vc-master-templates nil ido-saved-vc-mt)) |
(if vc-handled-backends nil ido-saved-vc-hb)) |
2140 |
(setq ido-text-init ido-text) |
(setq ido-text-init ido-text) |
2141 |
(setq ido-exit 'keep) |
(setq ido-exit 'keep) |
2142 |
(exit-minibuffer)))) |
(exit-minibuffer)))) |
2525 |
|
|
2526 |
(defun ido-sort-list (items) |
(defun ido-sort-list (items) |
2527 |
;; Simple list of file or buffer names |
;; Simple list of file or buffer names |
2528 |
(sort items (lambda (a b) (string-lessp a b)))) |
(sort items (lambda (a b) (string-lessp (ido-no-final-slash a) |
2529 |
|
(ido-no-final-slash b))))) |
2530 |
|
|
2531 |
(defun ido-sort-merged-list (items promote) |
(defun ido-sort-merged-list (items promote) |
2532 |
;; Input is list of ("file" . "dir") cons cells. |
;; Input is list of ("file" . "dir") cons cells. |
3772 |
((and (not (memq this-command ido-read-file-name-non-ido)) |
((and (not (memq this-command ido-read-file-name-non-ido)) |
3773 |
(or (null predicate) (eq predicate 'file-exists-p))) |
(or (null predicate) (eq predicate 'file-exists-p))) |
3774 |
(let (filename |
(let (filename |
3775 |
ido-saved-vc-mt |
ido-saved-vc-hb |
3776 |
(vc-master-templates (and (boundp 'vc-master-templates) vc-master-templates)) |
(vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) |
3777 |
(ido-current-directory (expand-file-name (or dir default-directory))) |
(ido-current-directory (expand-file-name (or dir default-directory))) |
3778 |
(ido-work-directory-index -1) |
(ido-work-directory-index -1) |
3779 |
(ido-work-file-index -1) |
(ido-work-file-index -1) |
3791 |
"Read directory name, prompting with PROMPT and completing in directory DIR. |
"Read directory name, prompting with PROMPT and completing in directory DIR. |
3792 |
See `read-file-name' for additional parameters." |
See `read-file-name' for additional parameters." |
3793 |
(let (filename |
(let (filename |
3794 |
ido-saved-vc-mt |
ido-saved-vc-hb |
3795 |
(ido-current-directory (expand-file-name (or dir default-directory))) |
(ido-current-directory (expand-file-name (or dir default-directory))) |
3796 |
(ido-work-directory-index -1) |
(ido-work-directory-index -1) |
3797 |
(ido-work-file-index -1)) |
(ido-work-file-index -1)) |