From: Jambunathan K <kjambunathan@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
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 16:34:06 +0530 [thread overview]
Message-ID: <87r4rc5q3d.fsf@gmail.com> (raw)
In-Reply-To: <m2a9y0l967.fsf@igel.home> (Andreas Schwab's message of "Sun, 12 Aug 2012 12:02:56 +0200")
[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]
Andreas Schwab <schwab@linux-m68k.org> writes:
> Jambunathan K <kjambunathan@gmail.com> writes:
>
>> Andreas Schwab <schwab@linux-m68k.org> writes:
>>
>>> Jambunathan K <kjambunathan@gmail.com> 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
`----
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bug#12159.patch --]
[-- Type: text/x-diff, Size: 4895 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 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."
[-- Attachment #3: Type: text/plain, Size: 14 bytes --]
> Andreas.
next prev parent reply other threads:[~2012-08-12 11:04 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 [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r4rc5q3d.fsf@gmail.com \
--to=kjambunathan@gmail.com \
--cc=12159@debbugs.gnu.org \
--cc=schwab@linux-m68k.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).