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: Mon, 13 Aug 2012 23:16:23 +0530 Message-ID: <87pq6ur8gg.fsf@gmail.com> References: <87pq71i7fy.fsf@gmail.com> <87d3312p4f.fsf@gmail.com> <871ujdpbqp.fsf@gmail.com> <87boigj2ti.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1344879999 17034 80.91.229.3 (13 Aug 2012 17:46:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 13 Aug 2012 17:46:39 +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 Mon Aug 13 19:46:39 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 1T0yiq-0002rv-Qs for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Aug 2012 19:46:37 +0200 Original-Received: from localhost ([::1]:58721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0yip-0004Gg-Sq for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Aug 2012 13:46:35 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0yik-0004G7-OV for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2012 13:46:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0yij-00085A-BU for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2012 13:46:30 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0yij-000850-78 for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2012 13:46:29 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T0yr0-0003Uu-6j for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2012 13:55: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: Mon, 13 Aug 2012 17:55: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.134488049613433 (code B ref 12159); Mon, 13 Aug 2012 17:55:02 +0000 Original-Received: (at 12159) by debbugs.gnu.org; 13 Aug 2012 17:54:56 +0000 Original-Received: from localhost ([127.0.0.1]:53871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0yqt-0003Ua-DC for submit@debbugs.gnu.org; Mon, 13 Aug 2012 13:54:56 -0400 Original-Received: from mail-gg0-f172.google.com ([209.85.161.172]:43958) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0yqr-0003UT-GP for 12159@debbugs.gnu.org; Mon, 13 Aug 2012 13:54:54 -0400 Original-Received: by ggnh4 with SMTP id h4so3751673ggn.3 for <12159@debbugs.gnu.org>; Mon, 13 Aug 2012 10:46:18 -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=+9iTU/0s4UX3rDyPnX6PJXOBoWrJAqkgO1kWU2gp1iA=; b=D6R2GT9ycI+kKSQmgPelkEaiIDqWz/PYEZTyKquba4gimNcuNxmz1ciluMmymyqP8c REjvD7qBS3GGjtJo4EQLMBAu3djlqtFfW2RxX6WwfR7wAoBmovI1ymMWYWyQgw9NN4zG v7TkCKbasw2y1/eySDk/iuAIBq/4vxsv/oDlwM37dg7I1PpayNx6KoPU2IzuozLRDwfX IjGnTyos7bP8nytkjB0v0BcH8EHHNWjiSofpT4De9rjDC5TjI16JkNqmgHVXWxRI67rx ruel7sc73UJSCzyP18jrYZPz7BQ2Y9GbjmKEujlhbEZ6TT7gM3YLqS/+AyRSEKUtS0x8 SJAg== Original-Received: by 10.68.228.193 with SMTP id sk1mr33993569pbc.97.1344879978329; Mon, 13 Aug 2012 10:46:18 -0700 (PDT) Original-Received: from debian-6.05 ([101.62.50.154]) by mx.google.com with ESMTPS id kt2sm57084pbc.73.2012.08.13.10.46.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 13 Aug 2012 10:46:17 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sun, 12 Aug 2012 10:13:05 -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:63109 Archived-At: --=-=-= Content-Type: text/plain FWIW, I am attaching two patches. If you want any changes please do it yourself. patch-1 :: There is only one command 'x' - which hides state at point. patch-2 :: `x' hides up-to-date and `C-u x' hides state at point. Personally, I will go with patch 1. It is simpler. No prefix key is used. Btw, reviewer who takes infinite time to review could either be a perfectionist or a procrastinator :-). --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=bug#12159-approach-1.patch Content-Description: approach-1.patch === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-12 22:52:33 +0000 +++ lisp/ChangeLog 2012-08-13 17:26:55 +0000 @@ -1,3 +1,12 @@ +2012-08-13 Jambunathan K + + * vc/vc-dir.el (vc-dir-hide-up-to-date): Remove it. + (vc-dir-hide-state): New command. + (vc-dir-mode-map): Map key "x" to `vc-dir-hide-state' instead of + `vc-dir-hide-up-to-date'. + (vc-dir-menu-map): Use `vc-dir-hide-state' instead of + `vc-dir-hide-up-to-date' + 2012-08-12 Stefan Monnier * subr.el (internal--before-with-seleted-window) === 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-13 17:32:12 +0000 @@ -123,9 +123,9 @@ '(menu-item "Refresh" revert-buffer :enable (not (vc-dir-busy)) :help "Refresh the contents of the directory buffer")) - (define-key map [remup] - '(menu-item "Hide Up-to-date" vc-dir-hide-up-to-date - :help "Hide up-to-date items from display")) + (define-key map [hide] + '(menu-item "Hide current state" vc-dir-hide-state + :help "Hide items share current state")) ;; Movement. (define-key map [sepmv] '("--")) (define-key map [next-line] @@ -271,7 +271,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-state) (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 +1106,30 @@ (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-state (state) + "Hide items that are in STATE from display. +See `vc-state' for valid values of STATE. + +Interactively, set STATE to state of item at point." + (interactive (list + ;; Infer STATE from point. Complain otherwise. + (let ((node (ewoc-locate vc-ewoc))) + (unless node (error "No file available")) + (or (vc-dir-fileinfo->state (ewoc-data node)) + (error "No state at point"))))) + (when state + (message "Hiding items in state \"%s\"" state) + (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 +1138,11 @@ (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 in specified STATE. STATE can be a + ;; symbol or a user-name. + (equal (vc-dir-fileinfo->state data) state)) (ewoc-delete vc-ewoc crt)) - (setq crt prev))))) + (setq crt prev)))))) (defun vc-dir-kill-line () "Remove the current line from display." --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=bug#12159-approach-2.patch Content-Description: approach-2.patch === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-12 22:52:33 +0000 +++ lisp/ChangeLog 2012-08-13 17:16:15 +0000 @@ -1,3 +1,8 @@ +2012-08-13 Jambunathan K + + * vc/vc-dir.el (vc-dir-hide-state): New command + (vc-dir-hide-up-to-date): Route it to `vc-dir-hide-state'. + 2012-08-12 Stefan Monnier * subr.el (internal--before-with-seleted-window) === 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-13 17:12:16 +0000 @@ -1106,9 +1106,22 @@ (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) +(defun vc-dir-hide-state (&optional state) + "Hide items that are in STATE from display. +See `vc-state' for valid values of STATE. + +If STATE is nil, default it to up-to-date. + +Interactively, if `current-prefix-arg' is non-nil, set STATE to +state of item at point. Otherwise, set STATE to up-to-date." + (interactive (list + (and current-prefix-arg + ;; Command is prefixed. Infer STATE from point. + (let ((node (ewoc-locate vc-ewoc))) + (and node (vc-dir-fileinfo->state (ewoc-data node))))))) + ;; If STATE is un-specified, use up-to-date. + (setq state (or state 'up-to-date)) + (message "Hiding items in state \"%s\"" state) (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 @@ -1120,18 +1133,21 @@ (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 - (or - ;; Nothing follows this directory. - (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)) - (ewoc-delete vc-ewoc crt)) - (setq crt prev))))) + (when (or + ;; Remove directories with no child files. + (and dir + (or + ;; Nothing follows this directory. + (not next) + ;; Next item is a directory. + (vc-dir-fileinfo->directory (ewoc-data next)))) + ;; Remove files in specified STATE. STATE can be a + ;; symbol or a user-name. + (equal (vc-dir-fileinfo->state data) state)) + (ewoc-delete vc-ewoc crt)) + (setq crt prev))))) + +(defalias 'vc-dir-hide-up-to-date 'vc-dir-hide-state) (defun vc-dir-kill-line () "Remove the current line from display." --=-=-= Content-Type: text/plain >> + * vc/vc-dir.el (vc-dir-hide-these-states): New custom variable. > > Don't bother. Just always default to up-to-date. > >> +(defun vc-dir-hide-some-states (&optional states) > > Make it `state' and not a list. > >> + (interactive >> + ;; Interactive use. > > Redundant comment. > >> + ;; Non-interactive use. >> + (unless (called-interactively-p 'any) >> + (setq states (or states vc-dir-hide-these-states))) > > The test is wrong (it prevents non-interactive use where you specify > the state explicitly). > The above should simply be (unless state (setq state 'up-to-date)). > >> +(defun vc-dir-hide-up-to-date () >> + "Hide up-to-date items from display." >> + (interactive) >> + (vc-dir-hide-some-states '("up-to-date"))) > > Why bother? > > > Stefan --=-=-=--