2012-04-25 23:18:47 -04:00
|
|
|
|
;;; vc-dir.el --- Directory status display under VC -*- lexical-binding: t -*-
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
|
;; Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2019-05-26 00:58:28 -07:00
|
|
|
|
;; Author: Dan Nicolaescu <dann@ics.uci.edu>
|
* lisp/finder.el (finder-known-keywords): Add keyword "vc"
for version control.
* add-log.el, cvs-status.el, diff.el, diff-mode.el, ediff.el,
* emerge.el, log-edit.el, log-view.el, pcvs.el, smerge-mode.el,
* vc-annotate.el, vc-bzr.el, vc-dir.el, vc-dispatcher.el, vc-git.el,
* vc-hg.el, vc-mtn.el, vc.el: Add keyword "vc".
2010-06-11 22:09:57 +03:00
|
|
|
|
;; Keywords: vc tools
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Package: vc
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
;;; Credits:
|
|
|
|
|
|
|
|
|
|
;; The original VC directory status implementation was based on dired.
|
|
|
|
|
;; This implementation was inspired by PCL-CVS.
|
|
|
|
|
;; Many people contributed comments, ideas and code to this
|
|
|
|
|
;; implementation. These include:
|
2008-06-27 23:29:15 +00:00
|
|
|
|
;;
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Alexandre Julliard <julliard@winehq.org>
|
|
|
|
|
;; Stefan Monnier <monnier@iro.umontreal.ca>
|
|
|
|
|
;; Tom Tromey <tromey@redhat.com>
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
2008-06-27 23:29:15 +00:00
|
|
|
|
;;
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
;;; Todo: see vc.el.
|
|
|
|
|
|
|
|
|
|
(require 'vc-hooks)
|
|
|
|
|
(require 'vc)
|
2008-06-26 05:16:49 +00:00
|
|
|
|
(require 'tool-bar)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(require 'ewoc)
|
2019-07-14 14:25:44 +02:00
|
|
|
|
(require 'seq)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
|
|
|
|
(eval-when-compile (require 'cl-lib))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2019-06-16 15:07:37 +02:00
|
|
|
|
(declare-function fileloop-continue "fileloop")
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defcustom vc-dir-mode-hook nil
|
|
|
|
|
"Normal hook run by `vc-dir-mode'.
|
|
|
|
|
See `run-hooks'."
|
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'vc)
|
|
|
|
|
|
|
|
|
|
;; Used to store information for the files displayed in the directory buffer.
|
|
|
|
|
;; Each item displayed corresponds to one of these defstructs.
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
|
|
|
|
(cl-defstruct (vc-dir-fileinfo
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(:copier nil)
|
|
|
|
|
(:type list) ;So we can use `member' on lists of FIs.
|
|
|
|
|
(:constructor
|
|
|
|
|
;; We could define it as an alias for `list'.
|
|
|
|
|
vc-dir-create-fileinfo (name state &optional extra marked directory))
|
|
|
|
|
(:conc-name vc-dir-fileinfo->))
|
|
|
|
|
name ;Keep it as first, for `member'.
|
|
|
|
|
state
|
2008-06-24 03:45:06 +00:00
|
|
|
|
;; For storing backend specific information.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
extra
|
|
|
|
|
marked
|
|
|
|
|
;; To keep track of not updated files during a global refresh
|
|
|
|
|
needs-update
|
|
|
|
|
;; To distinguish files and directories.
|
|
|
|
|
directory)
|
|
|
|
|
|
|
|
|
|
(defvar vc-ewoc nil)
|
2008-06-24 03:45:06 +00:00
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defvar vc-dir-process-buffer nil
|
|
|
|
|
"The buffer used for the asynchronous call that computes status.")
|
|
|
|
|
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(defvar vc-dir-backend nil
|
|
|
|
|
"The backend used by the current *vc-dir* buffer.")
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defun vc-dir-move-to-goal-column ()
|
|
|
|
|
;; Used to keep the cursor on the file name column.
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(unless (eolp)
|
2008-10-27 07:21:43 +00:00
|
|
|
|
;; Must be in sync with vc-default-dir-printer.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(forward-char 25)))
|
|
|
|
|
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(defun vc-dir-prepare-status-buffer (bname dir backend &optional create-new)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
"Find a buffer named BNAME showing DIR, or create a new one."
|
2008-08-23 16:57:13 +00:00
|
|
|
|
(setq dir (file-name-as-directory (expand-file-name dir)))
|
2009-09-29 13:07:50 +00:00
|
|
|
|
(let* ;; Look for another buffer name BNAME visiting the same directory.
|
|
|
|
|
((buf (save-excursion
|
|
|
|
|
(unless create-new
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
|
|
|
|
(cl-dolist (buffer vc-dir-buffers)
|
2009-09-29 13:07:50 +00:00
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(set-buffer buffer)
|
|
|
|
|
(when (and (derived-mode-p 'vc-dir-mode)
|
|
|
|
|
(eq vc-dir-backend backend)
|
|
|
|
|
(string= default-directory dir))
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
|
|
|
|
(cl-return buffer))))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(or buf
|
|
|
|
|
;; Create a new buffer named BNAME.
|
2010-01-07 23:46:44 +01:00
|
|
|
|
;; We pass a filename to create-file-buffer because it is what
|
|
|
|
|
;; the function expects, and also what uniquify needs (if active)
|
|
|
|
|
(with-current-buffer (create-file-buffer (expand-file-name bname dir))
|
2011-03-15 13:39:56 -04:00
|
|
|
|
(setq default-directory dir)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(vc-setup-buffer (current-buffer))
|
|
|
|
|
;; Reset the vc-parent-buffer-name so that it does not appear
|
|
|
|
|
;; in the mode-line.
|
|
|
|
|
(setq vc-parent-buffer-name nil)
|
|
|
|
|
(current-buffer)))))
|
|
|
|
|
|
|
|
|
|
(defvar vc-dir-menu-map
|
2015-05-12 20:42:42 -04:00
|
|
|
|
(let ((map (make-sparse-keymap "VC-Dir")))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(define-key map [quit]
|
|
|
|
|
'(menu-item "Quit" quit-window
|
|
|
|
|
:help "Quit"))
|
|
|
|
|
(define-key map [kill]
|
|
|
|
|
'(menu-item "Kill Update Command" vc-dir-kill-dir-status-process
|
|
|
|
|
:enable (vc-dir-busy)
|
|
|
|
|
:help "Kill the command that updates the directory buffer"))
|
|
|
|
|
(define-key map [refresh]
|
2008-06-24 03:45:06 +00:00
|
|
|
|
'(menu-item "Refresh" revert-buffer
|
2008-06-22 19:04:22 +00:00
|
|
|
|
:enable (not (vc-dir-busy))
|
|
|
|
|
:help "Refresh the contents of the directory buffer"))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(define-key map [remup]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Hide Up-to-date" vc-dir-hide-up-to-date
|
2008-06-24 03:45:06 +00:00
|
|
|
|
:help "Hide up-to-date items from display"))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Movement.
|
|
|
|
|
(define-key map [sepmv] '("--"))
|
|
|
|
|
(define-key map [next-line]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Next Line" vc-dir-next-line
|
2008-06-22 19:04:22 +00:00
|
|
|
|
:help "Go to the next line" :keys "n"))
|
|
|
|
|
(define-key map [previous-line]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Previous Line" vc-dir-previous-line
|
2008-06-22 19:04:22 +00:00
|
|
|
|
:help "Go to the previous line"))
|
|
|
|
|
;; Marking.
|
|
|
|
|
(define-key map [sepmrk] '("--"))
|
|
|
|
|
(define-key map [unmark-all]
|
|
|
|
|
'(menu-item "Unmark All" vc-dir-unmark-all-files
|
|
|
|
|
:help "Unmark all files that are in the same state as the current file\
|
|
|
|
|
\nWith prefix argument unmark all files"))
|
|
|
|
|
(define-key map [unmark-previous]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Unmark Previous " vc-dir-unmark-file-up
|
2008-06-22 19:04:22 +00:00
|
|
|
|
:help "Move to the previous line and unmark the file"))
|
|
|
|
|
|
|
|
|
|
(define-key map [mark-all]
|
|
|
|
|
'(menu-item "Mark All" vc-dir-mark-all-files
|
|
|
|
|
:help "Mark all files that are in the same state as the current file\
|
|
|
|
|
\nWith prefix argument mark all files"))
|
|
|
|
|
(define-key map [unmark]
|
|
|
|
|
'(menu-item "Unmark" vc-dir-unmark
|
|
|
|
|
:help "Unmark the current file or all files in the region"))
|
|
|
|
|
|
|
|
|
|
(define-key map [mark]
|
|
|
|
|
'(menu-item "Mark" vc-dir-mark
|
|
|
|
|
:help "Mark the current file or all files in the region"))
|
|
|
|
|
|
|
|
|
|
(define-key map [sepopn] '("--"))
|
2008-07-04 00:34:02 +00:00
|
|
|
|
(define-key map [qr]
|
2008-07-24 02:39:04 +00:00
|
|
|
|
'(menu-item "Query Replace in Files..." vc-dir-query-replace-regexp
|
2008-07-04 00:34:02 +00:00
|
|
|
|
:help "Replace a string in the marked files"))
|
2008-07-24 01:57:24 +00:00
|
|
|
|
(define-key map [se]
|
2008-07-24 02:39:04 +00:00
|
|
|
|
'(menu-item "Search Files..." vc-dir-search
|
2008-07-24 01:57:24 +00:00
|
|
|
|
:help "Search a regexp in the marked files"))
|
2008-07-24 02:39:04 +00:00
|
|
|
|
(define-key map [ires]
|
|
|
|
|
'(menu-item "Isearch Regexp Files..." vc-dir-isearch-regexp
|
|
|
|
|
:help "Incremental search a regexp in the marked files"))
|
|
|
|
|
(define-key map [ise]
|
|
|
|
|
'(menu-item "Isearch Files..." vc-dir-isearch
|
|
|
|
|
:help "Incremental search a string in the marked files"))
|
2014-12-29 02:47:05 +02:00
|
|
|
|
(define-key map [display]
|
|
|
|
|
'(menu-item "Display in Other Window" vc-dir-display-file
|
|
|
|
|
:help "Display the file on the current line, in another window"))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(define-key map [open-other]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Open in Other Window" vc-dir-find-file-other-window
|
2008-06-22 19:04:22 +00:00
|
|
|
|
:help "Find the file on the current line, in another window"))
|
|
|
|
|
(define-key map [open]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Open File" vc-dir-find-file
|
2008-06-22 19:04:22 +00:00
|
|
|
|
:help "Find the file on the current line"))
|
2019-07-13 06:10:29 +02:00
|
|
|
|
(define-key map [delete]
|
2019-07-14 14:25:44 +02:00
|
|
|
|
'(menu-item "Delete" vc-dir-clean-files
|
|
|
|
|
:help "Delete the unregistered marked files"))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(define-key map [sepvcdet] '("--"))
|
|
|
|
|
;; FIXME: This needs a key binding. And maybe a better name
|
|
|
|
|
;; ("Insert" like PCL-CVS uses does not sound that great either)...
|
|
|
|
|
(define-key map [ins]
|
|
|
|
|
'(menu-item "Show File" vc-dir-show-fileentry
|
|
|
|
|
:help "Show a file in the VC status listing even though it might be up to date"))
|
|
|
|
|
(define-key map [annotate]
|
|
|
|
|
'(menu-item "Annotate" vc-annotate
|
|
|
|
|
:help "Display the edit history of the current file using colors"))
|
|
|
|
|
(define-key map [diff]
|
|
|
|
|
'(menu-item "Compare with Base Version" vc-diff
|
|
|
|
|
:help "Compare file set with the base version"))
|
2010-06-03 16:08:26 -07:00
|
|
|
|
(define-key map [logo]
|
|
|
|
|
'(menu-item "Show Outgoing Log" vc-log-outgoing
|
|
|
|
|
:help "Show a log of changes that will be sent with a push operation"))
|
|
|
|
|
(define-key map [logi]
|
|
|
|
|
'(menu-item "Show Incoming Log" vc-log-incoming
|
|
|
|
|
:help "Show a log of changes that will be received with a pull operation"))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(define-key map [log]
|
2011-01-08 23:13:47 -05:00
|
|
|
|
'(menu-item "Show History" vc-print-log
|
2010-06-03 16:08:26 -07:00
|
|
|
|
:help "List the change log of the current file set in a window"))
|
|
|
|
|
(define-key map [rlog]
|
|
|
|
|
'(menu-item "Show Top of the Tree History " vc-print-root-log
|
|
|
|
|
:help "List the change log for the current tree in a window"))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
;; VC commands.
|
|
|
|
|
(define-key map [sepvccmd] '("--"))
|
2015-05-12 20:42:42 -04:00
|
|
|
|
(define-key map [push]
|
|
|
|
|
'(menu-item "Push Changes" vc-push
|
|
|
|
|
:enable (vc-find-backend-function vc-dir-backend 'push)
|
|
|
|
|
:help "Push the current branch's changes"))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(define-key map [update]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Update to Latest Version" vc-update
|
2008-06-24 03:45:06 +00:00
|
|
|
|
:help "Update the current fileset's files to their tip revisions"))
|
|
|
|
|
(define-key map [revert]
|
2011-09-18 23:43:20 +03:00
|
|
|
|
'(menu-item "Revert to Base Version" vc-revert
|
2008-06-24 03:45:06 +00:00
|
|
|
|
:help "Revert working copies of the selected fileset to their repository contents."))
|
|
|
|
|
(define-key map [next-action]
|
|
|
|
|
;; FIXME: This really really really needs a better name!
|
|
|
|
|
;; And a key binding too.
|
|
|
|
|
'(menu-item "Check In/Out" vc-next-action
|
|
|
|
|
:help "Do the next logical version control operation on the current fileset"))
|
|
|
|
|
(define-key map [register]
|
|
|
|
|
'(menu-item "Register" vc-register
|
|
|
|
|
:help "Register file set into the version control system"))
|
2013-08-04 10:55:45 +08:00
|
|
|
|
(define-key map [ignore]
|
|
|
|
|
'(menu-item "Ignore Current File" vc-dir-ignore
|
|
|
|
|
:help "Ignore the current file under current version control system"))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
map)
|
2009-01-29 12:34:08 +00:00
|
|
|
|
"Menu for VC dir.")
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2008-06-24 03:45:06 +00:00
|
|
|
|
;; VC backends can use this to add mode-specific menu items to
|
|
|
|
|
;; vc-dir-menu-map.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defun vc-dir-menu-map-filter (orig-binding)
|
|
|
|
|
(when (and (symbolp orig-binding) (fboundp orig-binding))
|
|
|
|
|
(setq orig-binding (indirect-function orig-binding)))
|
|
|
|
|
(let ((ext-binding
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(when (derived-mode-p 'vc-dir-mode)
|
|
|
|
|
(vc-call-backend vc-dir-backend 'extra-status-menu))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(if (null ext-binding)
|
|
|
|
|
orig-binding
|
|
|
|
|
(append orig-binding
|
|
|
|
|
'("----")
|
|
|
|
|
ext-binding))))
|
|
|
|
|
|
|
|
|
|
(defvar vc-dir-mode-map
|
2008-07-04 00:34:02 +00:00
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
;; VC commands
|
|
|
|
|
(define-key map "v" 'vc-next-action) ;; C-x v v
|
|
|
|
|
(define-key map "=" 'vc-diff) ;; C-x v =
|
2013-07-27 08:09:51 +08:00
|
|
|
|
(define-key map "D" 'vc-root-diff) ;; C-x v D
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(define-key map "i" 'vc-register) ;; C-x v i
|
|
|
|
|
(define-key map "+" 'vc-update) ;; C-x v +
|
2015-05-12 20:42:42 -04:00
|
|
|
|
;; I'd prefer some kind of symmetry with vc-update:
|
|
|
|
|
(define-key map "P" 'vc-push) ;; C-x v P
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(define-key map "l" 'vc-print-log) ;; C-x v l
|
2013-07-26 11:49:59 +02:00
|
|
|
|
(define-key map "L" 'vc-print-root-log) ;; C-x v L
|
2013-09-21 16:16:13 +08:00
|
|
|
|
(define-key map "I" 'vc-log-incoming) ;; C-x v I
|
2017-02-15 05:12:18 -07:00
|
|
|
|
(define-key map "O" 'vc-log-outgoing) ;; C-x v O
|
2008-06-24 03:45:06 +00:00
|
|
|
|
;; More confusing than helpful, probably
|
2008-08-01 18:05:37 +00:00
|
|
|
|
;;(define-key map "R" 'vc-revert) ;; u is taken by vc-dir-unmark.
|
|
|
|
|
;;(define-key map "A" 'vc-annotate) ;; g is taken by revert-buffer
|
|
|
|
|
;; bound by `special-mode'.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Marking.
|
|
|
|
|
(define-key map "m" 'vc-dir-mark)
|
2019-07-14 14:25:44 +02:00
|
|
|
|
(define-key map "d" 'vc-dir-clean-files)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(define-key map "M" 'vc-dir-mark-all-files)
|
|
|
|
|
(define-key map "u" 'vc-dir-unmark)
|
|
|
|
|
(define-key map "U" 'vc-dir-unmark-all-files)
|
|
|
|
|
(define-key map "\C-?" 'vc-dir-unmark-file-up)
|
|
|
|
|
(define-key map "\M-\C-?" 'vc-dir-unmark-all-files)
|
|
|
|
|
;; Movement.
|
|
|
|
|
(define-key map "n" 'vc-dir-next-line)
|
|
|
|
|
(define-key map " " 'vc-dir-next-line)
|
|
|
|
|
(define-key map "\t" 'vc-dir-next-directory)
|
|
|
|
|
(define-key map "p" 'vc-dir-previous-line)
|
2015-11-12 22:54:01 +02:00
|
|
|
|
(define-key map [?\S-\ ] 'vc-dir-previous-line)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(define-key map [backtab] 'vc-dir-previous-directory)
|
|
|
|
|
;;; Rebind paragraph-movement commands.
|
|
|
|
|
(define-key map "\M-}" 'vc-dir-next-directory)
|
|
|
|
|
(define-key map "\M-{" 'vc-dir-previous-directory)
|
|
|
|
|
(define-key map [C-down] 'vc-dir-next-directory)
|
|
|
|
|
(define-key map [C-up] 'vc-dir-previous-directory)
|
|
|
|
|
;; The remainder.
|
|
|
|
|
(define-key map "f" 'vc-dir-find-file)
|
2011-03-02 23:33:35 -08:00
|
|
|
|
(define-key map "e" 'vc-dir-find-file) ; dired-mode compatibility
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(define-key map "\C-m" 'vc-dir-find-file)
|
|
|
|
|
(define-key map "o" 'vc-dir-find-file-other-window)
|
2014-12-29 02:47:05 +02:00
|
|
|
|
(define-key map "\C-o" 'vc-dir-display-file)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process)
|
|
|
|
|
(define-key map [down-mouse-3] 'vc-dir-menu)
|
|
|
|
|
(define-key map [mouse-2] 'vc-dir-toggle-mark)
|
2008-10-25 18:28:42 +00:00
|
|
|
|
(define-key map [follow-link] 'mouse-face)
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(define-key map "x" 'vc-dir-hide-up-to-date)
|
2010-04-12 15:14:16 -04:00
|
|
|
|
(define-key map [?\C-k] 'vc-dir-kill-line)
|
2008-07-24 01:57:24 +00:00
|
|
|
|
(define-key map "S" 'vc-dir-search) ;; FIXME: Maybe use A like dired?
|
2008-07-04 00:34:02 +00:00
|
|
|
|
(define-key map "Q" 'vc-dir-query-replace-regexp)
|
2008-07-24 02:39:04 +00:00
|
|
|
|
(define-key map (kbd "M-s a C-s") 'vc-dir-isearch)
|
|
|
|
|
(define-key map (kbd "M-s a M-C-s") 'vc-dir-isearch-regexp)
|
2013-07-30 22:29:14 +08:00
|
|
|
|
(define-key map "G" 'vc-dir-ignore)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2017-02-15 05:19:50 -07:00
|
|
|
|
(let ((branch-map (make-sparse-keymap)))
|
|
|
|
|
(define-key map "B" branch-map)
|
|
|
|
|
(define-key branch-map "c" 'vc-create-tag)
|
|
|
|
|
(define-key branch-map "l" 'vc-print-branch-log)
|
|
|
|
|
(define-key branch-map "s" 'vc-retrieve-tag))
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Hook up the menu.
|
|
|
|
|
(define-key map [menu-bar vc-dir-mode]
|
|
|
|
|
`(menu-item
|
2008-06-24 03:45:06 +00:00
|
|
|
|
;; VC backends can use this to add mode-specific menu items to
|
|
|
|
|
;; vc-dir-menu-map.
|
2015-05-12 20:42:42 -04:00
|
|
|
|
"VC-Dir" ,vc-dir-menu-map :filter vc-dir-menu-map-filter))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
map)
|
|
|
|
|
"Keymap for directory buffer.")
|
|
|
|
|
|
2008-12-18 08:27:37 +00:00
|
|
|
|
(defmacro vc-dir-at-event (event &rest body)
|
2009-01-29 12:34:08 +00:00
|
|
|
|
"Evaluate BODY with point located at event-start of EVENT.
|
|
|
|
|
If BODY uses EVENT, it should be a variable,
|
2008-06-22 19:04:22 +00:00
|
|
|
|
otherwise it will be evaluated twice."
|
2008-12-18 08:27:37 +00:00
|
|
|
|
(let ((posn (make-symbol "vc-dir-at-event-posn")))
|
2008-12-18 03:29:02 +00:00
|
|
|
|
`(save-excursion
|
|
|
|
|
(unless (equal ,event '(tool-bar))
|
|
|
|
|
(let ((,posn (event-start ,event)))
|
|
|
|
|
(set-buffer (window-buffer (posn-window ,posn)))
|
|
|
|
|
(goto-char (posn-point ,posn))))
|
|
|
|
|
,@body)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-menu (e)
|
2008-08-01 18:05:37 +00:00
|
|
|
|
"Popup the VC dir menu."
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(interactive "e")
|
2008-12-18 08:27:37 +00:00
|
|
|
|
(vc-dir-at-event e (popup-menu vc-dir-menu-map e)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defvar vc-dir-tool-bar-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2011-01-08 23:13:47 -05:00
|
|
|
|
(tool-bar-local-item-from-menu 'find-file "new" map nil
|
|
|
|
|
:label "New File" :vert-only t)
|
|
|
|
|
(tool-bar-local-item-from-menu 'menu-find-file-existing "open" map nil
|
|
|
|
|
:label "Open" :vert-only t)
|
|
|
|
|
(tool-bar-local-item-from-menu 'dired "diropen" map nil
|
|
|
|
|
:vert-only t)
|
|
|
|
|
(tool-bar-local-item-from-menu 'quit-window "close" map vc-dir-mode-map
|
|
|
|
|
:vert-only t)
|
|
|
|
|
(tool-bar-local-item-from-menu 'vc-next-action "saveas" map
|
|
|
|
|
vc-dir-mode-map :label "Commit")
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(tool-bar-local-item-from-menu 'vc-print-log "info"
|
2011-01-08 23:13:47 -05:00
|
|
|
|
map vc-dir-mode-map
|
|
|
|
|
:label "Log")
|
|
|
|
|
(define-key-after map [separator-1] menu-bar-separator)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel"
|
Gtk tool bars can be text, icons with text or just icons.
* xsettings.c: Qmonospace_font_name, Qtool_bar_style and
current_tool_bar_style are new.
(store_config_changed_event): Rename from store_font_changed_event.
(XSETTINGS_TOOL_BAR_STYLE): New define.
(SEEN_FONT, SEEN_TB_STYLE): New enum values.
(struct xsettings): Add font and tb_style, set xft stuff inside #ifdef
HAVE_XFT.
(something_changedCB): store_font_changed_event is now
store_config_changed_event
(parse_settings): Rename from parse_xft_settings. Read
non-xft xsettings outside #ifdef HAVE_XFT.
(read_settings): Renamed from read_xft_settings.
(apply_xft_settings): Take current settings as parameter. Do not
call read_(xft)_settings.
(read_and_apply_settings): New function.
(xft_settings_event): Do non-xft stuff out of HAVE_XFT. Call
read_and_apply_settings if there are settings to be read.
(init_xsettings): Renamed from init_xfd_settings.
Call read_and_apply_settings unconditionally.
(xsettings_initialize): Call init_xsettings.
(Ftool_bar_get_system_style): New function.
(syms_of_xsettings): Define Qmonospace_font_name and
Qtool_bar_style. Initialize current_tool_bar_style to nil.
defsubr Stool_bar_get_system_style. Fprovide on
dynamic-setting.
* xsettings.h (Ftool_bar_get_system_style): Declare.
* xdisp.c: Vtool_bar_style, tool_bar_max_label_size,
Qtext, Qboth, Qboth_horiz are new.
(syms_of_xdisp): Intern Qtext, Qboth, Qboth_horiz, DEFVAR
Vtool_bar_style, tool_bar_max_label_size.
* lisp.h: Extern declare Qtext, Qboth, Qboth_horiz.
* keyboard.c: QClabel is new.
(parse_tool_bar_item): Take out QClabel from tool bar items.
Try to construct a label if ther is no QClabel.
(syms_of_keyboard): Intern :label as QClabel.
* dispextern.h (tool_bar_item_idx): TOOL_BAR_ITEM_LABEL is new.
(Vtool_bar_style, tool_bar_max_label_size, DEFAULT_TOOL_BAR_LABEL_SIZE):
New.
* Makefile.in (SOME_MACHINE_LISP): font-setting.el renamed to
dynamic-setting.el.
* gtkutil.c (xg_tool_bar_menu_proxy): Handle label in tool bar item.
(xg_make_tool_item, xg_show_toolbar_item): New function.
(update_frame_tool_bar): Take label from TOOL_BAR_ITEM_LABEL.
Call xg_make_tool_item to make a tool bar item.
Call xg_show_toolbar_item. Use wtoolbar instead of x->toolbar_widget.
* xterm.c (x_draw_image_relief): Take Vtool_bar_button_margin
into account for toolbars.
* vc-dir.el (vc-dir-tool-bar-map): Add :label on some tool bar items.
* tool-bar.el (tool-bar-setup): Add :label on some tool bar items.
* loadup.el: Load dynamic-setting.el if feature dynamic-setting
is present.
* info.el (info-tool-bar-map): Add labels.
* cus-start.el (all): Add tool-bar-style and tool-bar-max-label-size.
* cus-edit.el (custom-commands): Add labels for tool bar.
(custom-buffer-create-internal, Custom-mode): Adjust for
labels in custom-commands.
* dynamic-setting.el: Renamed from font-setting.el.
2010-04-20 20:52:07 +02:00
|
|
|
|
map vc-dir-mode-map
|
2011-01-08 23:13:47 -05:00
|
|
|
|
:label "Stop" :vert-only t)
|
|
|
|
|
(tool-bar-local-item-from-menu 'revert-buffer "refresh"
|
|
|
|
|
map vc-dir-mode-map :vert-only t)
|
|
|
|
|
(define-key-after map [separator-2] menu-bar-separator)
|
|
|
|
|
(tool-bar-local-item-from-menu (lookup-key menu-bar-edit-menu [cut])
|
|
|
|
|
"cut" map nil :vert-only t)
|
|
|
|
|
(tool-bar-local-item-from-menu (lookup-key menu-bar-edit-menu [copy])
|
|
|
|
|
"copy" map nil :vert-only t)
|
|
|
|
|
(tool-bar-local-item-from-menu (lookup-key menu-bar-edit-menu [paste])
|
|
|
|
|
"paste" map nil :vert-only t)
|
|
|
|
|
(define-key-after map [separator-3] menu-bar-separator)
|
|
|
|
|
(tool-bar-local-item-from-menu 'isearch-forward
|
|
|
|
|
"search" map nil
|
|
|
|
|
:label "Search" :vert-only t)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
map))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-node-directory (node)
|
|
|
|
|
;; Compute the directory for NODE.
|
2009-10-04 02:11:57 +00:00
|
|
|
|
;; If it's a directory node, get it from the node.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let ((data (ewoc-data node)))
|
|
|
|
|
(or (vc-dir-fileinfo->directory data)
|
|
|
|
|
;; Otherwise compute it from the file name.
|
|
|
|
|
(file-name-directory
|
2009-08-26 06:45:36 +00:00
|
|
|
|
(directory-file-name
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(vc-dir-fileinfo->name data)))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-update (entries buffer &optional noinsert)
|
|
|
|
|
"Update BUFFER's ewoc from the list of ENTRIES.
|
|
|
|
|
If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
|
|
|
|
|
;; Add ENTRIES to the vc-dir buffer BUFFER.
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
;; Insert the entries sorted by name into the ewoc.
|
|
|
|
|
;; We assume the ewoc is sorted too, which should be the
|
|
|
|
|
;; case if we always add entries with vc-dir-update.
|
|
|
|
|
(setq entries
|
2019-12-21 00:07:08 +02:00
|
|
|
|
(let ((entry-dirs
|
|
|
|
|
(mapcar (lambda (entry)
|
|
|
|
|
(cons (file-name-directory
|
|
|
|
|
(directory-file-name (expand-file-name (car entry))))
|
|
|
|
|
entry))
|
|
|
|
|
entries)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Sort: first files and then subdirectories.
|
2019-12-21 00:07:08 +02:00
|
|
|
|
(mapcar #'cdr
|
|
|
|
|
(sort entry-dirs
|
|
|
|
|
(lambda (pair1 pair2)
|
|
|
|
|
(let ((dir1 (car pair1))
|
|
|
|
|
(dir2 (car pair2)))
|
|
|
|
|
(cond
|
|
|
|
|
((string< dir1 dir2) t)
|
|
|
|
|
((not (string= dir1 dir2)) nil)
|
|
|
|
|
((string< (cadr pair1) (cadr pair2))))))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Insert directory entries in the right places.
|
|
|
|
|
(let ((entry (car entries))
|
2009-02-25 04:00:08 +00:00
|
|
|
|
(node (ewoc-nth vc-ewoc 0))
|
2010-06-01 00:15:55 -07:00
|
|
|
|
(to-remove nil)
|
2009-02-25 04:00:08 +00:00
|
|
|
|
(dotname (file-relative-name default-directory)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Insert . if it is not present.
|
|
|
|
|
(unless node
|
2009-02-25 04:00:08 +00:00
|
|
|
|
(ewoc-enter-last
|
|
|
|
|
vc-ewoc (vc-dir-create-fileinfo
|
2009-09-29 13:07:50 +00:00
|
|
|
|
dotname nil nil nil default-directory))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setq node (ewoc-nth vc-ewoc 0)))
|
2008-06-27 23:29:15 +00:00
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(while (and entry node)
|
|
|
|
|
(let* ((entryfile (car entry))
|
2009-08-26 06:45:36 +00:00
|
|
|
|
(entrydir (file-name-directory (directory-file-name
|
|
|
|
|
(expand-file-name entryfile))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(nodedir (vc-dir-node-directory node)))
|
|
|
|
|
(cond
|
|
|
|
|
;; First try to find the directory.
|
|
|
|
|
((string-lessp nodedir entrydir)
|
|
|
|
|
(setq node (ewoc-next vc-ewoc node)))
|
|
|
|
|
((string-equal nodedir entrydir)
|
|
|
|
|
;; Found the directory, find the place for the file name.
|
|
|
|
|
(let ((nodefile (vc-dir-fileinfo->name (ewoc-data node))))
|
|
|
|
|
(cond
|
2009-02-25 04:00:08 +00:00
|
|
|
|
((string= nodefile dotname)
|
|
|
|
|
(setq node (ewoc-next vc-ewoc node)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
((string-lessp nodefile entryfile)
|
|
|
|
|
(setq node (ewoc-next vc-ewoc node)))
|
|
|
|
|
((string-equal nodefile entryfile)
|
2010-06-01 00:15:55 -07:00
|
|
|
|
(if (nth 1 entry)
|
|
|
|
|
(progn
|
|
|
|
|
(setf (vc-dir-fileinfo->state (ewoc-data node)) (nth 1 entry))
|
|
|
|
|
(setf (vc-dir-fileinfo->extra (ewoc-data node)) (nth 2 entry))
|
|
|
|
|
(setf (vc-dir-fileinfo->needs-update (ewoc-data node)) nil)
|
|
|
|
|
(ewoc-invalidate vc-ewoc node))
|
|
|
|
|
;; If the state is nil, the file does not exist
|
|
|
|
|
;; anymore, so remember the entry so we can remove
|
|
|
|
|
;; it after we are done inserting all ENTRIES.
|
|
|
|
|
(push node to-remove))
|
2008-06-27 23:29:15 +00:00
|
|
|
|
(setq entries (cdr entries))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setq entry (car entries))
|
|
|
|
|
(setq node (ewoc-next vc-ewoc node)))
|
|
|
|
|
(t
|
2010-06-30 15:03:07 -07:00
|
|
|
|
(unless noinsert
|
|
|
|
|
(ewoc-enter-before vc-ewoc node
|
|
|
|
|
(apply 'vc-dir-create-fileinfo entry)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setq entries (cdr entries))
|
|
|
|
|
(setq entry (car entries))))))
|
|
|
|
|
(t
|
2010-06-30 15:03:07 -07:00
|
|
|
|
(unless noinsert
|
|
|
|
|
;; We might need to insert a directory node if the
|
|
|
|
|
;; previous node was in a different directory.
|
|
|
|
|
(let* ((rd (file-relative-name entrydir))
|
|
|
|
|
(prev-node (ewoc-prev vc-ewoc node))
|
2014-09-05 13:37:12 -04:00
|
|
|
|
(prev-dir (if prev-node
|
|
|
|
|
(vc-dir-node-directory prev-node))))
|
2010-06-30 15:03:07 -07:00
|
|
|
|
(unless (string-equal entrydir prev-dir)
|
|
|
|
|
(ewoc-enter-before
|
|
|
|
|
vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir))))
|
|
|
|
|
;; Now insert the node itself.
|
|
|
|
|
(ewoc-enter-before vc-ewoc node
|
|
|
|
|
(apply 'vc-dir-create-fileinfo entry)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setq entries (cdr entries) entry (car entries))))))
|
|
|
|
|
;; We're past the last node, all remaining entries go to the end.
|
|
|
|
|
(unless (or node noinsert)
|
|
|
|
|
(let ((lastdir (vc-dir-node-directory (ewoc-nth vc-ewoc -1))))
|
|
|
|
|
(dolist (entry entries)
|
2009-08-26 06:45:36 +00:00
|
|
|
|
(let ((entrydir (file-name-directory
|
|
|
|
|
(directory-file-name (expand-file-name (car entry))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Insert a directory node if needed.
|
|
|
|
|
(unless (string-equal lastdir entrydir)
|
|
|
|
|
(setq lastdir entrydir)
|
|
|
|
|
(let ((rd (file-relative-name entrydir)))
|
|
|
|
|
(ewoc-enter-last
|
|
|
|
|
vc-ewoc (vc-dir-create-fileinfo rd nil nil nil entrydir))))
|
|
|
|
|
;; Now insert the node itself.
|
|
|
|
|
(ewoc-enter-last vc-ewoc
|
2010-06-01 00:15:55 -07:00
|
|
|
|
(apply 'vc-dir-create-fileinfo entry))))))
|
|
|
|
|
(when to-remove
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(apply 'ewoc-delete vc-ewoc (nreverse to-remove)))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-busy ()
|
|
|
|
|
(and (buffer-live-p vc-dir-process-buffer)
|
|
|
|
|
(get-buffer-process vc-dir-process-buffer)))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-kill-dir-status-process ()
|
|
|
|
|
"Kill the temporary buffer and associated process."
|
|
|
|
|
(interactive)
|
|
|
|
|
(when (buffer-live-p vc-dir-process-buffer)
|
|
|
|
|
(let ((proc (get-buffer-process vc-dir-process-buffer)))
|
|
|
|
|
(when proc (delete-process proc))
|
|
|
|
|
(setq vc-dir-process-buffer nil)
|
|
|
|
|
(setq mode-line-process nil))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-kill-query ()
|
|
|
|
|
;; Make sure that when the status buffer is killed the update
|
|
|
|
|
;; process running in background is also killed.
|
|
|
|
|
(if (vc-dir-busy)
|
|
|
|
|
(when (y-or-n-p "Status update process running, really kill status buffer? ")
|
|
|
|
|
(vc-dir-kill-dir-status-process)
|
|
|
|
|
t)
|
|
|
|
|
t))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-next-line (arg)
|
|
|
|
|
"Go to the next line.
|
|
|
|
|
If a prefix argument is given, move by that many lines."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(ewoc-goto-next vc-ewoc arg)
|
|
|
|
|
(vc-dir-move-to-goal-column)))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-previous-line (arg)
|
|
|
|
|
"Go to the previous line.
|
|
|
|
|
If a prefix argument is given, move by that many lines."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(ewoc-goto-prev vc-ewoc arg)
|
|
|
|
|
(vc-dir-move-to-goal-column))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-next-directory ()
|
|
|
|
|
"Go to the next directory."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((orig (point)))
|
|
|
|
|
(if
|
|
|
|
|
(catch 'foundit
|
|
|
|
|
(while t
|
|
|
|
|
(let* ((next (ewoc-next vc-ewoc (ewoc-locate vc-ewoc))))
|
|
|
|
|
(cond ((not next)
|
|
|
|
|
(throw 'foundit t))
|
|
|
|
|
(t
|
|
|
|
|
(progn
|
|
|
|
|
(ewoc-goto-node vc-ewoc next)
|
|
|
|
|
(vc-dir-move-to-goal-column)
|
|
|
|
|
(if (vc-dir-fileinfo->directory (ewoc-data next))
|
|
|
|
|
(throw 'foundit nil))))))))
|
|
|
|
|
(goto-char orig))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-previous-directory ()
|
|
|
|
|
"Go to the previous directory."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((orig (point)))
|
|
|
|
|
(if
|
|
|
|
|
(catch 'foundit
|
|
|
|
|
(while t
|
|
|
|
|
(let* ((prev (ewoc-prev vc-ewoc (ewoc-locate vc-ewoc))))
|
|
|
|
|
(cond ((not prev)
|
|
|
|
|
(throw 'foundit t))
|
|
|
|
|
(t
|
|
|
|
|
(progn
|
|
|
|
|
(ewoc-goto-node vc-ewoc prev)
|
|
|
|
|
(vc-dir-move-to-goal-column)
|
|
|
|
|
(if (vc-dir-fileinfo->directory (ewoc-data prev))
|
|
|
|
|
(throw 'foundit nil))))))))
|
|
|
|
|
(goto-char orig))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-mark-unmark (mark-unmark-function)
|
|
|
|
|
(if (use-region-p)
|
2017-12-18 20:51:30 +01:00
|
|
|
|
(let ((processed-line nil)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(lastl (line-number-at-pos (region-end))))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (region-beginning))
|
2017-12-18 20:51:30 +01:00
|
|
|
|
(while (and (<= (line-number-at-pos) lastl)
|
|
|
|
|
;; We make sure to not get stuck processing the
|
|
|
|
|
;; same line in an infinite loop.
|
|
|
|
|
(not (eq processed-line (line-number-at-pos))))
|
|
|
|
|
(setq processed-line (line-number-at-pos))
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(funcall mark-unmark-function)
|
|
|
|
|
;; `vc-dir-mark-file' signals an error if we try marking
|
|
|
|
|
;; a directory containing marked files in its tree, or a
|
|
|
|
|
;; file in a marked directory tree. Just continue.
|
|
|
|
|
(error (vc-dir-next-line 1))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(funcall mark-unmark-function)))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-parent-marked-p (arg)
|
2011-12-19 15:00:16 +08:00
|
|
|
|
;; Non-nil iff a parent directory of arg is marked.
|
|
|
|
|
;; Return value, if non-nil is the `ewoc-data' for the marked parent.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let* ((argdir (vc-dir-node-directory arg))
|
2012-04-25 23:18:47 -04:00
|
|
|
|
;; (arglen (length argdir))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(crt arg)
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(found nil))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Go through the predecessors, checking if any directory that is
|
|
|
|
|
;; a parent is marked.
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(while (and (null found)
|
|
|
|
|
(setq crt (ewoc-prev vc-ewoc crt)))
|
|
|
|
|
(let ((data (ewoc-data crt))
|
|
|
|
|
(dir (vc-dir-node-directory crt)))
|
|
|
|
|
(and (vc-dir-fileinfo->directory data)
|
2012-04-16 19:57:09 -04:00
|
|
|
|
(string-prefix-p dir argdir)
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(vc-dir-fileinfo->marked data)
|
|
|
|
|
(setq found data))))
|
|
|
|
|
found))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-children-marked-p (arg)
|
2011-12-19 15:00:16 +08:00
|
|
|
|
;; Non-nil iff a child of ARG is marked.
|
|
|
|
|
;; Return value, if non-nil, is the `ewoc-data' for the marked child.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let* ((argdir-re (concat "\\`" (regexp-quote (vc-dir-node-directory arg))))
|
|
|
|
|
(is-child t)
|
|
|
|
|
(crt arg)
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(found nil))
|
|
|
|
|
(while (and is-child
|
|
|
|
|
(null found)
|
|
|
|
|
(setq crt (ewoc-next vc-ewoc crt)))
|
|
|
|
|
(let ((data (ewoc-data crt))
|
|
|
|
|
(dir (vc-dir-node-directory crt)))
|
|
|
|
|
(if (string-match argdir-re dir)
|
|
|
|
|
(if (vc-dir-fileinfo->marked data)
|
|
|
|
|
(setq found data))
|
|
|
|
|
;; We are done, we got to an entry that is not a child of `arg'.
|
|
|
|
|
(setq is-child nil))))
|
|
|
|
|
found))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-mark-file (&optional arg)
|
|
|
|
|
;; Mark ARG or the current file and move to the next line.
|
|
|
|
|
(let* ((crt (or arg (ewoc-locate vc-ewoc)))
|
|
|
|
|
(file (ewoc-data crt))
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(isdir (vc-dir-fileinfo->directory file))
|
|
|
|
|
;; Forbid marking a directory containing marked files in its
|
|
|
|
|
;; tree, or a file in a marked directory tree.
|
|
|
|
|
(conflict (if isdir
|
|
|
|
|
(vc-dir-children-marked-p crt)
|
|
|
|
|
(vc-dir-parent-marked-p crt))))
|
|
|
|
|
(when conflict
|
|
|
|
|
(error (if isdir
|
|
|
|
|
"File `%s' in this directory is already marked"
|
|
|
|
|
"Parent directory `%s' is already marked")
|
|
|
|
|
(vc-dir-fileinfo->name conflict)))
|
|
|
|
|
(setf (vc-dir-fileinfo->marked file) t)
|
|
|
|
|
(ewoc-invalidate vc-ewoc crt)
|
|
|
|
|
(unless (or arg (mouse-event-p last-command-event))
|
|
|
|
|
(vc-dir-next-line 1))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-mark ()
|
|
|
|
|
"Mark the current file or all files in the region.
|
|
|
|
|
If the region is active, mark all the files in the region.
|
|
|
|
|
Otherwise mark the file on the current line and move to the next
|
|
|
|
|
line."
|
|
|
|
|
(interactive)
|
|
|
|
|
(vc-dir-mark-unmark 'vc-dir-mark-file))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-mark-all-files (arg)
|
|
|
|
|
"Mark all files with the same state as the current one.
|
2020-02-12 00:24:24 +02:00
|
|
|
|
With a prefix argument mark all files (not directories).
|
2008-06-22 19:04:22 +00:00
|
|
|
|
If the current entry is a directory, mark all child files.
|
|
|
|
|
|
|
|
|
|
The commands operate on files that are on the same state.
|
|
|
|
|
This command is intended to make it easy to select all files that
|
|
|
|
|
share the same state."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(if arg
|
|
|
|
|
;; Mark all files.
|
|
|
|
|
(progn
|
|
|
|
|
;; First check that no directory is marked, we can't mark
|
|
|
|
|
;; files in that case.
|
|
|
|
|
(ewoc-map
|
|
|
|
|
(lambda (filearg)
|
|
|
|
|
(when (and (vc-dir-fileinfo->directory filearg)
|
|
|
|
|
(vc-dir-fileinfo->marked filearg))
|
|
|
|
|
(error "Cannot mark all files, directory `%s' marked"
|
|
|
|
|
(vc-dir-fileinfo->name filearg))))
|
|
|
|
|
vc-ewoc)
|
|
|
|
|
(ewoc-map
|
|
|
|
|
(lambda (filearg)
|
2020-02-12 00:24:24 +02:00
|
|
|
|
(unless (or (vc-dir-fileinfo->directory filearg)
|
|
|
|
|
(vc-dir-fileinfo->marked filearg))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setf (vc-dir-fileinfo->marked filearg) t)
|
|
|
|
|
t))
|
|
|
|
|
vc-ewoc))
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(let* ((crt (ewoc-locate vc-ewoc))
|
|
|
|
|
(data (ewoc-data crt)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(if (vc-dir-fileinfo->directory data)
|
|
|
|
|
;; It's a directory, mark child files.
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(let (crt-data)
|
|
|
|
|
(while (and (setq crt (ewoc-next vc-ewoc crt))
|
|
|
|
|
(setq crt-data (ewoc-data crt))
|
|
|
|
|
(not (vc-dir-fileinfo->directory crt-data)))
|
|
|
|
|
(setf (vc-dir-fileinfo->marked crt-data) t)
|
|
|
|
|
(ewoc-invalidate vc-ewoc crt)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; It's a file
|
2011-12-19 15:00:16 +08:00
|
|
|
|
(let ((state (vc-dir-fileinfo->state data)))
|
|
|
|
|
(setq crt (ewoc-nth vc-ewoc 0))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(while crt
|
|
|
|
|
(let ((crt-data (ewoc-data crt)))
|
|
|
|
|
(when (and (not (vc-dir-fileinfo->marked crt-data))
|
|
|
|
|
(eq (vc-dir-fileinfo->state crt-data) state)
|
|
|
|
|
(not (vc-dir-fileinfo->directory crt-data)))
|
|
|
|
|
(vc-dir-mark-file crt)))
|
|
|
|
|
(setq crt (ewoc-next vc-ewoc crt))))))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-unmark-file ()
|
|
|
|
|
;; Unmark the current file and move to the next line.
|
|
|
|
|
(let* ((crt (ewoc-locate vc-ewoc))
|
|
|
|
|
(file (ewoc-data crt)))
|
|
|
|
|
(setf (vc-dir-fileinfo->marked file) nil)
|
|
|
|
|
(ewoc-invalidate vc-ewoc crt)
|
|
|
|
|
(unless (mouse-event-p last-command-event)
|
|
|
|
|
(vc-dir-next-line 1))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-unmark ()
|
|
|
|
|
"Unmark the current file or all files in the region.
|
|
|
|
|
If the region is active, unmark all the files in the region.
|
2018-03-12 20:16:53 +01:00
|
|
|
|
Otherwise unmark the file on the current line and move to the next
|
2008-06-22 19:04:22 +00:00
|
|
|
|
line."
|
|
|
|
|
(interactive)
|
|
|
|
|
(vc-dir-mark-unmark 'vc-dir-unmark-file))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-unmark-file-up ()
|
|
|
|
|
"Move to the previous line and unmark the file."
|
|
|
|
|
(interactive)
|
|
|
|
|
;; If we're on the first line, we won't move up, but we will still
|
|
|
|
|
;; remove the mark. This seems a bit odd but it is what buffer-menu
|
|
|
|
|
;; does.
|
|
|
|
|
(let* ((prev (ewoc-goto-prev vc-ewoc 1))
|
|
|
|
|
(file (ewoc-data prev)))
|
|
|
|
|
(setf (vc-dir-fileinfo->marked file) nil)
|
|
|
|
|
(ewoc-invalidate vc-ewoc prev)
|
|
|
|
|
(vc-dir-move-to-goal-column)))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-unmark-all-files (arg)
|
|
|
|
|
"Unmark all files with the same state as the current one.
|
|
|
|
|
With a prefix argument unmark all files.
|
|
|
|
|
If the current entry is a directory, unmark all the child files.
|
|
|
|
|
|
|
|
|
|
The commands operate on files that are on the same state.
|
|
|
|
|
This command is intended to make it easy to deselect all files
|
|
|
|
|
that share the same state."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(if arg
|
|
|
|
|
(ewoc-map
|
|
|
|
|
(lambda (filearg)
|
|
|
|
|
(when (vc-dir-fileinfo->marked filearg)
|
|
|
|
|
(setf (vc-dir-fileinfo->marked filearg) nil)
|
|
|
|
|
t))
|
|
|
|
|
vc-ewoc)
|
|
|
|
|
(let* ((crt (ewoc-locate vc-ewoc))
|
|
|
|
|
(data (ewoc-data crt)))
|
|
|
|
|
(if (vc-dir-fileinfo->directory data)
|
|
|
|
|
;; It's a directory, unmark child files.
|
|
|
|
|
(while (setq crt (ewoc-next vc-ewoc crt))
|
|
|
|
|
(let ((crt-data (ewoc-data crt)))
|
|
|
|
|
(unless (vc-dir-fileinfo->directory crt-data)
|
|
|
|
|
(setf (vc-dir-fileinfo->marked crt-data) nil)
|
|
|
|
|
(ewoc-invalidate vc-ewoc crt))))
|
|
|
|
|
;; It's a file
|
|
|
|
|
(let ((crt-state (vc-dir-fileinfo->state (ewoc-data crt))))
|
|
|
|
|
(ewoc-map
|
|
|
|
|
(lambda (filearg)
|
|
|
|
|
(when (and (vc-dir-fileinfo->marked filearg)
|
|
|
|
|
(eq (vc-dir-fileinfo->state filearg) crt-state))
|
|
|
|
|
(setf (vc-dir-fileinfo->marked filearg) nil)
|
|
|
|
|
t))
|
|
|
|
|
vc-ewoc))))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-toggle-mark-file ()
|
|
|
|
|
(let* ((crt (ewoc-locate vc-ewoc))
|
|
|
|
|
(file (ewoc-data crt)))
|
|
|
|
|
(if (vc-dir-fileinfo->marked file)
|
|
|
|
|
(vc-dir-unmark-file)
|
|
|
|
|
(vc-dir-mark-file))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-toggle-mark (e)
|
|
|
|
|
(interactive "e")
|
2008-12-18 08:27:37 +00:00
|
|
|
|
(vc-dir-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2019-07-14 14:25:44 +02:00
|
|
|
|
(defun vc-dir-clean-files ()
|
2019-07-13 06:10:29 +02:00
|
|
|
|
"Delete the marked files, or the current file if no marks.
|
|
|
|
|
The files will not be marked as deleted in the version control
|
|
|
|
|
system; see `vc-dir-delete-file'."
|
|
|
|
|
(interactive)
|
2019-07-14 14:25:44 +02:00
|
|
|
|
(let* ((files (or (vc-dir-marked-files)
|
2019-07-13 06:10:29 +02:00
|
|
|
|
(list (vc-dir-current-file))))
|
2019-07-14 14:25:44 +02:00
|
|
|
|
(tracked
|
|
|
|
|
(seq-filter (lambda (file)
|
|
|
|
|
(not (eq (vc-call-backend vc-dir-backend 'state file)
|
|
|
|
|
'unregistered)))
|
|
|
|
|
files)))
|
|
|
|
|
(when tracked
|
2019-07-14 08:42:32 -04:00
|
|
|
|
(user-error (ngettext "Trying to clean tracked file: %s"
|
|
|
|
|
"Trying to clean tracked files: %s"
|
|
|
|
|
(length tracked))
|
2019-07-14 14:25:44 +02:00
|
|
|
|
(mapconcat #'file-name-nondirectory tracked ", ")))
|
|
|
|
|
(map-y-or-n-p "Delete %s? " #'delete-file files)
|
|
|
|
|
(revert-buffer)))
|
2019-07-13 06:10:29 +02:00
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defun vc-dir-delete-file ()
|
2019-07-13 06:10:29 +02:00
|
|
|
|
"Delete the marked files, or the current file if no marks.
|
|
|
|
|
The files will also be marked as deleted in the version control
|
|
|
|
|
system."
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(mapc 'vc-delete-file (or (vc-dir-marked-files)
|
|
|
|
|
(list (vc-dir-current-file)))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-find-file ()
|
|
|
|
|
"Find the file on the current line."
|
|
|
|
|
(interactive)
|
|
|
|
|
(find-file (vc-dir-current-file)))
|
|
|
|
|
|
2009-02-10 05:51:47 +00:00
|
|
|
|
(defun vc-dir-find-file-other-window (&optional event)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
"Find the file on the current line, in another window."
|
2009-02-10 05:51:47 +00:00
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
|
(if event (posn-set-point (event-end event)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(find-file-other-window (vc-dir-current-file)))
|
|
|
|
|
|
2014-12-29 02:47:05 +02:00
|
|
|
|
(defun vc-dir-display-file (&optional event)
|
|
|
|
|
"Display the file on the current line, in another window."
|
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
|
(if event (posn-set-point (event-end event)))
|
|
|
|
|
(display-buffer (find-file-noselect (vc-dir-current-file))
|
|
|
|
|
t))
|
|
|
|
|
|
2019-07-08 01:54:29 +03:00
|
|
|
|
(defun vc-dir-view-file ()
|
|
|
|
|
"Examine a file on the current line in view mode."
|
|
|
|
|
(interactive)
|
|
|
|
|
(view-file (vc-dir-current-file)))
|
|
|
|
|
|
2008-07-24 02:39:04 +00:00
|
|
|
|
(defun vc-dir-isearch ()
|
|
|
|
|
"Search for a string through all marked buffers using Isearch."
|
|
|
|
|
(interactive)
|
|
|
|
|
(multi-isearch-files
|
|
|
|
|
(mapcar 'car (vc-dir-marked-only-files-and-states))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-isearch-regexp ()
|
|
|
|
|
"Search for a regexp through all marked buffers using Isearch."
|
|
|
|
|
(interactive)
|
|
|
|
|
(multi-isearch-files-regexp
|
|
|
|
|
(mapcar 'car (vc-dir-marked-only-files-and-states))))
|
|
|
|
|
|
2008-07-24 01:57:24 +00:00
|
|
|
|
(defun vc-dir-search (regexp)
|
|
|
|
|
"Search through all marked files for a match for REGEXP.
|
|
|
|
|
For marked directories, use the files displayed from those directories.
|
|
|
|
|
Stops when a match is found.
|
|
|
|
|
To continue searching for next match, use command \\[tags-loop-continue]."
|
|
|
|
|
(interactive "sSearch marked files (regexp): ")
|
2019-06-20 17:45:52 -04:00
|
|
|
|
(tags-search regexp
|
2019-07-16 01:12:12 +03:00
|
|
|
|
(mapcar #'car (vc-dir-marked-only-files-and-states))))
|
2008-07-24 01:57:24 +00:00
|
|
|
|
|
2008-07-04 00:34:02 +00:00
|
|
|
|
(defun vc-dir-query-replace-regexp (from to &optional delimited)
|
|
|
|
|
"Do `query-replace-regexp' of FROM with TO, on all marked files.
|
|
|
|
|
If a directory is marked, then use the files displayed for that directory.
|
|
|
|
|
Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
|
|
|
|
|
If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
|
|
|
|
|
with the command \\[tags-loop-continue]."
|
2010-12-04 20:01:23 -05:00
|
|
|
|
;; FIXME: this is almost a copy of `dired-do-query-replace-regexp'. This
|
2008-07-04 00:34:02 +00:00
|
|
|
|
;; should probably be made generic and used in both places instead of
|
|
|
|
|
;; duplicating it here.
|
|
|
|
|
(interactive
|
|
|
|
|
(let ((common
|
|
|
|
|
(query-replace-read-args
|
|
|
|
|
"Query replace regexp in marked files" t t)))
|
|
|
|
|
(list (nth 0 common) (nth 1 common) (nth 2 common))))
|
|
|
|
|
(dolist (file (mapcar 'car (vc-dir-marked-only-files-and-states)))
|
|
|
|
|
(let ((buffer (get-file-buffer file)))
|
|
|
|
|
(if (and buffer (with-current-buffer buffer
|
|
|
|
|
buffer-read-only))
|
|
|
|
|
(error "File `%s' is visited read-only" file))))
|
2019-06-16 15:07:37 +02:00
|
|
|
|
(fileloop-initialize-replace
|
|
|
|
|
from to (mapcar 'car (vc-dir-marked-only-files-and-states))
|
|
|
|
|
(if (equal from (downcase from)) nil 'default)
|
|
|
|
|
delimited)
|
|
|
|
|
(fileloop-continue))
|
2008-07-04 00:34:02 +00:00
|
|
|
|
|
2019-09-15 15:00:20 +02:00
|
|
|
|
(defun vc-dir-ignore (&optional arg)
|
|
|
|
|
"Ignore the current file.
|
|
|
|
|
If a prefix argument is given, ignore all marked files."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(if arg
|
|
|
|
|
(ewoc-map
|
|
|
|
|
(lambda (filearg)
|
|
|
|
|
(when (vc-dir-fileinfo->marked filearg)
|
|
|
|
|
(vc-ignore (vc-dir-fileinfo->name filearg))
|
|
|
|
|
t))
|
|
|
|
|
vc-ewoc)
|
2020-02-25 01:03:28 +02:00
|
|
|
|
(let ((rel-dir (vc--ignore-base-dir)))
|
|
|
|
|
(vc-ignore
|
|
|
|
|
(file-relative-name (vc-dir-current-file) rel-dir)
|
|
|
|
|
rel-dir))))
|
2013-07-30 08:25:31 +08:00
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defun vc-dir-current-file ()
|
|
|
|
|
(let ((node (ewoc-locate vc-ewoc)))
|
|
|
|
|
(unless node
|
|
|
|
|
(error "No file available"))
|
|
|
|
|
(expand-file-name (vc-dir-fileinfo->name (ewoc-data node)))))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-marked-files ()
|
|
|
|
|
"Return the list of marked files."
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem)))
|
|
|
|
|
(ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked)))
|
|
|
|
|
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(defun vc-dir-marked-only-files-and-states ()
|
|
|
|
|
"Return the list of conses (FILE . STATE) for the marked files.
|
|
|
|
|
For marked directories return the corresponding conses for the
|
|
|
|
|
child files."
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let ((crt (ewoc-nth vc-ewoc 0))
|
|
|
|
|
result)
|
|
|
|
|
(while crt
|
|
|
|
|
(let ((crt-data (ewoc-data crt)))
|
|
|
|
|
(if (vc-dir-fileinfo->marked crt-data)
|
2008-06-25 03:19:14 +00:00
|
|
|
|
;; FIXME: use vc-dir-child-files-and-states here instead of duplicating it.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(if (vc-dir-fileinfo->directory crt-data)
|
|
|
|
|
(let* ((dir (vc-dir-fileinfo->directory crt-data))
|
2012-04-25 23:18:47 -04:00
|
|
|
|
;; (dirlen (length dir))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
data)
|
|
|
|
|
(while
|
|
|
|
|
(and (setq crt (ewoc-next vc-ewoc crt))
|
2012-04-16 19:57:09 -04:00
|
|
|
|
(string-prefix-p dir
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(progn
|
|
|
|
|
(setq data (ewoc-data crt))
|
|
|
|
|
(vc-dir-node-directory crt))))
|
|
|
|
|
(unless (vc-dir-fileinfo->directory data)
|
2008-06-27 23:29:15 +00:00
|
|
|
|
(push
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(cons (expand-file-name (vc-dir-fileinfo->name data))
|
|
|
|
|
(vc-dir-fileinfo->state data))
|
|
|
|
|
result))))
|
|
|
|
|
(push (cons (expand-file-name (vc-dir-fileinfo->name crt-data))
|
|
|
|
|
(vc-dir-fileinfo->state crt-data))
|
|
|
|
|
result)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setq crt (ewoc-next vc-ewoc crt)))
|
|
|
|
|
(setq crt (ewoc-next vc-ewoc crt)))))
|
2008-08-25 15:14:52 +00:00
|
|
|
|
(nreverse result)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(defun vc-dir-child-files-and-states ()
|
|
|
|
|
"Return the list of conses (FILE . STATE) for child files of the current entry if it's a directory.
|
|
|
|
|
If it is a file, return the corresponding cons for the file itself."
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let* ((crt (ewoc-locate vc-ewoc))
|
|
|
|
|
(crt-data (ewoc-data crt))
|
|
|
|
|
result)
|
|
|
|
|
(if (vc-dir-fileinfo->directory crt-data)
|
|
|
|
|
(let* ((dir (vc-dir-fileinfo->directory crt-data))
|
2012-04-25 23:18:47 -04:00
|
|
|
|
;; (dirlen (length dir))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
data)
|
|
|
|
|
(while
|
|
|
|
|
(and (setq crt (ewoc-next vc-ewoc crt))
|
2012-04-16 19:57:09 -04:00
|
|
|
|
(string-prefix-p dir (progn
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setq data (ewoc-data crt))
|
|
|
|
|
(vc-dir-node-directory crt))))
|
|
|
|
|
(unless (vc-dir-fileinfo->directory data)
|
2008-06-27 23:29:15 +00:00
|
|
|
|
(push
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(cons (expand-file-name (vc-dir-fileinfo->name data))
|
|
|
|
|
(vc-dir-fileinfo->state data))
|
|
|
|
|
result))))
|
2008-06-27 23:29:15 +00:00
|
|
|
|
(push
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(cons (expand-file-name (vc-dir-fileinfo->name crt-data))
|
|
|
|
|
(vc-dir-fileinfo->state crt-data)) result))
|
2008-08-25 15:14:52 +00:00
|
|
|
|
(nreverse result)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2008-07-05 18:09:32 +00:00
|
|
|
|
(defun vc-dir-recompute-file-state (fname def-dir)
|
|
|
|
|
(let* ((file-short (file-relative-name fname def-dir))
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(_remove-me-when-CVS-works
|
2008-07-22 02:18:29 +00:00
|
|
|
|
(when (eq vc-dir-backend 'CVS)
|
|
|
|
|
;; FIXME: Warning: UGLY HACK. The CVS backend caches the state
|
|
|
|
|
;; info, this forces the backend to update it.
|
2008-07-22 08:42:19 +00:00
|
|
|
|
(vc-call-backend vc-dir-backend 'registered fname)))
|
2008-07-05 18:09:32 +00:00
|
|
|
|
(state (vc-call-backend vc-dir-backend 'state fname))
|
|
|
|
|
(extra (vc-call-backend vc-dir-backend
|
|
|
|
|
'status-fileinfo-extra fname)))
|
|
|
|
|
(list file-short state extra)))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-find-child-files (dirname)
|
|
|
|
|
;; Give a DIRNAME string return the list of all child files shown in
|
|
|
|
|
;; the current *vc-dir* buffer.
|
|
|
|
|
(let ((crt (ewoc-nth vc-ewoc 0))
|
2012-04-25 23:18:47 -04:00
|
|
|
|
children)
|
2008-07-05 18:09:32 +00:00
|
|
|
|
;; Find DIR
|
2012-04-16 19:57:09 -04:00
|
|
|
|
(while (and crt (not (string-prefix-p
|
2008-07-05 18:09:32 +00:00
|
|
|
|
dirname (vc-dir-node-directory crt))))
|
|
|
|
|
(setq crt (ewoc-next vc-ewoc crt)))
|
2012-04-16 19:57:09 -04:00
|
|
|
|
(while (and crt (string-prefix-p
|
2008-07-05 18:09:32 +00:00
|
|
|
|
dirname
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(vc-dir-node-directory crt)))
|
2008-07-05 18:09:32 +00:00
|
|
|
|
(let ((data (ewoc-data crt)))
|
|
|
|
|
(unless (vc-dir-fileinfo->directory data)
|
|
|
|
|
(push (expand-file-name (vc-dir-fileinfo->name data)) children)))
|
|
|
|
|
(setq crt (ewoc-next vc-ewoc crt)))
|
|
|
|
|
children))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-resync-directory-files (dirname)
|
|
|
|
|
;; Update the entries for all the child files of DIRNAME shown in
|
|
|
|
|
;; the current *vc-dir* buffer.
|
|
|
|
|
(let ((files (vc-dir-find-child-files dirname))
|
2009-09-29 13:07:50 +00:00
|
|
|
|
(ddir default-directory)
|
2008-07-05 18:09:32 +00:00
|
|
|
|
fileentries)
|
|
|
|
|
(when files
|
|
|
|
|
(dolist (crt files)
|
|
|
|
|
(push (vc-dir-recompute-file-state crt ddir)
|
|
|
|
|
fileentries))
|
|
|
|
|
(vc-dir-update fileentries (current-buffer)))))
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defun vc-dir-resynch-file (&optional fname)
|
2009-01-29 12:34:08 +00:00
|
|
|
|
"Update the entries for FNAME in any directory buffers that list it."
|
2015-10-20 20:04:47 +03:00
|
|
|
|
(let ((file (expand-file-name (or fname buffer-file-name)))
|
2009-09-29 13:07:50 +00:00
|
|
|
|
(drop '()))
|
|
|
|
|
(save-current-buffer
|
|
|
|
|
;; look for a vc-dir buffer that might show this file.
|
|
|
|
|
(dolist (status-buf vc-dir-buffers)
|
|
|
|
|
(if (not (buffer-live-p status-buf))
|
|
|
|
|
(push status-buf drop)
|
|
|
|
|
(set-buffer status-buf)
|
|
|
|
|
(if (not (derived-mode-p 'vc-dir-mode))
|
|
|
|
|
(push status-buf drop)
|
|
|
|
|
(let ((ddir default-directory))
|
2012-04-16 19:57:09 -04:00
|
|
|
|
(when (string-prefix-p ddir file)
|
2009-09-29 13:07:50 +00:00
|
|
|
|
(if (file-directory-p file)
|
2010-01-17 12:36:21 -08:00
|
|
|
|
(progn
|
|
|
|
|
(vc-dir-resync-directory-files file)
|
|
|
|
|
(ewoc-set-hf vc-ewoc
|
|
|
|
|
(vc-dir-headers vc-dir-backend default-directory) ""))
|
2010-06-30 15:03:07 -07:00
|
|
|
|
(let* ((complete-state (vc-dir-recompute-file-state file ddir))
|
|
|
|
|
(state (cadr complete-state)))
|
2009-09-29 13:07:50 +00:00
|
|
|
|
(vc-dir-update
|
2010-06-30 15:03:07 -07:00
|
|
|
|
(list complete-state)
|
|
|
|
|
status-buf (or (not state)
|
|
|
|
|
(eq state 'up-to-date)))))))))))
|
2009-09-29 13:07:50 +00:00
|
|
|
|
;; Remove out-of-date entries from vc-dir-buffers.
|
|
|
|
|
(dolist (b drop) (setq vc-dir-buffers (delq b vc-dir-buffers)))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(defvar use-vc-backend) ;; dynamically bound
|
|
|
|
|
|
|
|
|
|
(define-derived-mode vc-dir-mode special-mode "VC dir"
|
2008-08-01 18:05:37 +00:00
|
|
|
|
"Major mode for VC directory buffers.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
Marking/Unmarking key bindings and actions:
|
2009-01-31 18:38:56 +00:00
|
|
|
|
m - mark a file/directory
|
|
|
|
|
- if the region is active, mark all the files in region.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
Restrictions: - a file cannot be marked if any parent directory is marked
|
|
|
|
|
- a directory cannot be marked if any child file or
|
|
|
|
|
directory is marked
|
2009-01-31 18:38:56 +00:00
|
|
|
|
u - unmark a file/directory
|
|
|
|
|
- if the region is active, unmark all the files in region.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
M - if the cursor is on a file: mark all the files with the same state as
|
|
|
|
|
the current file
|
|
|
|
|
- if the cursor is on a directory: mark all child files
|
|
|
|
|
- with a prefix argument: mark all files
|
|
|
|
|
U - if the cursor is on a file: unmark all the files with the same state
|
|
|
|
|
as the current file
|
|
|
|
|
- if the cursor is on a directory: unmark all child files
|
|
|
|
|
- with a prefix argument: unmark all files
|
2009-01-31 18:38:56 +00:00
|
|
|
|
mouse-2 - toggles the mark state
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2008-08-01 18:05:37 +00:00
|
|
|
|
VC commands
|
2009-01-31 18:38:56 +00:00
|
|
|
|
VC commands in the `C-x v' prefix can be used.
|
|
|
|
|
VC commands act on the marked entries. If nothing is marked, VC
|
|
|
|
|
commands act on the current entry.
|
2008-08-01 18:05:37 +00:00
|
|
|
|
|
|
|
|
|
Search & Replace
|
|
|
|
|
S - searches the marked files
|
|
|
|
|
Q - does a query replace on the marked files
|
|
|
|
|
M-s a C-s - does an isearch on the marked files
|
2008-08-06 03:49:03 +00:00
|
|
|
|
M-s a C-M-s - does a regexp isearch on the marked files
|
2008-08-01 18:05:37 +00:00
|
|
|
|
If nothing is marked, these commands act on the current entry.
|
|
|
|
|
When a directory is current or marked, the Search & Replace
|
2009-01-31 18:38:56 +00:00
|
|
|
|
commands act on the child files of that directory that are displayed in
|
|
|
|
|
the *vc-dir* buffer.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
\\{vc-dir-mode-map}"
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(set (make-local-variable 'vc-dir-backend) use-vc-backend)
|
2012-11-28 20:16:51 -05:00
|
|
|
|
(set (make-local-variable 'desktop-save-buffer)
|
|
|
|
|
'vc-dir-desktop-buffer-misc-data)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(setq buffer-read-only t)
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(when (boundp 'tool-bar-map)
|
|
|
|
|
(set (make-local-variable 'tool-bar-map) vc-dir-tool-bar-map))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let ((buffer-read-only nil))
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(set (make-local-variable 'vc-dir-process-buffer) nil)
|
2008-10-27 07:21:43 +00:00
|
|
|
|
(set (make-local-variable 'vc-ewoc) (ewoc-create #'vc-dir-printer))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(set (make-local-variable 'revert-buffer-function)
|
|
|
|
|
'vc-dir-revert-buffer-function)
|
2010-01-07 23:46:44 +01:00
|
|
|
|
(setq list-buffers-directory (expand-file-name "*vc-dir*" default-directory))
|
2009-09-29 13:07:50 +00:00
|
|
|
|
(add-to-list 'vc-dir-buffers (current-buffer))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Make sure that if the directory buffer is killed, the update
|
|
|
|
|
;; process running in the background is also killed.
|
|
|
|
|
(add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t)
|
2010-03-12 00:04:54 -08:00
|
|
|
|
(hack-dir-local-variables-non-file-buffer)
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(vc-dir-refresh)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-headers (backend dir)
|
|
|
|
|
"Display the headers in the *VC dir* buffer.
|
2008-10-27 07:21:43 +00:00
|
|
|
|
It calls the `dir-extra-headers' backend method to display backend
|
2008-06-22 19:04:22 +00:00
|
|
|
|
specific headers."
|
|
|
|
|
(concat
|
2008-11-04 08:58:24 +00:00
|
|
|
|
;; First layout the common headers.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(propertize "VC backend : " 'face 'font-lock-type-face)
|
|
|
|
|
(propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face)
|
|
|
|
|
(propertize "Working dir: " 'face 'font-lock-type-face)
|
2010-03-24 13:33:39 -04:00
|
|
|
|
(propertize (format "%s\n" (abbreviate-file-name dir))
|
|
|
|
|
'face 'font-lock-variable-name-face)
|
2008-11-04 08:58:24 +00:00
|
|
|
|
;; Then the backend specific ones.
|
|
|
|
|
(vc-call-backend backend 'dir-extra-headers dir)
|
|
|
|
|
"\n"))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2014-12-02 08:01:46 -05:00
|
|
|
|
(defun vc-dir-refresh-files (files)
|
2014-12-12 18:42:57 -08:00
|
|
|
|
"Refresh some files in the *VC-dir* buffer."
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let ((def-dir default-directory)
|
|
|
|
|
(backend vc-dir-backend))
|
|
|
|
|
(vc-set-mode-line-busy-indicator)
|
2011-11-02 03:05:53 +01:00
|
|
|
|
;; Call the `dir-status-files' backend function.
|
|
|
|
|
;; `dir-status-files' is supposed to be asynchronous.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; It should compute the results, and then call the function
|
|
|
|
|
;; passed as an argument in order to update the vc-dir buffer
|
|
|
|
|
;; with the results.
|
|
|
|
|
(unless (buffer-live-p vc-dir-process-buffer)
|
|
|
|
|
(setq vc-dir-process-buffer
|
|
|
|
|
(generate-new-buffer (format " *VC-%s* tmp status" backend))))
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(let ((buffer (current-buffer)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(with-current-buffer vc-dir-process-buffer
|
2011-03-15 13:39:56 -04:00
|
|
|
|
(setq default-directory def-dir)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(vc-call-backend
|
2014-12-02 08:01:46 -05:00
|
|
|
|
backend 'dir-status-files def-dir files
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(lambda (entries &optional more-to-come)
|
|
|
|
|
;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
|
|
|
|
|
;; If MORE-TO-COME is true, then more updates will come from
|
|
|
|
|
;; the asynchronous process.
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(vc-dir-update entries buffer)
|
|
|
|
|
(unless more-to-come
|
|
|
|
|
(setq mode-line-process nil)
|
|
|
|
|
;; Remove the ones that haven't been updated at all.
|
|
|
|
|
;; Those not-updated are those whose state is nil because the
|
|
|
|
|
;; file/dir doesn't exist and isn't versioned.
|
|
|
|
|
(ewoc-filter vc-ewoc
|
|
|
|
|
(lambda (info)
|
|
|
|
|
;; The state for directory entries might
|
|
|
|
|
;; have been changed to 'up-to-date,
|
2011-11-19 18:29:42 -08:00
|
|
|
|
;; reset it, otherwise it will be removed when doing 'x'
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; next time.
|
|
|
|
|
;; FIXME: There should be a more elegant way to do this.
|
|
|
|
|
(when (and (vc-dir-fileinfo->directory info)
|
|
|
|
|
(eq (vc-dir-fileinfo->state info)
|
|
|
|
|
'up-to-date))
|
|
|
|
|
(setf (vc-dir-fileinfo->state info) nil))
|
|
|
|
|
|
|
|
|
|
(not (vc-dir-fileinfo->needs-update info))))))))))))
|
|
|
|
|
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(defun vc-dir-revert-buffer-function (&optional _ignore-auto _noconfirm)
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(vc-dir-refresh))
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(defun vc-dir-refresh ()
|
|
|
|
|
"Refresh the contents of the *VC-dir* buffer.
|
|
|
|
|
Throw an error if another update process is in progress."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (vc-dir-busy)
|
|
|
|
|
(error "Another update process is in progress, cannot run two at a time")
|
|
|
|
|
(let ((def-dir default-directory)
|
|
|
|
|
(backend vc-dir-backend))
|
|
|
|
|
(vc-set-mode-line-busy-indicator)
|
|
|
|
|
;; Call the `dir-status' backend function.
|
|
|
|
|
;; `dir-status' is supposed to be asynchronous.
|
|
|
|
|
;; It should compute the results, and then call the function
|
|
|
|
|
;; passed as an argument in order to update the vc-dir buffer
|
|
|
|
|
;; with the results.
|
|
|
|
|
|
|
|
|
|
;; Create a buffer that can be used by `dir-status' and call
|
|
|
|
|
;; `dir-status' with this buffer as the current buffer. Use
|
|
|
|
|
;; `vc-dir-process-buffer' to remember this buffer, so that
|
|
|
|
|
;; it can be used later to kill the update process in case it
|
|
|
|
|
;; takes too long.
|
|
|
|
|
(unless (buffer-live-p vc-dir-process-buffer)
|
|
|
|
|
(setq vc-dir-process-buffer
|
|
|
|
|
(generate-new-buffer (format " *VC-%s* tmp status" backend))))
|
2008-07-07 16:59:39 +00:00
|
|
|
|
;; set the needs-update flag on all non-directory entries
|
|
|
|
|
(ewoc-map (lambda (info)
|
|
|
|
|
(unless (vc-dir-fileinfo->directory info)
|
|
|
|
|
(setf (vc-dir-fileinfo->needs-update info) t) nil))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
vc-ewoc)
|
2011-02-10 14:37:42 -05:00
|
|
|
|
;; Bzr has serious locking problems, so setup the headers first (this is
|
|
|
|
|
;; synchronous) rather than doing it while dir-status is running.
|
|
|
|
|
(ewoc-set-hf vc-ewoc (vc-dir-headers backend def-dir) "")
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(let ((buffer (current-buffer)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(with-current-buffer vc-dir-process-buffer
|
2011-03-15 13:39:56 -04:00
|
|
|
|
(setq default-directory def-dir)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(vc-call-backend
|
2014-12-02 10:10:55 -05:00
|
|
|
|
backend 'dir-status-files def-dir nil
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(lambda (entries &optional more-to-come)
|
|
|
|
|
;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
|
|
|
|
|
;; If MORE-TO-COME is true, then more updates will come from
|
|
|
|
|
;; the asynchronous process.
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(vc-dir-update entries buffer)
|
|
|
|
|
(unless more-to-come
|
|
|
|
|
(let ((remaining
|
|
|
|
|
(ewoc-collect
|
|
|
|
|
vc-ewoc 'vc-dir-fileinfo->needs-update)))
|
|
|
|
|
(if remaining
|
|
|
|
|
(vc-dir-refresh-files
|
2014-12-02 08:01:46 -05:00
|
|
|
|
(mapcar 'vc-dir-fileinfo->name remaining))
|
2011-02-10 14:37:42 -05:00
|
|
|
|
(setq mode-line-process nil))))))))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-dir-show-fileentry (file)
|
|
|
|
|
"Insert an entry for a specific file into the current *VC-dir* listing.
|
|
|
|
|
This is typically used if the file is up-to-date (or has been added
|
|
|
|
|
outside of VC) and one wants to do some operation on it."
|
|
|
|
|
(interactive "fShow file: ")
|
|
|
|
|
(vc-dir-update (list (list (file-relative-name file) (vc-state file))) (current-buffer)))
|
|
|
|
|
|
2012-08-13 17:31:56 -04:00
|
|
|
|
(defun vc-dir-hide-state (&optional state)
|
|
|
|
|
"Hide items that are in STATE from display.
|
|
|
|
|
See `vc-state' for valid values of STATE.
|
|
|
|
|
|
2014-11-10 03:29:58 +02:00
|
|
|
|
If STATE is nil, hide both `up-to-date' and `ignored' items.
|
2012-08-13 17:31:56 -04:00
|
|
|
|
|
|
|
|
|
Interactively, if `current-prefix-arg' is non-nil, set STATE to
|
2014-11-10 03:29:58 +02:00
|
|
|
|
state of item at point, if any."
|
2012-08-13 17:31:56 -04:00
|
|
|
|
(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)))))))
|
2014-11-10 03:29:58 +02:00
|
|
|
|
(if state
|
|
|
|
|
(message "Hiding items in state \"%s\"" state)
|
|
|
|
|
(message "Hiding up-to-date and ignored items"))
|
2008-06-28 07:30:47 +00:00
|
|
|
|
(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))
|
2012-08-13 17:31:56 -04:00
|
|
|
|
(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
|
2014-11-10 03:29:58 +02:00
|
|
|
|
;; symbol, a user-name, or nil.
|
|
|
|
|
(if state
|
|
|
|
|
(equal (vc-dir-fileinfo->state data) state)
|
|
|
|
|
(memq (vc-dir-fileinfo->state data) '(up-to-date ignored))))
|
2012-08-13 17:31:56 -04:00
|
|
|
|
(ewoc-delete vc-ewoc crt))
|
|
|
|
|
(setq crt prev)))))
|
|
|
|
|
|
|
|
|
|
(defalias 'vc-dir-hide-up-to-date 'vc-dir-hide-state)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2010-04-12 15:14:16 -04:00
|
|
|
|
(defun vc-dir-kill-line ()
|
|
|
|
|
"Remove the current line from display."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((crt (ewoc-locate vc-ewoc))
|
|
|
|
|
(inhibit-read-only t))
|
|
|
|
|
(ewoc-delete vc-ewoc crt)))
|
|
|
|
|
|
2008-10-27 07:21:43 +00:00
|
|
|
|
(defun vc-dir-printer (fileentry)
|
|
|
|
|
(vc-call-backend vc-dir-backend 'dir-printer fileentry))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(defun vc-dir-deduce-fileset (&optional state-model-only-files)
|
|
|
|
|
(let ((marked (vc-dir-marked-files))
|
|
|
|
|
files
|
|
|
|
|
only-files-list
|
|
|
|
|
state
|
|
|
|
|
model)
|
|
|
|
|
(if marked
|
|
|
|
|
(progn
|
|
|
|
|
(setq files marked)
|
|
|
|
|
(when state-model-only-files
|
|
|
|
|
(setq only-files-list (vc-dir-marked-only-files-and-states))))
|
|
|
|
|
(let ((crt (vc-dir-current-file)))
|
|
|
|
|
(setq files (list crt))
|
2008-06-27 23:29:15 +00:00
|
|
|
|
(when state-model-only-files
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(setq only-files-list (vc-dir-child-files-and-states)))))
|
|
|
|
|
|
|
|
|
|
(when state-model-only-files
|
|
|
|
|
(setq state (cdar only-files-list))
|
|
|
|
|
;; Check that all files are in a consistent state, since we use that
|
|
|
|
|
;; state to decide which operation to perform.
|
|
|
|
|
(dolist (crt (cdr only-files-list))
|
|
|
|
|
(unless (vc-compatible-state (cdr crt) state)
|
2009-03-20 13:56:42 +00:00
|
|
|
|
(error "When applying VC operations to multiple files, the files are required\nto be in similar VC states.\n%s in state %s clashes with %s in state %s"
|
2008-06-25 03:19:14 +00:00
|
|
|
|
(car crt) (cdr crt) (caar only-files-list) state)))
|
|
|
|
|
(setq only-files-list (mapcar 'car only-files-list))
|
|
|
|
|
(when (and state (not (eq state 'unregistered)))
|
|
|
|
|
(setq model (vc-checkout-model vc-dir-backend only-files-list))))
|
|
|
|
|
(list vc-dir-backend files only-files-list state model)))
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;;;###autoload
|
2008-06-29 12:50:20 +00:00
|
|
|
|
(defun vc-dir (dir &optional backend)
|
2009-04-10 14:19:12 +00:00
|
|
|
|
"Show the VC status for \"interesting\" files in and below DIR.
|
|
|
|
|
This allows you to mark files and perform VC operations on them.
|
|
|
|
|
The list omits files which are up to date, with no changes in your copy
|
|
|
|
|
or the repository, if there is nothing in particular to say about them.
|
|
|
|
|
|
|
|
|
|
Preparing the list of file status takes time; when the buffer
|
|
|
|
|
first appears, it has only the first few lines of summary information.
|
|
|
|
|
The file lines appear later.
|
|
|
|
|
|
2008-06-29 12:50:20 +00:00
|
|
|
|
Optional second argument BACKEND specifies the VC backend to use.
|
2009-04-10 14:19:12 +00:00
|
|
|
|
Interactively, a prefix argument means to ask for the backend.
|
|
|
|
|
|
|
|
|
|
These are the commands available for use in the file status buffer:
|
|
|
|
|
|
2009-12-05 00:24:03 +00:00
|
|
|
|
\\{vc-dir-mode-map}"
|
2009-04-10 14:19:12 +00:00
|
|
|
|
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list
|
2008-07-30 14:59:08 +00:00
|
|
|
|
;; When you hit C-x v d in a visited VC file,
|
|
|
|
|
;; the *vc-dir* buffer visits the directory under its truename;
|
|
|
|
|
;; therefore it makes sense to always do that.
|
|
|
|
|
;; Otherwise if you do C-x v d -> C-x C-f -> C-c v d
|
|
|
|
|
;; you may get a new *vc-dir* buffer, different from the original
|
2011-03-05 16:56:00 -05:00
|
|
|
|
(file-truename (read-directory-name "VC status for directory: "
|
2015-01-19 21:44:30 -08:00
|
|
|
|
(vc-root-dir) nil t
|
2011-03-05 16:56:00 -05:00
|
|
|
|
nil))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(if current-prefix-arg
|
|
|
|
|
(intern
|
|
|
|
|
(completing-read
|
|
|
|
|
"Use VC backend: "
|
2008-06-29 12:50:20 +00:00
|
|
|
|
(mapcar (lambda (b) (list (symbol-name b)))
|
|
|
|
|
vc-handled-backends)
|
|
|
|
|
nil t nil nil)))))
|
|
|
|
|
(unless backend
|
|
|
|
|
(setq backend (vc-responsible-backend dir)))
|
2010-05-18 20:01:24 -07:00
|
|
|
|
(let (pop-up-windows) ; based on cvs-examine; bug#6204
|
|
|
|
|
(pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(if (derived-mode-p 'vc-dir-mode)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(vc-dir-refresh)
|
2008-06-24 03:45:06 +00:00
|
|
|
|
;; FIXME: find a better way to pass the backend to `vc-dir-mode'.
|
|
|
|
|
(let ((use-vc-backend backend))
|
|
|
|
|
(vc-dir-mode))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(defun vc-default-dir-extra-headers (_backend _dir)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; Be loud by default to remind people to add code to display
|
|
|
|
|
;; backend specific headers.
|
|
|
|
|
;; XXX: change this to return nil before the release.
|
|
|
|
|
(concat
|
|
|
|
|
(propertize "Extra : " 'face 'font-lock-type-face)
|
|
|
|
|
(propertize "Please add backend specific headers here. It's easy!"
|
|
|
|
|
'face 'font-lock-warning-face)))
|
|
|
|
|
|
2009-02-11 06:36:32 +00:00
|
|
|
|
(defvar vc-dir-filename-mouse-map
|
2009-02-10 05:51:47 +00:00
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map [mouse-2] 'vc-dir-find-file-other-window)
|
|
|
|
|
map)
|
|
|
|
|
"Local keymap for visiting a file.")
|
|
|
|
|
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(defun vc-default-dir-printer (_backend fileentry)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
"Pretty print FILEENTRY."
|
|
|
|
|
;; If you change the layout here, change vc-dir-move-to-goal-column.
|
2009-02-11 06:36:32 +00:00
|
|
|
|
;; VC backends can implement backend specific versions of this
|
|
|
|
|
;; function. Changes here might need to be reflected in the
|
|
|
|
|
;; vc-BACKEND-dir-printer functions.
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(let* ((isdir (vc-dir-fileinfo->directory fileentry))
|
2008-06-24 03:45:06 +00:00
|
|
|
|
(state (if isdir "" (vc-dir-fileinfo->state fileentry)))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(filename (vc-dir-fileinfo->name fileentry)))
|
|
|
|
|
(insert
|
|
|
|
|
(propertize
|
|
|
|
|
(format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? ))
|
|
|
|
|
'face 'font-lock-type-face)
|
|
|
|
|
" "
|
|
|
|
|
(propertize
|
|
|
|
|
(format "%-20s" state)
|
|
|
|
|
'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face)
|
|
|
|
|
((memq state '(missing conflict)) 'font-lock-warning-face)
|
2011-05-22 15:36:07 -04:00
|
|
|
|
((eq state 'edited) 'font-lock-constant-face)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(t 'font-lock-variable-name-face))
|
|
|
|
|
'mouse-face 'highlight)
|
|
|
|
|
" "
|
|
|
|
|
(propertize
|
|
|
|
|
(format "%s" filename)
|
2008-06-24 03:45:06 +00:00
|
|
|
|
'face
|
|
|
|
|
(if isdir 'font-lock-comment-delimiter-face 'font-lock-function-name-face)
|
|
|
|
|
'help-echo
|
2008-06-27 23:29:15 +00:00
|
|
|
|
(if isdir
|
|
|
|
|
"Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu"
|
2008-06-24 03:45:06 +00:00
|
|
|
|
"File\nmouse-3: Pop-up menu")
|
2009-02-10 05:51:47 +00:00
|
|
|
|
'mouse-face 'highlight
|
2009-02-11 06:36:32 +00:00
|
|
|
|
'keymap vc-dir-filename-mouse-map))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(defun vc-default-extra-status-menu (_backend)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
2012-04-25 23:18:47 -04:00
|
|
|
|
(defun vc-default-status-fileinfo-extra (_backend _file)
|
2008-06-22 19:04:22 +00:00
|
|
|
|
"Default absence of extra information returned for a file."
|
|
|
|
|
nil)
|
|
|
|
|
|
2012-11-28 20:16:51 -05:00
|
|
|
|
|
|
|
|
|
;;; Support for desktop.el (adapted from what dired.el does).
|
|
|
|
|
|
|
|
|
|
(declare-function desktop-file-name "desktop" (filename dirname))
|
|
|
|
|
|
|
|
|
|
(defun vc-dir-desktop-buffer-misc-data (dirname)
|
|
|
|
|
"Auxiliary information to be saved in desktop file."
|
|
|
|
|
(cons (desktop-file-name default-directory dirname) vc-dir-backend))
|
|
|
|
|
|
Silence some vc compilation warnings
* lisp/vc/vc-arch.el (vc-exec-after): Declare.
(vc-switches): Autoload.
* lisp/vc/vc-bzr.el: No need to require vc when compiling.
(vc-exec-after, vc-set-async-update, vc-default-dir-printer)
(vc-resynch-buffer, vc-dir-refresh): Declare.
(vc-setup-buffer, vc-switches): Autoload.
* lisp/vc/vc-dir.el (desktop-missing-file-warning): Declare.
* lisp/vc/vc-mtn.el (vc-exec-after): Declare.
(vc-switches): Autoload.
* lisp/vc/vc-rcs.el (vc-expand-dirs, vc-switches)
(vc-tag-precondition, vc-buffer-sync, vc-rename-master): Autoload.
(vc-file-tree-walk): Declare.
* lisp/vc/vc-svn.el (vc-exec-after): Declare.
(vc-switches, vc-setup-buffer): Autoload.
* lisp/obsolete/vc-mcvs.el (vc-checkout, vc-switches, vc-default-revert):
Autoload.
(vc-resynch-buffer): Declare.
2013-05-28 00:01:59 -07:00
|
|
|
|
(defvar desktop-missing-file-warning)
|
|
|
|
|
|
2012-11-28 20:16:51 -05:00
|
|
|
|
(defun vc-dir-restore-desktop-buffer (_filename _buffername misc-data)
|
|
|
|
|
"Restore a `vc-dir' buffer specified in a desktop file."
|
|
|
|
|
(let ((dir (car misc-data))
|
|
|
|
|
(backend (cdr misc-data)))
|
|
|
|
|
(if (file-directory-p dir)
|
|
|
|
|
(progn
|
|
|
|
|
(vc-dir dir backend)
|
|
|
|
|
(current-buffer))
|
|
|
|
|
(message "Desktop: Directory %s no longer exists." dir)
|
|
|
|
|
(when desktop-missing-file-warning (sit-for 1))
|
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
|
|
(add-to-list 'desktop-buffer-mode-handlers
|
|
|
|
|
'(vc-dir-mode . vc-dir-restore-desktop-buffer))
|
|
|
|
|
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(provide 'vc-dir)
|
|
|
|
|
|
|
|
|
|
;;; vc-dir.el ends here
|