aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii2010-11-06 12:08:33 +0200
committerEli Zaretskii2010-11-06 12:08:33 +0200
commit169759a0d412e5f1eb9aea1663bbffb59002452c (patch)
tree26e7e48ff5053a8d5bb95c31a36f4e55cd8313e6 /lisp
parent21620882d7956ac84de26371f9fb504b6c558192 (diff)
downloademacs-169759a0d412e5f1eb9aea1663bbffb59002452c.tar.gz
emacs-169759a0d412e5f1eb9aea1663bbffb59002452c.zip
Back-port from trunk the fix for bug #6294.
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/ls-lisp.el59
2 files changed, 41 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 83915ca448d..135e1ea750f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,10 @@
12010-11-06 Eli Zaretskii <eliz@gnu.org> 12010-11-06 Eli Zaretskii <eliz@gnu.org>
2 2
3 * ls-lisp.el (insert-directory): Doc fix. (bug#7285) 3 * ls-lisp.el (insert-directory): Doc fix. (bug#7285)
4 (ls-lisp-classify-file): New function.
5 (ls-lisp-insert-directory): Call it if switches include -F (bug#6294).
6 (ls-lisp-classify): Call ls-lisp-classify-file.
7 (insert-directory): Remove blanks from switches.
4 8
52010-11-07 Wilson Snyder <wsnyder@wsnyder.org> 92010-11-07 Wilson Snyder <wsnyder@wsnyder.org>
6 10
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 28311f81e6c..b01ad6f9510 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -236,7 +236,7 @@ is assumed to be always present and cannot be turned off."
236 (if (string-match "--dired " switches) 236 (if (string-match "--dired " switches)
237 (setq switches (replace-match "" nil nil switches))) 237 (setq switches (replace-match "" nil nil switches)))
238 ;; Convert SWITCHES to a list of characters. 238 ;; Convert SWITCHES to a list of characters.
239 (setq switches (delete ?- (append switches nil))) 239 (setq switches (delete ?\ (delete ?- (append switches nil))))
240 ;; Sometimes we get ".../foo*/" as FILE. While the shell and 240 ;; Sometimes we get ".../foo*/" as FILE. While the shell and
241 ;; `ls' don't mind, we certainly do, because it makes us think 241 ;; `ls' don't mind, we certainly do, because it makes us think
242 ;; there is no wildcard, only a directory name. 242 ;; there is no wildcard, only a directory name.
@@ -406,7 +406,11 @@ not contain `d', so that a full listing is expected."
406 (setq file (substring file 0 -1))) 406 (setq file (substring file 0 -1)))
407 (let ((fattr (file-attributes file 'string))) 407 (let ((fattr (file-attributes file 'string)))
408 (if fattr 408 (if fattr
409 (insert (ls-lisp-format file fattr (nth 7 fattr) 409 (insert (ls-lisp-format
410 (if (memq ?F switches)
411 (ls-lisp-classify-file file fattr)
412 file)
413 fattr (nth 7 fattr)
410 switches time-index (current-time))) 414 switches time-index (current-time)))
411 (message "%s: doesn't exist or is inaccessible" file) 415 (message "%s: doesn't exist or is inaccessible" file)
412 (ding) (sit-for 2))))) ; to show user the message! 416 (ding) (sit-for 2))))) ; to show user the message!
@@ -523,29 +527,40 @@ SWITCHES is a list of characters. Default sorting is alphabetic."
523 (nreverse file-alist) 527 (nreverse file-alist)
524 file-alist)) 528 file-alist))
525 529
530(defun ls-lisp-classify-file (filename fattr)
531 "Append a character to FILENAME indicating the file type.
532
533FATTR is the file attributes returned by `file-attributes' for the file.
534The file type indicators are `/' for directories, `@' for symbolic
535links, `|' for FIFOs, `=' for sockets, `*' for regular files that
536are executable, and nothing for other types of files."
537 (let* ((type (car fattr))
538 (modestr (nth 8 fattr))
539 (typestr (substring modestr 0 1)))
540 (cond
541 (type
542 (concat filename (if (eq type t) "/" "@")))
543 ((string-match "x" modestr)
544 (concat filename "*"))
545 ((string= "p" typestr)
546 (concat filename "|"))
547 ((string= "s" typestr)
548 (concat filename "="))
549 (t filename))))
550
526(defun ls-lisp-classify (filedata) 551(defun ls-lisp-classify (filedata)
527 "Append a character to each file name indicating the file type. 552 "Append a character to file name in FILEDATA indicating the file type.
528Also, for regular files that are executable, append `*'. 553
554FILEDATA has the form (FILENAME . ATTRIBUTES), where ATTRIBUTES is the
555structure returned by `file-attributes' for that file.
556
529The file type indicators are `/' for directories, `@' for symbolic 557The file type indicators are `/' for directories, `@' for symbolic
530links, `|' for FIFOs, `=' for sockets, and nothing for regular files. 558links, `|' for FIFOs, `=' for sockets, `*' for regular files that
531\[But FIFOs and sockets are not recognized.] 559are executable, and nothing for other types of files."
532FILEDATA has the form (filename . `file-attributes'). Its `cadr' is t
533for directory, string (name linked to) for symbolic link, or nil."
534 (let ((file-name (car filedata)) 560 (let ((file-name (car filedata))
535 (type (cadr filedata))) 561 (fattr (cdr filedata)))
536 (cond (type 562 (setq file-name (propertize file-name 'dired-filename t))
537 (cons 563 (cons (ls-lisp-classify-file file-name fattr) fattr)))
538 (concat (propertize file-name 'dired-filename t)
539 (if (eq type t) "/" "@"))
540 (cdr filedata)))
541 ((string-match "x" (nth 9 filedata))
542 (cons
543 (concat (propertize file-name 'dired-filename t) "*")
544 (cdr filedata)))
545 (t
546 (cons
547 (propertize file-name 'dired-filename t)
548 (cdr filedata))))))
549 564
550(defun ls-lisp-extension (filename) 565(defun ls-lisp-extension (filename)
551 "Return extension of FILENAME (ignoring any version extension) 566 "Return extension of FILENAME (ignoring any version extension)