From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Trent W. Buck" Newsgroups: gmane.emacs.bugs Subject: bug#24547: 24.4; dired should colour in sockets and pipes Date: Mon, 29 Jul 2019 00:53:56 +1000 Message-ID: <20190728145350.GA29513@goll.lan> References: <87oa3b6q7s.fsf@gmail.com> <871rybh7u8.fsf@mouse.gnus.org> <875znnxhas.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="32920"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Lars Ingebrigtsen , 24547@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 28 16:55:09 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hrkZo-0008SY-Nu for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Jul 2019 16:55:08 +0200 Original-Received: from localhost ([::1]:45514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrkZn-00081e-Oj for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Jul 2019 10:55:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49099) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrkZj-00081Y-Fw for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:55:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hrkZi-0001VQ-9w for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:55:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hrkZi-0001Un-5R for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hrkZi-0004e5-42 for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Trent W. Buck" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Jul 2019 14:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24547 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 24547-submit@debbugs.gnu.org id=B24547.156432564917772 (code B ref 24547); Sun, 28 Jul 2019 14:55:02 +0000 Original-Received: (at 24547) by debbugs.gnu.org; 28 Jul 2019 14:54:09 +0000 Original-Received: from localhost ([127.0.0.1]:46972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrkYq-0004ca-OV for submit@debbugs.gnu.org; Sun, 28 Jul 2019 10:54:09 -0400 Original-Received: from mail-pf1-f171.google.com ([209.85.210.171]:39872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrkYo-0004c1-O4 for 24547@debbugs.gnu.org; Sun, 28 Jul 2019 10:54:07 -0400 Original-Received: by mail-pf1-f171.google.com with SMTP id f17so22709271pfn.6 for <24547@debbugs.gnu.org>; Sun, 28 Jul 2019 07:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rmuzxMKncWBQJu3TzA/Mb2LiEiWuJIk55u4rEndomns=; b=lz0v1/PoO94cicxuLLDJdlKoFxuBfKQrwOeN6drOat2T8PmtIz3cbUCo5ccYGrPkMl BAS9K56kcNx8LcMs2WRybf9GDurRO6ZDsOnAGjfgzGE0wz15BhVyHsiu+lqPCTm4xflL x+uZI/AsB6w3Ppwv+XGOTC2NFU42YeGAZ/W2ci7mZrDXxrMVVzRbvsLeECamfNsBJAoy 9ZAeq4hpjAOSXAiq6oJhOfEfCweyNBMptJvUa+bNgSutZIJfk1FWvB0CbRbwikUQdqJg wo0No5PPPp6nsc9wrKvTQVx7rFoDura7kFHGcBjmfxkEmZYyvpuONPbevjdAZdsiau0S fWaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rmuzxMKncWBQJu3TzA/Mb2LiEiWuJIk55u4rEndomns=; b=XYn10sqUx3kpJST8Rz8g7CH53xLGNv6JNQ7aFzRgscLSRSCQwxd5HhKXdlvQmQDxmI qqEf34nd2LWtuKIAi4C7k6XiHMOgoicVYKfc2FOEc51e7Fp1m1Nv3pNCW8PQy2WvWKo2 EpvfXAMHcqIjalycSExMg5fDHExxbm5hXTsa+Bytwu82gzNvrbvZWfkA1saAjdyutmuR 52GDMVBKwDPeLkOTy//AFUtxnSnr9gKvUzdhb0RNJziIT3Oe1Lq4xVux63uJWHxqJyfk 8VBOmdx6le7ICgsXXoRFn6ZhR5F3VqWmVysP4Q10ZT0X2FN6NGalX1L+QboRF4Nvl4Cq FL1w== X-Gm-Message-State: APjAAAX+TQ70QyxdoCyK8zHgqVi6JFY/Jd3tlILejzOgsiroEDuRMdsl mZpi3XrAvr2nj7/CSZ/+gMg= X-Google-Smtp-Source: APXvYqy0GvGPvKcb0ZEvncOjkFbWfUQwCNPvH2AWUBQJbxKCZcyo3BDd+ns5MAkNtu36i0DD1W1I2A== X-Received: by 2002:a17:90a:30aa:: with SMTP id h39mr108173155pjb.32.1564325640721; Sun, 28 Jul 2019 07:54:00 -0700 (PDT) Original-Received: from localhost (ppp118-209-216-227.bras2.mel11.internode.on.net. [118.209.216.227]) by smtp.gmail.com with ESMTPSA id a21sm66218247pfi.27.2019.07.28.07.53.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 28 Jul 2019 07:53:59 -0700 (PDT) Content-Disposition: inline In-Reply-To: <875znnxhas.fsf@mail.linkov.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:163966 Archived-At: TL;DR: explanation of dircolors(1) and terminfo(5). Juri Linkov wrote: > >> With GNU ls --color in a terminal, different colors are used for > >> > >> regular files, > >> directories, > >> symlinks, > >> sockets, > >> pipes, > >> (other stuff - dircolors?) > >> > >> In dired, the first three get different faces, > >> but sockets and pipes look like regular files. > >> > >> I think it's probably easy to fix sockets and pipes, > >> because the first character is "s" or "p", > >> at least in GNU ls output. > > > > Sounds reasonable. I've now done this in Emacs 27, but I've used just a > > single face for both sockets and pipes. Thanks! :-) > What are the remaining special file types possible in ls output? > > For example, in /run I see only "s" and "p" files. But in /dev there are > also "b" and "c". These "block" and "character" device files could be > highlighted using the same face with sockets and pipes. As I hinted earlier, GNU ls's --color output is governed by the dircolors program. "dircolors --print-database" gives a bunch of stuff. The part you asked about is: DIR 01;34 # directory LINK 01;36 # symbolic link. (If you set this to 'target' instead of a # numerical value, the color is as for the file pointed to.) MULTIHARDLINK 00 # regular file with more than one link FIFO 40;33 # pipe SOCK 01;35 # socket DOOR 01;35 # door BLK 40;33;01 # block device driver CHR 40;33;01 # character device driver ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ... MISSING 00 # ... and the files they point to Note that GNU ls/dircolors also uses different colors for different kinds of regular files e.g. "video", "audio", "pictures", "compressed files", "executables". This is done by filename extension rather than MIME type, because GNU/* filesystems generally don't store MIME type metadata, and running libmagic on every ls would be slow :-( Those codes are SGR escape sequences, also called "ANSI color". See also "man 5 terminfo". 01 above is "tput bold" (I think). 4x above is "tput setab x" (set background color). 3x above is "tput setaf x" (set foreground color). There are 8 colors (0 through 7), which you can see at the top of "emacs -nw -f list-colors-display": black red green yellow blue magenta cyan white The "bright" variants are selected automatically when bold is also set (if the terminal supports that). You might also want to consider what "man 2 stat" has to say, viz: switch (sb.st_mode & S_IFMT) { case S_IFBLK: printf("block device\n"); break; case S_IFCHR: printf("character device\n"); break; case S_IFDIR: printf("directory\n"); break; case S_IFIFO: printf("FIFO/pipe\n"); break; case S_IFLNK: printf("symlink\n"); break; case S_IFREG: printf("regular file\n"); break; case S_IFSOCK: printf("socket\n"); break; default: printf("unknown?\n"); break; } dired (as at 26.1) doesn't seem to have faces for file types (or MIME types), except for dired-directory and dired-symlink. I suppose you could just add more faces. The only downside to that, AFAICT, is that it will annoy people who write emacs color themes. For my personal needs, I don't *REALLY* care about the details, so long as "special" inodes stand out from "regular" inodes. Doing so acts as a warning to me to e.g. add "--devices=skip" to "grep -r".