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: Sun, 12 Aug 2012 07:20:49 +0530 [thread overview]
Message-ID: <87boigj2ti.fsf@gmail.com> (raw)
In-Reply-To: <jwv1ujd59z5.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 11 Aug 2012 18:40:34 -0400")
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vc-dir-hide-some-states.patch --]
[-- Type: text/x-diff, Size: 5042 bytes --]
=== 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 <kjambunathan@gmail.com>
+
+ * 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 <rgm@gnu.org>
* 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."
next prev parent reply other threads:[~2012-08-12 1:50 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 [this message]
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
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=87boigj2ti.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.