From unknown Sun Jun 15 08:54:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17064: 24.3.50; Enhancement request: dired: fontification of symlinks Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Mar 2014 23:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17064 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 17064@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.139544489319117 (code B ref -1); Fri, 21 Mar 2014 23:35:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 Mar 2014 23:34:53 +0000 Received: from localhost ([127.0.0.1]:44009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WR8xg-0004yG-R9 for submit@debbugs.gnu.org; Fri, 21 Mar 2014 19:34:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56128) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WR8xf-0004y9-Dy for submit@debbugs.gnu.org; Fri, 21 Mar 2014 19:34:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WR8xX-0007Om-Ud for submit@debbugs.gnu.org; Fri, 21 Mar 2014 19:34:51 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR8xX-0007Oi-ST for submit@debbugs.gnu.org; Fri, 21 Mar 2014 19:34:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR8xR-0000W3-Nj for bug-gnu-emacs@gnu.org; Fri, 21 Mar 2014 19:34:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WR8xL-0007Hx-Ig for bug-gnu-emacs@gnu.org; Fri, 21 Mar 2014 19:34:37 -0400 Received: from mout.web.de ([212.227.15.4]:50630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR8xL-0007HK-9f for bug-gnu-emacs@gnu.org; Fri, 21 Mar 2014 19:34:31 -0400 Received: from drachen.dragon ([90.186.94.218]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0Lpw63-1X4LOW0Dgt-00fhqL for ; Sat, 22 Mar 2014 00:34:29 +0100 From: Michael Heerdegen Date: Sat, 22 Mar 2014 00:34:01 +0100 Message-ID: <87siqb6s9i.fsf@web.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:awZaKDJCSj3ETzCFwgyeOateEVc6+1ZNF+do/B8kqCZUJUrCLzc twgDCYeaP1ijOrkC+HfZdUWo6JaUcqDXcGaxp7JcfZpupDSTZFrt1B6HSM4VMlJ/yKN8Xe1 tLXRJwbS/5mNVfluVCIi2UE83Ki71MOpdKvFqqcvW0f7B0ly48ooVsqmpk4QZ+G93jyWP1M F/egBLcEKs9heEW5s5+fQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hi, in dired, symlinks look like symlink -> target where the whole thing is fontified with dired-symlink-face. But I already know from the -> that I have a symlink, it would be more useful to know whether TARGET is a directory, which is what I normally see for non symlink files in dired by fontification with dired-directory-face. My proposal: fontify only the first part "symlink ->" with dired-symlink-face. Fontify "target" according to its truename type. I'm no expert for font lock, so I don't send a patch but just post the code I use in my config: --8<---------------cut here---------------start------------->8--- (cl-callf2 cl-remove dired-re-sym dired-font-lock-keywords :key #'car) (cl-callf nconc dired-font-lock-keywords `((,dired-re-sym ((lambda (end) (when (let ((file (dired-file-name-at-point))) (file-directory-p (file-truename file))) (search-forward-regexp "\\(.+-> ?\\)\\(.+\\)" end t))) (dired-move-to-filename) nil (1 dired-symlink-face) (2 dired-directory-face))) (,dired-re-sym ((lambda (end) (when (let ((file (dired-file-name-at-point))) (file-regular-p (file-truename file))) (search-forward-regexp "\\(.+-> ?\\)\\(.+\\)" end t))) (dired-move-to-filename) nil (1 dired-symlink-face) (2 'default))))) --8<---------------cut here---------------end--------------->8--- Or could this have any bad side effects? Is it maybe too heavy to call `file-truename'? Thanks, Michael. In GNU Emacs 24.3.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.7) of 2014-03-14 on drachen Windowing system distributor `The X.Org Foundation', version 11.0.11500000 System Description: Debian GNU/Linux testing (jessie) Important settings: value of $LC_ALL: de_DE.utf8 value of $LC_COLLATE: C value of $LC_TIME: C value of $LANG: de_DE.utf8 locale-coding-system: utf-8-unix Major mode: Emacs-Lisp From unknown Sun Jun 15 08:54:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17064: 24.3.50; Enhancement request: dired: fontification of symlinks Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Oct 2019 23:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17064 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Michael Heerdegen Cc: 17064@debbugs.gnu.org Received: via spool by 17064-submit@debbugs.gnu.org id=B17064.157247838917868 (code B ref 17064); Wed, 30 Oct 2019 23:34:02 +0000 Received: (at 17064) by debbugs.gnu.org; 30 Oct 2019 23:33:09 +0000 Received: from localhost ([127.0.0.1]:51887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iPxSe-0004e8-W2 for submit@debbugs.gnu.org; Wed, 30 Oct 2019 19:33:09 -0400 Received: from quimby.gnus.org ([80.91.231.51]:36262) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iPxSc-0004du-Ux for 17064@debbugs.gnu.org; Wed, 30 Oct 2019 19:33:07 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iPxSY-0008M6-Rx; Thu, 31 Oct 2019 00:33:05 +0100 From: Lars Ingebrigtsen References: <87siqb6s9i.fsf@web.de> Date: Thu, 31 Oct 2019 00:33:02 +0100 In-Reply-To: <87siqb6s9i.fsf@web.de> (Michael Heerdegen's message of "Sat, 22 Mar 2014 00:34:01 +0100") Message-ID: <87v9s5n70x.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Michael Heerdegen writes: > in dired, symlinks look like > > symlink -> target > > where the whole thing is fontified with dired-symlink-face. But I > already know from the -> that I have a symlink, it would be more useful > t [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Heerdegen writes: > in dired, symlinks look like > > symlink -> target > > where the whole thing is fontified with dired-symlink-face. But I > already know from the -> that I have a symlink, it would be more useful > to know whether TARGET is a directory, which is what I normally see for > non symlink files in dired by fontification with dired-directory-face. > > My proposal: fontify only the first part "symlink ->" with > dired-symlink-face. Fontify "target" according to its truename type. Sounds good to me. > (cl-callf nconc dired-font-lock-keywords > `((,dired-re-sym > ((lambda (end) (when (let ((file (dired-file-name-at-point))) > (file-directory-p (file-truename file))) > (search-forward-regexp "\\(.+-> ?\\)\\(.+\\)" end t))) > (dired-move-to-filename) > nil > (1 dired-symlink-face) > (2 dired-directory-face))) [...] > Or could this have any bad side effects? Is it maybe too heavy to call > `file-truename'? Normally, there aren't many symlinks in a buffer, so I think the performance impact would be negligible. I've added a modified version of your code to Emacs 27 -- more error checking was necessary, because symlinks may be circular etc. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 30 19:33:16 2019 Received: (at control) by debbugs.gnu.org; 30 Oct 2019 23:33:16 +0000 Received: from localhost ([127.0.0.1]:51890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iPxSm-0004eb-9d for submit@debbugs.gnu.org; Wed, 30 Oct 2019 19:33:16 -0400 Received: from quimby.gnus.org ([80.91.231.51]:36276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iPxSk-0004eT-J3 for control@debbugs.gnu.org; Wed, 30 Oct 2019 19:33:14 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iPxSh-0008MH-Rt for control@debbugs.gnu.org; Thu, 31 Oct 2019 00:33:13 +0100 Date: Thu, 31 Oct 2019 00:33:11 +0100 Message-Id: <87tv7pn70o.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #17064 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 17064 fixed close 17064 27.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 17064 fixed close 17064 27.1 quit