Show More
@@ -39,8 +39,15 b'' | |||
|
39 | 39 | |
|
40 | 40 | ;;; Internal variables. |
|
41 | 41 | |
|
42 | (defvar mq-mode nil | |
|
43 | "Is this file managed by MQ?") | |
|
44 | (make-variable-buffer-local 'mq-mode) | |
|
45 | (put 'mq-mode 'permanent-local t) | |
|
46 | ||
|
42 | 47 | (defvar mq-patch-history nil) |
|
43 | 48 | |
|
49 | (defvar mq-top-patch '(nil)) | |
|
50 | ||
|
44 | 51 | (defvar mq-prev-buffer nil) |
|
45 | 52 | (make-variable-buffer-local 'mq-prev-buffer) |
|
46 | 53 | (put 'mq-prev-buffer 'permanent-local t) |
@@ -61,6 +68,8 b'' | |||
|
61 | 68 | (define-key mq-global-map "p" 'mq-previous) |
|
62 | 69 | (define-key mq-global-map "t" 'mq-top) |
|
63 | 70 | |
|
71 | (add-minor-mode 'mq-mode 'mq-mode) | |
|
72 | ||
|
64 | 73 | |
|
65 | 74 | ;;; Refresh edit mode keymap. |
|
66 | 75 | |
@@ -94,7 +103,8 b' May return nil, meaning \\"use the defaul' | |||
|
94 | 103 | (revert-buffer t t t) |
|
95 | 104 | (hg-restore-context ctx) |
|
96 | 105 | (message "Refreshing %s...done" (buffer-name)))))) |
|
97 |
(hg-update-mode-lines root) |
|
|
106 | (hg-update-mode-lines root) | |
|
107 | (mq-update-mode-lines root)) | |
|
98 | 108 | |
|
99 | 109 | (defun mq-last-line () |
|
100 | 110 | (goto-char (point-max)) |
@@ -234,6 +244,42 b' This would become the active patch if po' | |||
|
234 | 244 | (kill-buffer nil) |
|
235 | 245 | (switch-to-buffer buf)))) |
|
236 | 246 | |
|
247 | (defun mq-get-top (root) | |
|
248 | (let ((entry (assoc root mq-top-patch))) | |
|
249 | (if entry | |
|
250 | (cdr entry)))) | |
|
251 | ||
|
252 | (defun mq-set-top (root patch) | |
|
253 | (let ((entry (assoc root mq-top-patch))) | |
|
254 | (if entry | |
|
255 | (if patch | |
|
256 | (setcdr entry patch) | |
|
257 | (setq mq-top-patch (delq entry mq-top-patch))) | |
|
258 | (setq mq-top-patch (cons (cons root patch) mq-top-patch))))) | |
|
259 | ||
|
260 | (defun mq-update-mode-lines (root) | |
|
261 | (let ((cwd default-directory)) | |
|
262 | (cd root) | |
|
263 | (condition-case nil | |
|
264 | (mq-set-top root (mq-patch-info "qtop")) | |
|
265 | (error (mq-set-top root nil))) | |
|
266 | (cd cwd)) | |
|
267 | (let ((patch (mq-get-top root))) | |
|
268 | (save-excursion | |
|
269 | (dolist (buf (hg-buffers-visiting-repo root)) | |
|
270 | (set-buffer buf) | |
|
271 | (if mq-mode | |
|
272 | (setq mq-mode (or (and patch (concat " MQ:" patch)) " MQ"))))))) | |
|
273 | ||
|
274 | (defun mq-mode (&optional arg) | |
|
275 | "Minor mode for Mercurial repositories with an MQ patch queue" | |
|
276 | (interactive "i") | |
|
277 | (cond ((hg-root) | |
|
278 | (setq mq-mode (if (null arg) (not mq-mode) | |
|
279 | arg)) | |
|
280 | (mq-update-mode-lines (hg-root)))) | |
|
281 | (run-hooks 'mq-mode-hook)) | |
|
282 | ||
|
237 | 283 | (defun mq-edit-mode () |
|
238 | 284 | "Mode for editing the description of a patch. |
|
239 | 285 |
General Comments 0
You need to be logged in to leave comments.
Login now