Emacs's editing mode, dired, will ls individual files when it creates changes. However, our current implementation of ls may use different column widths for different sets of files being ls'd. This means that if a single dired directory listing includes data from multiple invocations of ls, the columns may not align properly. This problem should also exist under any other directory utility which directly displays the output of ls, and will display data obtained from multiple invocations with different filesets at the same time. Fix: I propose a change to ls which will allow minimum column widths to be set in the environment. A runtime environment variable, LS_COLWIDTHS is added. This is a colon-delimited list of minimum column widths for each variable-width column, in order of display by 'ls -lois'. For example, by default, 'ls -l' may display: total 321 -rw-r--r-- 1 joelh bin 7435 Jun 21 13:45 cmp.o -rwxr-xr-x 1 joelh bin 238385 Jun 21 14:42 ls -rw-r--r-- 1 joelh bin 4352 Jun 21 14:42 ls.1.gz -rw-r--r-- 1 joelh bin 21182 Jun 21 14:42 ls.o -rw-r--r-- 1 joelh bin 16457 Jun 21 13:45 print.o -rw-r--r-- 1 joelh bin 9814 Jun 21 13:45 stat_flags.o -rw-r--r-- 1 joelh bin 11508 Jun 21 13:45 util.o However, with LS_COLWIDTHS set to 6:4:2:8:8:1:7:0 (the affected fields for a simple -l listing are block count, user, group, and size), 'ls -l' in the same directory will display: total 321 -rw-r--r-- 1 joelh bin 7435 Jun 21 13:45 cmp.o -rwxr-xr-x 1 joelh bin 238385 Jun 21 14:42 ls -rw-r--r-- 1 joelh bin 4352 Jun 21 14:42 ls.1.gz -rw-r--r-- 1 joelh bin 21182 Jun 21 14:42 ls.o -rw-r--r-- 1 joelh bin 16457 Jun 21 13:45 print.o -rw-r--r-- 1 joelh bin 9814 Jun 21 13:45 stat_flags.o -rw-r--r-- 1 joelh bin 11508 Jun 21 13:45 util.o By setting LS_COLWIDTHS to a reasonable value, all invocations of ls will use the same column widths, thereby effectively allowing a repeatable output format under normal conditions. (The problem will still manifest as before if the column widths specified in LS_COLWIDTHS are insufficient to display the requested listing, since the columns output will still expand to meet the needs of the listing.) If additional output columns are added in the future, it is recommended to append column width specifiers to LS_COLWIDTHS rather than adding them in display order, to maintain backward compatibility. Attached are the diffs to ls.c and ls.1 to implement the recommended change. Happy hacking, joelh How-To-Repeat: Launch Emacs. Press: C-x C-f ~ RET Dired will launch and displays a directory listing of the home directory. A portion of a sample follows: -rwxr-xr-x 1 joelh joelh 3863 May 11 23:20 .bashrc -rw-r--r-- 1 joelh joelh 32126 Jun 21 14:10 .emacs -rw-r--r-- 1 joelh joelh 209 Jan 8 12:34 .emacs.bmk -rw-r--r-- 1 joelh joelh 0 Mar 4 02:45 .emacs_args -rw------- 1 joelh joelh 4217 Jun 17 00:24 .fetchmailrc Using C-n and C-p, navigate to an item that uses less than the maximum width of any column (eg, has a size an order of magnitude smaller than another). (I am using .emacs.bmk as an example.) Press M (dired-do-chmod). Press u+r (which is probably a nop in chmod, but will cause the file selected to refresh by itself). The directory will now have skewed columns: -rwxr-xr-x 1 joelh joelh 3863 May 11 23:20 .bashrc -rw-r--r-- 1 joelh joelh 32126 Jun 21 14:10 .emacs -rw-r--r-- 1 joelh joelh 209 Jan 8 12:34 .emacs.bmk -rw-r--r-- 1 joelh joelh 0 Mar 4 02:45 .emacs_args -rw------- 1 joelh joelh 4217 Jun 17 00:24 .fetchmailrc
State Changed From-To: open->suspended awaiting committer
Responsible Changed From-To: freebsd-bugs->hoek I'll do this as soon Babylon 5 is over. And maybe Buff/Vampire-Slayer, too.
State Changed From-To: suspended->closed Modified patches applied. Thanks! "Ordered lists shall remain ordered!" - bde, on -hackers, date unknown. ;-)