[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r116999: Provide function for asking vc about projec
From: |
Daniel Colascione |
Subject: |
[Emacs-diffs] trunk r116999: Provide function for asking vc about project root |
Date: |
Sun, 20 Apr 2014 23:24:13 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 116999
revision-id: address@hidden
parent: address@hidden
committer: Daniel Colascione <address@hidden>
branch nick: trunk
timestamp: Sun 2014-04-20 16:24:04 -0700
message:
Provide function for asking vc about project root
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/vc/vc-hooks.el vchooks.el-20091113204419-o5vbwnq5f7feedwu-501
lisp/vc/vc.el vc.el-20091113204419-o5vbwnq5f7feedwu-502
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-04-20 02:34:22 +0000
+++ b/lisp/ChangeLog 2014-04-20 23:24:04 +0000
@@ -1,5 +1,13 @@
2014-04-20 Daniel Colascione <address@hidden>
+ * 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 <address@hidden>
+
* emacs-lisp/cl-macs.el (cl-the): Make `cl-the' assert its type
argument.
(cl--const-expr-val): cl--const-expr-val should macroexpand its
=== modified file 'lisp/vc/vc-hooks.el'
--- a/lisp/vc/vc-hooks.el 2014-01-01 07:43:34 +0000
+++ b/lisp/vc/vc-hooks.el 2014-04-20 23:24:04 +0000
@@ -190,6 +190,11 @@
(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 @@
(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.
=== modified file 'lisp/vc/vc.el'
--- a/lisp/vc/vc.el 2014-03-23 18:13:35 +0000
+++ b/lisp/vc/vc.el 2014-04-20 23:24:04 +0000
@@ -1879,6 +1879,19 @@
(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.
If the current file is named `F', the revision is named `F.~REV~'.
- [Emacs-diffs] trunk r116999: Provide function for asking vc about project root,
Daniel Colascione <=