From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Thibault Kruse" Newsgroups: gmane.emacs.bugs Subject: bug#7229: Aw: Re: Re: Re: bug#7229: 23.1; ido guess and ffap bug Date: Sat, 13 Jul 2013 10:01:33 +0200 (CEST) Message-ID: References: <20101016200828.264940@gmx.net> , NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/html; charset=UTF-8 X-Trace: ger.gmane.org 1373702532 13708 80.91.229.3 (13 Jul 2013 08:02:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 13 Jul 2013 08:02:12 +0000 (UTC) To: 7229@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 13 10:02:14 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UxumR-0001w6-Ue for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Jul 2013 10:02:12 +0200 Original-Received: from localhost ([::1]:43572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxumR-0001XU-HV for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Jul 2013 04:02:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxumM-0001XC-6Y for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2013 04:02:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxumJ-0004gt-BH for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2013 04:02:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57640) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxumJ-0004gB-8V for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2013 04:02:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1UxumI-0006oE-5o for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2013 04:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Thibault Kruse" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Jul 2013 08:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7229 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7229-submit@debbugs.gnu.org id=B7229.137370250626113 (code B ref 7229); Sat, 13 Jul 2013 08:02:02 +0000 Original-Received: (at 7229) by debbugs.gnu.org; 13 Jul 2013 08:01:46 +0000 Original-Received: from localhost ([127.0.0.1]:51956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uxum0-0006n4-FF for submit@debbugs.gnu.org; Sat, 13 Jul 2013 04:01:45 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:56887) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uxulw-0006ml-C6 for 7229@debbugs.gnu.org; Sat, 13 Jul 2013 04:01:42 -0400 Original-Received: from 3capp-gmx-bs12.server.lan ([172.19.170.63]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0MZiPg-1UkER12oIw-00LaCW for <7229@debbugs.gnu.org>; Sat, 13 Jul 2013 10:01:33 +0200 Original-Received: from [92.229.152.222] by 3capp-gmx-bs12.server.lan with HTTP; Sat Jul 13 10:01:33 CEST 2013 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K0:9WY6VunPJ+cOCaLpy682g/90AbRhc6fKiPpLmYOFj8v K62gEN2L7Gr/FTJCdlHyMH3pq1XB23QXaGH9tGMb64u0nq+ikZ EAkdDmpVMU0ZNfUZ3C/0ILY6RlULMFyubdwYx+1MRbdnroPe1h Hm06MLQ9/F8KLApTS+Ve06dxWjkK4Tk0Uq9UFCACVgCSEB+b2T XDQ3Ui+FqOF2UPBYVt3sdcaqK5LPUIE75USHyPQmDM2jRD/jTT cXsTKi4OtnTUE4EJIBGa2sFfc/KrDuYMmH/O3Urowd7Ajx8hY8 pS6+kI= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:76316 Archived-At:
Ok, so what I get with what you tell me is that:
C-x C-f never uses ffap
C-u C-x C-f   always uses ffap (and thus also has the false positives for '/**' and '/>' )
 
So as a user I'd have to learn and remember another keyboard shortcut to use when I want to have ido with ffap, is that the idea?
 
Personally, that idea might work for me (though I don't love it), but that leaves the rest of the world with bad defaults.
 
 
On a related note, I found this:
http://www.emacswiki.org/emacs/FindFileAtPoint
See "Ignore '/'" for a workaround by someone else to fix related problems.
 
 
Also looking at ffap.el sourcecode:
http://bzr.savannah.gnu.org/lh/emacs/emacs-23/annotate/head:/lisp/ffap.el
 
;; Immediate rejects (/ and // and /* are too common in C/C++):
((member name '("" "/" "//" "/*" ".")) nil)
 
So really ffap already breaks consistency for convenience, but only considers C/C++ coders. And '/' is not considered a valid completion prefix, though '/>' is considered a valid prefix and resolves to the only existing parent '/'. That's all a bit weird in ffap. If '/' itself is not valid, then maybe '/' should never be returned as suggestion by ffap (as in />, or /foo where /foo does not exist)?
 
Actually the way I fixed the problem in 7229 is this (sorry i took some time to remember, it has been 3 years):
 
 
(defadvice ffap-file-at-point (around bugfix-ffap  activate)
  "returns nil when point is somewhere we do not want to guess filenames"
  (require 'thingatpt)
;;; prevent in javadoc style comments
  (unless (or
           ;; ignore shebang lines, we are there very often and mostly do not want to open the executable
           (thing-at-point-looking-at "#!/[a-zA-Z0-9:_.-/]+")
           ;; ignore /**...* comment starts (Java-like languages, files name /*** are possible, but really unlikely)
           (thing-at-point-looking-at "/[\\*]+")
           ;; for xml modes, don't attemt to ffap-file-at-point when point is on </foo> or after <foo />, because we never want that.
           (and (member major-mode '(sgml-mode nxml-mode))
                ;; don't care about <somenode/> and </somenode>
                (or (thing-at-point-looking-at "</?[a-zA-Z_][a-zA-Z0-9:_.-]*>?")
                    (thing-at-point-looking-at "/>"))))
    ad-do-it))
 
So my advice would be to update the ffap ffap-file-at-point functions immediate rejects to include several more common false positive cases outside C/C++. My "patch" above also fixes shebang lines like "#! /usr/bin/python" which is highly annoying when working with several python scripts, and ido was constantly suggesting to open the python executable.
 
Another shortcut (like C-u C-x C-f) should IMHO only be necessary for forcing ffap to not reject anything, for those corner cases when a user has unusual work to do.
Again, it is a design decision, not a bug. I believe emacs users will be happier if C-x C-f with ido-ffap uses heuristics to avoid common false positives, rather than having to learn another shortcut.
 
 
 
Gesendet: Samstag, 13. Juli 2013 um 03:25 Uhr
Von: "Leo Liu" <sdl.web@gmail.com>
An: "Thibault Kruse" <thibault.kruse@gmx.de>
Cc: 7229@debbugs.gnu.org
Betreff: Re: Aw: Re: Re: bug#7229: 23.1; ido guess and ffap bug
On 2013-07-12 15:52 +0800, Thibault Kruse wrote:
> I tried:
> emacs -q --no-site-file
> M-x ido-mode
> M-x ielm
> pasted the lines you gave
> switch to scratch buffer
> typed "~/local" which exists
> press C-x C-f

Instead of C-x C-f, Try C-u C-x C-f.

> no prefix is used, ido just shows ~
> debugger also indicates the prefix var is nil

Please please write to the bug address 7229@debbugs.gnu.org instead of
my email.

Leo