aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2010-05-29 10:55:40 +0300
committerEli Zaretskii2010-05-29 10:55:40 +0300
commit9b655a0a2297971654ab4e94a9103a8a98863e84 (patch)
tree41a3be66b59e2e0c0952acd18276c56ff7f3e9e6
parent0040735a56036641be0ed2fe1d3b954bbd5b4765 (diff)
downloademacs-9b655a0a2297971654ab4e94a9103a8a98863e84.tar.gz
emacs-9b655a0a2297971654ab4e94a9103a8a98863e84.zip
Fix bug #6294.
lisp/ls-lisp.el (ls-lisp-classify-file): New function. (ls-lisp-insert-directory): Call it if switches include -F. (ls-lisp-classify): Call ls-lisp-classify-file. (insert-directory): Remove blanks from switches.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/ls-lisp.el59
2 files changed, 44 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8dc505c4734..f56d29196f6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12010-05-29 Eli Zaretskii <eliz@gnu.org>
2
3 * ls-lisp.el (ls-lisp-classify-file): New function.
4 (ls-lisp-insert-directory): Call it if switches include -F (bug#6294).
5 (ls-lisp-classify): Call ls-lisp-classify-file.
6 (insert-directory): Remove blanks from switches.
7
12010-05-28 Juri Linkov <juri@jurta.org> 82010-05-28 Juri Linkov <juri@jurta.org>
2 9
3 * image-dired.el (image-dired-dired-toggle-marked-thumbs): 10 * image-dired.el (image-dired-dired-toggle-marked-thumbs):
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 2e061558466..f91c7a808ec 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -235,7 +235,7 @@ that work are: A a c i r S s t u U X g G B C R n and F partly."
235 (if (string-match "--dired " switches) 235 (if (string-match "--dired " switches)
236 (setq switches (replace-match "" nil nil switches))) 236 (setq switches (replace-match "" nil nil switches)))
237 ;; Convert SWITCHES to a list of characters. 237 ;; Convert SWITCHES to a list of characters.
238 (setq switches (delete ?- (append switches nil))) 238 (setq switches (delete ?\ (delete ?- (append switches nil))))
239 ;; Sometimes we get ".../foo*/" as FILE. While the shell and 239 ;; Sometimes we get ".../foo*/" as FILE. While the shell and
240 ;; `ls' don't mind, we certainly do, because it makes us think 240 ;; `ls' don't mind, we certainly do, because it makes us think
241 ;; there is no wildcard, only a directory name. 241 ;; there is no wildcard, only a directory name.
@@ -405,7 +405,11 @@ not contain `d', so that a full listing is expected."
405 (setq file (substring file 0 -1))) 405 (setq file (substring file 0 -1)))
406 (let ((fattr (file-attributes file 'string))) 406 (let ((fattr (file-attributes file 'string)))
407 (if fattr 407 (if fattr
408 (insert (ls-lisp-format file fattr (nth 7 fattr) 408 (insert (ls-lisp-format
409 (if (memq ?F switches)
410 (ls-lisp-classify-file file fattr)
411 file)
412 fattr (nth 7 fattr)
409 switches time-index (current-time))) 413 switches time-index (current-time)))
410 (message "%s: doesn't exist or is inaccessible" file) 414 (message "%s: doesn't exist or is inaccessible" file)
411 (ding) (sit-for 2))))) ; to show user the message! 415 (ding) (sit-for 2))))) ; to show user the message!
@@ -522,29 +526,40 @@ SWITCHES is a list of characters. Default sorting is alphabetic."
522 (nreverse file-alist) 526 (nreverse file-alist)
523 file-alist)) 527 file-alist))
524 528
529(defun ls-lisp-classify-file (filename fattr)
530 "Append a character to FILENAME indicating the file type.
531
532FATTR is the file attributes returned by `file-attributes' for the file.
533The file type indicators are `/' for directories, `@' for symbolic
534links, `|' for FIFOs, `=' for sockets, `*' for regular files that
535are executable, and nothing for other types of files."
536 (let* ((type (car fattr))
537 (modestr (nth 8 fattr))
538 (typestr (substring modestr 0 1)))
539 (cond
540 (type
541 (concat filename (if (eq type t) "/" "@")))
542 ((string-match "x" modestr)
543 (concat filename "*"))
544 ((string= "p" typestr)
545 (concat filename "|"))
546 ((string= "s" typestr)
547 (concat filename "="))
548 (t filename))))
549
525(defun ls-lisp-classify (filedata) 550(defun ls-lisp-classify (filedata)
526 "Append a character to each file name indicating the file type. 551 "Append a character to file name in FILEDATA indicating the file type.
527Also, for regular files that are executable, append `*'. 552
553FILEDATA has the form (FILENAME . ATTRIBUTES), where ATTRIBUTES is the
554structure returned by `file-attributes' for that file.
555
528The file type indicators are `/' for directories, `@' for symbolic 556The file type indicators are `/' for directories, `@' for symbolic
529links, `|' for FIFOs, `=' for sockets, and nothing for regular files. 557links, `|' for FIFOs, `=' for sockets, `*' for regular files that
530\[But FIFOs and sockets are not recognized.] 558are executable, and nothing for other types of files."
531FILEDATA has the form (filename . `file-attributes'). Its `cadr' is t
532for directory, string (name linked to) for symbolic link, or nil."
533 (let ((file-name (car filedata)) 559 (let ((file-name (car filedata))
534 (type (cadr filedata))) 560 (fattr (cdr filedata)))
535 (cond (type 561 (setq file-name (propertize file-name 'dired-filename t))
536 (cons 562 (cons (ls-lisp-classify-file file-name fattr) fattr)))
537 (concat (propertize file-name 'dired-filename t)
538 (if (eq type t) "/" "@"))
539 (cdr filedata)))
540 ((string-match "x" (nth 9 filedata))
541 (cons
542 (concat (propertize file-name 'dired-filename t) "*")
543 (cdr filedata)))
544 (t
545 (cons
546 (propertize file-name 'dired-filename t)
547 (cdr filedata))))))
548 563
549(defun ls-lisp-extension (filename) 564(defun ls-lisp-extension (filename)
550 "Return extension of FILENAME (ignoring any version extension) 565 "Return extension of FILENAME (ignoring any version extension)