Mercurial > dotfiles
annotate .elisp/mercurial.el @ 12:d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Wed, 03 Dec 2008 22:34:01 -0600 |
parents | |
children |
rev | line source |
---|---|
12
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 ;;; mercurial.el --- Emacs support for the Mercurial distributed SCM |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 ;; Copyright (C) 2005, 2006 Bryan O'Sullivan |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 ;; Author: Bryan O'Sullivan <bos@serpentine.com> |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 ;; mercurial.el is free software; you can redistribute it and/or |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 ;; modify it under the terms of version 2 of the GNU General Public |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 ;; License as published by the Free Software Foundation. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 ;; mercurial.el is distributed in the hope that it will be useful, but |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 ;; General Public License for more details. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 ;; You should have received a copy of the GNU General Public License |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 ;; along with mercurial.el, GNU Emacs, or XEmacs; see the file COPYING |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 ;; (`C-h C-l'). If not, write to the Free Software Foundation, Inc., |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 ;; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 ;;; Commentary: |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 ;; mercurial.el builds upon Emacs's VC mode to provide flexible |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 ;; integration with the Mercurial distributed SCM tool. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 ;; To get going as quickly as possible, load mercurial.el into Emacs and |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 ;; type `C-c h h'; this runs hg-help-overview, which prints a helpful |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 ;; usage overview. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 ;; Much of the inspiration for mercurial.el comes from Rajesh |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 ;; Vaidheeswarran's excellent p4.el, which does an admirably thorough |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 ;; job for the commercial Perforce SCM product. In fact, substantial |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 ;; chunks of code are adapted from p4.el. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 ;; This code has been developed under XEmacs 21.5, and may not work as |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 ;; well under GNU Emacs (albeit tested under 21.4). Patches to |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 ;; enhance the portability of this code, fix bugs, and add features |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 ;; are most welcome. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 ;; As of version 22.3, GNU Emacs's VC mode has direct support for |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 ;; Mercurial, so this package may not prove as useful there. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 ;; Please send problem reports and suggestions to bos@serpentine.com. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 ;;; Code: |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 (eval-when-compile (require 'cl)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 (require 'diff-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 (require 'easymenu) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 (require 'executable) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 (require 'vc) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 (defmacro hg-feature-cond (&rest clauses) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 "Test CLAUSES for feature at compile time. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 Each clause is (FEATURE BODY...)." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 (dolist (x clauses) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 (let ((feature (car x)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 (body (cdr x))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 (when (or (eq feature t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 (featurep feature)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 (return (cons 'progn body)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 ;;; XEmacs has view-less, while GNU Emacs has view. Joy. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 (hg-feature-cond |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
68 (xemacs (require 'view-less)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 (t (require 'view))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 ;;; Variables accessible through the custom system. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 (defgroup mercurial nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 "Mercurial distributed SCM." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
76 :group 'tools) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 (defcustom hg-binary |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 (or (executable-find "hg") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 (dolist (path '("~/bin/hg" "/usr/bin/hg" "/usr/local/bin/hg")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
81 (when (file-executable-p path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 (return path)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 "The path to Mercurial's hg executable." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 :type '(file :must-match t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
87 (defcustom hg-mode-hook nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
88 "Hook run when a buffer enters hg-mode." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
89 :type 'sexp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
90 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
91 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
92 (defcustom hg-commit-mode-hook nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
93 "Hook run when a buffer is created to prepare a commit." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
94 :type 'sexp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
95 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 (defcustom hg-pre-commit-hook nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
98 "Hook run before a commit is performed. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
99 If you want to prevent the commit from proceeding, raise an error." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
100 :type 'sexp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
101 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
102 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 (defcustom hg-log-mode-hook nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 "Hook run after a buffer is filled with log information." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
105 :type 'sexp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
106 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
107 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 (defcustom hg-global-prefix "\C-ch" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
109 "The global prefix for Mercurial keymap bindings." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
110 :type 'sexp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
111 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
112 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
113 (defcustom hg-commit-allow-empty-message nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
114 "Whether to allow changes to be committed with empty descriptions." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
115 :type 'boolean |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
116 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
117 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
118 (defcustom hg-commit-allow-empty-file-list nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
119 "Whether to allow changes to be committed without any modified files." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
120 :type 'boolean |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
121 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
122 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
123 (defcustom hg-rev-completion-limit 100 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
124 "The maximum number of revisions that hg-read-rev will offer to complete. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
125 This affects memory usage and performance when prompting for revisions |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
126 in a repository with a lot of history." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
127 :type 'integer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
128 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
129 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
130 (defcustom hg-log-limit 50 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
131 "The maximum number of revisions that hg-log will display." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
132 :type 'integer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
133 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
134 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
135 (defcustom hg-update-modeline t |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
136 "Whether to update the modeline with the status of a file after every save. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
137 Set this to nil on platforms with poor process management, such as Windows." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
138 :type 'boolean |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
139 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 (defcustom hg-incoming-repository "default" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 "The repository from which changes are pulled from by default. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 This should be a symbolic repository name, since it is used for all |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 repository-related commands." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
145 :type 'string |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
146 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
147 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
148 (defcustom hg-outgoing-repository "default-push" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 "The repository to which changes are pushed to by default. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
150 This should be a symbolic repository name, since it is used for all |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
151 repository-related commands." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
152 :type 'string |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
153 :group 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
156 ;;; Other variables. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 (defvar hg-mode nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
159 "Is this file managed by Mercurial?") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
160 (make-variable-buffer-local 'hg-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
161 (put 'hg-mode 'permanent-local t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
162 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
163 (defvar hg-status nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
164 (make-variable-buffer-local 'hg-status) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
165 (put 'hg-status 'permanent-local t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
166 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
167 (defvar hg-prev-buffer nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
168 (make-variable-buffer-local 'hg-prev-buffer) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
169 (put 'hg-prev-buffer 'permanent-local t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
170 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
171 (defvar hg-root nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
172 (make-variable-buffer-local 'hg-root) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
173 (put 'hg-root 'permanent-local t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
174 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
175 (defvar hg-view-mode nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
176 (make-variable-buffer-local 'hg-view-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
177 (put 'hg-view-mode 'permanent-local t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
178 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
179 (defvar hg-view-file-name nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
180 (make-variable-buffer-local 'hg-view-file-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
181 (put 'hg-view-file-name 'permanent-local t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
182 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
183 (defvar hg-output-buffer-name "*Hg*" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
184 "The name to use for Mercurial output buffers.") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
185 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
186 (defvar hg-file-history nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
187 (defvar hg-repo-history nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
188 (defvar hg-rev-history nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
189 (defvar hg-repo-completion-table nil) ; shut up warnings |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
190 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
191 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
192 ;;; Random constants. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
193 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
194 (defconst hg-commit-message-start |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
195 "--- Enter your commit message. Type `C-c C-c' to commit. ---\n") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
196 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
197 (defconst hg-commit-message-end |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
198 "--- Files in bold will be committed. Click to toggle selection. ---\n") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
199 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
200 (defconst hg-state-alist |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
201 '((?M . modified) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
202 (?A . added) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
203 (?R . removed) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
204 (?! . deleted) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
205 (?C . normal) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
206 (?I . ignored) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
207 (?? . nil))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
208 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
209 ;;; hg-mode keymap. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
210 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
211 (defvar hg-prefix-map |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
212 (let ((map (make-sparse-keymap))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
213 (hg-feature-cond (xemacs (set-keymap-name map 'hg-prefix-map))) ; XEmacs |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
214 (set-keymap-parent map vc-prefix-map) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
215 (define-key map "=" 'hg-diff) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
216 (define-key map "c" 'hg-undo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
217 (define-key map "g" 'hg-annotate) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
218 (define-key map "i" 'hg-add) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
219 (define-key map "l" 'hg-log) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
220 (define-key map "n" 'hg-commit-start) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
221 ;; (define-key map "r" 'hg-update) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
222 (define-key map "u" 'hg-revert-buffer) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
223 (define-key map "~" 'hg-version-other-window) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
224 map) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
225 "This keymap overrides some default vc-mode bindings.") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
226 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
227 (defvar hg-mode-map |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
228 (let ((map (make-sparse-keymap))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
229 (define-key map "\C-xv" hg-prefix-map) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
230 map)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
231 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
232 (add-minor-mode 'hg-mode 'hg-mode hg-mode-map) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
233 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
234 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
235 ;;; Global keymap. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
236 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
237 (defvar hg-global-map |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
238 (let ((map (make-sparse-keymap))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
239 (define-key map "," 'hg-incoming) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
240 (define-key map "." 'hg-outgoing) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
241 (define-key map "<" 'hg-pull) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
242 (define-key map "=" 'hg-diff-repo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 (define-key map ">" 'hg-push) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
244 (define-key map "?" 'hg-help-overview) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
245 (define-key map "A" 'hg-addremove) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
246 (define-key map "U" 'hg-revert) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
247 (define-key map "a" 'hg-add) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
248 (define-key map "c" 'hg-commit-start) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
249 (define-key map "f" 'hg-forget) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
250 (define-key map "h" 'hg-help-overview) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
251 (define-key map "i" 'hg-init) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
252 (define-key map "l" 'hg-log-repo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
253 (define-key map "r" 'hg-root) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
254 (define-key map "s" 'hg-status) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
255 (define-key map "u" 'hg-update) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
256 map)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
257 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
258 (global-set-key hg-global-prefix hg-global-map) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
259 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
260 ;;; View mode keymap. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
261 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
262 (defvar hg-view-mode-map |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
263 (let ((map (make-sparse-keymap))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
264 (hg-feature-cond (xemacs (set-keymap-name map 'hg-view-mode-map))) ; XEmacs |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
265 (define-key map (hg-feature-cond (xemacs [button2]) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
266 (t [mouse-2])) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
267 'hg-buffer-mouse-clicked) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
268 map)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
269 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
270 (add-minor-mode 'hg-view-mode "" hg-view-mode-map) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
271 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
272 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
273 ;;; Commit mode keymaps. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
274 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
275 (defvar hg-commit-mode-map |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
276 (let ((map (make-sparse-keymap))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
277 (define-key map "\C-c\C-c" 'hg-commit-finish) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
278 (define-key map "\C-c\C-k" 'hg-commit-kill) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
279 (define-key map "\C-xv=" 'hg-diff-repo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
280 map)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
281 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
282 (defvar hg-commit-mode-file-map |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
283 (let ((map (make-sparse-keymap))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
284 (define-key map (hg-feature-cond (xemacs [button2]) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
285 (t [mouse-2])) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
286 'hg-commit-mouse-clicked) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
287 (define-key map " " 'hg-commit-toggle-file) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
288 (define-key map "\r" 'hg-commit-toggle-file) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
289 map)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
290 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
291 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
292 ;;; Convenience functions. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
293 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
294 (defsubst hg-binary () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
295 (if hg-binary |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
296 hg-binary |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
297 (error "No `hg' executable found!"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
298 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
299 (defsubst hg-replace-in-string (str regexp newtext &optional literal) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
300 "Replace all matches in STR for REGEXP with NEWTEXT string. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
301 Return the new string. Optional LITERAL non-nil means do a literal |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
302 replacement. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
303 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
304 This function bridges yet another pointless impedance gap between |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
305 XEmacs and GNU Emacs." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
306 (hg-feature-cond |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
307 (xemacs (replace-in-string str regexp newtext literal)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
308 (t (replace-regexp-in-string regexp newtext str nil literal)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
309 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
310 (defsubst hg-strip (str) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
311 "Strip leading and trailing blank lines from a string." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
312 (hg-replace-in-string (hg-replace-in-string str "[\r\n][ \t\r\n]*\\'" "") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
313 "\\`[ \t\r\n]*[\r\n]" "")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
314 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
315 (defsubst hg-chomp (str) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
316 "Strip trailing newlines from a string." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
317 (hg-replace-in-string str "[\r\n]+\\'" "")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
318 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
319 (defun hg-run-command (command &rest args) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
320 "Run the shell command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT). |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
321 The list ARGS contains a list of arguments to pass to the command." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
322 (let* (exit-code |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
323 (output |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
324 (with-output-to-string |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
325 (with-current-buffer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
326 standard-output |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
327 (setq exit-code |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
328 (apply 'call-process command nil t nil args)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
329 (cons exit-code output))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
330 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
331 (defun hg-run (command &rest args) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
332 "Run the Mercurial command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT)." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
333 (apply 'hg-run-command (hg-binary) command args)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
334 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
335 (defun hg-run0 (command &rest args) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
336 "Run the Mercurial command COMMAND, returning its output. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
337 If the command does not exit with a zero status code, raise an error." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
338 (let ((res (apply 'hg-run-command (hg-binary) command args))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
339 (if (not (eq (car res) 0)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
340 (error "Mercurial command failed %s - exit code %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
341 (cons command args) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
342 (car res)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
343 (cdr res)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
344 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
345 (defmacro hg-do-across-repo (path &rest body) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
346 (let ((root-name (make-symbol "root-")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
347 (buf-name (make-symbol "buf-"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
348 `(let ((,root-name (hg-root ,path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
349 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
350 (dolist (,buf-name (buffer-list)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
351 (set-buffer ,buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
352 (when (and hg-status (equal (hg-root buffer-file-name) ,root-name)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
353 ,@body)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
354 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
355 (put 'hg-do-across-repo 'lisp-indent-function 1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
356 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
357 (defun hg-sync-buffers (path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
358 "Sync buffers visiting PATH with their on-disk copies. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
359 If PATH is not being visited, but is under the repository root, sync |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
360 all buffers visiting files in the repository." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
361 (let ((buf (find-buffer-visiting path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
362 (if buf |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
363 (with-current-buffer buf |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
364 (vc-buffer-sync)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
365 (hg-do-across-repo path |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
366 (vc-buffer-sync))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
367 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
368 (defun hg-buffer-commands (pnt) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
369 "Use the properties of a character to do something sensible." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
370 (interactive "d") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
371 (let ((rev (get-char-property pnt 'rev)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
372 (file (get-char-property pnt 'file))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
373 (cond |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
374 (file |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
375 (find-file-other-window file)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
376 (rev |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
377 (hg-diff hg-view-file-name rev rev)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
378 ((message "I don't know how to do that yet"))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
379 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
380 (defsubst hg-event-point (event) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
381 "Return the character position of the mouse event EVENT." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
382 (hg-feature-cond (xemacs (event-point event)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
383 (t (posn-point (event-start event))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
384 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
385 (defsubst hg-event-window (event) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
386 "Return the window over which mouse event EVENT occurred." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
387 (hg-feature-cond (xemacs (event-window event)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
388 (t (posn-window (event-start event))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
389 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
390 (defun hg-buffer-mouse-clicked (event) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
391 "Translate the mouse clicks in a HG log buffer to character events. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
392 These are then handed off to `hg-buffer-commands'. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
393 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
394 Handle frickin' frackin' gratuitous event-related incompatibilities." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
395 (interactive "e") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
396 (select-window (hg-event-window event)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
397 (hg-buffer-commands (hg-event-point event))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
398 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
399 (defsubst hg-abbrev-file-name (file) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
400 "Portable wrapper around abbreviate-file-name." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
401 (hg-feature-cond (xemacs (abbreviate-file-name file t)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
402 (t (abbreviate-file-name file)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
403 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
404 (defun hg-read-file-name (&optional prompt default) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
405 "Read a file or directory name, or a pattern, to use with a command." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
406 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
407 (while hg-prev-buffer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
408 (set-buffer hg-prev-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
409 (let ((path (or default |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
410 (buffer-file-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
411 (expand-file-name default-directory)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
412 (if (or (not path) current-prefix-arg) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
413 (expand-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
414 (eval (list* 'read-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
415 (format "File, directory or pattern%s: " |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
416 (or prompt "")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
417 (and path (file-name-directory path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
418 nil nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
419 (and path (file-name-nondirectory path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
420 (hg-feature-cond |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
421 (xemacs (cons (quote 'hg-file-history) nil)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
422 (t nil))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
423 path)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
424 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
425 (defun hg-read-number (&optional prompt default) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
426 "Read a integer value." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
427 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
428 (if (or (not default) current-prefix-arg) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
429 (string-to-number |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
430 (eval (list* 'read-string |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
431 (or prompt "") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
432 (if default (cons (format "%d" default) nil) nil)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
433 default))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
434 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
435 (defun hg-read-config () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
436 "Return an alist of (key . value) pairs of Mercurial config data. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
437 Each key is of the form (section . name)." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
438 (let (items) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
439 (dolist (line (split-string (hg-chomp (hg-run0 "debugconfig")) "\n") items) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
440 (string-match "^\\([^=]*\\)=\\(.*\\)" line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
441 (let* ((left (substring line (match-beginning 1) (match-end 1))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
442 (right (substring line (match-beginning 2) (match-end 2))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
443 (key (split-string left "\\.")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
444 (value (hg-replace-in-string right "\\\\n" "\n" t))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
445 (setq items (cons (cons (cons (car key) (cadr key)) value) items)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
446 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
447 (defun hg-config-section (section config) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
448 "Return an alist of (name . value) pairs for SECTION of CONFIG." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
449 (let (items) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
450 (dolist (item config items) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
451 (when (equal (caar item) section) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
452 (setq items (cons (cons (cdar item) (cdr item)) items)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
453 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
454 (defun hg-string-starts-with (sub str) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
455 "Indicate whether string STR starts with the substring or character SUB." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
456 (if (not (stringp sub)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
457 (and (> (length str) 0) (equal (elt str 0) sub)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
458 (let ((sub-len (length sub))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
459 (and (<= sub-len (length str)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
460 (string= sub (substring str 0 sub-len)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
461 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
462 (defun hg-complete-repo (string predicate all) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
463 "Attempt to complete a repository name. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
464 We complete on either symbolic names from Mercurial's config or real |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
465 directory names from the file system. We do not penalise URLs." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
466 (or (if all |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
467 (all-completions string hg-repo-completion-table predicate) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
468 (try-completion string hg-repo-completion-table predicate)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
469 (let* ((str (expand-file-name string)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
470 (dir (file-name-directory str)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
471 (file (file-name-nondirectory str))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
472 (if all |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
473 (let (completions) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
474 (dolist (name (delete "./" (file-name-all-completions file dir)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
475 completions) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
476 (let ((path (concat dir name))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
477 (when (file-directory-p path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
478 (setq completions (cons name completions)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
479 (let ((comp (file-name-completion file dir))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
480 (if comp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
481 (hg-abbrev-file-name (concat dir comp)))))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
482 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
483 (defun hg-read-repo-name (&optional prompt initial-contents default) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
484 "Read the location of a repository." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
485 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
486 (while hg-prev-buffer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
487 (set-buffer hg-prev-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
488 (let (hg-repo-completion-table) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
489 (if current-prefix-arg |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
490 (progn |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
491 (dolist (path (hg-config-section "paths" (hg-read-config))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
492 (setq hg-repo-completion-table |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
493 (cons (cons (car path) t) hg-repo-completion-table)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
494 (unless (hg-string-starts-with (hg-feature-cond |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
495 (xemacs directory-sep-char) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
496 (t ?/)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
497 (cdr path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
498 (setq hg-repo-completion-table |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
499 (cons (cons (cdr path) t) hg-repo-completion-table)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
500 (completing-read (format "Repository%s: " (or prompt "")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
501 'hg-complete-repo |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
502 nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
503 nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
504 initial-contents |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
505 'hg-repo-history |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
506 default)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
507 default)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
508 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
509 (defun hg-read-rev (&optional prompt default) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
510 "Read a revision or tag, offering completions." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
511 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
512 (while hg-prev-buffer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
513 (set-buffer hg-prev-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
514 (let ((rev (or default "tip"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
515 (if current-prefix-arg |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
516 (let ((revs (split-string |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
517 (hg-chomp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
518 (hg-run0 "-q" "log" "-l" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
519 (format "%d" hg-rev-completion-limit))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
520 "[\n:]"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
521 (dolist (line (split-string (hg-chomp (hg-run0 "tags")) "\n")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
522 (setq revs (cons (car (split-string line "\\s-")) revs))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
523 (completing-read (format "Revision%s (%s): " |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
524 (or prompt "") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
525 (or default "tip")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
526 (mapcar (lambda (x) (cons x x)) revs) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
527 nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
528 nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
529 nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
530 'hg-rev-history |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
531 (or default "tip"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
532 rev)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
533 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
534 (defun hg-parents-for-mode-line (root) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
535 "Format the parents of the working directory for the mode line." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
536 (let ((parents (split-string (hg-chomp |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
537 (hg-run0 "--cwd" root "parents" "--template" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
538 "{rev}\n")) "\n"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
539 (mapconcat 'identity parents "+"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
540 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
541 (defun hg-buffers-visiting-repo (&optional path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
542 "Return a list of buffers visiting the repository containing PATH." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
543 (let ((root-name (hg-root (or path (buffer-file-name)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
544 bufs) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
545 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
546 (dolist (buf (buffer-list) bufs) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
547 (set-buffer buf) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
548 (let ((name (buffer-file-name))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
549 (when (and hg-status name (equal (hg-root name) root-name)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
550 (setq bufs (cons buf bufs)))))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
551 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
552 (defun hg-update-mode-lines (path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
553 "Update the mode lines of all buffers visiting the same repository as PATH." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
554 (let* ((root (hg-root path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
555 (parents (hg-parents-for-mode-line root))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
556 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
557 (dolist (info (hg-path-status |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
558 root |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
559 (mapcar |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
560 (function |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
561 (lambda (buf) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
562 (substring (buffer-file-name buf) (length root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
563 (hg-buffers-visiting-repo root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
564 (let* ((name (car info)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
565 (status (cdr info)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
566 (buf (find-buffer-visiting (concat root name)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
567 (when buf |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
568 (set-buffer buf) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
569 (hg-mode-line-internal status parents))))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
570 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
571 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
572 ;;; View mode bits. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
573 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
574 (defun hg-exit-view-mode (buf) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
575 "Exit from hg-view-mode. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
576 We delete the current window if entering hg-view-mode split the |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
577 current frame." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
578 (when (and (eq buf (current-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
579 (> (length (window-list)) 1)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
580 (delete-window)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
581 (when (buffer-live-p buf) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
582 (kill-buffer buf))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
583 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
584 (defun hg-view-mode (prev-buffer &optional file-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
585 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
586 (set-buffer-modified-p nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
587 (toggle-read-only t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
588 (hg-feature-cond (xemacs (view-minor-mode prev-buffer 'hg-exit-view-mode)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
589 (t (view-mode-enter nil 'hg-exit-view-mode))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
590 (setq hg-view-mode t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
591 (setq truncate-lines t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
592 (when file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
593 (setq hg-view-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
594 (hg-abbrev-file-name file-name)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
595 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
596 (defun hg-file-status (file) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
597 "Return status of FILE, or nil if FILE does not exist or is unmanaged." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
598 (let* ((s (hg-run "status" file)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
599 (exit (car s)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
600 (output (cdr s))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
601 (if (= exit 0) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
602 (let ((state (and (>= (length output) 2) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
603 (= (aref output 1) ? ) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
604 (assq (aref output 0) hg-state-alist)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
605 (if state |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
606 (cdr state) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
607 'normal))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
608 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
609 (defun hg-path-status (root paths) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
610 "Return status of PATHS in repo ROOT as an alist. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
611 Each entry is a pair (FILE-NAME . STATUS)." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
612 (let ((s (apply 'hg-run "--cwd" root "status" "-marduc" paths)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
613 result) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
614 (dolist (entry (split-string (hg-chomp (cdr s)) "\n") (nreverse result)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
615 (let (state name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
616 (cond ((= (aref entry 1) ? ) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
617 (setq state (assq (aref entry 0) hg-state-alist) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
618 name (substring entry 2))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
619 ((string-match "\\(.*\\): " entry) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
620 (setq name (match-string 1 entry)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
621 (setq result (cons (cons name state) result)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
622 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
623 (defmacro hg-view-output (args &rest body) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
624 "Execute BODY in a clean buffer, then quickly display that buffer. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
625 If the buffer contains one line, its contents are displayed in the |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
626 minibuffer. Otherwise, the buffer is displayed in view-mode. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
627 ARGS is of the form (BUFFER-NAME &optional FILE), where BUFFER-NAME is |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
628 the name of the buffer to create, and FILE is the name of the file |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
629 being viewed." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
630 (let ((prev-buf (make-symbol "prev-buf-")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
631 (v-b-name (car args)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
632 (v-m-rest (cdr args))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
633 `(let ((view-buf-name ,v-b-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
634 (,prev-buf (current-buffer))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
635 (get-buffer-create view-buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
636 (kill-buffer view-buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
637 (get-buffer-create view-buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
638 (set-buffer view-buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
639 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
640 ,@body) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
641 (case (count-lines (point-min) (point-max)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
642 ((0) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
643 (kill-buffer view-buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
644 (message "(No output)")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
645 ((1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
646 (let ((msg (hg-chomp (buffer-substring (point-min) (point-max))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
647 (kill-buffer view-buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
648 (message "%s" msg))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
649 (t |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
650 (pop-to-buffer view-buf-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
651 (setq hg-prev-buffer ,prev-buf) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
652 (hg-view-mode ,prev-buf ,@v-m-rest)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
653 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
654 (put 'hg-view-output 'lisp-indent-function 1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
655 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
656 ;;; Context save and restore across revert and other operations. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
657 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
658 (defun hg-position-context (pos) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
659 "Return information to help find the given position again." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
660 (let* ((end (min (point-max) (+ pos 98)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
661 (list pos |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
662 (buffer-substring (max (point-min) (- pos 2)) end) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
663 (- end pos)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
664 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
665 (defun hg-buffer-context () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
666 "Return information to help restore a user's editing context. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
667 This is useful across reverts and merges, where a context is likely |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
668 to have moved a little, but not really changed." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
669 (let ((point-context (hg-position-context (point))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
670 (mark-context (let ((mark (mark-marker))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
671 (and mark |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
672 ;; make sure active mark |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
673 (marker-buffer mark) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
674 (marker-position mark) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
675 (hg-position-context mark))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
676 (list point-context mark-context))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
677 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
678 (defun hg-find-context (ctx) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
679 "Attempt to find a context in the given buffer. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
680 Always returns a valid, hopefully sane, position." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
681 (let ((pos (nth 0 ctx)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
682 (str (nth 1 ctx)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
683 (fixup (nth 2 ctx))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
684 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
685 (goto-char (max (point-min) (- pos 15000))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
686 (if (and (not (equal str "")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
687 (search-forward str nil t)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
688 (- (point) fixup) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
689 (max pos (point-min)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
690 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
691 (defun hg-restore-context (ctx) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
692 "Attempt to restore the user's editing context." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
693 (let ((point-context (nth 0 ctx)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
694 (mark-context (nth 1 ctx))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
695 (goto-char (hg-find-context point-context)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
696 (when mark-context |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
697 (set-mark (hg-find-context mark-context))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
698 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
699 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
700 ;;; Hooks. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
701 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
702 (defun hg-mode-line-internal (status parents) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
703 (setq hg-status status |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
704 hg-mode (and status (concat " Hg:" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
705 parents |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
706 (cdr (assq status |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
707 '((normal . "") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
708 (removed . "r") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
709 (added . "a") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
710 (deleted . "!") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
711 (modified . "m")))))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
712 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
713 (defun hg-mode-line (&optional force) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
714 "Update the modeline with the current status of a file. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
715 An update occurs if optional argument FORCE is non-nil, |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
716 hg-update-modeline is non-nil, or we have not yet checked the state of |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
717 the file." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
718 (let ((root (hg-root))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
719 (when (and root (or force hg-update-modeline (not hg-mode))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
720 (let ((status (hg-file-status buffer-file-name)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
721 (parents (hg-parents-for-mode-line root))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
722 (hg-mode-line-internal status parents) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
723 status)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
724 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
725 (defun hg-mode (&optional toggle) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
726 "Minor mode for Mercurial distributed SCM integration. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
727 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
728 The Mercurial mode user interface is based on that of VC mode, so if |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
729 you're already familiar with VC, the same keybindings and functions |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
730 will generally work. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
731 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
732 Below is a list of many common SCM tasks. In the list, `G/L\' |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
733 indicates whether a key binding is global (G) to a repository or |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
734 local (L) to a file. Many commands take a prefix argument. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
735 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
736 SCM Task G/L Key Binding Command Name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
737 -------- --- ----------- ------------ |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
738 Help overview (what you are reading) G C-c h h hg-help-overview |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
739 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
740 Tell Mercurial to manage a file G C-c h a hg-add |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
741 Commit changes to current file only L C-x v n hg-commit-start |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
742 Undo changes to file since commit L C-x v u hg-revert-buffer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
743 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
744 Diff file vs last checkin L C-x v = hg-diff |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
745 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
746 View file change history L C-x v l hg-log |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
747 View annotated file L C-x v a hg-annotate |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
748 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
749 Diff repo vs last checkin G C-c h = hg-diff-repo |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
750 View status of files in repo G C-c h s hg-status |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
751 Commit all changes G C-c h c hg-commit-start |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
752 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
753 Undo all changes since last commit G C-c h U hg-revert |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
754 View repo change history G C-c h l hg-log-repo |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
755 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
756 See changes that can be pulled G C-c h , hg-incoming |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
757 Pull changes G C-c h < hg-pull |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
758 Update working directory after pull G C-c h u hg-update |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
759 See changes that can be pushed G C-c h . hg-outgoing |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
760 Push changes G C-c h > hg-push" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
761 (unless vc-make-backup-files |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
762 (set (make-local-variable 'backup-inhibited) t)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
763 (run-hooks 'hg-mode-hook)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
764 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
765 (defun hg-find-file-hook () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
766 (ignore-errors |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
767 (when (hg-mode-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
768 (hg-mode)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
769 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
770 (add-hook 'find-file-hooks 'hg-find-file-hook) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
771 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
772 (defun hg-after-save-hook () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
773 (ignore-errors |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
774 (let ((old-status hg-status)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
775 (hg-mode-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
776 (if (and (not old-status) hg-status) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
777 (hg-mode))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
778 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
779 (add-hook 'after-save-hook 'hg-after-save-hook) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
780 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
781 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
782 ;;; User interface functions. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
783 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
784 (defun hg-help-overview () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
785 "This is an overview of the Mercurial SCM mode for Emacs. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
786 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
787 You can find the source code, license (GPL v2), and credits for this |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
788 code by typing `M-x find-library mercurial RET'." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
789 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
790 (hg-view-output ("Mercurial Help Overview") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
791 (insert (documentation 'hg-help-overview)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
792 (let ((pos (point))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
793 (insert (documentation 'hg-mode)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
794 (goto-char pos) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
795 (end-of-line 1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
796 (delete-region pos (point))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
797 (let ((hg-root-dir (hg-root))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
798 (if (not hg-root-dir) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
799 (error "error: %s: directory is not part of a Mercurial repository." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
800 default-directory) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
801 (cd hg-root-dir))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
802 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
803 (defun hg-fix-paths () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
804 "Fix paths reported by some Mercurial commands." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
805 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
806 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
807 (while (re-search-forward " \\.\\.." nil t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
808 (replace-match " " nil nil)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
809 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
810 (defun hg-add (path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
811 "Add PATH to the Mercurial repository on the next commit. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
812 With a prefix argument, prompt for the path to add." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
813 (interactive (list (hg-read-file-name " to add"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
814 (let ((buf (current-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
815 (update (equal buffer-file-name path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
816 (hg-view-output (hg-output-buffer-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
817 (apply 'call-process (hg-binary) nil t nil (list "add" path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
818 (hg-fix-paths) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
819 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
820 (cd (hg-root path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
821 (when update |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
822 (unless vc-make-backup-files |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
823 (set (make-local-variable 'backup-inhibited) t)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
824 (with-current-buffer buf |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
825 (hg-mode-line))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
826 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
827 (defun hg-addremove () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
828 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
829 (error "not implemented")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
830 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
831 (defun hg-annotate () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
832 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
833 (error "not implemented")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
834 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
835 (defun hg-commit-toggle-file (pos) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
836 "Toggle whether or not the file at POS will be committed." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
837 (interactive "d") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
838 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
839 (goto-char pos) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
840 (let ((face (get-text-property pos 'face)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
841 (inhibit-read-only t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
842 bol) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
843 (beginning-of-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
844 (setq bol (+ (point) 4)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
845 (end-of-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
846 (if (eq face 'bold) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
847 (progn |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
848 (remove-text-properties bol (point) '(face nil)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
849 (message "%s will not be committed" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
850 (buffer-substring bol (point)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
851 (add-text-properties bol (point) '(face bold)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
852 (message "%s will be committed" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
853 (buffer-substring bol (point))))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
854 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
855 (defun hg-commit-mouse-clicked (event) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
856 "Toggle whether or not the file at POS will be committed." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
857 (interactive "@e") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
858 (hg-commit-toggle-file (hg-event-point event))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
859 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
860 (defun hg-commit-kill () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
861 "Kill the commit currently being prepared." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
862 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
863 (when (or (not (buffer-modified-p)) (y-or-n-p "Really kill this commit? ")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
864 (let ((buf hg-prev-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
865 (kill-buffer nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
866 (switch-to-buffer buf)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
867 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
868 (defun hg-commit-finish () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
869 "Finish preparing a commit, and perform the actual commit. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
870 The hook hg-pre-commit-hook is run before anything else is done. If |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
871 the commit message is empty and hg-commit-allow-empty-message is nil, |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
872 an error is raised. If the list of files to commit is empty and |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
873 hg-commit-allow-empty-file-list is nil, an error is raised." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
874 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
875 (let ((root hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
876 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
877 (run-hooks 'hg-pre-commit-hook) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
878 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
879 (search-forward hg-commit-message-start) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
880 (let (message files) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
881 (let ((start (point))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
882 (goto-char (point-max)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
883 (search-backward hg-commit-message-end) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
884 (setq message (hg-strip (buffer-substring start (point))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
885 (when (and (= (length message) 0) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
886 (not hg-commit-allow-empty-message)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
887 (error "Cannot proceed - commit message is empty")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
888 (forward-line 1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
889 (beginning-of-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
890 (while (< (point) (point-max)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
891 (let ((pos (+ (point) 4))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
892 (end-of-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
893 (when (eq (get-text-property pos 'face) 'bold) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
894 (end-of-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
895 (setq files (cons (buffer-substring pos (point)) files)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
896 (forward-line 1)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
897 (when (and (= (length files) 0) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
898 (not hg-commit-allow-empty-file-list)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
899 (error "Cannot proceed - no files to commit")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
900 (setq message (concat message "\n")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
901 (apply 'hg-run0 "--cwd" hg-root "commit" "-m" message files)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
902 (let ((buf hg-prev-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
903 (kill-buffer nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
904 (switch-to-buffer buf)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
905 (hg-update-mode-lines root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
906 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
907 (defun hg-commit-mode () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
908 "Mode for describing a commit of changes to a Mercurial repository. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
909 This involves two actions: describing the changes with a commit |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
910 message, and choosing the files to commit. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
911 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
912 To describe the commit, simply type some text in the designated area. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
913 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
914 By default, all modified, added and removed files are selected for |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
915 committing. Files that will be committed are displayed in bold face\; |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
916 those that will not are displayed in normal face. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
917 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
918 To toggle whether a file will be committed, move the cursor over a |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
919 particular file and hit space or return. Alternatively, middle click |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
920 on the file. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
921 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
922 Key bindings |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
923 ------------ |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
924 \\[hg-commit-finish] proceed with commit |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
925 \\[hg-commit-kill] kill commit |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
926 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
927 \\[hg-diff-repo] view diff of pending changes" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
928 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
929 (use-local-map hg-commit-mode-map) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
930 (set-syntax-table text-mode-syntax-table) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
931 (setq local-abbrev-table text-mode-abbrev-table |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
932 major-mode 'hg-commit-mode |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
933 mode-name "Hg-Commit") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
934 (set-buffer-modified-p nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
935 (setq buffer-undo-list nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
936 (run-hooks 'text-mode-hook 'hg-commit-mode-hook)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
937 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
938 (defun hg-commit-start () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
939 "Prepare a commit of changes to the repository containing the current file." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
940 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
941 (while hg-prev-buffer |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
942 (set-buffer hg-prev-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
943 (let ((root (hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
944 (prev-buffer (current-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
945 modified-files) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
946 (unless root |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
947 (error "Cannot commit outside a repository!")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
948 (hg-sync-buffers root) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
949 (setq modified-files (hg-chomp (hg-run0 "--cwd" root "status" "-arm"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
950 (when (and (= (length modified-files) 0) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
951 (not hg-commit-allow-empty-file-list)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
952 (error "No pending changes to commit")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
953 (let* ((buf-name (format "*Mercurial: Commit %s*" root))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
954 (pop-to-buffer (get-buffer-create buf-name)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
955 (when (= (point-min) (point-max)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
956 (set (make-local-variable 'hg-root) root) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
957 (setq hg-prev-buffer prev-buffer) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
958 (insert "\n") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
959 (let ((bol (point))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
960 (insert hg-commit-message-end) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
961 (add-text-properties bol (point) '(face bold-italic))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
962 (let ((file-area (point))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
963 (insert modified-files) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
964 (goto-char file-area) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
965 (while (< (point) (point-max)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
966 (let ((bol (point))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
967 (forward-char 1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
968 (insert " ") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
969 (end-of-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
970 (add-text-properties (+ bol 4) (point) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
971 '(face bold mouse-face highlight))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
972 (forward-line 1)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
973 (goto-char file-area) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
974 (add-text-properties (point) (point-max) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
975 `(keymap ,hg-commit-mode-file-map)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
976 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
977 (insert hg-commit-message-start) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
978 (add-text-properties (point-min) (point) '(face bold-italic)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
979 (insert "\n\n") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
980 (forward-line -1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
981 (save-excursion |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
982 (goto-char (point-max)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
983 (search-backward hg-commit-message-end) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
984 (add-text-properties (match-beginning 0) (point-max) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
985 '(read-only t)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
986 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
987 (search-forward hg-commit-message-start) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
988 (add-text-properties (match-beginning 0) (match-end 0) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
989 '(read-only t))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
990 (hg-commit-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
991 (cd root)))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
992 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
993 (defun hg-diff (path &optional rev1 rev2) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
994 "Show the differences between REV1 and REV2 of PATH. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
995 When called interactively, the default behaviour is to treat REV1 as |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
996 the \"parent\" revision, REV2 as the current edited version of the file, and |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
997 PATH as the file edited in the current buffer. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
998 With a prefix argument, prompt for all of these." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
999 (interactive (list (hg-read-file-name " to diff") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1000 (let ((rev1 (hg-read-rev " to start with" 'parent))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1001 (and (not (eq rev1 'parent)) rev1)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1002 (let ((rev2 (hg-read-rev " to end with" 'working-dir))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1003 (and (not (eq rev2 'working-dir)) rev2)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1004 (hg-sync-buffers path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1005 (let ((a-path (hg-abbrev-file-name path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1006 ;; none revision is specified explicitly |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1007 (none (and (not rev1) (not rev2))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1008 ;; only one revision is specified explicitly |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1009 (one (or (and (or (equal rev1 rev2) (not rev2)) rev1) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1010 (and (not rev1) rev2))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1011 diff) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1012 (hg-view-output ((cond |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1013 (none |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1014 (format "Mercurial: Diff against parent of %s" a-path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1015 (one |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1016 (format "Mercurial: Diff of rev %s of %s" one a-path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1017 (t |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1018 (format "Mercurial: Diff from rev %s to %s of %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1019 rev1 rev2 a-path)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1020 (cond |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1021 (none |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1022 (call-process (hg-binary) nil t nil "diff" path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1023 (one |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1024 (call-process (hg-binary) nil t nil "diff" "-r" one path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1025 (t |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1026 (call-process (hg-binary) nil t nil "diff" "-r" rev1 "-r" rev2 path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1027 (diff-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1028 (setq diff (not (= (point-min) (point-max)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1029 (font-lock-fontify-buffer) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1030 (cd (hg-root path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1031 diff)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1032 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1033 (defun hg-diff-repo (path &optional rev1 rev2) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1034 "Show the differences between REV1 and REV2 of repository containing PATH. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1035 When called interactively, the default behaviour is to treat REV1 as |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1036 the \"parent\" revision, REV2 as the current edited version of the file, and |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1037 PATH as the `hg-root' of the current buffer. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1038 With a prefix argument, prompt for all of these." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1039 (interactive (list (hg-read-file-name " to diff") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1040 (let ((rev1 (hg-read-rev " to start with" 'parent))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1041 (and (not (eq rev1 'parent)) rev1)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1042 (let ((rev2 (hg-read-rev " to end with" 'working-dir))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1043 (and (not (eq rev2 'working-dir)) rev2)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1044 (hg-diff (hg-root path) rev1 rev2)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1045 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1046 (defun hg-forget (path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1047 "Lose track of PATH, which has been added, but not yet committed. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1048 This will prevent the file from being incorporated into the Mercurial |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1049 repository on the next commit. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1050 With a prefix argument, prompt for the path to forget." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1051 (interactive (list (hg-read-file-name " to forget"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1052 (let ((buf (current-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1053 (update (equal buffer-file-name path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1054 (hg-view-output (hg-output-buffer-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1055 (apply 'call-process (hg-binary) nil t nil (list "forget" path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1056 ;; "hg forget" shows pathes relative NOT TO ROOT BUT TO REPOSITORY |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1057 (hg-fix-paths) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1058 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1059 (cd (hg-root path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1060 (when update |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1061 (with-current-buffer buf |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1062 (when (local-variable-p 'backup-inhibited) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1063 (kill-local-variable 'backup-inhibited)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1064 (hg-mode-line))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1065 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1066 (defun hg-incoming (&optional repo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1067 "Display changesets present in REPO that are not present locally." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1068 (interactive (list (hg-read-repo-name " where changes would come from"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1069 (hg-view-output ((format "Mercurial: Incoming from %s to %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1070 (hg-abbrev-file-name (hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1071 (hg-abbrev-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1072 (or repo hg-incoming-repository)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1073 (call-process (hg-binary) nil t nil "incoming" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1074 (or repo hg-incoming-repository)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1075 (hg-log-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1076 (cd (hg-root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1077 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1078 (defun hg-init () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1079 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1080 (error "not implemented")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1081 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1082 (defun hg-log-mode () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1083 "Mode for viewing a Mercurial change log." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1084 (goto-char (point-min)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1085 (when (looking-at "^searching for changes.*$") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1086 (delete-region (match-beginning 0) (match-end 0))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1087 (run-hooks 'hg-log-mode-hook)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1088 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1089 (defun hg-log (path &optional rev1 rev2 log-limit) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1090 "Display the revision history of PATH. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1091 History is displayed between REV1 and REV2. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1092 Number of displayed changesets is limited to LOG-LIMIT. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1093 REV1 defaults to the tip, while REV2 defaults to 0. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1094 LOG-LIMIT defaults to `hg-log-limit'. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1095 With a prefix argument, prompt for each parameter." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1096 (interactive (list (hg-read-file-name " to log") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1097 (hg-read-rev " to start with" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1098 "tip") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1099 (hg-read-rev " to end with" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1100 "0") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1101 (hg-read-number "Output limited to: " |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1102 hg-log-limit))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1103 (let ((a-path (hg-abbrev-file-name path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1104 (r1 (or rev1 "tip")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1105 (r2 (or rev2 "0")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1106 (limit (format "%d" (or log-limit hg-log-limit)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1107 (hg-view-output ((if (equal r1 r2) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1108 (format "Mercurial: Log of rev %s of %s" rev1 a-path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1109 (format |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1110 "Mercurial: at most %s log(s) from rev %s to %s of %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1111 limit r1 r2 a-path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1112 (eval (list* 'call-process (hg-binary) nil t nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1113 "log" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1114 "-r" (format "%s:%s" r1 r2) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1115 "-l" limit |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1116 (if (> (length path) (length (hg-root path))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1117 (cons path nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1118 nil))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1119 (hg-log-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1120 (cd (hg-root path))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1121 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1122 (defun hg-log-repo (path &optional rev1 rev2 log-limit) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1123 "Display the revision history of the repository containing PATH. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1124 History is displayed between REV1 and REV2. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1125 Number of displayed changesets is limited to LOG-LIMIT, |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1126 REV1 defaults to the tip, while REV2 defaults to 0. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1127 LOG-LIMIT defaults to `hg-log-limit'. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1128 With a prefix argument, prompt for each parameter." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1129 (interactive (list (hg-read-file-name " to log") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1130 (hg-read-rev " to start with" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1131 "tip") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1132 (hg-read-rev " to end with" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1133 "0") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1134 (hg-read-number "Output limited to: " |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1135 hg-log-limit))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1136 (hg-log (hg-root path) rev1 rev2 log-limit)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1137 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1138 (defun hg-outgoing (&optional repo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1139 "Display changesets present locally that are not present in REPO." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1140 (interactive (list (hg-read-repo-name " where changes would go to" nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1141 hg-outgoing-repository))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1142 (hg-view-output ((format "Mercurial: Outgoing from %s to %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1143 (hg-abbrev-file-name (hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1144 (hg-abbrev-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1145 (or repo hg-outgoing-repository)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1146 (call-process (hg-binary) nil t nil "outgoing" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1147 (or repo hg-outgoing-repository)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1148 (hg-log-mode) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1149 (cd (hg-root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1150 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1151 (defun hg-pull (&optional repo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1152 "Pull changes from repository REPO. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1153 This does not update the working directory." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1154 (interactive (list (hg-read-repo-name " to pull from"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1155 (hg-view-output ((format "Mercurial: Pull to %s from %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1156 (hg-abbrev-file-name (hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1157 (hg-abbrev-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1158 (or repo hg-incoming-repository)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1159 (call-process (hg-binary) nil t nil "pull" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1160 (or repo hg-incoming-repository)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1161 (cd (hg-root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1162 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1163 (defun hg-push (&optional repo) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1164 "Push changes to repository REPO." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1165 (interactive (list (hg-read-repo-name " to push to"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1166 (hg-view-output ((format "Mercurial: Push from %s to %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1167 (hg-abbrev-file-name (hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1168 (hg-abbrev-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1169 (or repo hg-outgoing-repository)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1170 (call-process (hg-binary) nil t nil "push" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1171 (or repo hg-outgoing-repository)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1172 (cd (hg-root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1173 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1174 (defun hg-revert-buffer-internal () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1175 (let ((ctx (hg-buffer-context))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1176 (message "Reverting %s..." buffer-file-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1177 (hg-run0 "revert" buffer-file-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1178 (revert-buffer t t t) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1179 (hg-restore-context ctx) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1180 (hg-mode-line) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1181 (message "Reverting %s...done" buffer-file-name))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1182 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1183 (defun hg-revert-buffer () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1184 "Revert current buffer's file back to the latest committed version. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1185 If the file has not changed, nothing happens. Otherwise, this |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1186 displays a diff and asks for confirmation before reverting." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1187 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1188 (let ((vc-suppress-confirm nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1189 (obuf (current-buffer)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1190 diff) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1191 (vc-buffer-sync) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1192 (unwind-protect |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1193 (setq diff (hg-diff buffer-file-name)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1194 (when diff |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1195 (unless (yes-or-no-p "Discard changes? ") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1196 (error "Revert cancelled"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1197 (when diff |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1198 (let ((buf (current-buffer))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1199 (delete-window (selected-window)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1200 (kill-buffer buf)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1201 (set-buffer obuf) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1202 (when diff |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1203 (hg-revert-buffer-internal)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1204 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1205 (defun hg-root (&optional path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1206 "Return the root of the repository that contains the given path. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1207 If the path is outside a repository, return nil. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1208 When called interactively, the root is printed. A prefix argument |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1209 prompts for a path to check." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1210 (interactive (list (hg-read-file-name))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1211 (if (or path (not hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1212 (let ((root (do ((prev nil dir) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1213 (dir (file-name-directory |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1214 (or |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1215 path |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1216 buffer-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1217 (expand-file-name default-directory))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1218 (file-name-directory (directory-file-name dir)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1219 ((equal prev dir)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1220 (when (file-directory-p (concat dir ".hg")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1221 (return dir))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1222 (when (interactive-p) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1223 (if root |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1224 (message "The root of this repository is `%s'." root) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1225 (message "The path `%s' is not in a Mercurial repository." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1226 (hg-abbrev-file-name path)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1227 root) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1228 hg-root)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1229 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1230 (defun hg-cwd (&optional path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1231 "Return the current directory of PATH within the repository." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1232 (do ((stack nil (cons (file-name-nondirectory |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1233 (directory-file-name dir)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1234 stack)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1235 (prev nil dir) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1236 (dir (file-name-directory (or path buffer-file-name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1237 (expand-file-name default-directory))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1238 (file-name-directory (directory-file-name dir)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1239 ((equal prev dir)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1240 (when (file-directory-p (concat dir ".hg")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1241 (let ((cwd (mapconcat 'identity stack "/"))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1242 (unless (equal cwd "") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1243 (return (file-name-as-directory cwd))))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1244 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1245 (defun hg-status (path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1246 "Print revision control status of a file or directory. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1247 With prefix argument, prompt for the path to give status for. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1248 Names are displayed relative to the repository root." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1249 (interactive (list (hg-read-file-name " for status" (hg-root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1250 (let ((root (hg-root))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1251 (hg-view-output ((format "Mercurial: Status of %s in %s" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1252 (let ((name (substring (expand-file-name path) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1253 (length root)))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1254 (if (> (length name) 0) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1255 name |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1256 "*")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1257 (hg-abbrev-file-name root))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1258 (apply 'call-process (hg-binary) nil t nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1259 (list "--cwd" root "status" path)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1260 (cd (hg-root path))))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1261 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1262 (defun hg-undo () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1263 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1264 (error "not implemented")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1265 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1266 (defun hg-update () |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1267 (interactive) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1268 (error "not implemented")) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1269 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1270 (defun hg-version-other-window (rev) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1271 "Visit version REV of the current file in another window. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1272 If the current file is named `F', the version is named `F.~REV~'. |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1273 If `F.~REV~' already exists, use it instead of checking it out again." |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1274 (interactive "sVersion to visit (default is workfile version): ") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1275 (let* ((file buffer-file-name) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1276 (version (if (string-equal rev "") |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1277 "tip" |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1278 rev)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1279 (automatic-backup (vc-version-backup-file-name file version)) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1280 (manual-backup (vc-version-backup-file-name file version 'manual))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1281 (unless (file-exists-p manual-backup) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1282 (if (file-exists-p automatic-backup) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1283 (rename-file automatic-backup manual-backup nil) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1284 (hg-run0 "-q" "cat" "-r" version "-o" manual-backup file))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1285 (find-file-other-window manual-backup))) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1286 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1287 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1288 (provide 'mercurial) |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1289 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1290 |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1291 ;;; Local Variables: |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1292 ;;; prompt-to-byte-compile: nil |
d4d720c4c416
Add mercurial support to emacs. Improve setting of PYTHONPATH in there.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1293 ;;; end: |