##// END OF EJS Templates
mq.el: add mode-line hook
Brendan Cully -
r3370:b7fe334f default
parent child Browse files
Show More
@@ -39,8 +39,15 b''
39
39
40 ;;; Internal variables.
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 (defvar mq-patch-history nil)
47 (defvar mq-patch-history nil)
43
48
49 (defvar mq-top-patch '(nil))
50
44 (defvar mq-prev-buffer nil)
51 (defvar mq-prev-buffer nil)
45 (make-variable-buffer-local 'mq-prev-buffer)
52 (make-variable-buffer-local 'mq-prev-buffer)
46 (put 'mq-prev-buffer 'permanent-local t)
53 (put 'mq-prev-buffer 'permanent-local t)
@@ -61,6 +68,8 b''
61 (define-key mq-global-map "p" 'mq-previous)
68 (define-key mq-global-map "p" 'mq-previous)
62 (define-key mq-global-map "t" 'mq-top)
69 (define-key mq-global-map "t" 'mq-top)
63
70
71 (add-minor-mode 'mq-mode 'mq-mode)
72
64
73
65 ;;; Refresh edit mode keymap.
74 ;;; Refresh edit mode keymap.
66
75
@@ -94,7 +103,8 b' May return nil, meaning \\"use the defaul'
94 (revert-buffer t t t)
103 (revert-buffer t t t)
95 (hg-restore-context ctx)
104 (hg-restore-context ctx)
96 (message "Refreshing %s...done" (buffer-name))))))
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 (defun mq-last-line ()
109 (defun mq-last-line ()
100 (goto-char (point-max))
110 (goto-char (point-max))
@@ -234,6 +244,42 b' This would become the active patch if po'
234 (kill-buffer nil)
244 (kill-buffer nil)
235 (switch-to-buffer buf))))
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 (defun mq-edit-mode ()
283 (defun mq-edit-mode ()
238 "Mode for editing the description of a patch.
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