Function: vc-mode-line

vc-mode-line is an interactive and byte-compiled function defined in vc-hooks.el.gz.

Signature

(vc-mode-line FILE &optional BACKEND)

Documentation

Set vc-mode(var)/vc-mode(fun) to display type of version control for FILE.

The value is set in the current buffer, which should be the buffer visiting FILE. If BACKEND is passed use it as the VC backend when computing the result.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-hooks.el.gz
(defun vc-mode-line (file &optional backend)
  "Set `vc-mode' to display type of version control for FILE.
The value is set in the current buffer, which should be the buffer
visiting FILE.
If BACKEND is passed use it as the VC backend when computing the result."
  (interactive (list buffer-file-name))
  (setq backend (or backend (vc-backend file)))
  (cond
   ((not backend)
    (setq vc-mode nil))
   ((null vc-display-status)
    (setq vc-mode (concat " " (symbol-name backend))))
   (t
    (let* ((ml-string (vc-call-backend backend 'mode-line-string file))
	   (ml-echo (get-text-property 0 'help-echo ml-string)))
      (setq vc-mode
	    (concat
	     " "
	     (propertize
	      ml-string
	      'mouse-face 'mode-line-highlight
	      'help-echo
	      (concat (or ml-echo
			  (format "File under the %s version control system"
				  backend))
		      "\nmouse-1: Version Control menu")
	      'local-map vc-mode-line-map))))
    ;; If the user is root, and the file is not owner-writable,
    ;; then pretend that we can't write it
    ;; even though we can (because root can write anything).
    ;; This way, even root cannot modify a file that isn't locked.
    (and (equal file buffer-file-name)
	 (not buffer-read-only)
	 (zerop (user-real-uid))
	 (zerop (logand (file-modes buffer-file-name) 128))
	 (setq buffer-read-only t))))
  (force-mode-line-update)
  backend)