--- monotone.el.orig 2007-01-18 10:30:56.435594400 -0800 +++ monotone.el 2007-01-18 12:30:57.154344400 -0800 @@ -38,6 +38,8 @@ ;; -- Prefix arg on diff should probably prompt for parent ;; -- Have a version that diffs against branch-point +(require 'easymenu) + ;;; User vars: ;; These vars are likley to be changed by the user. @@ -356,7 +358,7 @@ (setq mtn-status (process-exit-status p))) ;; make the buffer nice. (goto-char (point-min)) - (view-mode) + (view-mode nil 'kill-buffer) (set-buffer-modified-p nil) ;; did we part on good terms? (when (and mtn-status (not (zerop mtn-status))) @@ -493,7 +495,7 @@ (defun monotone-vc-commit (args) "Do a commit." (interactive "p") - (setq args (monotone-arg-decode args)) + (setq args (monotone-arg-decode-soft args 'global)) (when (eq args 'file) (when (not (setq args buffer-file-name)) (error "Cant commit a buffer without a filename"))) @@ -610,17 +612,24 @@ (defun monotone-arg-decode (arg) "Decode the ARG into the scope monotone should work on." - (interactive "p") (monotone-msg "%s" arg) (cond ((member arg '(global tree file)) arg) ;; identity - ((= arg 1) 'global) - ((= arg 4) 'tree) - ((= arg 16) 'file) - (t (error "Prefix should be in (1,4,16) or (global tree file)")))) + ((or (null arg) + (= arg 1)) nil) + ((= arg 4) 'global) + ((= arg 16) 'tree) + ((= arg 64) 'file) + (t (error "Prefix should be in (1,4,16,64) or (global tree file)")))) ;; (monotone-arg-decode 4) ;; (monotone-arg-decode 'file) + +(defun monotone-arg-decode-soft (arg default) + "Decode the ARG into the scope monotone should work on." + (or (monotone-arg-decode arg) + default)) + ;;(defun monotone-arg-scope (scope filename) ;; "Turn the SCOPE and FILENAME into and arg for monotone." ;; (when (numberp scope) @@ -691,22 +700,22 @@ ;; MONOTONE BUG: when using "log ." the command must be run in that dir. ;; monotone.el runs its commands in the top dir so ;; just report it for now - (when (eq 'tree (monotone-arg-decode arg)) - (error "monotone subtree log is busted")) - ;; - (let ((cmds (list "log" "--no-merges")) - (depth monotone-log-depth)) - (when (and (numberp depth) (< 0 depth)) - (setq cmds (append cmds (list (format "--last=%d" depth))))) - (monotone-cmd-buf arg cmds) - (replace-buffer "*monotone log*"))) + (let ((what (monotone-arg-decode-soft arg 'file))) + (if (eq 'tree what) + (error "monotone subtree log is busted") + (let ((cmds (list "log" "--no-merges")) + (depth monotone-log-depth)) + (when (and (numberp depth) (< 0 depth)) + (setq cmds (append cmds (list (format "--last=%d" depth))))) + (monotone-cmd-buf what cmds) + (replace-buffer "*monotone log*"))))) ;; (monotone-vc-print-log) (defun monotone-vc-diff (&optional arg) "Print the diffs for this buffer. With prefix ARG, the global diffs." (interactive "p") (save-some-buffers) - (let* ((what (monotone-arg-decode arg)) + (let* ((what (monotone-arg-decode-soft arg 'file)) (target-buffer-name (format "*monotone diff %s*" (cond @@ -813,49 +822,27 @@ ;;;;;;;;;; -(defvar monotone-menu - (let ((map (make-sparse-keymap "Monotone"))) - ;; These need to be in reverse order - (define-key map [monotone-sync] - '(menu-item "DB Sync" monotone-sync)) - (define-key map [monotone-push] - '(menu-item "DB Push" monotone-push)) - (define-key map [monotone-pull] - '(menu-item "DB Pull" monotone-pull)) - (define-key map [monotone-separator] '("--")) - ;; - (define-key map [monotone-cat-rid] - '(menu-item "Cat this revision id" monotone-cat-revisionid)) - (define-key map [monotone-cat-mid] - '(menu-item "Cat this manifest id" monotone-cat-manifestid)) - (define-key map [monotone-cat-fid] - '(menu-item "Cat this file id" monotone-cat-fileid)) - (define-key map [monotone-separator] '("--")) - ;; - (define-key map [monotone-grab-id] - '(menu-item "Grab ID" monotone-grab-id)) - (define-key map [monotone-vc-status] - '(menu-item "Status" monotone-vc-status)) - (define-key map [monotone-vc-diff] - '(menu-item "Diff" monotone-vc-diff)) - (define-key map [monotone-vc-log] - '(menu-item "Log" monotone-vc-log)) - ;; - map)) - -;; People have reported problems with the menu. -;; dont report an error for now. -(let ((ok nil)) - (condition-case nil - (progn - (when monotone-menu-name - (define-key-after - (lookup-key global-map [menu-bar]) - [monotone] (cons monotone-menu-name monotone-menu))) - (setq ok t)) - (error nil)) - (when (not ok) - (message "Menu bar failed to load."))) +(easy-menu-define monotone-menu monotone-vc-prefix-map + "Menu for monotone mode." + (list + "Monotone" + ["Log" monotone-vc-print-log] + ["Diff" monotone-vc-diff] + ["Status" monotone-vc-status] + ["Grab ID" monotone-grab-id] + "---" + ["Cat this file id" monotone-cat-fileid] + ["Cat this manifest id" monotone-cat-manifestid] + ["Cat this revision id" monotone-cat-revisionid] + ["DB Pull" monotone-pull] + ["DB Push" monotone-push] + ["DB Sync" monotone-sync] + )) + +;; TODO: Figure out when to add the menu to a buffer. +(when nil + (when (fboundp 'easy-menu-add) + (easy-menu-add monotone-menu monotone-vc-prefix-map)))) (provide 'monotone) ;;; monotone.el ends here