mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-17 18:37:33 +00:00
Provide function for asking vc about project root
This commit is contained in:
parent
0462bf34b3
commit
e8a77f2423
3 changed files with 30 additions and 4 deletions
|
|
@ -1,3 +1,11 @@
|
|||
2014-04-20 Daniel Colascione <dancol@dancol.org>
|
||||
|
||||
* vc/vc.el (vc-root-dir): New public autoloaded function for
|
||||
generically finding the current VC root.
|
||||
* vc/vc-hooks.el (vc-not-supported): New error.
|
||||
(vc-call-backend): Signal `vc-not-supported' instead of generic
|
||||
error.
|
||||
|
||||
2014-04-20 Daniel Colascione <dancol@dancol.org>
|
||||
|
||||
* emacs-lisp/cl-macs.el (cl-the): Make `cl-the' assert its type
|
||||
|
|
|
|||
|
|
@ -190,6 +190,11 @@ individually should stay local."
|
|||
(make-variable-buffer-local 'vc-mode)
|
||||
(put 'vc-mode 'permanent-local t)
|
||||
|
||||
;;; We signal this error when we try to do something a VC backend
|
||||
;;; doesn't support. Two arguments: the method that's not supported
|
||||
;;; and the backend
|
||||
(define-error 'vc-not-supported "VC method not implemented for backend")
|
||||
|
||||
(defun vc-mode (&optional _arg)
|
||||
;; Dummy function for C-h m
|
||||
"Version Control minor mode.
|
||||
|
|
@ -268,10 +273,10 @@ It is usually called via the `vc-call' macro."
|
|||
(setq f (vc-find-backend-function backend function-name))
|
||||
(push (cons function-name f) (get backend 'vc-functions)))
|
||||
(cond
|
||||
((null f)
|
||||
(error "Sorry, %s is not implemented for %s" function-name backend))
|
||||
((consp f) (apply (car f) (cdr f) args))
|
||||
(t (apply f args)))))
|
||||
((null f)
|
||||
(signal 'vc-not-supported (list function-name backend)))
|
||||
((consp f) (apply (car f) (cdr f) args))
|
||||
(t (apply f args)))))
|
||||
|
||||
(defmacro vc-call (fun file &rest args)
|
||||
"A convenience macro for calling VC backend functions.
|
||||
|
|
|
|||
|
|
@ -1878,6 +1878,19 @@ saving the buffer."
|
|||
t (list backend (list rootdir) working-revision) nil nil
|
||||
(called-interactively-p 'interactive))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun vc-root-dir ()
|
||||
"Return the root directory for the current VC tree.
|
||||
Return nil if the root directory cannot be identified."
|
||||
(let ((backend (vc-deduce-backend)))
|
||||
(if backend
|
||||
(condition-case err
|
||||
(vc-call-backend backend 'root default-directory)
|
||||
(vc-not-supported
|
||||
(unless (eq (cadr err) 'root)
|
||||
(signal (car err) (cdr err)))
|
||||
nil)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun vc-revision-other-window (rev)
|
||||
"Visit revision REV of the current file in another window.
|
||||
|
|
|
|||
Loading…
Reference in a new issue