all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 12159@debbugs.gnu.org
Subject: bug#12159: 24.1.50; vc-dir: Need a way to hide unregistered files
Date: Mon, 13 Aug 2012 23:16:23 +0530	[thread overview]
Message-ID: <87pq6ur8gg.fsf@gmail.com> (raw)
In-Reply-To: <jwvvcgo42xk.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 12 Aug 2012 10:13:05 -0400")

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]


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 :-).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: approach-1.patch --]
[-- Type: text/x-diff, Size: 3968 bytes --]

=== 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  <kjambunathan@gmail.com>
+
+	* 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  <monnier@iro.umontreal.ca>
 
 	* 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."


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: approach-2.patch --]
[-- Type: text/x-diff, Size: 2721 bytes --]

=== 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  <kjambunathan@gmail.com>
+
+	* 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  <monnier@iro.umontreal.ca>
 
 	* 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."


[-- Attachment #4: Type: text/plain, Size: 782 bytes --]


>> +	* 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

  parent reply	other threads:[~2012-08-13 17:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-08 18:07 bug#12159: 24.1.50; vc-dir: Need a way to hide unregistered files Jambunathan K
2012-08-08 18:27 ` Glenn Morris
2012-08-08 18:52   ` Jambunathan K
2012-08-09  1:54     ` Stefan Monnier
2012-08-11 17:41       ` Jambunathan K
2012-08-11 22:40         ` Stefan Monnier
2012-08-12  1:50           ` Jambunathan K
2012-08-12  7:37             ` Andreas Schwab
2012-08-12  9:58               ` Jambunathan K
2012-08-12 10:02                 ` Andreas Schwab
2012-08-12 11:04                   ` Jambunathan K
2012-08-12 14:07                     ` Andreas Schwab
2012-08-12 14:13             ` Stefan Monnier
2012-08-12 14:22               ` Jambunathan K
2012-08-12 19:11               ` Jambunathan K
2012-08-12 19:20                 ` Eli Zaretskii
2012-08-12 19:40                   ` Jambunathan K
2012-08-13 14:21                     ` Bastien
2012-08-12 22:35                 ` Stefan Monnier
2012-08-13 17:46               ` Jambunathan K [this message]
2012-08-13 21:34                 ` Stefan Monnier
2012-08-13 22:09                   ` Bastien
2012-08-14  4:28   ` Jambunathan K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pq6ur8gg.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=12159@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.