From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Christopher Schmidt Newsgroups: gmane.emacs.bugs Subject: bug#6799: 24.0.50; Please add dired-details.el to Emacs [patch] Date: Mon, 17 Dec 2012 13:24:31 +0000 (GMT) Message-ID: <87mwxcx149@ch.ristopher.com> References: <9C9137560F644E759AD573BBBD8E59EF@us.oracle.com> <5EA47A0255F8494DB430B52D46876641@us.oracle.com> <65D921448B0644988BE6445A2EF3E021@us.oracle.com> <21FFB8EA85964411A9B790386C5DA3AD@us.oracle.com> <878v8zow44@ch.ristopher.com> <87k3sj6juj@ch.ristopher.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1355750765 25486 80.91.229.3 (17 Dec 2012 13:26:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Dec 2012 13:26:05 +0000 (UTC) Cc: Michael Heerdegen To: 6799@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 17 14:26:16 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tkahx-0002M0-3u for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Dec 2012 14:26:13 +0100 Original-Received: from localhost ([::1]:56459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tkahj-0004ih-I0 for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Dec 2012 08:25:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tkahc-0004fx-13 for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 08:25:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkahX-0001Ch-Kk for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 08:25:51 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkahX-0001Cb-H7 for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 08:25:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Tkaij-0007rU-Lt for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 08:27:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Christopher Schmidt Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Dec 2012 13:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6799 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.135575079930191 (code B ref -1); Mon, 17 Dec 2012 13:27:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Dec 2012 13:26:39 +0000 Original-Received: from localhost ([127.0.0.1]:46880 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkai1-0007qW-8L for submit@debbugs.gnu.org; Mon, 17 Dec 2012 08:26:22 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:50586) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkahr-0007qI-TE for submit@debbugs.gnu.org; Mon, 17 Dec 2012 08:26:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tkaga-0000qO-Hc for submit@debbugs.gnu.org; Mon, 17 Dec 2012 08:24:52 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:37577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tkaga-0000qJ-EZ for submit@debbugs.gnu.org; Mon, 17 Dec 2012 08:24:48 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkagW-0004S4-24 for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 08:24:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkagN-0000mS-2m for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 08:24:43 -0500 Original-Received: from ristopher.com ([146.185.21.93]:37266 helo=saturn.ch.ristopher.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkagM-0000lt-N1 for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 08:24:34 -0500 Original-Received: by saturn.ch.ristopher.com (Postfix, from userid 0) id BCF352016E; Mon, 17 Dec 2012 13:24:31 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ch.ristopher.com; s=mail; t=1355750671; bh=jHxaSIdUrngFsrCCc8sHGdWdaE4qqO4+qclL0rAfSj0=; h=From:To:Cc:Subject:In-Reply-To:Message-ID:References:MIME-Version: Content-Type:Date; b=WRL6Hdp4mblT2S9FjYTdN4fD0+8wlQRaqsOR0uqP8tA4DL2Mix343LFcW2Z1XRvA4 5EcM7Mo4ERa4+KvtTWZo7emEkVav1fF8Ii+J0s+Wc0gpBcfSik3DzcGkEcYMUOCD2K hNTwHHiPqFRfkpsCVsLTGlRxJxD0AbtZq9vRxGg4= In-Reply-To: (Stefan Monnier's message of "Sun, 16 Dec 2012 17:31:39 -0500") Mail-Followup-To: bug-gnu-emacs@gnu.org, Stefan Monnier , Drew Adams , Michael Heerdegen X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:68635 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: Hi Stefan, thanks for your input. Here is a preliminary patch for the trunk. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-dired-hide-details-mode.diff --- lisp/dired.el +++ lisp/dired.el @@ -230,6 +230,12 @@ :version "22.1" :group 'dired) +(defcustom dired-hide-details-hide-symlink-targets t + "If non-nil, `dired-hide-details-mode' hides symbolic link targets." + :type 'boolean + :version "24.4" + :group 'dired) + ;; Internal variables (defvar dired-marker-char ?* ; the answer is 42 @@ -1222,15 +1228,22 @@ (goto-char beg) (while (< (point) end) (condition-case nil - (if (dired-move-to-filename) - (add-text-properties - (point) - (save-excursion - (dired-move-to-end-of-filename) - (point)) - '(mouse-face highlight - dired-filename t - help-echo "mouse-2: visit this file in other window"))) + (when (dired-move-to-filename) + (put-text-property (+ (line-beginning-position) 2) (point) + 'invisible 'dired-detail) + (add-text-properties + (point) + (progn + (dired-move-to-end-of-filename) + (point)) + '(mouse-face + highlight + dired-filename t + help-echo "mouse-2: visit this file in other window")) + (when (and dired-hide-details-hide-symlink-targets + (< (+ (point) 4) (line-end-position))) + (put-text-property (+ (point) 4) (line-end-position) + 'invisible 'dired-detail))) (error nil)) (forward-line 1)))) @@ -1494,6 +1507,7 @@ ;; hiding (define-key map "$" 'dired-hide-subdir) (define-key map "\M-$" 'dired-hide-all) + (define-key map "(" 'dired-hide-details-mode) ;; isearch (define-key map (kbd "M-s a C-s") 'dired-do-isearch) (define-key map (kbd "M-s a M-C-s") 'dired-do-isearch-regexp) @@ -1584,6 +1598,14 @@ '(menu-item "Toggle Image Thumbnails in This Buffer" image-dired-dired-toggle-marked-thumbs :help "Add or remove image thumbnails in front of marked file names")) + (define-key map [menu-bar immediate unhide-details] + '(menu-item "UnHide Details" dired-hide-details-mode + :help "Unhide details in buffer" + :visible dired-hide-details-mode)) + (define-key map [menu-bar immediate hide-details] + '(menu-item "Hide Details" dired-hide-details-mode + :help "Hide details in buffer" + :visible (not dired-hide-details-mode))) (define-key map [menu-bar immediate revert-buffer] '(menu-item "Refresh" revert-buffer :help "Update contents of shown directories")) @@ -1912,6 +1934,9 @@ selective-display t ; for subdirectory hiding mode-line-buffer-identification (propertized-buffer-identification "%17b")) + ;; ignore dired-detail value of invisible text property by default + (when (eq buffer-invisibility-spec t) + (setq buffer-invisibility-spec (list t))) (set (make-local-variable 'revert-buffer-function) (function dired-revert)) (set (make-local-variable 'buffer-stale-function) @@ -2228,6 +2253,20 @@ (substring file (match-end 0)) file)) +;;; Minor mode for hiding details +;;;###autoload +(define-minor-mode dired-hide-details-mode + "Hide details in `dired-mode'." + :group 'dired + (unless (derived-mode-p 'dired-mode) + (error "Not a Dired buffer")) + (funcall (if dired-hide-details-mode + 'add-to-invisibility-spec + 'remove-from-invisibility-spec) + 'dired-detail)) + +(put 'dired-hide-details-mode 'safe-local-variable 'booleanp) + ;;; Functions for finding the file name in a dired buffer line. (defvar dired-permission-flags-regexp --=-=-= Content-Type: text/plain I would love to hear your feedback. >> (save-restriction >> (widen) > > Please add a comment explaining why widening should be used here. Widening is not necessary any more. >> do (let ((buffer-read-only)) >> (put-text-property (point) end >> 'invisible my-dired-hide-details-mode)) > > Better bind inhibit-read-only to t. Or better yet, use > with-silent-modifications (but move it outside the loop). > > Also, rather than set the invisible property to nil or t, better set > it to another symbol (e.g. `dired-details'), whose meaning is then > controlled by add-to-invisibility-spec. Right. Obviously this simplifies the implementation. >> (defadvice dired-insert-set-properties >> (after my-add-hide-props (beg end) activate) > > Obviously, this would have to be turned into a patch, and since it's > not small, it would need to be moved to its own function (which would > be called from dired-insert-set-properties). Check the new patch. Altogether 7 new lines are added to dired-insert-set-properties. >> (defadvice find-dired (after my-fix-move-process-mark-to-arg activate) >> (move-marker (process-mark (get-buffer-process (current-buffer))) >> (save-excursion >> (goto-char (point-min)) >> (forward-line 1) >> (point)))) > > How is that related to dired-details? This is not necessary any more. My former implementation hid every non-file line that dired-insert-set-properties is called upon. Vanilla dired calls dired-insert-set-properties on every line except the directory headerline so my-dired-hide-details-mode hid the information line. total used in directory RMS available VI Initially find-dired inserts the directory headerline, newline and the find arguments and set the process mark is set to 1. In the process filter of find find-dired evals (dired-insert-set-properties (process-mark proc) (1+ (point))) (move-marker (process-mark proc) (1+ (point))) with (point) being right before the end of the last complete line added by find. That is dired-insert-set-properties is called on the first and second line so my former code added the invisible property to the directory headerline as well. This is why I added that advice - just move the process mark to the second line so dired-insert-set-properties is not called on the directory headerline. I removed the hiding of non-file lines. Hiding full lines via text properties might cause confusion when it comes to interactive line movement. There are no changed to find-dired.el now. Christopher --=-=-=--