Subject: bug#5049: 23.1.50; ido-use-filename-at-point fails for files in default-directory

From: Andreas Politz <[email-masked]>
Date: Thu, 26 Nov 2009 18:29:23 +0100

Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the [email-masked] mailing list.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

Setting ido-use-filename-at-point to 'guess and trying to, for example,
find a included header-file w/o a directory component (#include "foo.h")
fails, because ido thinks that the file is invalid, due to
file-name-directory returning nil.

I think the following patch fixes this.

diff --git a/lisp/ido.el b/lisp/ido.el
index 7317540..ded7cbb 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -2288,7 +2288,7 @@ If cursor is not at the end of the user input, move to end of input."
 			      (ffap-guesser)
 			    (ffap-string-at-point))))
 	       (not (string-match "^http:/" fn))
-	       (setq d (file-name-directory fn))
+	       (setq d (file-name-directory (expand-file-name fn)))
 	       (file-directory-p d))
 	  (setq ido-current-directory d)
 	  (setq initial (file-name-nondirectory fn))))))

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/home/politza/src/emacs23/etc/DEBUG.

In GNU Emacs 23.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.3)
 of 2009-11-26 on raven
Windowing system distributor `The X.Org Foundation', version 11.0.10605000
Important settings:
  value of $LC_ALL: C
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Help

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  view-mode: t

Recent input:
i d o - m o d e <return> C-x C-f C-g M-x C-g C-. C-h 
V i d o - <tab> f f <tab> <backspace> i n d <tab> - 
f <tab> M-h C-k i d o <tab> <tab> SPC C-x o C-x o C-s 
f <backspace> p o i n t C-s <return> <return> C-x o 
C-M-SPC M-w M-: ( s e t q SPC C-y SPC t ) <return> 
C-x 0 C-x C-g C-p C-p C-p C-p C-p C-x C-f C-g M-: M-p 
C-e C-b C-h C-g <backspace> ' g u e s s <return> C-x 
C-f C-g C-n C-n C-n C-n C-n C-x C-f C-g C-. g C-/ C-h 
g M-x f i n d - f u n <tab> <return> i d o - f i n 
d - f i l e - i <tab> <M-backspace> <M-backspace> <M-backspace> 
<M-backspace> <tab> f i n <tab> d - f i l e <return> 
C-s i d o C-g M-x i m e n u <return> i d o - f i l 
e - i <tab> <return> C-M-l C-s h t t p C-n M-f C-l 
C-f ( e x p a n d - f i l e - a n C-h C-h C-g <backspace> 
<backspace> n a m e SPC M-f ) C-M-x C-x b p <return> 
C-x C-f C-g C-x b <return> C-x v = y M-x r e p o r 
t - e m <tab> <return> i d o - f i l e - a t - p o 
i n t <backspace> <backspace> <backspace> M-/ M-h C-k 
C-g C-x b h e <return> C-c C-b C-x ESC ESC C-r a t 
- p o i n C-r C-r <return> <return> C-M-SPC M-w M-x 
r e p o M-p <return>

Recent messages:
Buffer ido.el modified; save it? (y or n) 
Saving file /home/politza/src/emacs23/lisp/ido.el...
Wrote /home/politza/src/emacs23/lisp/ido.el
Finding changes in /home/politza/src/emacs23/lisp/ido.el...done
Scanning for dabbrevs...100%
dabbrev-expand: No dynamic expansion for `ido-file-at-po' found
Quit
help-go-back: No previous help buffer
Type "q" to restore this window.
Mark set

Load-path shadows:
None found.

Features:
(shadow mail-extr dabbrev emacsbug diff-mode easy-mmode vc reposition
imenu find-func goto-addr thingatpt vc-git ffap pp help-mode view
tramp-imap epa derived epg epg-config imap-hash imap message sendmail
ecomplete rfc822 mml mml-sec mm-decode mm-bodies mm-encode mailcap
mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader
mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 hex-util
hashcash mail-utils assoc tramp-gw tramp-fish tramp-smb tramp-cache
tramp-ftp tramp-cmds tramp auth-source gnus-util netrc time-date advice
help-fns advice-preload shell comint ring password-cache format-spec
tramp-compat trampver ido multi-isearch vc-dispatcher vc-svn cc-mode
cc-fonts easymenu cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs regexp-opt tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
loaddefs button minibuffer faces cus-face text-properties overlay md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind font-render-setting gtk
x-toolkit x multi-tty emacs)