bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16747: 24.3.50; ido-find-file with ido-use-filename-at-point in dire


From: Leo Liu
Subject: bug#16747: 24.3.50; ido-find-file with ido-use-filename-at-point in dired inserts directory at point twice
Date: Fri, 14 Feb 2014 14:52:07 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (OS X 10.9.1)

On 2014-02-14 14:05 +0800, Dmitry Gutov wrote:
> Tags: patch
>
> 1. (setq ido-use-filename-at-point t)
>
> 2. M-x ido-mode
>
> 3. Open a Dired buffer, move point to a directory, press C-x C-f.
>
> 4. See the directory name inserted in the prompt both as directory and a
> file name.

I wonder if we could move to a simpler (and maybe better) way of
integrating ffap, for example something like:

diff --git a/lisp/ido.el b/lisp/ido.el
index 9a17c0ca..f1a6b770 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -581,25 +581,6 @@ (defcustom ido-work-directory-list-ignore-regexps nil
   :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."
@@ -2353,35 +2334,6 @@ (defun ido-file-internal (method &optional fallback 
default prompt item initial
            (and (not ido-directory-nonreadable)
                 (ido-directory-too-big-p ido-current-directory))))
 
-    (when (and (eq item 'file)
-          (or ido-use-url-at-point ido-use-filename-at-point))
-      (let (fn d)
-       (require 'ffap)
-       ;; Duplicate code from ffap-guesser as we want different
-       ;; behavior for files and URLs.
-       (cond
-        ((with-no-warnings
-           (and ido-use-url-at-point
-                ffap-url-regexp
-                (ffap-fixup-url (or (ffap-url-at-point)
-                                    (ffap-gopher-at-point)))))
-         (setq ido-exit 'ffap
-               filename t))
-
-        ((and ido-use-filename-at-point
-              (setq fn (with-no-warnings
-                         (if (eq ido-use-filename-at-point 'guess)
-                             (ffap-guesser)
-                           (ffap-string-at-point))))
-              (not (string-match "^http:/" fn))
-              (let ((absolute-fn (expand-file-name fn)))
-                (setq d (if (file-directory-p absolute-fn)
-                            (file-name-as-directory absolute-fn)
-                          (file-name-directory absolute-fn))))
-              (file-directory-p d))
-         (setq ido-current-directory d)
-         (setq initial (file-name-nondirectory fn))))))
-
     (let (ido-saved-vc-hb
          (vc-handled-backends (and (boundp 'vc-handled-backends) 
vc-handled-backends))
          (ido-work-directory-index -1)
@@ -2424,9 +2376,6 @@ (defun ido-file-internal (method &optional fallback 
default prompt item initial
                        (t 'dired))
                  (concat ido-current-directory (or ido-text ""))))
 
-       ((eq ido-exit 'ffap)
-       (find-file-at-point))
-
        ((eq method 'alt-file)
        (ido-record-work-file filename)
        (setq default-directory ido-current-directory)
@@ -4186,7 +4135,7 @@ (defun ido-find-file-in-dir (dir)
   (ido-file-internal ido-default-file-method nil dir nil nil nil 'ignore))
 
 ;;;###autoload
-(defun ido-find-file ()
+(defun ido-find-file (&optional use-ffap)
   "Edit file with name obtained via minibuffer.
 The file is displayed according to `ido-default-file-method' -- the
 default is to show it in the same window, unless it is already
@@ -4226,8 +4175,9 @@ (defun ido-find-file ()
 \\[ido-completion-help] Show list of matching files in separate window.
 \\[ido-toggle-ignore] Toggle ignoring files listed in `ido-ignore-files'."
 
-  (interactive)
-  (ido-file-internal ido-default-file-method))
+  (interactive "P")
+  (if use-ffap (find-file-at-point)
+    (ido-file-internal ido-default-file-method)))
 
 ;;;###autoload
 (defun ido-find-file-other-window ()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]