From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.devel Subject: [PATCH] vc-dir-hide-some-states: New command Date: Wed, 08 Aug 2012 20:26:41 +0530 Message-ID: <87hasdmnyu.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1344437819 17797 80.91.229.3 (8 Aug 2012 14:56:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Aug 2012 14:56:59 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 08 16:56:59 2012 Return-path: Envelope-to: ged-emacs-devel@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 1Sz7gt-0002wl-LU for ged-emacs-devel@m.gmane.org; Wed, 08 Aug 2012 16:56:55 +0200 Original-Received: from localhost ([::1]:51397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz7gs-0003H0-Vr for ged-emacs-devel@m.gmane.org; Wed, 08 Aug 2012 10:56:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz7gq-0003Gb-8s for emacs-devel@gnu.org; Wed, 08 Aug 2012 10:56:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sz7gi-0007UF-IF for emacs-devel@gnu.org; Wed, 08 Aug 2012 10:56:52 -0400 Original-Received: from mail-pb0-f41.google.com ([209.85.160.41]:35765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz7gi-0007Tr-97 for emacs-devel@gnu.org; Wed, 08 Aug 2012 10:56:44 -0400 Original-Received: by pbbjt11 with SMTP id jt11so1765363pbb.0 for ; Wed, 08 Aug 2012 07:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=dByMWPP0lvIFVmCREYlXXSGk2ein7QAb8MsgSziliFM=; b=VKMCZ37BAH+NKpOsGasD2fqmVWAfqZHbcFShrg21k+jrI9bwwjwVyN4R8uvI5M/9ie HX6Xr9vkU5nOdW7KxHjWilWlJkol8CvkBL3M8yQIbt/1cirCrDJINmzzUSv6jeHMg/iO pHUlODrguBn9g/CRlUYQJNs7T5hFOZ9Si9Z9654cblvyHzxVkZsclV+cU0trDp52IiOi OMR1avapEUYqDfarFaw1MPfyWSuERckzsEYfTxmls3AlclHyHa0Ob3DI5NH34SzKgjc3 Rnn8Rbdo8HloqtYDguD0MpUw5XnXsa3g5qrZnPG7PNiYquMo29ittlHLqX4xX1+7I3Ur aW6w== Original-Received: by 10.68.237.103 with SMTP id vb7mr36804966pbc.38.1344437803330; Wed, 08 Aug 2012 07:56:43 -0700 (PDT) Original-Received: from debian-6.05 ([115.242.185.133]) by mx.google.com with ESMTPS id qo8sm6956755pbb.19.2012.08.08.07.56.39 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 08 Aug 2012 07:56:42 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152336 Archived-At: --=-=-= Content-Type: text/plain I am attaching a bzr bundle. Can someone review and commit this? --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=vc-dir-hide-some-states.txt Content-Description: vc-dir-hide-some-states.txt # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kjambunathan@gmail.com-20120808144428-8msbw7xveglogy9b # target_branch: bzr://bzr.savannah.gnu.org/emacs/trunk/ # testament_sha1: 0a43bb0d585f74c15f549d63dc6a08fa44154d2d # timestamp: 2012-08-08 20:17:20 +0530 # source_branch: bzr://bzr.savannah.gnu.org/emacs/trunk # base_revision_id: michael.albinus@gmx.de-20120808134045-\ # t26l1voivvzfypey # # Begin patch === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-08 13:40:45 +0000 +++ lisp/ChangeLog 2012-08-08 14:44:28 +0000 @@ -1,3 +1,11 @@ +2012-08-08 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-vc-states'. + (vc-dir-mode-map): Map "x" to `vc-dir-hide-vc-states' instead of + `vc-dir-hide-up-to-date'. + 2012-08-08 Michael Albinus * net/tramp-sh.el (tramp-find-file-exists-command): Protect the === 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-08 14:44:28 +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,56 @@ (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') specified as a +string. + +If STATES is null, use `vc-dir-hide-these-states'. + +In interactive mode, if you provide a prefix argument or if +`vc-dir-hide-these-states' is nil, you will be queried for a state +to hide." + (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. Prompt + ;; for a state to hide. + (let ((crt (ewoc-nth vc-ewoc -1)) + (first (ewoc-nth vc-ewoc 0)) + displayed-states) + ;; Collect all the states that are on display. + (while (not (eq crt first)) + (let* ((data (ewoc-data crt)) + (dir (vc-dir-fileinfo->directory data)) + (prev (ewoc-prev vc-ewoc crt))) + (when (not dir) + (let ((s (vc-dir-fileinfo->state data))) + (unless (member s displayed-states) + (push (format "%s" s) displayed-states)))) + (setq crt prev))) + ;; Query the user for a state to hide. + (when displayed-states + (list (completing-read "States to hide: " + displayed-states nil t))))))) + + ;; Non-interactive use. + (unless (called-interactively-p 'any) + (setq states (or states vc-dir-hide-these-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 +1183,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." # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWULZDS4ACD1fgFgwU/f//3r/ fwD////wYA2910rPdveG991oPR8iyZTnl7nbevV9989XtGoo7Z9rM5gfcQkoJoAQyZJPBqbVP1MU DQAAAAAEoSaMIGk0TaJpANAAGgAAaGgDEERKbNJPSeE9UZGIAaDAgxGAEYEmpE0ingKmnqeKP1TJ +UT1PU00MTQBo0D1AAIoimTQNBGlP2kyT01R6nkmTT1GgGgAGmagRSJoAJo0CaSbJPKnqfoU9T1P U8oBo0AA0ar4ApkUAqYIKEEQUEVgZ3DdkYdasRhCUSP0hogMEsrG1+zi2ZpIucaBr21NAKSoiZW1 8e7h+B4K5L6i1uTstN57Xf37nopoydxfTerFX+/dbXXgMBcvW1uV0m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