From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.bugs Subject: bug#12159: 24.1.50; vc-dir: Need a way to hide unregistered files Date: Sun, 12 Aug 2012 07:20:49 +0530 Message-ID: <87boigj2ti.fsf@gmail.com> References: <87pq71i7fy.fsf@gmail.com> <87d3312p4f.fsf@gmail.com> <871ujdpbqp.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1344736306 545 80.91.229.3 (12 Aug 2012 01:51:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 12 Aug 2012 01:51:46 +0000 (UTC) Cc: 12159@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 12 03:51:46 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 1T0NLF-00083y-0b for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 Aug 2012 03:51:45 +0200 Original-Received: from localhost ([::1]:33155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0NLE-0007Jy-59 for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Aug 2012 21:51:44 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0NLA-0007Jf-Nd for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 21:51:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0NL9-0003Ds-Ip for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 21:51:40 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0NL9-0003Do-FK for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 21:51:39 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T0NTG-0001q7-Lh for bug-gnu-emacs@gnu.org; Sat, 11 Aug 2012 22:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jambunathan K Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Aug 2012 02:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12159 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 12159-submit@debbugs.gnu.org id=B12159.13447367727011 (code B ref 12159); Sun, 12 Aug 2012 02:00:02 +0000 Original-Received: (at 12159) by debbugs.gnu.org; 12 Aug 2012 01:59:32 +0000 Original-Received: from localhost ([127.0.0.1]:50228 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0NSl-0001p1-CV for submit@debbugs.gnu.org; Sat, 11 Aug 2012 21:59:31 -0400 Original-Received: from mail-pb0-f44.google.com ([209.85.160.44]:64269) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0NSj-0001ot-6h for 12159@debbugs.gnu.org; Sat, 11 Aug 2012 21:59:30 -0400 Original-Received: by pbbrr4 with SMTP id rr4so6426188pbb.3 for <12159@debbugs.gnu.org>; Sat, 11 Aug 2012 18:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=w7ZtNIArBBjUgRxD/7OYRxQZvdgWsbT1lVLCk4tGkjM=; b=VbRAv+CpXuv6xYMpaCtyXKIpeLryhcoQUYpbftF6A0MEG+SVeL2ku7bCkgRdfnNmO/ +snKLVhUXYd3bjYmRbVncfJpmLBZQoWuEYPSsGb5w9Oq28BD7JIEm9xFj5e+8zVBgsB1 JmU9rUkyT0OYj7xjwdXyIxcMSnktCjR1m7dTOOyaGF87OlKQ3hqtx9bc5hIZy/X4lsTD snfEBbmgZ53HOLyLvp2tJ74ml/m8z/wlXA0J0AXuj73NoctlDHWblq2tUFnGXvgqFuvK ggOKGYI02chSx+2kMPrQY6iQxqgRwmFhrk0h0ORvxZI6YG0Px3U/ZV16RtWh7955GDaW XxJw== Original-Received: by 10.66.73.132 with SMTP id l4mr8810017pav.30.1344736264231; Sat, 11 Aug 2012 18:51:04 -0700 (PDT) Original-Received: from debian-6.05 ([115.242.245.217]) by mx.google.com with ESMTPS id qn13sm2366246pbb.71.2012.08.11.18.51.00 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 11 Aug 2012 18:51:02 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sat, 11 Aug 2012 18:40:34 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) 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 (newer, 2) 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:63058 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> If there are marked files, then potentially a super-set of marked files >> could get hidden. This "superset" behaviour will surprise the user - >> "Why does even un-marked files get hidden?" > > I don't see why it should pay attention to the marks. I am attaching the modified patch. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=vc-dir-hide-some-states.patch Content-Description: vc-dir-hide-some-states.patch === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-11 04:46:38 +0000 +++ lisp/ChangeLog 2012-08-12 01:44:26 +0000 @@ -1,3 +1,11 @@ +2012-08-12 Jambunathan K + + * vc/vc-dir.el (vc-dir-hide-these-states): New custom variable. + (vc-dir-hide-some-states): New command. + (vc-dir-hide-up-to-date): Use `vc-dir-hide-some-states'. + (vc-dir-mode-map): Map "x" to `vc-dir-hide-some-states' instead of + `vc-dir-hide-up-to-date'. + 2012-08-11 Glenn Morris * emacs-lisp/copyright.el (copyright-update-directory): Logic fix. === modified file 'lisp/vc/vc-dir.el' --- lisp/vc/vc-dir.el 2012-07-11 23:13:41 +0000 +++ lisp/vc/vc-dir.el 2012-08-12 01:47:36 +0000 @@ -51,6 +51,25 @@ :type 'hook :group 'vc) +(defcustom vc-dir-hide-these-states '("up-to-date") + "States hidden by `vc-dir-hide-some-states'." + :type '(choice + (const :tag "None") + (set :tag "Choices" + (string :tag "VC State" "added") + (string :tag "VC State" "conflict") + (string :tag "VC State" "edited") + (string :tag "VC State" "ignored") + (string :tag "VC State" "missing") + (string :tag "VC State" "needs-merge") + (string :tag "VC State" "needs-update") + (string :tag "VC State" "removed") + (string :tag "VC State" "unlocked-changes") + (string :tag "VC State" "unregistered") + (string :tag "VC State" "up-to-date"))) + :group 'vc + :version "24.2") + ;; Used to store information for the files displayed in the directory buffer. ;; Each item displayed corresponds to one of these defstructs. (cl-defstruct (vc-dir-fileinfo @@ -271,7 +290,7 @@ (define-key map [down-mouse-3] 'vc-dir-menu) (define-key map [mouse-2] 'vc-dir-toggle-mark) (define-key map [follow-link] 'mouse-face) - (define-key map "x" 'vc-dir-hide-up-to-date) + (define-key map "x" 'vc-dir-hide-some-states) (define-key map [?\C-k] 'vc-dir-kill-line) (define-key map "S" 'vc-dir-search) ;; FIXME: Maybe use A like dired? (define-key map "Q" 'vc-dir-query-replace-regexp) @@ -1106,20 +1125,45 @@ (interactive "fShow file: ") (vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer))) -(defun vc-dir-hide-up-to-date () - "Hide up-to-date items from display." - (interactive) - (let ((crt (ewoc-nth vc-ewoc -1)) - (first (ewoc-nth vc-ewoc 0))) - ;; Go over from the last item to the first and remove the - ;; up-to-date files and directories with no child files. - (while (not (eq crt first)) - (let* ((data (ewoc-data crt)) - (dir (vc-dir-fileinfo->directory data)) - (next (ewoc-next vc-ewoc crt)) - (prev (ewoc-prev vc-ewoc crt)) - ;; ewoc-delete does not work without this... - (inhibit-read-only t)) +(defun vc-dir-hide-some-states (&optional states) + "Hide items that are in STATES from display. +STATES is a list of vc states (see`vc-state') formatted as a +string. + +If STATES is nil, use `vc-dir-hide-these-states' as the default +value. + +In interactive mode, if prefix argument is non-nil or if +`vc-dir-hide-these-states' is nil, hide items that share the same +state as file at point." + (interactive + ;; Interactive use. + (list + (or (and (not current-prefix-arg) vc-dir-hide-these-states) + ;; No prefix arg or `vc-dir-hide-these-states' is nil. State + ;; to hide is the one at point. + (let ((node (ewoc-locate vc-ewoc))) + (unless node (error "No file available")) + (let* ((data (ewoc-data node)) + (state (vc-dir-fileinfo->state data))) + (unless state (error "No state at point")) + (list (format "%s" state))))))) + ;; Non-interactive use. + (unless (called-interactively-p 'any) + (setq states (or states vc-dir-hide-these-states))) + ;; Hide specified states. + (when states + (let ((crt (ewoc-nth vc-ewoc -1)) + (first (ewoc-nth vc-ewoc 0))) + ;; Go over from the last item to the first and remove the + ;; up-to-date files and directories with no child files. + (while (not (eq crt first)) + (let* ((data (ewoc-data crt)) + (dir (vc-dir-fileinfo->directory data)) + (next (ewoc-next vc-ewoc crt)) + (prev (ewoc-prev vc-ewoc crt)) + ;; ewoc-delete does not work without this... + (inhibit-read-only t)) (when (or ;; Remove directories with no child files. (and dir @@ -1128,10 +1172,15 @@ (not next) ;; Next item is a directory. (vc-dir-fileinfo->directory (ewoc-data next)))) - ;; Remove files in the up-to-date state. - (eq (vc-dir-fileinfo->state data) 'up-to-date)) + ;; Remove files that are to be hidden. + (member (format "%s" (vc-dir-fileinfo->state data)) states)) (ewoc-delete vc-ewoc crt)) - (setq crt prev))))) + (setq crt prev)))))) + +(defun vc-dir-hide-up-to-date () + "Hide up-to-date items from display." + (interactive) + (vc-dir-hide-some-states '("up-to-date"))) (defun vc-dir-kill-line () "Remove the current line from display." --=-=-=--