unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Dired doesn't understand localized file dates
@ 2002-06-03 10:35 karl.eklund
  2002-06-03 22:36 ` Richard Stallman
  2002-06-04 11:26 ` Paul Stoeber
  0 siblings, 2 replies; 10+ messages in thread
From: karl.eklund @ 2002-06-03 10:35 UTC (permalink / raw)


I think I found a bug in dired's handling of dates in file listings.

When you set LC_TIME to sv_SE and run dired, it doesn't understand the 
file dates like " 2 maj 15.16", but it understands "18 okt  2001". When 
you press enter or f on the file with the former date (from this year), it 
says "No file on this line". On the latter (from last year), it acts 
normal. When you walk up and down the directory with the arrow keys, it 
goes to the beginning of the line at the files it doesn't understand, and 
to the beginning of the filename at files it does understand.

The version is "GNU Emacs 21.2.1 (i386-debian-linux-gnu, X toolkit, Xaw3d 
scroll bars) of 2002-03-22 on raven, modified by Debian" and the operating 
system is Debian 3.0 "woody".

Karl

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-03 10:35 Dired doesn't understand localized file dates karl.eklund
@ 2002-06-03 22:36 ` Richard Stallman
  2002-06-04  2:22   ` Thien-Thi Nguyen
  2002-06-04 11:26 ` Paul Stoeber
  1 sibling, 1 reply; 10+ messages in thread
From: Richard Stallman @ 2002-06-03 22:36 UTC (permalink / raw)
  Cc: bug-gnu-emacs

It turns out to be very very difficult to make Dired properly handle
all the kinds of dates that it can encounter.  A few years ago I
concluded it was ill-advised to make further changes, because changes
here had a tendency to fix some cases and break others.  What makes it
so hard is the need to detect the dates *and* handle file names with
spaces in them.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-03 22:36 ` Richard Stallman
@ 2002-06-04  2:22   ` Thien-Thi Nguyen
  2002-06-04 19:10     ` Colin Walters
  0 siblings, 1 reply; 10+ messages in thread
From: Thien-Thi Nguyen @ 2002-06-04  2:22 UTC (permalink / raw)
  Cc: karl.eklund, bug-gnu-emacs

Richard Stallman <rms@gnu.org> writes:

   It turns out to be very very difficult to make Dired properly handle
   all the kinds of dates that it can encounter.  A few years ago I
   concluded it was ill-advised to make further changes, because changes
   here had a tendency to fix some cases and break others.  What makes it
   so hard is the need to detect the dates *and* handle file names with
   spaces in them.

the way to do this generally would be to create a temporary file (w/ known
name, excluding spaces, and mtime), capture its ls(1) output, and figure out
parse hints for use by dired (learn-by-example).  this would have to be done
at least once per session.  maintenance then becomes the accumulation of
patterns into the table consulted by the "figure-it-out" engine.

(blue-sky-mode: generalizing this a bit further allows for real-time mail
virus scanning, for example, presuming the virus db format is open...)

thi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-03 10:35 Dired doesn't understand localized file dates karl.eklund
  2002-06-03 22:36 ` Richard Stallman
@ 2002-06-04 11:26 ` Paul Stoeber
  2002-06-04 12:13   ` Paul Stoeber
  2002-06-06 12:04   ` Richard Stallman
  1 sibling, 2 replies; 10+ messages in thread
From: Paul Stoeber @ 2002-06-04 11:26 UTC (permalink / raw)


What about

(setq dired-move-to-filename-regexp "^ *[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +")

I've always relied on this format when parsing ls with awk, but maybe
it's wrong under some locales.  It appears to be correct under
LC_TIME=sv_SE.

On Mon, Jun 03, 2002 at 12:35:15PM +0200, karl.eklund@amnesty.se wrote:
> I think I found a bug in dired's handling of dates in file listings.
> 
> When you set LC_TIME to sv_SE and run dired, it doesn't understand the 
> file dates like " 2 maj 15.16", but it understands "18 okt  2001". When 
> you press enter or f on the file with the former date (from this year), it 
> says "No file on this line". On the latter (from last year), it acts 
> normal. When you walk up and down the directory with the arrow keys, it 
> goes to the beginning of the line at the files it doesn't understand, and 
> to the beginning of the filename at files it does understand.
> 
> The version is "GNU Emacs 21.2.1 (i386-debian-linux-gnu, X toolkit, Xaw3d 
> scroll bars) of 2002-03-22 on raven, modified by Debian" and the operating 
> system is Debian 3.0 "woody".
> 
> Karl
> 
> _______________________________________________
> Bug-gnu-emacs mailing list
> Bug-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-04 11:26 ` Paul Stoeber
@ 2002-06-04 12:13   ` Paul Stoeber
  2002-06-04 13:12     ` Paul Stoeber
  2002-06-06 12:04   ` Richard Stallman
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Stoeber @ 2002-06-04 12:13 UTC (permalink / raw)


On Tue, Jun 04, 2002 at 01:26:42PM +0200, Paul Stoeber wrote:
> (setq dired-move-to-filename-regexp "^ *[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +")

(setq dired-move-to-filename-regexp "^. [^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +")

is a better bet.

(I didn't realize why dired-readin would indent-rigidly the whole buffer...)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-04 12:13   ` Paul Stoeber
@ 2002-06-04 13:12     ` Paul Stoeber
  2002-06-05 14:01       ` Werner LEMBERG
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Stoeber @ 2002-06-04 13:12 UTC (permalink / raw)


On Tue, Jun 04, 2002 at 02:13:08PM +0200, Paul Stoeber wrote:
> On Tue, Jun 04, 2002 at 01:26:42PM +0200, Paul Stoeber wrote:
> > (setq dired-move-to-filename-regexp "^ *[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +")
> 
> (setq dired-move-to-filename-regexp "^. [^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +")
> 
> is a better bet.

That's defeated by filenames starting with space.  Next try:

(setq dired-move-to-filename-regexp "^. [^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ ")

It relies on `ls' always printing the date as three space-separated fields,
      and on the last field of the date being right-justified,
      and on `ls' emitting no tabs for justification (GNU ls is okay),
      and on user+group names containing no space,
      and on Dired not laying further traps like marking,
      and on, and on, ...
Damn, it must be wrong, but I won't post further corrections.

Look at the default value of dired-move-to-filename-regexp.

Exercises
  1. [49]  Convice yourself of the fact that Dired is not ill-designed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-04  2:22   ` Thien-Thi Nguyen
@ 2002-06-04 19:10     ` Colin Walters
  0 siblings, 0 replies; 10+ messages in thread
From: Colin Walters @ 2002-06-04 19:10 UTC (permalink / raw)


On Mon, 2002-06-03 at 22:22, Thien-Thi Nguyen wrote:

> the way to do this generally would be to create a temporary file (w/ known
> name, excluding spaces, and mtime), capture its ls(1) output, and figure out
> parse hints for use by dired (learn-by-example).  

The real solution is to reimplement ls in Lisp, and then change Dired to
use it. Then it will be completely reliable, something that a solution
based on regexps will, generally speaking, never be.

The first part has already been done (see ls-lisp.el).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-04 13:12     ` Paul Stoeber
@ 2002-06-05 14:01       ` Werner LEMBERG
  0 siblings, 0 replies; 10+ messages in thread
From: Werner LEMBERG @ 2002-06-05 14:01 UTC (permalink / raw)
  Cc: bug-gnu-emacs


> Exercises
>   1. [49]  Convice yourself of the fact that Dired is not ill-designed.

This remark made me laugh a lot!  I don't know how many people on the
list do recognize this joke wihtout reading TAOCP...


   Werner

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-04 11:26 ` Paul Stoeber
  2002-06-04 12:13   ` Paul Stoeber
@ 2002-06-06 12:04   ` Richard Stallman
  2002-06-06 12:37     ` Andreas Schwab
  1 sibling, 1 reply; 10+ messages in thread
From: Richard Stallman @ 2002-06-06 12:04 UTC (permalink / raw)
  Cc: bug-gnu-emacs

    (setq dired-move-to-filename-regexp "^ *[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +")

That works by counting whitespace regions.  I think I saw cases long
ago where that would not work, which is why I did not use it.
I don't remember what the case was; perhaps it was user names with
spaces in them, or perhaps it was locales that altered the number
of spaces in the date.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Dired doesn't understand localized file dates
  2002-06-06 12:04   ` Richard Stallman
@ 2002-06-06 12:37     ` Andreas Schwab
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2002-06-06 12:37 UTC (permalink / raw)
  Cc: paul.stoeber, bug-gnu-emacs

Richard Stallman <rms@gnu.org> writes:

|>     (setq dired-move-to-filename-regexp "^ *[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +")
|> 
|> That works by counting whitespace regions.  I think I saw cases long
|> ago where that would not work, which is why I did not use it.
|> I don't remember what the case was; perhaps it was user names with
|> spaces in them, or perhaps it was locales that altered the number
|> of spaces in the date.

For example, ls from fileutils 4.1.8 uses ISO style dates by default if
LC_TIME is not the C locale, which means only one space in the date field
for dates inside the 3 month range (05-14 11:55), and no space for the
other dates (2001-09-03).

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-06-06 12:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-03 10:35 Dired doesn't understand localized file dates karl.eklund
2002-06-03 22:36 ` Richard Stallman
2002-06-04  2:22   ` Thien-Thi Nguyen
2002-06-04 19:10     ` Colin Walters
2002-06-04 11:26 ` Paul Stoeber
2002-06-04 12:13   ` Paul Stoeber
2002-06-04 13:12     ` Paul Stoeber
2002-06-05 14:01       ` Werner LEMBERG
2002-06-06 12:04   ` Richard Stallman
2002-06-06 12:37     ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).