Re: detecting charset of directories

2006-10-24 Thread Richard Stallman
Does this work right?

*** dired.el01 Oct 2006 23:09:50 -0400  1.352
--- dired.el24 Oct 2006 07:52:31 -0400  
***
*** 791,796 
--- 791,798 
(run-hooks 'dired-before-readin-hook)
(if (consp buffer-undo-list)
  (setq buffer-undo-list nil))
+   (set (make-local-variable 'file-name-coding-system)
+  (or coding-system-for-read file-name-coding-system))
(let (buffer-read-only
;; Don't make undo entries for readin.
(buffer-undo-list t))


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: detecting charset of directories

2006-10-23 Thread Kevin Rodgers

Richard Stallman wrote:

> I think to make that work, dired-revert needs the same fix as
> dired-mode, namely:

> (set (make-local-variable 'file-name-coding-system)
>  (or coding-system-for-read file-name-coding-system))

Kevin, I don't understand that suggestion.  I don't see anything
like that code in dired-mode.

Are you proposing a change to dired-mode AND a change to dired-revert?


Yes, that is what I am proposing.  Or alternatively, a single change
to dired-readin.


Could use diff to show the change you are suggesting?


*** lisp/dired.el~  2006-10-23 11:58:19.628889700 -0600
--- lisp/dired.el   2006-10-23 12:02:15.497851300 -0600
***
*** 1042,1047 
--- 1042,1049 
  ;; treat top level dir extra (it may contain wildcards)
  (dired-uncache
   (if (consp dired-directory) (car dired-directory) dired-directory))
+ (set (make-local-variable 'file-name-coding-system)
+(or coding-system-for-read file-name-coding-system))
  (dired-readin)
  (let ((dired-after-readin-hook nil))
;; don't run that hook for each subdir...
***
*** 1627,1632 
--- 1629,1636 
 '(dired-font-lock-keywords t nil nil beginning-of-line))
(set (make-local-variable 'desktop-save-buffer)
 'dired-desktop-buffer-misc-data)
+   (set (make-local-variable 'file-name-coding-system)
+(or coding-system-for-read file-name-coding-system))
(setq dired-switches-alist nil)
(dired-sort-other dired-actual-switches t)
(when (featurep 'dnd)

--
Kevin



___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: detecting charset of directories

2006-10-21 Thread Richard Stallman
> I think to make that work, dired-revert needs the same fix as
> dired-mode, namely:

> (set (make-local-variable 'file-name-coding-system)
>  (or coding-system-for-read file-name-coding-system))

Kevin, I don't understand that suggestion.  I don't see anything
like that code in dired-mode.

Are you proposing a change to dired-mode AND a change to dired-revert?

Could use diff to show the change you are suggesting?


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: detecting charset of directories

2006-10-20 Thread Kenichi Handa
In article <[EMAIL PROTECTED]>, Kevin Rodgers <[EMAIL PROTECTED]> writes:

> > > Also, how can one ensure that `C-x m c CODING-SYSTEM g' will (1) have
> > > its intended effect and (2) persist its effect, for subsequent `g'
> > > commands?
> > 
> > Sorry, I don't understand what you mean.  Could you please
> > paraphrase it?

> [Sorry, `C-x m c ...' should have been `C-x C-m c ...']

> Let's say you are in a Dired buffer and you realize the coding system is
> wrong, so you try to re-read it with `C-x RET c CODING-SYSTEM g'.  Does
> that work?  If later you decide to simply run `g', does it use
> CODING-SYSTEM to re-read the directory?

> I think to make that work, dired-revert needs the same fix as
> dired-mode, namely:

> (set (make-local-variable 'file-name-coding-system)
>  (or coding-system-for-read file-name-coding-system))

> Or perhaps that should be done later in just one place: dired-readin.

I basically agree with you, but as I don't know the code of
dired, I don't know which part is the right place to fix.
I'd like to ask maintainers of dired.el to work on it.

---
Kenichi Handa
[EMAIL PROTECTED]


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: detecting charset of directories

2006-10-20 Thread Kevin Rodgers
Kenichi Handa writes:
> In article <[EMAIL PROTECTED]>, Kevin Rodgers <[EMAIL PROTECTED]> writes:
> > > Detecting a coding system of filenames in a directory is
> > > difficult to implement, but it won't be that difficult to
> > > respect a coding system explicitly specified by C-x C-m c
> > > for dired.  Perhaps, it can be done by locally setting
> > > file-name-coding-system of that buffer and making
> > > dired-revert to pay attention to that value.
> 
> > `C-x C-m c' temporarily binds coding-system-for-read and
> > coding-system-for-write, so wouldn't it be more transparent to locally
> > set those variables (in dired-mode, where the other buffer-local
> > variables are set)?
> 
> Those variables are mainly for let-binding by programs.
> Directly setting them may leads to a problem.  For instance,
> qM-x shell-command invoded from that buffer will use those
> values.

I'm not sure shell-command shouldn't use those values in that buffer,
but it does seem safer to set file-name-coding-system instead.

> > Also, how can one ensure that `C-x m c CODING-SYSTEM g' will (1) have
> > its intended effect and (2) persist its effect, for subsequent `g'
> > commands?
> 
> Sorry, I don't understand what you mean.  Could you please
> paraphrase it?

[Sorry, `C-x m c ...' should have been `C-x C-m c ...']

Let's say you are in a Dired buffer and you realize the coding system is
wrong, so you try to re-read it with `C-x RET c CODING-SYSTEM g'.  Does
that work?  If later you decide to simply run `g', does it use
CODING-SYSTEM to re-read the directory?

I think to make that work, dired-revert needs the same fix as
dired-mode, namely:

(set (make-local-variable 'file-name-coding-system)
 (or coding-system-for-read file-name-coding-system))

Or perhaps that should be done later in just one place: dired-readin.

-- 
Kevin







___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: detecting charset of directories

2006-10-20 Thread Kenichi Handa
In article <[EMAIL PROTECTED]>, Kevin Rodgers <[EMAIL PROTECTED]> writes:
> > Detecting a coding system of filenames in a directory is
> > difficult to implement, but it won't be that difficult to
> > respect a coding system explicitly specified by C-x C-m c
> > for dired.  Perhaps, it can be done by locally setting
> > file-name-coding-system of that buffer and making
> > dired-revert to pay attention to that value.

> `C-x C-m c' temporarily binds coding-system-for-read and
> coding-system-for-write, so wouldn't it be more transparent to locally
> set those variables (in dired-mode, where the other buffer-local
> variables are set)?

Those variables are mainly for let-binding by programs.
Directly setting them may leads to a problem.  For instance,
qM-x shell-command invoded from that buffer will use those
values.

> Also, how can one ensure that `C-x m c CODING-SYSTEM g' will (1) have
> its intended effect and (2) persist its effect, for subsequent `g'
> commands?

Sorry, I don't understand what you mean.  Could you please
paraphrase it?

---
Kenichi Handa
[EMAIL PROTECTED]


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: detecting charset of directories

2006-10-19 Thread Kevin Rodgers

Kenichi Handa wrote:

In article <[EMAIL PROTECTED]>, Dan Jacobson <[EMAIL PROTECTED]> writes:


One can "set coding system for the next command" to dired a mounted
CDROM directory in the proper charset (big5 in my case). But the
moment one types g to refresh the dired, the dired is back in the
default charset.



So emacs is very clever in detecting the coding systems of files, but
not very cooperative for directories full of filenames all in a
particular coding system.


Detecting a coding system of filenames in a directory is
difficult to implement, but it won't be that difficult to
respect a coding system explicitly specified by C-x C-m c
for dired.  Perhaps, it can be done by locally setting
file-name-coding-system of that buffer and making
dired-revert to pay attention to that value.


`C-x C-m c' temporarily binds coding-system-for-read and
coding-system-for-write, so wouldn't it be more transparent to locally
set those variables (in dired-mode, where the other buffer-local
variables are set)?

Also, how can one ensure that `C-x m c CODING-SYSTEM g' will (1) have
its intended effect and (2) persist its effect, for subsequent `g'
commands?


As I've never touch the code of dired.el, I'm not sure how
such a change is safe.  So, shall I try it in
emacs-unicode-2 branch?


--
Kevin



___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


detecting charset of directories

2006-10-15 Thread Dan Jacobson
One can "set coding system for the next command" to dired a mounted
CDROM directory in the proper charset (big5 in my case). But the
moment one types g to refresh the dired, the dired is back in the
default charset.

So emacs is very clever in detecting the coding systems of files, but
not very cooperative for directories full of filenames all in a
particular coding system.

One can work around this with
$ LC_ALL= emacs -q /cdrom

And I solved it in .emacs by wrapping this section in an and condition:

(and (string=(getenv "LANG")"zh_TW.utf8")
 (progn
   (set-language-environment "UTF-8")
   (prefer-coding-system 'utf-8-unix)
;emacs22 still need? yes.
   (set-coding-priority ;So that big5 is still guessed right after utf-8.
(reverse ;Found these lisp thingies and it works.
 (delete-duplicates
  (reverse
   (append(list 'coding-category-utf-8
'coding-category-big5)coding-category-list)))

Anyways, hope my report helps, but I've found my workaround (probably
working around an earlier workaround), so I have no further comments,
particularly as there are too many factors at play, including
mount(8), so its off (adios) to the next bug for me.


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug