emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vc-*-root finctions


From: Thien-Thi Nguyen
Subject: Re: vc-*-root finctions
Date: Wed, 20 Feb 2008 12:12:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

() Stefan Monnier <address@hidden>
() Tue, 19 Feb 2008 17:06:09 -0500

   Could you explain what the vc-*-root are supposed to do?

Would this blurb in vc.el Commentary explain things sufficiently?

;; - root (dir)
;;
;;   Return DIR's "root" directory, that is, a parent directory of
;;   DIR for which the same backend as used for DIR applies.  If no
;;   such parent exists, this function should return DIR.

I am using vc-BACKEND-root for (work-in-progress, see below)
`vc-status-mode' munging.

thi


_________________________________________________________________
(defun vc-status-mode ()
  "Major mode for VC Status.
Prepare the buffer to begin with the lines:

Directory: DEFAULT-DIRECTORY
  Updated: YYYY-MM-DD HH:MM:SS

If the `default-directory' is under the project's \"root\"
directory, make its root component a button that can run
command `vc-status' there.

Keys do not self-insert; instead they do different things:
\\{vc-status-mode-map}"
  (buffer-disable-undo)
  (erase-buffer)
  (let* ((backend (vc-responsible-backend default-directory))
         (find-root (vc-find-backend-function backend 'root))
         (root (if find-root
                   (funcall find-root default-directory)
                 default-directory)))
    (setq major-mode 'vc-status-mode)
    (setq mode-name (format "VC-%s Status" backend))
    (insert "Directory: ")
    (if (or (not root) (string= root default-directory))
        (insert root)
      (let* ((root-fn (directory-file-name root))
             (parent (file-name-directory root-fn))
             (leaf (file-name-nondirectory root-fn)))
        (insert parent)
        (if (featurep 'button)
            (insert-text-button
             leaf
             'root root
             'action (lambda (button)
                       (vc-status (button-get button 'root)))
             'follow-link t)
          (insert leaf))
        (insert (substring default-directory (1- (length root))))))
    (insert "\n")
    (set (make-local-variable 'vc-status)
         (ewoc-create #'vc-status-printer
                      (format-time-string "  Updated: %F %T\n")))
    (use-local-map vc-status-mode-map)
    (setq buffer-read-only t)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]