aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Colascione2014-04-20 16:24:04 -0700
committerDaniel Colascione2014-04-20 16:24:04 -0700
commite8a77f2423f5e66e040a40a1d57aec640cc08dcf (patch)
treef8742934509660594c654bb90cd5c9f8150ba13f
parent0462bf34b3227cc4ac12edf35fbed7e72c311e77 (diff)
downloademacs-e8a77f2423f5e66e040a40a1d57aec640cc08dcf.tar.gz
emacs-e8a77f2423f5e66e040a40a1d57aec640cc08dcf.zip
Provide function for asking vc about project root
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/vc/vc-hooks.el13
-rw-r--r--lisp/vc/vc.el13
3 files changed, 30 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a1da41a5695..28b9c79079e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
12014-04-20 Daniel Colascione <dancol@dancol.org> 12014-04-20 Daniel Colascione <dancol@dancol.org>
2 2
3 * vc/vc.el (vc-root-dir): New public autoloaded function for
4 generically finding the current VC root.
5 * vc/vc-hooks.el (vc-not-supported): New error.
6 (vc-call-backend): Signal `vc-not-supported' instead of generic
7 error.
8
92014-04-20 Daniel Colascione <dancol@dancol.org>
10
3 * emacs-lisp/cl-macs.el (cl-the): Make `cl-the' assert its type 11 * emacs-lisp/cl-macs.el (cl-the): Make `cl-the' assert its type
4 argument. 12 argument.
5 (cl--const-expr-val): cl--const-expr-val should macroexpand its 13 (cl--const-expr-val): cl--const-expr-val should macroexpand its
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 1cd297ae43a..ce7f2c8f4ed 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -190,6 +190,11 @@ individually should stay local."
190(make-variable-buffer-local 'vc-mode) 190(make-variable-buffer-local 'vc-mode)
191(put 'vc-mode 'permanent-local t) 191(put 'vc-mode 'permanent-local t)
192 192
193;;; We signal this error when we try to do something a VC backend
194;;; doesn't support. Two arguments: the method that's not supported
195;;; and the backend
196(define-error 'vc-not-supported "VC method not implemented for backend")
197
193(defun vc-mode (&optional _arg) 198(defun vc-mode (&optional _arg)
194 ;; Dummy function for C-h m 199 ;; Dummy function for C-h m
195 "Version Control minor mode. 200 "Version Control minor mode.
@@ -268,10 +273,10 @@ It is usually called via the `vc-call' macro."
268 (setq f (vc-find-backend-function backend function-name)) 273 (setq f (vc-find-backend-function backend function-name))
269 (push (cons function-name f) (get backend 'vc-functions))) 274 (push (cons function-name f) (get backend 'vc-functions)))
270 (cond 275 (cond
271 ((null f) 276 ((null f)
272 (error "Sorry, %s is not implemented for %s" function-name backend)) 277 (signal 'vc-not-supported (list function-name backend)))
273 ((consp f) (apply (car f) (cdr f) args)) 278 ((consp f) (apply (car f) (cdr f) args))
274 (t (apply f args))))) 279 (t (apply f args)))))
275 280
276(defmacro vc-call (fun file &rest args) 281(defmacro vc-call (fun file &rest args)
277 "A convenience macro for calling VC backend functions. 282 "A convenience macro for calling VC backend functions.
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 305cc6b561e..5491d67e700 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1879,6 +1879,19 @@ saving the buffer."
1879 (called-interactively-p 'interactive)))))) 1879 (called-interactively-p 'interactive))))))
1880 1880
1881;;;###autoload 1881;;;###autoload
1882(defun vc-root-dir ()
1883 "Return the root directory for the current VC tree.
1884Return nil if the root directory cannot be identified."
1885 (let ((backend (vc-deduce-backend)))
1886 (if backend
1887 (condition-case err
1888 (vc-call-backend backend 'root default-directory)
1889 (vc-not-supported
1890 (unless (eq (cadr err) 'root)
1891 (signal (car err) (cdr err)))
1892 nil)))))
1893
1894;;;###autoload
1882(defun vc-revision-other-window (rev) 1895(defun vc-revision-other-window (rev)
1883 "Visit revision REV of the current file in another window. 1896 "Visit revision REV of the current file in another window.
1884If the current file is named `F', the revision is named `F.~REV~'. 1897If the current file is named `F', the revision is named `F.~REV~'.