[Top][All Lists]

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

Re: [Monotone-devel] emacs code for add-change-log-entry

From: Sebastian Rose
Subject: Re: [Monotone-devel] emacs code for add-change-log-entry
Date: Mon, 04 Dec 2006 16:24:33 +0100

Sorry. To small pieces of text accidentally thrown in...
Here is the corrected code:

(provide 'sr-monotone)

(defun mtn-get-parent-directory (child)
  "Retruns the parent directory or nil, if there is no parent.
Parent has always a trailing slash, or what ever is your systems
file separtor.
Improvements and suggestions to address@hidden"
  (if (file-regular-p child)
      (file-name-as-directory (file-name-directory child))
                                        ; this is else:
    (let ((child (file-name-as-directory child)))
      (let ((dir (file-name-as-directory (expand-file-name child)))
            (parent (file-truename
                     (file-name-as-directory (expand-file-name (concat
child ".."))))))
        (if (string= dir parent)

(defun mtn-add-change-log-entry()
  "Searches in buffers default-directory and above for a directory
named '_MTN'. If it exists, monotone-add-change-log-entry calls
add-change-log-entry interactively with apropriate arguments.
Otherwise interactively calls add-change-log-entry the normal way.
So one can just bind this function to the keys, that call
add-change-log-entry now, and it will work just fine.

Improvements and suggestions to address@hidden"
  (let ((filename buffer-file-name)
        (is-mtn-dir nil)
        (original-default-directory default-directory)
        (original-change-log-filename nil))
    (if (boundp 'change-log-default-name)
        (setq original-change-log-filename change-log-default-name))
          (if filename
                (catch 'done
                  (while (setq filename (mtn-get-parent-directory
                    (if (file-directory-p (concat filename "_MTN"))
                          (setq change-log-default-name "log")
                          (setq is-mtn-dir (concat filename "_MTN"))
                          (throw 'done 'is-mtn-dir)))))
                (if is-mtn-dir
                    (let ((default-directory is-mtn-dir))
                      (call-interactively 'add-change-log-entry))
                  (call-interactively 'add-change-log-entry))
      (setq default-directory original-default-directory)
      (setq change-log-default-name original-change-log-filename))))

Sebastian Rose <address@hidden>

reply via email to

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