aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ido.el83
1 files changed, 66 insertions, 17 deletions
diff --git a/lisp/ido.el b/lisp/ido.el
index 46da5b92e52..57736ae7d26 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -553,6 +553,20 @@ the `ido-work-directory-list' list."
553 :group 'ido) 553 :group 'ido)
554 554
555 555
556(defcustom ido-use-filename-at-point nil
557 "*Non-nil means that ido shall look for a filename at point.
558If 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.
565If found, call `find-file-at-point' to visit it."
566 :type 'boolean
567 :group 'ido)
568
569
556(defcustom ido-enable-tramp-completion t 570(defcustom ido-enable-tramp-completion t
557 "*Non-nil means that ido shall perform tramp method and server name completion. 571 "*Non-nil means that ido shall perform tramp method and server name completion.
558A tramp file name uses the following syntax: /method:user@host:filename." 572A tramp file name uses the following syntax: /method:user@host:filename."
@@ -954,8 +968,8 @@ it doesn't interfere with other minibuffer usage.")
954;; Value is a list (ido-text dir cur-list ignored-list matches). 968;; Value is a list (ido-text dir cur-list ignored-list matches).
955(defvar ido-pre-merge-state) 969(defvar ido-pre-merge-state)
956 970
957;; Original value of vc-master-templates for use in ido-toggle-vc. 971;; Original value of vc-handled-backends for use in ido-toggle-vc.
958(defvar ido-saved-vc-mt) 972(defvar ido-saved-vc-hb)
959 973
960;; Stores temporary state of literal find file. 974;; Stores temporary state of literal find file.
961(defvar ido-find-literal) 975(defvar ido-find-literal)
@@ -1372,6 +1386,13 @@ This function also adds a hook to the minibuffer."
1372 (fix-it (concat dir "/")) 1386 (fix-it (concat dir "/"))
1373 (t nil))) 1387 (t nil)))
1374 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
1375(defun ido-set-current-directory (dir &optional subdir no-merge) 1396(defun ido-set-current-directory (dir &optional subdir no-merge)
1376 ;; Set ido's current directory to DIR or DIR/SUBDIR 1397 ;; Set ido's current directory to DIR or DIR/SUBDIR
1377 (setq dir (ido-final-slash dir t)) 1398 (setq dir (ido-final-slash dir t))
@@ -1408,7 +1429,7 @@ This function also adds a hook to the minibuffer."
1408 (floor (* (frame-width) ido-max-file-prompt-width)) 1429 (floor (* (frame-width) ido-max-file-prompt-width))
1409 ido-max-file-prompt-width)) 1430 ido-max-file-prompt-width))
1410 (literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) ")) 1431 (literal (and (boundp 'ido-find-literal) ido-find-literal "(literal) "))
1411 (vc-off (and ido-saved-vc-mt (not vc-master-templates) "[-VC] ")) 1432 (vc-off (and ido-saved-vc-hb (not vc-handled-backends) "[-VC] "))
1412 (prefix nil) 1433 (prefix nil)
1413 (rule ido-rewrite-file-prompt-rules)) 1434 (rule ido-rewrite-file-prompt-rules))
1414 (let ((case-fold-search nil)) 1435 (let ((case-fold-search nil))
@@ -1832,22 +1853,46 @@ If INITIAL is non-nil, it specifies the initial input string."
1832 1853
1833(defun ido-file-internal (method &optional fallback default prompt item initial) 1854(defun ido-file-internal (method &optional fallback default prompt item initial)
1834 ;; Internal function for ido-find-file and friends 1855 ;; Internal function for ido-find-file and friends
1856 (unless item
1857 (setq item 'file))
1835 (let ((ido-current-directory (expand-file-name (or default default-directory))) 1858 (let ((ido-current-directory (expand-file-name (or default default-directory)))
1836 filename) 1859 filename)
1837 1860
1838 (if (or (not ido-mode) (ido-is-slow-ftp-host)) 1861 (cond
1839 (setq filename t 1862 ((or (not ido-mode) (ido-is-slow-ftp-host))
1840 ido-exit 'fallback)) 1863 (setq filename t
1841 1864 ido-exit 'fallback))
1842 (let (ido-saved-vc-mt 1865
1843 (vc-master-templates (and (boundp 'vc-master-templates) vc-master-templates)) 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-hb
1888 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends))
1844 (ido-work-directory-index -1) 1889 (ido-work-directory-index -1)
1845 (ido-work-file-index -1) 1890 (ido-work-file-index -1)
1846 (ido-find-literal nil)) 1891 (ido-find-literal nil))
1847 1892
1848 (unless filename 1893 (unless filename
1849 (setq ido-saved-vc-mt vc-master-templates) 1894 (setq ido-saved-vc-hb vc-handled-backends)
1850 (setq filename (ido-read-internal (or item 'file) 1895 (setq filename (ido-read-internal item
1851 (or prompt "Find file: ") 1896 (or prompt "Find file: ")
1852 'ido-file-history nil nil initial))) 1897 'ido-file-history nil nil initial)))
1853 1898
@@ -1868,6 +1913,9 @@ If INITIAL is non-nil, it specifies the initial input string."
1868 ((eq ido-exit 'dired) 1913 ((eq ido-exit 'dired)
1869 (dired (concat ido-current-directory (or ido-text "")))) 1914 (dired (concat ido-current-directory (or ido-text ""))))
1870 1915
1916 ((eq ido-exit 'ffap)
1917 (find-file-at-point))
1918
1871 ((eq method 'alt-file) 1919 ((eq method 'alt-file)
1872 (ido-record-work-file filename) 1920 (ido-record-work-file filename)
1873 (setq default-directory ido-current-directory) 1921 (setq default-directory ido-current-directory)
@@ -2087,8 +2135,8 @@ If no merge has yet taken place, toggle automatic merging option."
2087 (interactive) 2135 (interactive)
2088 (if (and ido-mode (eq ido-cur-item 'file)) 2136 (if (and ido-mode (eq ido-cur-item 'file))
2089 (progn 2137 (progn
2090 (setq vc-master-templates 2138 (setq vc-handled-backends
2091 (if vc-master-templates nil ido-saved-vc-mt)) 2139 (if vc-handled-backends nil ido-saved-vc-hb))
2092 (setq ido-text-init ido-text) 2140 (setq ido-text-init ido-text)
2093 (setq ido-exit 'keep) 2141 (setq ido-exit 'keep)
2094 (exit-minibuffer)))) 2142 (exit-minibuffer))))
@@ -2477,7 +2525,8 @@ for first matching file."
2477 2525
2478(defun ido-sort-list (items) 2526(defun ido-sort-list (items)
2479 ;; Simple list of file or buffer names 2527 ;; Simple list of file or buffer names
2480 (sort items (lambda (a b) (string-lessp a b)))) 2528 (sort items (lambda (a b) (string-lessp (ido-no-final-slash a)
2529 (ido-no-final-slash b)))))
2481 2530
2482(defun ido-sort-merged-list (items promote) 2531(defun ido-sort-merged-list (items promote)
2483 ;; Input is list of ("file" . "dir") cons cells. 2532 ;; Input is list of ("file" . "dir") cons cells.
@@ -3723,8 +3772,8 @@ See `read-file-name' for additional parameters."
3723 ((and (not (memq this-command ido-read-file-name-non-ido)) 3772 ((and (not (memq this-command ido-read-file-name-non-ido))
3724 (or (null predicate) (eq predicate 'file-exists-p))) 3773 (or (null predicate) (eq predicate 'file-exists-p)))
3725 (let (filename 3774 (let (filename
3726 ido-saved-vc-mt 3775 ido-saved-vc-hb
3727 (vc-master-templates (and (boundp 'vc-master-templates) vc-master-templates)) 3776 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends))
3728 (ido-current-directory (expand-file-name (or dir default-directory))) 3777 (ido-current-directory (expand-file-name (or dir default-directory)))
3729 (ido-work-directory-index -1) 3778 (ido-work-directory-index -1)
3730 (ido-work-file-index -1) 3779 (ido-work-file-index -1)
@@ -3742,7 +3791,7 @@ See `read-file-name' for additional parameters."
3742 "Read directory name, prompting with PROMPT and completing in directory DIR. 3791 "Read directory name, prompting with PROMPT and completing in directory DIR.
3743See `read-file-name' for additional parameters." 3792See `read-file-name' for additional parameters."
3744 (let (filename 3793 (let (filename
3745 ido-saved-vc-mt 3794 ido-saved-vc-hb
3746 (ido-current-directory (expand-file-name (or dir default-directory))) 3795 (ido-current-directory (expand-file-name (or dir default-directory)))
3747 (ido-work-directory-index -1) 3796 (ido-work-directory-index -1)
3748 (ido-work-file-index -1)) 3797 (ido-work-file-index -1))