diff options
| author | Dan Nicolaescu | 2008-04-27 19:52:13 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-04-27 19:52:13 +0000 |
| commit | 6e61fbe177d5b08be97cc05935f33b52051a3692 (patch) | |
| tree | fbf1e414ba8390e55fdbbce9918eb5dc33a37d74 | |
| parent | bfeee9d15131df60ef028dda6ca4ab7c29e7d7d2 (diff) | |
| download | emacs-6e61fbe177d5b08be97cc05935f33b52051a3692.tar.gz emacs-6e61fbe177d5b08be97cc05935f33b52051a3692.zip | |
(vc-dir-mode-map): Change bindings for unmark all and revert.
(vc-dir-parent-marked-p, vc-dir-children-marked-p): Implement.
(vc-dir-mark-file): Add an optional argument.
(vc-dir-mark-all-files, vc-dir-unmark-all-files): Deal with directories.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/vc.el | 153 |
2 files changed, 126 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b4ff9088ebb..8df5b4958c7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2008-04-27 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc.el (vc-dir-mode-map): Change bindings for unmark all and revert. | ||
| 4 | (vc-dir-parent-marked-p, vc-dir-children-marked-p): Implement. | ||
| 5 | (vc-dir-mark-file): Add an optional argument. | ||
| 6 | (vc-dir-mark-all-files, vc-dir-unmark-all-files): Deal with directories. | ||
| 7 | |||
| 1 | 2008-04-27 Daiki Ueno <ueno@unixuser.org> | 8 | 2008-04-27 Daiki Ueno <ueno@unixuser.org> |
| 2 | 9 | ||
| 3 | * epa-file.el (auto-encryption-mode): Rename from epa-file-mode. | 10 | * epa-file.el (auto-encryption-mode): Rename from epa-file-mode. |
diff --git a/lisp/vc.el b/lisp/vc.el index 88aedf2df32..451da02435d 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -2933,6 +2933,7 @@ specific headers." | |||
| 2933 | (define-key map "m" 'vc-dir-mark) | 2933 | (define-key map "m" 'vc-dir-mark) |
| 2934 | (define-key map "M" 'vc-dir-mark-all-files) | 2934 | (define-key map "M" 'vc-dir-mark-all-files) |
| 2935 | (define-key map "u" 'vc-dir-unmark) | 2935 | (define-key map "u" 'vc-dir-unmark) |
| 2936 | (define-key map "U" 'vc-dir-unmark-all-files) | ||
| 2936 | (define-key map "\C-?" 'vc-dir-unmark-file-up) | 2937 | (define-key map "\C-?" 'vc-dir-unmark-file-up) |
| 2937 | (define-key map "\M-\C-?" 'vc-dir-unmark-all-files) | 2938 | (define-key map "\M-\C-?" 'vc-dir-unmark-all-files) |
| 2938 | ;; Movement. | 2939 | ;; Movement. |
| @@ -2948,7 +2949,7 @@ specific headers." | |||
| 2948 | 2949 | ||
| 2949 | ;;XXX: Maybe use something else here, so we can use 'U' for unmark | 2950 | ;;XXX: Maybe use something else here, so we can use 'U' for unmark |
| 2950 | ;;all, similar to 'M'.. | 2951 | ;;all, similar to 'M'.. |
| 2951 | (define-key map "U" 'vc-revert) ;; u is taken by unmark. | 2952 | (define-key map "R" 'vc-revert) ;; u is taken by unmark. |
| 2952 | 2953 | ||
| 2953 | ;; Can't be "g" (as in vc map), so "A" for "Annotate". | 2954 | ;; Can't be "g" (as in vc map), so "A" for "Annotate". |
| 2954 | (define-key map "A" 'vc-annotate) | 2955 | (define-key map "A" 'vc-annotate) |
| @@ -3301,23 +3302,74 @@ If a prefix argument is given, move by that many lines." | |||
| 3301 | (funcall mark-unmark-function))) | 3302 | (funcall mark-unmark-function))) |
| 3302 | 3303 | ||
| 3303 | (defun vc-dir-parent-marked-p (arg) | 3304 | (defun vc-dir-parent-marked-p (arg) |
| 3304 | ;; Return t if any of the children of arg is marked. | 3305 | (when vc-dir-insert-directories |
| 3305 | nil) | 3306 | ;; Return nil if none of the parent directories of arg is marked. |
| 3307 | (let* ((argdata (ewoc-data arg)) | ||
| 3308 | (argdir | ||
| 3309 | (let ((crtdir (vc-dir-fileinfo->directory argdata))) | ||
| 3310 | (if crtdir | ||
| 3311 | crtdir | ||
| 3312 | (file-name-directory (expand-file-name | ||
| 3313 | (vc-dir-fileinfo->name argdata)))))) | ||
| 3314 | (arglen (length argdir)) | ||
| 3315 | (crt arg) | ||
| 3316 | data dir) | ||
| 3317 | ;; Go through the predecessors, checking if any directory that is | ||
| 3318 | ;; a parent is marked. | ||
| 3319 | (while (setq crt (ewoc-prev vc-ewoc crt)) | ||
| 3320 | (setq data (ewoc-data crt)) | ||
| 3321 | (setq dir | ||
| 3322 | (let ((crtdir (vc-dir-fileinfo->directory data))) | ||
| 3323 | (if crtdir | ||
| 3324 | crtdir | ||
| 3325 | (file-name-directory (expand-file-name | ||
| 3326 | (vc-dir-fileinfo->name data)))))) | ||
| 3327 | |||
| 3328 | (when (and (vc-dir-fileinfo->directory data) | ||
| 3329 | (string-equal (substring argdir 0 (length dir)) dir)) | ||
| 3330 | (when (vc-dir-fileinfo->marked data) | ||
| 3331 | (error "Cannot mark `%s', parent directory `%s' marked" | ||
| 3332 | (vc-dir-fileinfo->name argdata) | ||
| 3333 | (vc-dir-fileinfo->name data))))) | ||
| 3334 | nil))) | ||
| 3306 | 3335 | ||
| 3307 | (defun vc-dir-children-marked-p (arg) | 3336 | (defun vc-dir-children-marked-p (arg) |
| 3308 | ;; Return t if any of the children of arg is marked. | 3337 | ;; Return nil if none of the children of arg is marked. |
| 3309 | nil) | 3338 | (when vc-dir-insert-directories |
| 3310 | 3339 | (let* ((argdata (ewoc-data arg)) | |
| 3311 | (defun vc-dir-mark-file () | 3340 | (argdir (vc-dir-fileinfo->directory argdata)) |
| 3312 | ;; Mark the current file and move to the next line. | 3341 | (arglen (length argdir)) |
| 3313 | (let* ((crt (ewoc-locate vc-ewoc)) | 3342 | (is-child t) |
| 3343 | (crt arg) | ||
| 3344 | data dir) | ||
| 3345 | (while (and is-child (setq crt (ewoc-next vc-ewoc crt))) | ||
| 3346 | (setq data (ewoc-data crt)) | ||
| 3347 | (setq dir | ||
| 3348 | (let ((crtdir (vc-dir-fileinfo->directory data))) | ||
| 3349 | (if crtdir | ||
| 3350 | crtdir | ||
| 3351 | (file-name-directory (expand-file-name | ||
| 3352 | (vc-dir-fileinfo->name data)))))) | ||
| 3353 | (if (string-equal argdir (substring dir 0 arglen)) | ||
| 3354 | (when (vc-dir-fileinfo->marked data) | ||
| 3355 | (error "Cannot mark `%s', child `%s' marked" | ||
| 3356 | (vc-dir-fileinfo->name argdata) | ||
| 3357 | (vc-dir-fileinfo->name data))) | ||
| 3358 | ;; We are done, we got to an entry that is not a child of `arg'. | ||
| 3359 | (setq is-child nil))) | ||
| 3360 | nil))) | ||
| 3361 | |||
| 3362 | (defun vc-dir-mark-file (&optional arg) | ||
| 3363 | ;; Mark ARG or the current file and move to the next line. | ||
| 3364 | (let* ((crt (or arg (ewoc-locate vc-ewoc))) | ||
| 3314 | (file (ewoc-data crt)) | 3365 | (file (ewoc-data crt)) |
| 3315 | (isdir (vc-dir-fileinfo->directory file))) | 3366 | (isdir (vc-dir-fileinfo->directory file))) |
| 3316 | (when (or (and isdir (not (vc-dir-children-marked-p crt))) | 3367 | (when (or (and isdir (not (vc-dir-children-marked-p crt))) |
| 3317 | (and (not isdir) (not (vc-dir-parent-marked-p crt)))) | 3368 | (and (not isdir) (not (vc-dir-parent-marked-p crt)))) |
| 3318 | (setf (vc-dir-fileinfo->marked file) t) | 3369 | (setf (vc-dir-fileinfo->marked file) t) |
| 3319 | (ewoc-invalidate vc-ewoc crt) | 3370 | (ewoc-invalidate vc-ewoc crt) |
| 3320 | (vc-dir-next-line 1)))) | 3371 | (unless arg |
| 3372 | (vc-dir-next-line 1))))) | ||
| 3321 | 3373 | ||
| 3322 | (defun vc-dir-mark () | 3374 | (defun vc-dir-mark () |
| 3323 | "Mark the current file or all files in the region. | 3375 | "Mark the current file or all files in the region. |
| @@ -3332,27 +3384,50 @@ line." | |||
| 3332 | (defun vc-dir-mark-all-files (arg) | 3384 | (defun vc-dir-mark-all-files (arg) |
| 3333 | "Mark all files with the same state as the current one. | 3385 | "Mark all files with the same state as the current one. |
| 3334 | With a prefix argument mark all files. | 3386 | With a prefix argument mark all files. |
| 3387 | If the current entry is a directory, mark all child files. | ||
| 3335 | 3388 | ||
| 3336 | The VC commands operate on files that are on the same state. | 3389 | The VC commands operate on files that are on the same state. |
| 3337 | This command is intended to make it easy to select all files that | 3390 | This command is intended to make it easy to select all files that |
| 3338 | share the same state." | 3391 | share the same state." |
| 3339 | (interactive "P") | 3392 | (interactive "P") |
| 3340 | (if arg | 3393 | (if arg |
| 3341 | (ewoc-map | 3394 | ;; Mark all files. |
| 3342 | (lambda (filearg) | 3395 | (progn |
| 3343 | (unless (vc-dir-fileinfo->marked filearg) | 3396 | ;; First check that no directory is marked, we can't mark |
| 3344 | (setf (vc-dir-fileinfo->marked filearg) t) | 3397 | ;; files in that case. |
| 3345 | t)) | 3398 | (ewoc-map |
| 3346 | vc-ewoc) | 3399 | (lambda (filearg) |
| 3347 | (let* ((crt (ewoc-locate vc-ewoc)) | 3400 | (when (and (vc-dir-fileinfo->directory filearg) |
| 3348 | (crt-state (vc-dir-fileinfo->state (ewoc-data crt)))) | 3401 | (vc-dir-fileinfo->directory filearg)) |
| 3349 | (ewoc-map | 3402 | (error "Cannot mark all files, directory `%s' marked" |
| 3350 | (lambda (filearg) | 3403 | (vc-dir-fileinfo->name filearg)))) |
| 3351 | (when (and (not (vc-dir-fileinfo->marked filearg)) | 3404 | vc-ewoc) |
| 3352 | (eq (vc-dir-fileinfo->state filearg) crt-state)) | 3405 | (ewoc-map |
| 3353 | (setf (vc-dir-fileinfo->marked filearg) t) | 3406 | (lambda (filearg) |
| 3354 | t)) | 3407 | (unless (vc-dir-fileinfo->marked filearg) |
| 3355 | vc-ewoc)))) | 3408 | (setf (vc-dir-fileinfo->marked filearg) t) |
| 3409 | t)) | ||
| 3410 | vc-ewoc)) | ||
| 3411 | (let ((data (ewoc-data (ewoc-locate vc-ewoc)))) | ||
| 3412 | (if (vc-dir-fileinfo->directory data) | ||
| 3413 | ;; It's a directory, mark child files. | ||
| 3414 | (let ((crt (ewoc-locate vc-ewoc))) | ||
| 3415 | (unless (vc-dir-children-marked-p crt) | ||
| 3416 | (while (setq crt (ewoc-next vc-ewoc crt)) | ||
| 3417 | (let ((crt-data (ewoc-data crt))) | ||
| 3418 | (unless (vc-dir-fileinfo->directory crt-data) | ||
| 3419 | (setf (vc-dir-fileinfo->marked crt-data) t) | ||
| 3420 | (ewoc-invalidate vc-ewoc crt)))))) | ||
| 3421 | ;; It's a file | ||
| 3422 | (let ((state (vc-dir-fileinfo->state data)) | ||
| 3423 | (crt (ewoc-nth vc-ewoc 0))) | ||
| 3424 | (while crt | ||
| 3425 | (let ((crt-data (ewoc-data crt))) | ||
| 3426 | (when (and (not (vc-dir-fileinfo->marked crt-data)) | ||
| 3427 | (eq (vc-dir-fileinfo->state crt-data) state) | ||
| 3428 | (not (vc-dir-fileinfo->directory crt-data))) | ||
| 3429 | (vc-dir-mark-file crt))) | ||
| 3430 | (setq crt (ewoc-next vc-ewoc crt)))))))) | ||
| 3356 | 3431 | ||
| 3357 | (defun vc-dir-unmark-file () | 3432 | (defun vc-dir-unmark-file () |
| 3358 | ;; Unmark the current file and move to the next line. | 3433 | ;; Unmark the current file and move to the next line. |
| @@ -3384,7 +3459,8 @@ line." | |||
| 3384 | 3459 | ||
| 3385 | (defun vc-dir-unmark-all-files (arg) | 3460 | (defun vc-dir-unmark-all-files (arg) |
| 3386 | "Unmark all files with the same state as the current one. | 3461 | "Unmark all files with the same state as the current one. |
| 3387 | With a prefix argument mark all files. | 3462 | With a prefix argument unmark all files. |
| 3463 | If the current entry is a directory, unmark all the child files. | ||
| 3388 | 3464 | ||
| 3389 | The VC commands operate on files that are on the same state. | 3465 | The VC commands operate on files that are on the same state. |
| 3390 | This command is intended to make it easy to deselect all files | 3466 | This command is intended to make it easy to deselect all files |
| @@ -3398,14 +3474,23 @@ that share the same state." | |||
| 3398 | t)) | 3474 | t)) |
| 3399 | vc-ewoc) | 3475 | vc-ewoc) |
| 3400 | (let* ((crt (ewoc-locate vc-ewoc)) | 3476 | (let* ((crt (ewoc-locate vc-ewoc)) |
| 3401 | (crt-state (vc-dir-fileinfo->state (ewoc-data crt)))) | 3477 | (data (ewoc-data crt))) |
| 3402 | (ewoc-map | 3478 | (if (vc-dir-fileinfo->directory data) |
| 3403 | (lambda (filearg) | 3479 | ;; It's a directory, unmark child files. |
| 3404 | (when (and (vc-dir-fileinfo->marked filearg) | 3480 | (while (setq crt (ewoc-next vc-ewoc crt)) |
| 3405 | (eq (vc-dir-fileinfo->state filearg) crt-state)) | 3481 | (let ((crt-data (ewoc-data crt))) |
| 3406 | (setf (vc-dir-fileinfo->marked filearg) nil) | 3482 | (unless (vc-dir-fileinfo->directory crt-data) |
| 3407 | t)) | 3483 | (setf (vc-dir-fileinfo->marked crt-data) nil) |
| 3408 | vc-ewoc)))) | 3484 | (ewoc-invalidate vc-ewoc crt)))) |
| 3485 | ;; It's a file | ||
| 3486 | (let ((crt-state (vc-dir-fileinfo->state (ewoc-data crt)))) | ||
| 3487 | (ewoc-map | ||
| 3488 | (lambda (filearg) | ||
| 3489 | (when (and (vc-dir-fileinfo->marked filearg) | ||
| 3490 | (eq (vc-dir-fileinfo->state filearg) crt-state)) | ||
| 3491 | (setf (vc-dir-fileinfo->marked filearg) nil) | ||
| 3492 | t)) | ||
| 3493 | vc-ewoc)))))) | ||
| 3409 | 3494 | ||
| 3410 | (defun vc-dir-toggle-mark-file () | 3495 | (defun vc-dir-toggle-mark-file () |
| 3411 | (let* ((crt (ewoc-locate vc-ewoc)) | 3496 | (let* ((crt (ewoc-locate vc-ewoc)) |