##// END OF EJS Templates
mq.el: add mq-new function.
Bryan O'Sullivan -
r4422:7b0d0ace default
parent child Browse files
Show More
@@ -64,6 +64,7 b''
64 64 (define-key mq-global-map "<" 'mq-pop-all)
65 65 (define-key mq-global-map "r" 'mq-refresh)
66 66 (define-key mq-global-map "e" 'mq-refresh-edit)
67 (define-key mq-global-map "i" 'mq-new)
67 68 (define-key mq-global-map "n" 'mq-next)
68 69 (define-key mq-global-map "p" 'mq-previous)
69 70 (define-key mq-global-map "t" 'mq-top)
@@ -80,12 +81,12 b''
80 81
81 82 ;;; Helper functions.
82 83
83 (defun mq-read-patch-name (&optional source prompt)
84 (defun mq-read-patch-name (&optional source prompt force)
84 85 "Read a patch name to use with a command.
85 86 May return nil, meaning \"use the default\"."
86 87 (let ((patches (split-string
87 88 (hg-chomp (hg-run0 (or source "qseries"))) "\n")))
88 (when current-prefix-arg
89 (when force
89 90 (completing-read (format "Patch%s: " (or prompt ""))
90 91 (map 'list 'cons patches patches)
91 92 nil
@@ -120,7 +121,8 b' May return nil, meaning \\"use the defaul'
120 121 (defun mq-push (&optional patch)
121 122 "Push patches until PATCH is reached.
122 123 If PATCH is nil, push at most one patch."
123 (interactive (list (mq-read-patch-name "qunapplied" " to push")))
124 (interactive (list (mq-read-patch-name "qunapplied" " to push"
125 current-prefix-arg)))
124 126 (let ((root (hg-root))
125 127 (prev-buf (current-buffer))
126 128 last-line ok)
@@ -158,7 +160,8 b' If PATCH is nil, push at most one patch.'
158 160 (defun mq-pop (&optional patch)
159 161 "Pop patches until PATCH is reached.
160 162 If PATCH is nil, pop at most one patch."
161 (interactive (list (mq-read-patch-name "qapplied" " to pop to")))
163 (interactive (list (mq-read-patch-name "qapplied" " to pop to"
164 current-prefix-arg)))
162 165 (let ((root (hg-root))
163 166 last-line ok)
164 167 (unless root
@@ -318,6 +321,22 b' Key bindings'
318 321 (cd root)))
319 322 (message "Type `C-c C-c' to finish editing and refresh the patch."))
320 323
324 (defun mq-new (name)
325 "Create a new empty patch named NAME.
326 The patch is applied on top of the current topmost patch.
327 With a prefix argument, forcibly create the patch even if the working
328 directory is modified."
329 (interactive (list (mq-read-patch-name "qseries" " to create" t)))
330 (message "Creating patch...")
331 (let ((ret (if current-prefix-arg
332 (hg-run "qnew" "-f" name)
333 (hg-run "qnew" name))))
334 (if (equal (car ret) 0)
335 (progn
336 (hg-update-mode-lines (buffer-file-name))
337 (message "Creating patch... done."))
338 (error "Creating patch... %s" (hg-chomp (cdr ret))))))
339
321 340
322 341 (provide 'mq)
323 342
General Comments 0
You need to be logged in to leave comments. Login now