Mercurial > emacs
comparison lisp/vc-dispatcher.el @ 94647:d0547efd97db
More policy-mechanism separation.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Mon, 05 May 2008 22:33:44 +0000 |
parents | cb8291c75f39 |
children | 276c5ce56449 |
comparison
equal
deleted
inserted
replaced
94646:2234170de09e | 94647:d0547efd97db |
---|---|
1600 (funcall (vc-client-object->updater client-object))) | 1600 (funcall (vc-client-object->updater client-object))) |
1601 (run-hooks 'vc-dir-mode-hook)) | 1601 (run-hooks 'vc-dir-mode-hook)) |
1602 | 1602 |
1603 (put 'vc-dir-mode 'mode-class 'special) | 1603 (put 'vc-dir-mode 'mode-class 'special) |
1604 | 1604 |
1605 (defun vc-dispatcher-browsing () | |
1606 "Are we in a directory browser buffer?" | |
1607 (or vc-dired-mode (eq major-mode 'vc-dir-mode))) | |
1608 | |
1609 (defun vc-dispatcher-selection-set (eligible | |
1610 &optional | |
1611 allow-directory-wildcard | |
1612 allow-inegible | |
1613 include-files-not-directories) | |
1614 "Deduce a set of files to which to apply an operation. Return the fileset. | |
1615 If we're in VC-dired mode, the fileset is the list of marked files. | |
1616 Otherwise, if we're looking at a buffer for which ELIGIBLE returns non-NIL, | |
1617 the fileset is a singleton containing this file. | |
1618 If neither of these things is true, but ALLOW-DIRECTORY-WILDCARD is on | |
1619 and we're in a dired buffer, select the current directory. | |
1620 If none of these conditions is met, but ALLOW-INELIGIBLE is on and the | |
1621 visited file is not registered, return a singleton fileset containing it. | |
1622 If INCLUDE-FILES-NOT-DIRECTORIES then if directories are marked, | |
1623 return the list of VC files in those directories instead of | |
1624 the directories themselves. | |
1625 Otherwise, throw an error." | |
1626 (cond | |
1627 ;; Browsing with dired | |
1628 (vc-dired-mode | |
1629 (let ((marked (dired-map-over-marks (dired-get-filename) nil))) | |
1630 (if marked | |
1631 marked | |
1632 (error "No files have been selected.")))) | |
1633 ;; Browsing with vc-dir | |
1634 ((eq major-mode 'vc-dir-mode) | |
1635 (or | |
1636 (if include-files-not-directories | |
1637 (vc-dir-marked-only-files) | |
1638 (vc-dir-marked-files)) | |
1639 (list (vc-dir-current-file)))) | |
1640 ;; Visiting an eligible file | |
1641 ((funcall eligible buffer-file-name) | |
1642 (list buffer-file-name)) | |
1643 ;; No eligible file -- if there's a parent buffer, deuce from there | |
1644 ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) | |
1645 (with-current-buffer vc-parent-buffer | |
1646 (vc-dispatcher-browsing)))) | |
1647 (progn | |
1648 (set-buffer vc-parent-buffer) | |
1649 (vc-dispatcher-selection-set))) | |
1650 ;; No parent buffer, we may want to select entire directory | |
1651 ;; | |
1652 ;; This is guarded by an enabling arg so users won't potentially | |
1653 ;; shoot themselves in the foot by modifying a fileset they can't | |
1654 ;; verify by eyeball. Allow it for nondestructive commands like | |
1655 ;; making diffs, or possibly for destructive ones that have | |
1656 ;; confirmation prompts. | |
1657 ((and allow-directory-wildcard | |
1658 ;; I think this is a misfeature. For now, I'll leave it in, but | |
1659 ;; I'll disable it anywhere else than in dired buffers. --Stef | |
1660 (and (derived-mode-p 'dired-mode) | |
1661 (equal buffer-file-name nil) | |
1662 (equal list-buffers-directory default-directory))) | |
1663 (progn | |
1664 (message "All eligible files below %s selected." | |
1665 default-directory) | |
1666 (list default-directory))) | |
1667 ;; Last, if we're allowing ineligible files and visiting one, select it. | |
1668 ((and allow-ineligible (not (eligible buffer-file-name))) | |
1669 (list buffer-file-name)) | |
1670 ;; No good set here, throw error | |
1671 (t (error "No fileset is available here.")))) | |
1672 | |
1605 ;; arch-tag: 7d08b17f-5470-4799-914b-bfb9fcf6a246 | 1673 ;; arch-tag: 7d08b17f-5470-4799-914b-bfb9fcf6a246 |
1606 ;;; vc-dispatcher.el ends here | 1674 ;;; vc-dispatcher.el ends here |