annotate contrib/mq.el @ 25815:e71e5629e006

parser: separate actions for primary expression and prefix operator This will allow us to define both a primary expression, ":", and a prefix operator, ":y". The ambiguity will be resolved by the next patch. Prefix actions in elements table are adjusted as follows: original prefix primary prefix ----------------- -------- ----------------- ("group", 1, ")") -> n/a ("group", 1, ")") ("negate", 19) -> n/a ("negate", 19) ("symbol",) -> "symbol" n/a
author Yuya Nishihara <yuya@tcha.org>
date Sun, 05 Jul 2015 12:02:13 +0900
parents 7de7630053cb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1 ;;; mq.el --- Emacs support for Mercurial Queues
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
3 ;; Copyright (C) 2006 Bryan O'Sullivan
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
4
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
5 ;; Author: Bryan O'Sullivan <bos@serpentine.com>
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
6
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
7 ;; mq.el is free software; you can redistribute it and/or modify it
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 5468
diff changeset
8 ;; under the terms of the GNU General Public License version 2 or any
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 5468
diff changeset
9 ;; later version.
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
10
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
11 ;; mq.el is distributed in the hope that it will be useful, but
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
14 ;; General Public License for more details.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
15
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
16 ;; You should have received a copy of the GNU General Public License
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
17 ;; along with mq.el, GNU Emacs, or XEmacs; see the file COPYING (`C-h
15782
7de7630053cb Remove FSF mailing address from GPL headers
Martin Geisler <mg@aragost.com>
parents: 10263
diff changeset
18 ;; C-l'). If not, see <http://www.gnu.org/licenses/>.
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
19
5465
9873cbb134b2 mercurial.el, mq.el: remove runtime dependencies on CL package
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5081
diff changeset
20 (eval-when-compile (require 'cl))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
21 (require 'mercurial)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
22
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
23
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
24 (defcustom mq-mode-hook nil
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
25 "Hook run when a buffer enters mq-mode."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
26 :type 'sexp
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
27 :group 'mercurial)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
28
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
29 (defcustom mq-global-prefix "\C-cq"
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
30 "The global prefix for Mercurial Queues keymap bindings."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
31 :type 'sexp
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
32 :group 'mercurial)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
33
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
34 (defcustom mq-edit-mode-hook nil
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
35 "Hook run after a buffer is populated to edit a patch description."
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
36 :type 'sexp
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
37 :group 'mercurial)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
38
4427
b59611e9dd64 mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4426
diff changeset
39 (defcustom mq-edit-finish-hook nil
b59611e9dd64 mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4426
diff changeset
40 "Hook run before a patch description is finished up with."
b59611e9dd64 mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4426
diff changeset
41 :type 'sexp
b59611e9dd64 mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4426
diff changeset
42 :group 'mercurial)
b59611e9dd64 mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4426
diff changeset
43
4429
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
44 (defcustom mq-signoff-address nil
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
45 "Address with which to sign off on a patch."
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
46 :type 'string
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
47 :group 'mercurial)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
48
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
49
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
50 ;;; Internal variables.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
51
3370
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
52 (defvar mq-mode nil
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
53 "Is this file managed by MQ?")
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
54 (make-variable-buffer-local 'mq-mode)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
55 (put 'mq-mode 'permanent-local t)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
56
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
57 (defvar mq-patch-history nil)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
58
3370
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
59 (defvar mq-top-patch '(nil))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
60
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
61 (defvar mq-prev-buffer nil)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
62 (make-variable-buffer-local 'mq-prev-buffer)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
63 (put 'mq-prev-buffer 'permanent-local t)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
64
5466
87860c62e003 mq.el: declare variable mq-top
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5465
diff changeset
65 (defvar mq-top nil)
87860c62e003 mq.el: declare variable mq-top
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5465
diff changeset
66 (make-variable-buffer-local 'mq-top)
87860c62e003 mq.el: declare variable mq-top
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5465
diff changeset
67 (put 'mq-top 'permanent-local t)
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
68
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
69 ;;; Global keymap.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
70
5468
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
71 (defvar mq-global-map
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
72 (let ((map (make-sparse-keymap)))
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
73 (define-key map "." 'mq-push)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
74 (define-key map ">" 'mq-push-all)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
75 (define-key map "," 'mq-pop)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
76 (define-key map "<" 'mq-pop-all)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
77 (define-key map "=" 'mq-diff)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
78 (define-key map "r" 'mq-refresh)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
79 (define-key map "e" 'mq-refresh-edit)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
80 (define-key map "i" 'mq-new)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
81 (define-key map "n" 'mq-next)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
82 (define-key map "o" 'mq-signoff)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
83 (define-key map "p" 'mq-previous)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
84 (define-key map "s" 'mq-edit-series)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
85 (define-key map "t" 'mq-top)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
86 map))
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
87
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
88 (global-set-key mq-global-prefix mq-global-map)
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
89
3370
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
90 (add-minor-mode 'mq-mode 'mq-mode)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
91
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
92
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
93 ;;; Refresh edit mode keymap.
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
94
5468
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
95 (defvar mq-edit-mode-map
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
96 (let ((map (make-sparse-keymap)))
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
97 (define-key map "\C-c\C-c" 'mq-edit-finish)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
98 (define-key map "\C-c\C-k" 'mq-edit-kill)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
99 (define-key map "\C-c\C-s" 'mq-signoff)
24eb1bf8dd83 mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5466
diff changeset
100 map))
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
101
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
102
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
103 ;;; Helper functions.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
104
4422
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
105 (defun mq-read-patch-name (&optional source prompt force)
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
106 "Read a patch name to use with a command.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
107 May return nil, meaning \"use the default\"."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
108 (let ((patches (split-string
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
109 (hg-chomp (hg-run0 (or source "qseries"))) "\n")))
4422
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
110 (when force
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
111 (completing-read (format "Patch%s: " (or prompt ""))
5465
9873cbb134b2 mercurial.el, mq.el: remove runtime dependencies on CL package
NIIMI Satoshi <sa2c@sa2c.net>
parents: 5081
diff changeset
112 (mapcar (lambda (x) (cons x x)) patches)
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
113 nil
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
114 nil
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
115 nil
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
116 'mq-patch-history))))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
117
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
118 (defun mq-refresh-buffers (root)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
119 (save-excursion
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
120 (dolist (buf (hg-buffers-visiting-repo root))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
121 (when (not (verify-visited-file-modtime buf))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
122 (set-buffer buf)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
123 (let ((ctx (hg-buffer-context)))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
124 (message "Refreshing %s..." (buffer-name))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
125 (revert-buffer t t t)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
126 (hg-restore-context ctx)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
127 (message "Refreshing %s...done" (buffer-name))))))
3370
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
128 (hg-update-mode-lines root)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
129 (mq-update-mode-lines root))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
130
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
131 (defun mq-last-line ()
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
132 (goto-char (point-max))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
133 (beginning-of-line)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
134 (when (looking-at "^$")
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
135 (forward-line -1))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
136 (let ((bol (point)))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
137 (end-of-line)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
138 (let ((line (buffer-substring bol (point))))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
139 (when (> (length line) 0)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
140 line))))
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4429
diff changeset
141
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
142 (defun mq-push (&optional patch)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
143 "Push patches until PATCH is reached.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
144 If PATCH is nil, push at most one patch."
4422
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
145 (interactive (list (mq-read-patch-name "qunapplied" " to push"
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
146 current-prefix-arg)))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
147 (let ((root (hg-root))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
148 (prev-buf (current-buffer))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
149 last-line ok)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
150 (unless root
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
151 (error "Cannot push outside a repository!"))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
152 (hg-sync-buffers root)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
153 (let ((buf-name (format "MQ: Push %s" (or patch "next patch"))))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
154 (kill-buffer (get-buffer-create buf-name))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
155 (split-window-vertically)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
156 (other-window 1)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
157 (switch-to-buffer (get-buffer-create buf-name))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
158 (cd root)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
159 (message "Pushing...")
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
160 (setq ok (= 0 (apply 'call-process (hg-binary) nil t t "qpush"
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
161 (if patch (list patch))))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
162 last-line (mq-last-line))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
163 (let ((lines (count-lines (point-min) (point-max))))
4428
fa51e66117b4 mq.el: don't fill half the screen with a single line of output.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4427
diff changeset
164 (if (or (<= lines 1)
fa51e66117b4 mq.el: don't fill half the screen with a single line of output.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4427
diff changeset
165 (and (equal lines 2) (string-match "Now at:" last-line)))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
166 (progn
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
167 (kill-buffer (current-buffer))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
168 (delete-window))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
169 (hg-view-mode prev-buf))))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
170 (mq-refresh-buffers root)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
171 (sit-for 0)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
172 (when last-line
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
173 (if ok
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
174 (message "Pushing... %s" last-line)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
175 (error "Pushing... %s" last-line)))))
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4429
diff changeset
176
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
177 (defun mq-push-all ()
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
178 "Push patches until all are applied."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
179 (interactive)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
180 (mq-push "-a"))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
181
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
182 (defun mq-pop (&optional patch)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
183 "Pop patches until PATCH is reached.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
184 If PATCH is nil, pop at most one patch."
4422
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
185 (interactive (list (mq-read-patch-name "qapplied" " to pop to"
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
186 current-prefix-arg)))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
187 (let ((root (hg-root))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
188 last-line ok)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
189 (unless root
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
190 (error "Cannot pop outside a repository!"))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
191 (hg-sync-buffers root)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
192 (set-buffer (generate-new-buffer "qpop"))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
193 (cd root)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
194 (message "Popping...")
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
195 (setq ok (= 0 (apply 'call-process (hg-binary) nil t t "qpop"
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
196 (if patch (list patch))))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
197 last-line (mq-last-line))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
198 (kill-buffer (current-buffer))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
199 (mq-refresh-buffers root)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
200 (sit-for 0)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
201 (when last-line
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
202 (if ok
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
203 (message "Popping... %s" last-line)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
204 (error "Popping... %s" last-line)))))
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4429
diff changeset
205
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
206 (defun mq-pop-all ()
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
207 "Push patches until none are applied."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
208 (interactive)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
209 (mq-pop "-a"))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
210
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
211 (defun mq-refresh-internal (root &rest args)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
212 (hg-sync-buffers root)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
213 (let ((patch (mq-patch-info "qtop")))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
214 (message "Refreshing %s..." patch)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
215 (let ((ret (apply 'hg-run "qrefresh" args)))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
216 (if (equal (car ret) 0)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
217 (message "Refreshing %s... done." patch)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
218 (error "Refreshing %s... %s" patch (hg-chomp (cdr ret)))))))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
219
4426
807c7b99ff13 imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4425
diff changeset
220 (defun mq-refresh (&optional git)
807c7b99ff13 imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4425
diff changeset
221 "Refresh the topmost applied patch.
807c7b99ff13 imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4425
diff changeset
222 With a prefix argument, generate a git-compatible patch."
807c7b99ff13 imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4425
diff changeset
223 (interactive "P")
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
224 (let ((root (hg-root)))
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
225 (unless root
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
226 (error "Cannot refresh outside of a repository!"))
4426
807c7b99ff13 imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4425
diff changeset
227 (apply 'mq-refresh-internal root (if git '("--git")))))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
228
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
229 (defun mq-patch-info (cmd &optional msg)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
230 (let* ((ret (hg-run cmd))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
231 (info (hg-chomp (cdr ret))))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
232 (if (equal (car ret) 0)
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
233 (if msg
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
234 (message "%s patch: %s" msg info)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
235 info)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
236 (error "%s" info))))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
237
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
238 (defun mq-top ()
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
239 "Print the name of the topmost applied patch."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
240 (interactive)
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
241 (mq-patch-info "qtop" "Top"))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
242
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
243 (defun mq-next ()
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
244 "Print the name of the next patch to be pushed."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
245 (interactive)
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
246 (mq-patch-info "qnext" "Next"))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
247
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
248 (defun mq-previous ()
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
249 "Print the name of the first patch below the topmost applied patch.
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
250 This would become the active patch if popped to."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
251 (interactive)
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
252 (mq-patch-info "qprev" "Previous"))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
253
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
254 (defun mq-edit-finish ()
3010
06696f9c30c0 mq.el: Add comment to mq-edit-finish.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3009
diff changeset
255 "Finish editing the description of this patch, and refresh the patch."
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
256 (interactive)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
257 (unless (equal (mq-patch-info "qtop") mq-top)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
258 (error "Topmost patch has changed!"))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
259 (hg-sync-buffers hg-root)
4427
b59611e9dd64 mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4426
diff changeset
260 (run-hooks 'mq-edit-finish-hook)
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
261 (mq-refresh-internal hg-root "-m" (buffer-substring (point-min) (point-max)))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
262 (let ((buf mq-prev-buffer))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
263 (kill-buffer nil)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
264 (switch-to-buffer buf)))
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4429
diff changeset
265
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
266 (defun mq-edit-kill ()
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
267 "Kill the edit currently being prepared."
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
268 (interactive)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
269 (when (or (not (buffer-modified-p)) (y-or-n-p "Really kill this edit? "))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
270 (let ((buf mq-prev-buffer))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
271 (kill-buffer nil)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
272 (switch-to-buffer buf))))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
273
3370
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
274 (defun mq-get-top (root)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
275 (let ((entry (assoc root mq-top-patch)))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
276 (if entry
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
277 (cdr entry))))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
278
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
279 (defun mq-set-top (root patch)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
280 (let ((entry (assoc root mq-top-patch)))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
281 (if entry
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
282 (if patch
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
283 (setcdr entry patch)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
284 (setq mq-top-patch (delq entry mq-top-patch)))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
285 (setq mq-top-patch (cons (cons root patch) mq-top-patch)))))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
286
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
287 (defun mq-update-mode-lines (root)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
288 (let ((cwd default-directory))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
289 (cd root)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
290 (condition-case nil
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
291 (mq-set-top root (mq-patch-info "qtop"))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
292 (error (mq-set-top root nil)))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
293 (cd cwd))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
294 (let ((patch (mq-get-top root)))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
295 (save-excursion
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
296 (dolist (buf (hg-buffers-visiting-repo root))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
297 (set-buffer buf)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
298 (if mq-mode
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
299 (setq mq-mode (or (and patch (concat " MQ:" patch)) " MQ")))))))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
300
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
301 (defun mq-mode (&optional arg)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
302 "Minor mode for Mercurial repositories with an MQ patch queue"
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
303 (interactive "i")
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
304 (cond ((hg-root)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
305 (setq mq-mode (if (null arg) (not mq-mode)
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
306 arg))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
307 (mq-update-mode-lines (hg-root))))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
308 (run-hooks 'mq-mode-hook))
b7fe334ff4fb mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents: 3010
diff changeset
309
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
310 (defun mq-edit-mode ()
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
311 "Mode for editing the description of a patch.
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
312
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
313 Key bindings
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
314 ------------
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
315 \\[mq-edit-finish] use this description
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
316 \\[mq-edit-kill] abandon this description"
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
317 (interactive)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
318 (use-local-map mq-edit-mode-map)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
319 (set-syntax-table text-mode-syntax-table)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
320 (setq local-abbrev-table text-mode-abbrev-table
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
321 major-mode 'mq-edit-mode
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
322 mode-name "MQ-Edit")
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
323 (set-buffer-modified-p nil)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
324 (setq buffer-undo-list nil)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
325 (run-hooks 'text-mode-hook 'mq-edit-mode-hook))
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4429
diff changeset
326
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
327 (defun mq-refresh-edit ()
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
328 "Refresh the topmost applied patch, editing the patch description."
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
329 (interactive)
3009
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
330 (while mq-prev-buffer
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
331 (set-buffer mq-prev-buffer))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
332 (let ((root (hg-root))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
333 (prev-buffer (current-buffer))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
334 (patch (mq-patch-info "qtop")))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
335 (hg-sync-buffers root)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
336 (let ((buf-name (format "*MQ: Edit description of %s*" patch)))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
337 (switch-to-buffer (get-buffer-create buf-name))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
338 (when (= (point-min) (point-max))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
339 (set (make-local-variable 'hg-root) root)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
340 (set (make-local-variable 'mq-top) patch)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
341 (setq mq-prev-buffer prev-buffer)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
342 (insert (hg-run0 "qheader"))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
343 (goto-char (point-min)))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
344 (mq-edit-mode)
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
345 (cd root)))
e2bad806ccc3 mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3007
diff changeset
346 (message "Type `C-c C-c' to finish editing and refresh the patch."))
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
347
4422
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
348 (defun mq-new (name)
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
349 "Create a new empty patch named NAME.
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
350 The patch is applied on top of the current topmost patch.
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
351 With a prefix argument, forcibly create the patch even if the working
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
352 directory is modified."
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
353 (interactive (list (mq-read-patch-name "qseries" " to create" t)))
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
354 (message "Creating patch...")
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
355 (let ((ret (if current-prefix-arg
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
356 (hg-run "qnew" "-f" name)
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
357 (hg-run "qnew" name))))
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
358 (if (equal (car ret) 0)
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
359 (progn
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
360 (hg-update-mode-lines (buffer-file-name))
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
361 (message "Creating patch... done."))
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
362 (error "Creating patch... %s" (hg-chomp (cdr ret))))))
7b0d0acea6d6 mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3370
diff changeset
363
4423
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
364 (defun mq-edit-series ()
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
365 "Edit the MQ series file directly."
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
366 (interactive)
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
367 (let ((root (hg-root)))
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
368 (unless root
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
369 (error "Not in an MQ repository!"))
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
370 (find-file (concat root ".hg/patches/series"))))
2647f1fbc24c mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4422
diff changeset
371
4425
a57ac6049e22 mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4424
diff changeset
372 (defun mq-diff (&optional git)
a57ac6049e22 mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4424
diff changeset
373 "Display a diff of the topmost applied patch.
a57ac6049e22 mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4424
diff changeset
374 With a prefix argument, display a git-compatible diff."
a57ac6049e22 mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4424
diff changeset
375 (interactive "P")
4424
1d31302c4522 mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4423
diff changeset
376 (hg-view-output ((format "MQ: Diff of %s" (mq-patch-info "qtop")))
4425
a57ac6049e22 mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4424
diff changeset
377 (if git
a57ac6049e22 mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4424
diff changeset
378 (call-process (hg-binary) nil t nil "qdiff" "--git")
a57ac6049e22 mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4424
diff changeset
379 (call-process (hg-binary) nil t nil "qdiff"))
4424
1d31302c4522 mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4423
diff changeset
380 (diff-mode)
1d31302c4522 mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4423
diff changeset
381 (font-lock-fontify-buffer)))
1d31302c4522 mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4423
diff changeset
382
4429
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
383 (defun mq-signoff ()
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
384 "Sign off on the current patch, in the style used by the Linux kernel.
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
385 If the variable mq-signoff-address is non-nil, it will be used, otherwise
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
386 the value of the ui.username item from your hgrc will be used."
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
387 (interactive)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
388 (let ((was-editing (eq major-mode 'mq-edit-mode))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
389 signed)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
390 (unless was-editing
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
391 (mq-refresh-edit))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
392 (save-excursion
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
393 (let* ((user (or mq-signoff-address
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
394 (hg-run0 "debugconfig" "ui.username")))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
395 (signoff (concat "Signed-off-by: " user)))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
396 (if (search-forward signoff nil t)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
397 (message "You have already signed off on this patch.")
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
398 (goto-char (point-max))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
399 (let ((case-fold-search t))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
400 (if (re-search-backward "^Signed-off-by: " nil t)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
401 (forward-line 1)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
402 (insert "\n")))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
403 (insert signoff)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
404 (message "%s" signoff)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
405 (setq signed t))))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
406 (unless was-editing
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
407 (if signed
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
408 (mq-edit-finish)
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
409 (mq-edit-kill)))))
3b0f73edee57 mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents: 4428
diff changeset
410
3007
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
411
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
412 (provide 'mq)
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
413
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
414
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
415 ;;; Local Variables:
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
416 ;;; prompt-to-byte-compile: nil
425413d9ef59 Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
417 ;;; end: