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 16:34:06 +0530 Message-ID: <87r4rc5q3d.fsf@gmail.com> References: <87pq71i7fy.fsf@gmail.com> <87d3312p4f.fsf@gmail.com> <871ujdpbqp.fsf@gmail.com> <87boigj2ti.fsf@gmail.com> <87pq6we8jk.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1344769483 31610 80.91.229.3 (12 Aug 2012 11:04:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 12 Aug 2012 11:04:43 +0000 (UTC) Cc: 12159@debbugs.gnu.org To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 12 13:04:43 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 1T0VyN-0002fk-4A for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 Aug 2012 13:04:43 +0200 Original-Received: from localhost ([::1]:59403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0VyM-0006dw-79 for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 Aug 2012 07:04:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0VyJ-0006dp-MB for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 07:04:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0VyH-0000AR-1R for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 07:04:39 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0VyG-0000AN-TE for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 07:04:36 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T0W6Q-0006ug-Dq for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 07:13: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 11:13: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.134476995526541 (code B ref 12159); Sun, 12 Aug 2012 11:13:02 +0000 Original-Received: (at 12159) by debbugs.gnu.org; 12 Aug 2012 11:12:35 +0000 Original-Received: from localhost ([127.0.0.1]:50673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0W5x-0006u1-FQ for submit@debbugs.gnu.org; Sun, 12 Aug 2012 07:12:34 -0400 Original-Received: from mail-pb0-f44.google.com ([209.85.160.44]:55814) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0W5t-0006tr-CP for 12159@debbugs.gnu.org; Sun, 12 Aug 2012 07:12:31 -0400 Original-Received: by pbbrr4 with SMTP id rr4so7170773pbb.3 for <12159@debbugs.gnu.org>; Sun, 12 Aug 2012 04:04:01 -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=wIzm1RUOf7q0QEFCObo0mGCcJV2SQnz6VcKgFphLyi0=; b=oAkU/z/p55WZm4IsZ7M+QAuGwvFY+5OpzuoG0CTow5Ga/O4lyEZTn0kxLwdCJQ6RmO foBIevN1CQ7Rse9igItX55Ch9WuZuwCjVS2R+Im/EnK/MjQhksDQLZ5eOdKX8KdShmaP Xh7E/UpIxMJkL6YWIHd0FZdYbNaR0qzMdG+OtEOtz/HHA4AvJsBYreWQTKh2y3hNq3i1 84nRwmg8pBzSceAhdv0cHv4o8q7oukJNmCzB1r8jv9COMTvF113ryZpFsKGn4tyULDKw oHllHW/LFMVK3081ZHhE0b//cu0qjCTiOzQaNCtTT/Fyqw8ohSMKJ8ukZlpRWaxQLTD8 KxQg== Original-Received: by 10.66.88.233 with SMTP id bj9mr11015656pab.72.1344769441359; Sun, 12 Aug 2012 04:04:01 -0700 (PDT) Original-Received: from debian-6.05 ([115.184.4.123]) by mx.google.com with ESMTPS id os1sm3150179pbc.31.2012.08.12.04.03.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 12 Aug 2012 04:04:00 -0700 (PDT) In-Reply-To: (Andreas Schwab's message of "Sun, 12 Aug 2012 12:02:56 +0200") 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:63067 Archived-At: --=-=-= Content-Type: text/plain Andreas Schwab writes: > Jambunathan K writes: > >> Andreas Schwab writes: >> >>> Jambunathan K writes: >>> >>>> +(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") >>> >>> Why a string? Using the symbol would be more natural. >> >> There is a note up in the thread, which reads: >> >> ,---- >> | 2. Magnus' changes assumes that states are just elisp symbols. This >> | may not be true. In case of locked states - designated as USER in >> | `vc-state' - the state could actually be a string. >> `---- > > There is nothing wrong with using a string where the state is a string. > But if the user name happens to match the name of one of the state > symbols it becomes ambigous. Sure, I will name my next kid `conflict' or even better `missing'. In the latter case, I will have hard time reporting to police if he ever goes missing. Here comes the modified patch. I think I am hitting a bug with defcustom and I will open a separte report for it. When I do, M-x customize-variable RET vc-hide-these-states RET, I see two "up-to-date"s and "added" goes missing. I will let you folks handle the defcustom issue. ,---- | Operate on all settings in this buffer: | Revert... Apply Apply and Save | | Hide Vc Dir Hide These States: Value Menu Choices: | [X] VC State: up-to-date | [ ] VC State: conflict | [ ] VC State: edited | [ ] VC State: ignored | [ ] VC State: missing | [ ] VC State: needs-merge | [ ] VC State: needs-update | [ ] VC State: removed | [ ] VC State: unlocked-changes | [ ] VC State: unregistered | [ ] VC State: up-to-date | State : STANDARD. | States hidden by `vc-dir-hide-some-states'. | Groups: Vc `---- --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=bug#12159-vc-dir-hide-some-states.patch Content-Description: bug#12159.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 10:47:23 +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" + (symbol :tag "VC State" added) + (symbol :tag "VC State" conflict) + (symbol :tag "VC State" edited) + (symbol :tag "VC State" ignored) + (symbol :tag "VC State" missing) + (symbol :tag "VC State" needs-merge) + (symbol :tag "VC State" needs-update) + (symbol :tag "VC State" removed) + (symbol :tag "VC State" unlocked-changes) + (symbol :tag "VC State" unregistered) + (symbol :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,43 @@ (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'). + +If STATES is nil, use `vc-dir-hide-these-states' as default. + +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) + ;; Command is prefixed 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 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 @@ -1129,9 +1171,14 @@ ;; 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)) + (member (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." --=-=-= Content-Type: text/plain > Andreas. --=-=-=--