GNU bug report logs - #15337
24.3.50; [PATCH] cd to directory name with french accent fail from term/ansi-term

Previous Next

Package: emacs;

Reported by: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>

Date: Wed, 11 Sep 2013 11:59:01 UTC

Severity: normal

Tags: patch

Found in version 24.3.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15337 in the body.
You can then email your comments to 15337 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Wed, 11 Sep 2013 11:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thierry Volpiatto <thierry.volpiatto <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 11 Sep 2013 11:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; [PATCH] cd to directory name with french accent fail from
 term/ansi-term
Date: Wed, 11 Sep 2013 13:57:24 +0200
Hi,
From M-x ansi-term
cd ~/Téléchargements/

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (error "No such directory found via CDPATH environment variable")
  signal(error ("No such directory found via CDPATH environment variable"))
  error("No such directory found via CDPATH environment variable")
  cd("/home/thierry/T\303\251l\303\251chargements")
  (cond ((equal string "") t) ((= (aref string 0) 26) (let* ((first-colon (string-match ":" string 1)) (second-colon (string-match ":" string (1+ first-colon))) (filename (substring string 1 first-colon)) (fileline (string-to-number (substring string (1+ first-colon) second-colon)))) (setq term-pending-frame (cons filename fileline)))) ((= (aref string 0) 47) (cd (substring string 1))) (t))
[...]
--8<---------------cut here---------------end--------------->8---

The bug is in `cd' in files.el.

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/files.el b/lisp/files.el
index f9ff3c9..a27bb06 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -729,7 +729,7 @@ The path separator is colon in GNU and GNU-like systems."
     (setq cd-path (or (parse-colon-path (getenv "CDPATH"))
                       (list "./"))))
   (cd-absolute
-   (or (locate-file dir cd-path nil
+   (or (locate-file (decode-coding-string dir locale-coding-system) cd-path nil
                     (lambda (f) (and (file-directory-p f) 'dir-ok)))
        (error "No such directory found via CDPATH environment variable"))))
--8<---------------cut here---------------end--------------->8---
 




In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
 of 2013-09-10 on dell-14z
Windowing system distributor `The X.Org Foundation', version 11.0.11103000
System Description:	Ubuntu 12.04.3 LTS

Important settings:
  value of $LC_MONETARY: fr_FR.UTF-8
  value of $LC_NUMERIC: fr_FR.UTF-8
  value of $LC_TIME: fr_FR.UTF-8
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  TeX-PDF-mode: t
  recentf-mode: t
  git-gutter-mode: t
  winner-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  auto-image-file-mode: t
  eldoc-in-minibuffer-mode: t
  show-paren-mode: t
  display-time-mode: t
  savehist-mode: t
  golden-ratio-mode: t
  eldoc-mode: t
  minibuffer-depth-indicate-mode: t
  diff-auto-refine-mode: t
  helm-mode: t
  helm-descbinds-mode: t
  shell-dirtrack-mode: t
  helm-adaptative-mode: t
  helm-match-plugin-mode: t
  helm-occur-match-plugin-mode: t
  tooltip-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<up> <up> <up> <up> <up> C-M-SPC M-w C-x C-² <right> 
C-M-x M-x c d SPC ~ / l a b o <return> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <return> <left> M-< <return> C-x C-f l 
s p C-g C-x C-f C-g M-x <return> l s p <return> C-x 
C-f C-g <left> C-M-SPC M-w C-x C-b <down> <return> 
C-x C-s M-< <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <return> 
C-y <return> <up> C-M-a <right> <right> <right> <right> 
<right> <right> <up> ( w i t h - e v a l - a f <tab> 
<tab> <down> <up> SPC M-" f i l e C-x C-b C-g s . e 
l <down> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> <tab> C-M-q <C-M-right> ) <C-M-left> C-x C-s 
C-x C-s C-x C-b C-g M-x r e p o r t <down> <return
>

Recent messages:
Mark set
Saved text until "und via CDPATH environment variable"))))"
cd
Mark set
Saved text until "und via CDPATH environment variable"))))"
(No changes need to be saved)
Mark set [3 times]
Saving file /home/thierry/.emacs.d/emacs-config-laptop/.emacs.el...
Wrote /home/thierry/.emacs.d/emacs-config-laptop/.emacs.el
(No changes need to be saved)

Load-path shadows:
/usr/local/share/emacs/24.3.50/lisp/gnus/.dir-locals hides ~/elisp/magit/.dir-locals
~/elisp/auctex/lpath hides ~/elisp/emacs-wget/lpath
~/elisp/Emacs-wgrep/wgrep-ack hides ~/elisp/jenkins/emacs-wgrep/wgrep-ack
~/elisp/Emacs-wgrep/wgrep-helm hides ~/elisp/jenkins/emacs-wgrep/wgrep-helm
~/elisp/Emacs-wgrep/wgrep-test hides ~/elisp/jenkins/emacs-wgrep/wgrep-test
~/elisp/Emacs-wgrep/wgrep hides ~/elisp/jenkins/emacs-wgrep/wgrep
/usr/local/share/emacs/24.3.50/lisp/emacs-lisp/tq hides ~/elisp/emms/lisp/tq
~/.emacs.d/.gnus hides ~/.emacs.d/emacs-config-laptop/.gnus

Features:
(shadow epa-mail cl-indent vc view help-mode helm-firefox emacsbug
pcmpl-unix mule-util helm-eshell debbugs-gnu debbugs soap-client
url-http url-auth url-gw helm-command helm-dabbrev qp gnus-dup gnus-html
url-cache smiley gnus-cite mm-archive mail-extr gnus-async gnus-bcklg
gnus-ml nndraft nnmh nnagent utf-7 nnimap utf7 nnml nnfolder parse-time
netrc network-stream starttls tls gnus-agent gnus-srvr gnus-score
score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime
smime dig nntp gnus-cache gnus-dired nnir gnus-sum gnus-group gnus-undo
nnmail mail-source nnoo gnus-start gnus-spec gnus-int gnus-range
gnus-win preview prv-emacs tex-buf reftex-dcr reftex-auc reftex imenu
reftex-vars font-latex latex tex-style tex dbus crm latexenc recentf ido
cc-langs cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs vc-dispatcher vc-rcs sh-script smie executable
jka-compr conf-mode vc-git naquadah-theme em-smart em-unix em-script
em-prompt em-ls em-hist em-pred em-glob em-dirs em-cmpl em-basic
em-banner em-alias align-let git-gutter server package winner undo-tree
diff slime-xref-browser slime-banner slime-tramp slime-asdf slime-fancy
slime-fontifying-fu slime-package-fu slime-references slime-scratch
slime-presentations slime-fuzzy slime-fancy-trace slime-fancy-inspector
slime-c-p-c slime-editing-commands slime-autodoc slime-parse slime-repl
elp image-file newsticker newst-treeview tree-widget newst-plainview
newst-reader newst-ticker newst-backend xdvi-search preview-latex
pcomplete-extension em-term term disp-table ehelp electric helm-ipython
helm-elisp helm-eval python rx eldoc-eval whitespace paren time avoid
savehist warnings emamux golden-ratio smtpmail-async smtpmail sendmail
helm-async persistent-sessions boxquote markdown-mode iterator
google-maps google-maps-static google-maps-geocode google-maps-base json
simple-call-tree iedit-rect rect iedit iedit-lib zop-to-char smallurl
mm-url gnus gnus-ems nnheader rectangle-utils ledger-config ledger
esh-var esh-io esh-cmd esh-opt esh-ext esh-proc eldoc esh-groups eshell
esh-module esh-mode esh-arg esh-util tv-utils async pcvs vc-cvs
pcvs-parse pcvs-info pcvs-defs ewoc mb-depth ioccur cl-info slime
hyperspec slime-autoloads tex-site auto-loads esh-toggle flymake no-word
dired-extension emms-mpd-config emms-playlist-limit emms-volume
emms-volume-amixer emms-i18n emms-history emms-score emms-stream-info
emms-metaplaylist-mode emms-bookmarks emms-cue emms-mode-line-icon
emms-browser sort emms-playlist-sort emms-last-played emms-player-xine
emms-player-mpd tq emms-playing-time emms-lyrics emms-url hl-line
emms-tag-editor emms-mark emms-mode-line emms-cache emms-info-ogginfo
emms-info-mp3info emms-playlist-mode emms-player-vlc emms-player-mplayer
emms-info emms-streams later-do emms-source-playlist emms-source-file
emms-player-simple emms-setup emms emms-compat magit-blame magit-cherry
magit-bisect magit-log-edit log-edit pcvs-util add-log magit-key-mode
magit diff-mode magit-compat htmlize-hack htmlize muse-colors
muse-docbook muse-texinfo texnfo-upd texinfo muse-latex muse-html
muse-xml-common muse-wiki cus-edit cus-start cus-load muse-publish
muse-project muse-protocols muse-regexps wid-edit muse muse-nested-tags
muse-mode muse-autoloads org-config-thierry ob-sh cal-china lunar solar
cal-dst cal-bahai cal-islam cal-hebrew holidays hol-loaddefs vc-hg
org-wl org-w3m org-vm org-rmail org-mhe org-mew org-irc org-jsinfo
org-infojs org-html org-exp ob-exp org-exp-blocks org-info org-gnus
org-docview org-bibtex bibtex org-bbdb org-agenda appt diary-lib
diary-loaddefs org-annotation-helper org-capture org-mks remember
org-remember org-datetree addressbook-bookmark message rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mailabbrev mail-utils gmm-utils mailheader firefox-protocol
bookmark-firefox-handler bookmark-extensions bookmark pp
init-helm-thierry helm-mode helm-ls-git helm-descbinds helm-ls-hg
helm-files image-dired tramp tramp-compat tramp-loaddefs trampver shell
dired-x dired-aux ffap thingatpt helm-buffers helm-elscreen helm-tags
helm-bookmark helm-adaptative helm-info helm-net browse-url xml url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse url-vars mailcap helm-plugin helm-help
helm-match-plugin helm-grep wgrep-helm wgrep helm-regexp grep
helm-external helm-utils dired compile helm-locate helm helm-config
helm-aliases epa-file epa derived epg epg-config auth-source eieio
eieio-core gnus-util mm-util mail-prsvr password-cache usage-memo info
cl-macs gv edmacro kmacro org-crypt org byte-opt bytecomp byte-compile
cconv advice help-fns ob-tangle ob-ref ob-lob ob-table org-footnote
org-src ob-comint ob-keys org-pcomplete pcomplete comint ansi-color ring
org-list org-faces org-entities time-date noutline outline easy-mmode
org-version ob-emacs-lisp ob org-compat org-macs ob-eval org-loaddefs
format-spec find-func cal-menu easymenu calendar cal-loaddefs net-utils
cl cl-loaddefs cl-lib tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar 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 minibuffer nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Wed, 11 Sep 2013 13:53:01 GMT) Full text and rfc822 format available.

Message #8 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent fail
 from	term/ansi-term
Date: Wed, 11 Sep 2013 16:51:31 +0300
> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
> Date: Wed, 11 Sep 2013 13:57:24 +0200
> 
> diff --git a/lisp/files.el b/lisp/files.el
> index f9ff3c9..a27bb06 100644
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -729,7 +729,7 @@ The path separator is colon in GNU and GNU-like systems."
>      (setq cd-path (or (parse-colon-path (getenv "CDPATH"))
>                        (list "./"))))
>    (cd-absolute
> -   (or (locate-file dir cd-path nil
> +   (or (locate-file (decode-coding-string dir locale-coding-system) cd-path nil
>                      (lambda (f) (and (file-directory-p f) 'dir-ok)))
>         (error "No such directory found via CDPATH environment variable"))))
> --8<---------------cut here---------------end--------------->8---

How come cd-path got a value that is a unibyte string?  If it came
from getenv, then that function explicitly decodes the values.

IOW, please dig deeper and tell where did the unibyte string in
cd-path come from, because I don't see why would it be TRT to decode
it where you suggest; perhaps I'm missing something.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Wed, 11 Sep 2013 14:13:01 GMT) Full text and rfc822 format available.

Message #11 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent fail
 from	term/ansi-term
Date: Wed, 11 Sep 2013 16:12:28 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
>> Date: Wed, 11 Sep 2013 13:57:24 +0200
>> 
>> diff --git a/lisp/files.el b/lisp/files.el
>> index f9ff3c9..a27bb06 100644
>> --- a/lisp/files.el
>> +++ b/lisp/files.el
>> @@ -729,7 +729,7 @@ The path separator is colon in GNU and GNU-like systems."
>>      (setq cd-path (or (parse-colon-path (getenv "CDPATH"))
>>                        (list "./"))))
>>    (cd-absolute
>> -   (or (locate-file dir cd-path nil
>> +   (or (locate-file (decode-coding-string dir locale-coding-system) cd-path nil
>>                      (lambda (f) (and (file-directory-p f) 'dir-ok)))
>>         (error "No such directory found via CDPATH environment variable"))))
>> --8<---------------cut here---------------end--------------->8---
>
> How come cd-path got a value that is a unibyte string?  If it came
> from getenv, then that function explicitly decodes the values.
>
> IOW, please dig deeper and tell where did the unibyte string in
> cd-path come from, because I don't see why would it be TRT to decode
> it where you suggest; perhaps I'm missing something.

I am using emacs -Q here and CDPATH is empty (I don't use it).
(getenv "CDPATH") => nil
env | grep CDPATH => empty too.

cd is working as expected from emacs itself, but when used from term,
the string "~/Téléchargement" is
"/home/thierry/T\303\251l\303\251chargements"
so `file-directory-p' fails on
"/home/thierry/T\303\251l\303\251chargements"
And the CDPATH error is called.

So the patch I send fix the problem but yes maybe the decoding should
occur somewhere in term.el instead when sending the string to `cd'.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Wed, 11 Sep 2013 16:22:01 GMT) Full text and rfc822 format available.

Message #14 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent fail
 from	term/ansi-term
Date: Wed, 11 Sep 2013 19:21:00 +0300
> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
> Cc: 15337 <at> debbugs.gnu.org
> Date: Wed, 11 Sep 2013 16:12:28 +0200
> 
> > IOW, please dig deeper and tell where did the unibyte string in
> > cd-path come from, because I don't see why would it be TRT to decode
> > it where you suggest; perhaps I'm missing something.
> 
> I am using emacs -Q here and CDPATH is empty (I don't use it).
> (getenv "CDPATH") => nil
> env | grep CDPATH => empty too.
> 
> cd is working as expected from emacs itself, but when used from term,
> the string "~/Téléchargement" is
> "/home/thierry/T\303\251l\303\251chargements"
> so `file-directory-p' fails on
> "/home/thierry/T\303\251l\303\251chargements"
> And the CDPATH error is called.
> 
> So the patch I send fix the problem but yes maybe the decoding should
> occur somewhere in term.el instead when sending the string to `cd'.

If you cannot figure out where does the unibyte string come from,
please provide a test case starting from "emacs -Q".  Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Thu, 12 Sep 2013 05:12:01 GMT) Full text and rfc822 format available.

Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent fail
 from	term/ansi-term
Date: Thu, 12 Sep 2013 07:11:00 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
>> Cc: 15337 <at> debbugs.gnu.org
>> Date: Wed, 11 Sep 2013 16:12:28 +0200
>> 
>> > IOW, please dig deeper and tell where did the unibyte string in
>> > cd-path come from, because I don't see why would it be TRT to decode
>> > it where you suggest; perhaps I'm missing something.
>> 
>> I am using emacs -Q here and CDPATH is empty (I don't use it).
>> (getenv "CDPATH") => nil
>> env | grep CDPATH => empty too.
>> 
>> cd is working as expected from emacs itself, but when used from term,
>> the string "~/Téléchargement" is
>> "/home/thierry/T\303\251l\303\251chargements"
>> so `file-directory-p' fails on
>> "/home/thierry/T\303\251l\303\251chargements"
>> And the CDPATH error is called.
>> 
>> So the patch I send fix the problem but yes maybe the decoding should
>> occur somewhere in term.el instead when sending the string to `cd'.
>
> If you cannot figure out where does the unibyte string come from,
> please provide a test case starting from "emacs -Q".  Thanks.

So from emacs -Q

(I repeat my initial message)

M-x ansi-term
cd ~/Téléchargements/

Debugger entered--Lisp error: (error "No such directory found via CDPATH environment variable")
  signal(error ("No such directory found via CDPATH environment variable"))
  error("No such directory found via CDPATH environment variable")
  cd("/home/thierry/T\303\251l\303\251chargements")
  #[(string) "\306\232\203\307\207\310H\311U\2031\312\313\314#\312\313	T#\314	O\315	T\nO!\fB\211,\207\310H\316U\203@\317\314\320O!\207\307\207" [string first-colon second-colon filename fileline term-pending-frame "" t 0 26 string-match ":" 1 string-to-number 47 cd nil] 4]("//home/thierry/T\303\251l\303\251chargements")
  term-emulate-terminal(#<process *ansi-term*> "\n//home/thierry/T\303\251l\303\251chargements\n[01;32mthierry <at> dell-14z[00m:[01;34m~/T\303\251l\303\251chargements[00m$ ")

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Thu, 12 Sep 2013 15:34:01 GMT) Full text and rfc822 format available.

Message #20 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent
 fail	from	term/ansi-term
Date: Thu, 12 Sep 2013 18:33:27 +0300
> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
> Date: Thu, 12 Sep 2013 07:11:00 +0200
> 
> > If you cannot figure out where does the unibyte string come from,
> > please provide a test case starting from "emacs -Q".  Thanks.
> 
> So from emacs -Q
> 
> (I repeat my initial message)

Sorry, I didn't realize from your original message that M-x ansi-term
is all that is needed after "emacs -Q".

> M-x ansi-term
> cd ~/Téléchargements/
> 
> Debugger entered--Lisp error: (error "No such directory found via CDPATH environment variable")
>   signal(error ("No such directory found via CDPATH environment variable"))
>   error("No such directory found via CDPATH environment variable")
>   cd("/home/thierry/T\303\251l\303\251chargements")

I think I see the problem.  term.el disables decoding of the shell
output, see term-exec-1.  So the text it gets from the shell is
unibyte, un-decoded text.  Therefore, whenever term.el calls other
functions, let alone functions that can be defined by the user, it
must decode the strings it passes to those functions.  And in this
case, it doesn't:

                         ((and (eq char ?\032)
                               (not handled-ansi-message))
                          (let ((end (string-match "\r?$" str i)))
                            (if end
                                (funcall term-command-hook
                                         (prog1 (substring str (1+ i) end)
                                           (setq i (match-end 0))))

Here 'str' is a unibyte string, while term-command-hook expects a
normal, multibyte string as its argument.

So please see if decoding the result of prog1 with
decode-coding-string, like you suggested to do in 'cd', but before
passing it to funcall, fixes the problem.  Something like this:

     (funcall term-command-hook
              (decode-coding-string
                (prog1 (substring str (1+ i) end)
                   (setq i (match-end 0)))
                locale-coding-system))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Fri, 13 Sep 2013 05:23:02 GMT) Full text and rfc822 format available.

Message #23 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent
 fail	from	term/ansi-term
Date: Fri, 13 Sep 2013 07:21:44 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> So please see if decoding the result of prog1 with
> decode-coding-string, like you suggested to do in 'cd', but before
> passing it to funcall, fixes the problem.  Something like this:
>
>      (funcall term-command-hook
>               (decode-coding-string
>                 (prog1 (substring str (1+ i) end)
>                    (setq i (match-end 0)))
>                 locale-coding-system))

Yes it is working, or just decoding 'string' in `term-command-hook'
works too.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Fri, 13 Sep 2013 07:50:02 GMT) Full text and rfc822 format available.

Message #26 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent
 fail	from	term/ansi-term
Date: Fri, 13 Sep 2013 10:49:28 +0300
> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
> Cc: 15337 <at> debbugs.gnu.org
> Date: Fri, 13 Sep 2013 07:21:44 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > So please see if decoding the result of prog1 with
> > decode-coding-string, like you suggested to do in 'cd', but before
> > passing it to funcall, fixes the problem.  Something like this:
> >
> >      (funcall term-command-hook
> >               (decode-coding-string
> >                 (prog1 (substring str (1+ i) end)
> >                    (setq i (match-end 0)))
> >                 locale-coding-system))
> 
> Yes it is working

Then please install.

> or just decoding 'string' in `term-command-hook' works too.

I considered that as well, but decided that doing it before
term-command-hook is called is better, since that hook might be
redefined by users of term.el (right?).  So it is better to pass the
hook an already decoded string, because Lisp code does not generally
expect to get unibyte strings, especially if they are file names.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Fri, 13 Sep 2013 11:31:01 GMT) Full text and rfc822 format available.

Message #29 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent
 fail	from	term/ansi-term
Date: Fri, 13 Sep 2013 13:29:33 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
>> Cc: 15337 <at> debbugs.gnu.org
>> Date: Fri, 13 Sep 2013 07:21:44 +0200
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > So please see if decoding the result of prog1 with
>> > decode-coding-string, like you suggested to do in 'cd', but before
>> > passing it to funcall, fixes the problem.  Something like this:
>> >
>> >      (funcall term-command-hook
>> >               (decode-coding-string
>> >                 (prog1 (substring str (1+ i) end)
>> >                    (setq i (match-end 0)))
>> >                 locale-coding-system))
>> 
>> Yes it is working
>
> Then please install.

I can't, please do it.

>> or just decoding 'string' in `term-command-hook' works too.
>
> I considered that as well, but decided that doing it before
> term-command-hook is called is better, since that hook might be
> redefined by users of term.el (right?).  So it is better to pass the
> hook an already decoded string, because Lisp code does not generally
> expect to get unibyte strings, especially if they are file names.

Ok.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Fri, 13 Sep 2013 12:01:01 GMT) Full text and rfc822 format available.

Message #32 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent
 fail	from	term/ansi-term
Date: Fri, 13 Sep 2013 13:59:42 +0200
Thierry Volpiatto <thierry.volpiatto <at> gmail.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
>>> Cc: 15337 <at> debbugs.gnu.org
>>> Date: Fri, 13 Sep 2013 07:21:44 +0200
>>> 
>>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>> 
>>> > So please see if decoding the result of prog1 with
>>> > decode-coding-string, like you suggested to do in 'cd', but before
>>> > passing it to funcall, fixes the problem.  Something like this:
>>> >
>>> >      (funcall term-command-hook
>>> >               (decode-coding-string
>>> >                 (prog1 (substring str (1+ i) end)
>>> >                    (setq i (match-end 0)))
>>> >                 locale-coding-system))
>>> 
>>> Yes it is working
>>
>> Then please install.
>
> I can't, please do it.
>
>>> or just decoding 'string' in `term-command-hook' works too.
>>
>> I considered that as well, but decided that doing it before
>> term-command-hook is called is better, since that hook might be
>> redefined by users of term.el (right?).  So it is better to pass the
>> hook an already decoded string, because Lisp code does not generally
>> expect to get unibyte strings, especially if they are file names.
>
> Ok.

BTW, `term-command-hook' is not really a hook and hardly customizable by
user, so probably the function with same name (confusing) should be
renamed and called directly (without funcall) and the var
`term-command-hook' removed.
 
-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Fri, 13 Sep 2013 13:25:02 GMT) Full text and rfc822 format available.

Notification sent to Thierry Volpiatto <thierry.volpiatto <at> gmail.com>:
bug acknowledged by developer. (Fri, 13 Sep 2013 13:25:04 GMT) Full text and rfc822 format available.

Message #37 received at 15337-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Cc: 15337-done <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50;
 [PATCH] cd to directory name with french accent
 fail	from	term/ansi-term
Date: Fri, 13 Sep 2013 16:23:42 +0300
> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
> Cc: 15337 <at> debbugs.gnu.org
> Date: Fri, 13 Sep 2013 13:29:33 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
> >> Cc: 15337 <at> debbugs.gnu.org
> >> Date: Fri, 13 Sep 2013 07:21:44 +0200
> >> 
> >> Eli Zaretskii <eliz <at> gnu.org> writes:
> >> 
> >> > So please see if decoding the result of prog1 with
> >> > decode-coding-string, like you suggested to do in 'cd', but before
> >> > passing it to funcall, fixes the problem.  Something like this:
> >> >
> >> >      (funcall term-command-hook
> >> >               (decode-coding-string
> >> >                 (prog1 (substring str (1+ i) end)
> >> >                    (setq i (match-end 0)))
> >> >                 locale-coding-system))
> >> 
> >> Yes it is working
> >
> > Then please install.
> 
> I can't, please do it.

Done.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15337; Package emacs. (Fri, 13 Sep 2013 13:26:01 GMT) Full text and rfc822 format available.

Message #40 received at 15337 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Cc: 15337 <at> debbugs.gnu.org
Subject: Re: bug#15337: 24.3.50; [PATCH] cd to directory name with french
 accent	fail	from	term/ansi-term
Date: Fri, 13 Sep 2013 16:25:13 +0300
> From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
> Date: Fri, 13 Sep 2013 13:59:42 +0200
> 
> >>> or just decoding 'string' in `term-command-hook' works too.
> >>
> >> I considered that as well, but decided that doing it before
> >> term-command-hook is called is better, since that hook might be
> >> redefined by users of term.el (right?).  So it is better to pass the
> >> hook an already decoded string, because Lisp code does not generally
> >> expect to get unibyte strings, especially if they are file names.
> >
> > Ok.
> 
> BTW, `term-command-hook' is not really a hook and hardly customizable by
> user

By "user" I meant some Lisp code.

> so probably the function with same name (confusing) should be
> renamed and called directly (without funcall) and the var
> `term-command-hook' removed.

Feel free.  I know nothing about term.el and cannot say anything
intelligent about this.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 12 Oct 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 207 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.