Subject: Re: How I solved my 'dired' problem...

From: [email-masked] (George Nassas)
Date: 11 Jan 1996 17:31:47 GMT

> Go ahead, make me look foolish!

Never mind, I did it myself!

The following code will try to change dired do a case insensitive sort. 

;; sort files in dired buffer by name disregarding case
(add-hook 'dired-after-readin-hook
	  (function (lambda ()
		      (let ((sort-fold-case t))
			(goto-char 0) (next-line 2)
			(sort-fields -1 (point) (point-max))
			;; (sort-numeric-fields 5 (point) (point-max))
			))))

I say try to because it doesn't work for me. When I set sort-fold-case to t I
get some gibberish order, when I set it to nil (ie. do a case sensitive sort)
I get the normal dired order. If you uncomment the sort-numeric-fields it
does
what you'd think (sort by size). What's wrong with sort-fields? I tried this
same code on a 19.29.2 under mips-sgi-irix5.3 and it worked fine.

Does anyone else get this problem under ntemacs?

- George

---

From: [email-masked] (Steve Allen)
Date: Thu, 11 Jan 1996 14:57:22 -0500

> The following code will try to change dired do a case insensitive sort.

I fixed the real root of the problem - disabling the case sensitive sort of
file names in ls-lisp.el

Add this replacement function to your ~/_emacs and you'll
be much happier.  Perhaps we can add this to the default
release in the future (or a common fixes area?).

(defun ls-lisp-handle-switches (file-alist switches)
  ;; FILE-ALIST's elements are (FILE . FILE-ATTRIBUTES).
  ;; Return new alist sorted according to SWITCHES which is a list of
  ;; characters.  Default sorting is alphabetically.
  (let (index)
    (setq file-alist
	  (sort file-alist
		(cond ((memq ?S switches) ; sorted on size
		       (function
			(lambda (x y)
			  ;; 7th file attribute is file size
			  ;; Make largest file come first
			  (< (nth 7 (cdr y))
			     (nth 7 (cdr x))))))
		      ((memq ?t switches) ; sorted on time
		       (setq index (ls-lisp-time-index switches))
		       (function
			(lambda (x y)
			  (ls-lisp-time-lessp (nth index (cdr y))
					      (nth index (cdr x))))))
		      (t		; sorted alphabetically
		       (function
			(lambda (x y)
			  (string-lessp (downcase (car x))
					(downcase (car y))))))))))
  (if (memq ?r switches)		; reverse sort order
      (setq file-alist (nreverse file-alist)))
  file-alist)

-- 
Steve Allen
Clay Hill Engineering (Founder/ASIC Design Consultant)
http://www.ultranet.com/~allen (My Pgp Public key available here)