all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Leo Liu <sdl.web@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 16747@debbugs.gnu.org
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	[thread overview]
Message-ID: <m18ute9ofc.fsf@gmail.com> (raw)
In-Reply-To: <871tz61b6b.fsf@yandex.ru> (Dmitry Gutov's message of "Fri, 14 Feb 2014 08:05:32 +0200")

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	other threads:[~2014-02-14  6:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14  6:05 bug#16747: 24.3.50; ido-find-file with ido-use-filename-at-point in dired inserts directory at point twice Dmitry Gutov
2014-02-14  6:52 ` Leo Liu [this message]
2014-02-14 12:18   ` Dmitry Gutov
2014-02-15  9:36     ` Leo Liu
2014-02-16  4:17       ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m18ute9ofc.fsf@gmail.com \
    --to=sdl.web@gmail.com \
    --cc=16747@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.