From owner-ntemacs-users@trout  Fri Mar 28 12:06:47 1997
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
	[nil "" "28" "March" "1997" "14:20:49" "-0500" "Dan Schmidt" "dfan@harmonixmusic.com" nil "168" "Re: ls-lisp.el Modification to Ignore Case" "^From:" nil nil "3" nil nil nil nil]
	nil)
Received: from joker.cs.washington.edu (joker.cs.washington.edu [128.95.1.42]) by june.cs.washington.edu (8.8.5+CS/7.2ju) with SMTP id MAA01803 for <voelker@june.cs.washington.edu>; Fri, 28 Mar 1997 12:06:47 -0800
Received: from trout.cs.washington.edu (trout.cs.washington.edu [128.95.1.178]) by joker.cs.washington.edu (8.6.12/7.2ws+) with ESMTP id MAA29716 for <voelker@joker.cs.washington.edu>; Fri, 28 Mar 1997 12:06:34 -0800
Received: from june.cs.washington.edu (june.cs.washington.edu [128.95.1.4]) by trout.cs.washington.edu (8.8.5+CS/7.2ws+) with ESMTP id LAA20809 for <ntemacs-users@trout.cs.washington.edu>; Fri, 28 Mar 1997 11:22:58 -0800 (PST)
Received: from ntserver.harmonixmusic.com (harmonix.ma.ultranet.com [146.115.237.55]) by june.cs.washington.edu (8.8.5+CS/7.2ju) with ESMTP id LAA28318 for <ntemacs-users@cs.washington.edu>; Fri, 28 Mar 1997 11:21:42 -0800
Received: from turangalila.harmonixmusic.com ([146.115.90.78])           by ntserver.harmonixmusic.com (post.office MTA v2.0 0813           ID# 0-29126U35) with SMTP id AAA251;           Fri, 28 Mar 1997 14:10:48 -0500
References: <c=US%a=_%p=INTERGRAPH%l=HQ6-970328162817Z-12651@hq15.pcmail.ingr.com>
Organization: Harmonix Music Systems
In-Reply-To: "Rosinger, David S"'s message of Fri, 28 Mar 1997 10:28:17 -0600
Message-ID: <wkhghvvn5a.fsf@turangalila.harmonixmusic.com>
Lines: 168
X-Mailer: Gnus v5.4.33/Emacs 19.34
From: Dan Schmidt <dfan@harmonixmusic.com>
Sender: dfan@turangalila.harmonixmusic.com
To: ntemacs-users@cs.washington.edu
Subject: Re: ls-lisp.el Modification to Ignore Case
Date: 28 Mar 1997 14:20:49 -0500

"Rosinger, David S" <dsrosing@ingr.com> writes:

| INTRO
| 
| I have made a (trivial) modification to "ls-lisp.el" to
| ignore case when sorting files alphabetically in dired mode.
| 
| This seems particularly appropriate on Win32.

I made a similar change to my ls-lisp.el:

 - directories are displayed before files.
 - links, UID and GID are not displayed, since they're not applicable
   on Win95.
 - file names in all caps are displayed in all lowercase (and are
   sorted that way, too).

All of these options are toggleable.

Here's a patch, if anyone is interested.  It should be obvious how to
toggle the above options from the defvar's (they're all on by
default).

Dan

*** c:/app/emacs-19.34/lisp/ls-lisp.el	Wed Aug 28 23:56:18 1996
--- z:/home/dfan/Emacs/ls-lisp.el	Tue Aug 06 17:54:08 1996
***************
*** 55,60 ****
--- 55,72 ----
  
  ;;; Code:
  
+ (defvar ls-lisp-lg-style t
+   "*Display directories in what I consider to be a nicer format.
+ All subdirectories are displayed before all files.
+ Sorting of files is done in a case-insensitive manner.")
+ 
+ (defvar ls-lisp-downcase-names t
+   "*When displaying directories, convert filenames that are all caps to
+ be all lowercase, to compensate for Windows 95.")
+ 
+ (defvar ls-lisp-succint t
+   "*Don't display links, UID and GID.")
+ 
  ;;;###autoload
  (defvar ls-lisp-support-shell-wildcards t
    "*Non-nil means file patterns are treated as shell wildcards.
***************
*** 121,127 ****
  		   (function
  		    (lambda (x)
  		      ;; file-attributes("~bogus") bombs
! 		      (cons x (file-attributes (expand-file-name x)))))
  		   ;; inserting the call to directory-files right here
  		   ;; seems to stimulate an Emacs bug
  		   ;; ILLEGAL DATATYPE (#o37777777727) or #o67
--- 133,140 ----
  		   (function
  		    (lambda (x)
  		      ;; file-attributes("~bogus") bombs
! 		      (cons (ls-lisp-canonicalize-name x)
!                             (file-attributes (expand-file-name x)))))
  		   ;; inserting the call to directory-files right here
  		   ;; seems to stimulate an Emacs bug
  		   ;; ILLEGAL DATATYPE (#o37777777727) or #o67
***************
*** 184,194 ****
  			(lambda (x y)
  			  (ls-lisp-time-lessp (nth index (cdr y))
  					      (nth index (cdr x))))))
! 		      (t		; sorted alphabetically
! 		       (function
! 			(lambda (x y)
! 			  (string-lessp (car x)
! 					(car y)))))))))
    (if (memq ?r switches)		; reverse sort order
        (setq file-alist (nreverse file-alist)))
    file-alist)
--- 197,217 ----
  			(lambda (x y)
  			  (ls-lisp-time-lessp (nth index (cdr y))
  					      (nth index (cdr x))))))
! 
!                       (t                
!                        (if ls-lisp-lg-style
!                            (function        ; sorted alphabetically, dirs first,
!                             (lambda (x y)   ; case insensitive
!                               (if (eq (car (cdr x))
!                                       (car (cdr y)))
!                                   (string-lessp (downcase (car x))
!                                                 (downcase (car y)))
!                                 (eq (car (cdr x)) t))))
!                          (function          ; sorted alphabetically
!                           (lambda (x y)
!                             (string-lessp (car x)
!                                           (car y))))))))))
! 
    (if (memq ?r switches)		; reverse sort order
        (setq file-alist (nreverse file-alist)))
    file-alist)
***************
*** 203,209 ****
  	(and (= hi0 hi1)
  	     (< lo0 lo1)))))
  
- 
  (defun ls-lisp-format (file-name file-attr &optional switches)
    (let ((file-type (nth 0 file-attr)))
      (concat (if (memq ?i switches)	; inode number
--- 226,231 ----
***************
*** 216,232 ****
  	    ;; Emacs should be able to make strings of them.
  	    ;; user-login-name and user-full-name could take an
  	    ;; optional arg.
! 	    (format " %3d %-8s %-8s %8d "
! 		    (nth 1 file-attr)	; no. of links
! 		    (if (= (user-uid) (nth 2 file-attr))
! 			(user-login-name)
! 		      (int-to-string (nth 2 file-attr)))	; uid
! 		    (if (eq system-type 'ms-dos)
! 			"root"		; everything is root on MSDOS.
! 		      (int-to-string (nth 3 file-attr)))	; gid
! 		    (nth 7 file-attr)	; size in bytes
! 		    )
! 	    (ls-lisp-format-time file-attr switches)
  	    " "
  	    file-name
  	    (if (stringp file-type)	; is a symbolic link
--- 238,257 ----
  	    ;; Emacs should be able to make strings of them.
  	    ;; user-login-name and user-full-name could take an
  	    ;; optional arg.
!             (if ls-lisp-succint
!                 (format " %8d "
!                         (nth 7 file-attr))
!                 (format " %3d %8s %8s %8d "
!                         (nth 1 file-attr) ; no. of links
!                         (if (= (user-uid) (nth 2 file-attr))
!                             (user-login-name)
!                           (int-to-string (nth 2 file-attr))) ; uid
!                         (if (eq system-type 'ms-dos)
!                             "root"      ; everything is root on MSDOS.
!                           (int-to-string (nth 3 file-attr))) ; gid
!                         (nth 7 file-attr) ; size in bytes
!                         ))
!             (ls-lisp-format-time file-attr switches)
  	    " "
  	    file-name
  	    (if (stringp file-type)	; is a symbolic link
***************
*** 266,271 ****
--- 291,305 ----
  		  year)))
      (error
       "Jan 00 00:00")))
+ 
+ (defun ls-lisp-canonicalize-name (file-name)
+   ;; If ls-lisp-downcase-names is non-nil, downcase FILE-NAME if
+   ;; it's currently all caps. Useful for dealing with Windows95, in
+   ;; which files tend to be in all caps if you didn't specify otherwise.
+   (if (and ls-lisp-downcase-names
+            (equal (upcase file-name) file-name))
+       (downcase file-name)
+     file-name))
  
  (provide 'ls-lisp)

