Mercurial > emacs
annotate lisp/ediff-help.el @ 33488:352cb95d9f27
(diff-imenu-generic-expression): Modify unidiff
pattern.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 14 Nov 2000 18:09:21 +0000 |
parents | 42f9a58e0fc4 |
children | f6a67d77484a |
rev | line source |
---|---|
16247 | 1 ;;; ediff-help.el --- Code related to the contents of Ediff help buffers |
2 | |
18054 | 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. |
16247 | 4 |
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Code: | |
18054 | 25 |
26 (provide 'ediff-help) | |
16247 | 27 |
28 ;; Compiler pacifier start | |
29 (defvar ediff-multiframe) | |
18054 | 30 |
31 (eval-when-compile | |
32 (let ((load-path (cons (expand-file-name ".") load-path))) | |
33 (or (featurep 'ediff-init) | |
34 (load "ediff-init.el" nil nil 'nosuffix)) | |
35 )) | |
16247 | 36 ;; end pacifier |
37 | |
18054 | 38 (require 'ediff-init) |
39 | |
16247 | 40 ;; Help messages |
41 | |
42 (defconst ediff-long-help-message-head | |
43 " Move around | Toggle features | Manipulate | |
44 =====================|===========================|=============================" | |
45 "The head of the full help message.") | |
46 (defconst ediff-long-help-message-tail | |
47 "=====================|===========================|============================= | |
48 R -show registry | = -compare regions | M -show session group | |
49 D -diff output | E -browse Ediff manual| G -send bug report | |
50 i -status info | ? -help off | z/q -suspend/quit | |
51 ------------------------------------------------------------------------------- | |
52 For help on a specific command: Click Button 2 over it; or | |
53 Put the cursor over it and type RET." | |
54 "The tail of the full-help message.") | |
55 | |
56 (defconst ediff-long-help-message-compare3 | |
57 " | |
58 p,DEL -previous diff | | -vert/horiz split | xy -copy buf X's region to Y | |
59 n,SPC -next diff | h -hilighting | rx -restore buf X's old diff | |
60 j -jump to diff | @ -auto-refinement | * -refine current region | |
61 gx -goto X's point| | ! -update diff regions | |
62 C-l -recenter | ## -ignore whitespace | | |
63 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | |
64 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | |
65 ~ -rotate buffers| m -wide display | | |
66 " | |
67 "Help message usually used for 3-way comparison. | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
68 Normally, not a user option. See `ediff-help-message' for details.") |
16247 | 69 |
70 (defconst ediff-long-help-message-compare2 | |
71 " | |
72 p,DEL -previous diff | | -vert/horiz split |a/b -copy A/B's region to B/A | |
73 n,SPC -next diff | h -hilighting | rx -restore buf X's old diff | |
74 j -jump to diff | @ -auto-refinement | * -refine current region | |
75 gx -goto X's point| | ! -update diff regions | |
76 C-l -recenter | ## -ignore whitespace | | |
77 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | |
78 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | |
79 ~ -swap variants | m -wide display | | |
80 " | |
81 "Help message usually used for 2-way comparison. | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
82 Normally, not a user option. See `ediff-help-message' for details.") |
16247 | 83 |
84 (defconst ediff-long-help-message-narrow2 | |
85 " | |
86 p,DEL -previous diff | | -vert/horiz split |a/b -copy A/B's region to B/A | |
87 n,SPC -next diff | h -hilighting | rx -restore buf X's old diff | |
88 j -jump to diff | @ -auto-refinement | * -refine current region | |
89 gx -goto X's point| % -narrow/widen buffs | ! -update diff regions | |
90 C-l -recenter | ## -ignore whitespace | | |
91 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | |
92 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | |
93 ~ -swap variants | m -wide display | | |
94 " | |
95 "Help message when comparing windows or regions line-by-line. | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
96 Normally, not a user option. See `ediff-help-message' for details.") |
16247 | 97 |
98 (defconst ediff-long-help-message-word-mode | |
99 " | |
100 p,DEL -previous diff | | -vert/horiz split | xy -copy buf X's region to Y | |
101 n,SPC -next diff | h -hilighting | rx -restore buf X's old diff | |
102 j -jump to diff | | | |
103 gx -goto X's point| % -narrow/widen buffs | ! -recompute diffs | |
104 C-l -recenter | | | |
105 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | |
106 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | |
107 ~ -swap variants | m -wide display | | |
108 " | |
109 "Help message when comparing windows or regions word-by-word. | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
110 Normally, not a user option. See `ediff-help-message' for details.") |
16247 | 111 |
112 (defconst ediff-long-help-message-merge | |
113 " | |
114 p,DEL -previous diff | | -vert/horiz split | x -copy buf X's region to C | |
115 n,SPC -next diff | h -hilighting | r -restore buf C's old diff | |
116 j -jump to diff | @ -auto-refinement | * -refine current region | |
117 gx -goto X's point| ## -ignore whitespace | ! -update diff regions | |
118 C-l -recenter | #f/#h -focus/hide regions | + -combine diff regions | |
119 v/V -scroll up/dn | X -read-only in buf X | wx -save buf X | |
120 </> -scroll lt/rt | m -wide display | wd -save diff output | |
121 ~ -swap variants | s -shrink window C | / -show ancestor buff | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
122 | $$ -show clashes only | & -merge w/new default |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
123 | $* -skip changed regions | |
16247 | 124 " |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
125 "Help message for merge sessions. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
126 Normally, not a user option. See `ediff-help-message' for details.") |
16247 | 127 |
128 ;; The actual long help message. | |
129 (ediff-defvar-local ediff-long-help-message "" | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
130 "Normally, not a user option. See `ediff-help-message' for details.") |
16247 | 131 |
132 (defconst ediff-brief-message-string | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
133 " ? -quick help " |
16247 | 134 "Contents of the brief help message.") |
135 ;; The actual brief help message | |
136 (ediff-defvar-local ediff-brief-help-message "" | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
137 "Normally, not a user option. See `ediff-help-message' for details.") |
16247 | 138 |
139 (ediff-defvar-local ediff-brief-help-message-function nil | |
140 "The brief help message that the user can customize. | |
141 If the user sets this to a parameter-less function, Ediff will use it to | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
142 produce the brief help message. This function must return a string.") |
16247 | 143 (ediff-defvar-local ediff-long-help-message-function nil |
144 "The long help message that the user can customize. | |
145 See `ediff-brief-help-message-function' for more.") | |
146 | |
147 (defvar ediff-use-long-help-message nil | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
148 "*If t, Ediff displays a long help message. Short help message otherwise.") |
16247 | 149 |
150 ;; The actual help message. | |
151 (ediff-defvar-local ediff-help-message "" | |
152 "The actual help message. | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
153 Normally, the user shouldn't touch this. However, if you want Ediff to |
16247 | 154 start up with different help messages for different jobs, you can change |
155 the value of this variable and the variables `ediff-help-message-*' in | |
156 `ediff-startup-hook'.") | |
157 | |
158 | |
159 ;; the keymap that defines clicks over the quick help regions | |
160 (defvar ediff-help-region-map (make-sparse-keymap)) | |
161 | |
162 (define-key | |
163 ediff-help-region-map | |
164 (if ediff-emacs-p [mouse-2] [button2]) | |
165 'ediff-help-for-quick-help) | |
166 | |
167 ;; runs in the control buffer | |
168 (defun ediff-set-help-overlays () | |
169 (goto-char (point-min)) | |
170 (let (overl beg end cmd) | |
171 (while (re-search-forward " *\\([^ \t\n|]+\\||\\) +-[^|\n]+" nil 'noerror) | |
172 (setq beg (match-beginning 0) | |
173 end (match-end 0) | |
174 cmd (buffer-substring (match-beginning 1) (match-end 1))) | |
175 (setq overl (ediff-make-overlay beg end)) | |
176 (if ediff-emacs-p | |
177 (ediff-overlay-put overl 'mouse-face 'highlight) | |
178 (ediff-overlay-put overl 'highlight t)) | |
179 (ediff-overlay-put overl 'ediff-help-info cmd)))) | |
180 | |
181 | |
182 (defun ediff-help-for-quick-help () | |
183 "Explain Ediff commands in more detail." | |
184 (interactive) | |
185 (ediff-barf-if-not-control-buffer) | |
18054 | 186 (let ((pos (ediff-event-point last-command-event)) |
16247 | 187 overl cmd) |
188 | |
189 (if ediff-xemacs-p | |
190 (setq overl (extent-at pos (current-buffer) 'ediff-help-info) | |
191 cmd (ediff-overlay-get overl 'ediff-help-info)) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
192 (setq cmd (car (mapcar (lambda (elt) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
193 (overlay-get elt 'ediff-help-info)) |
16247 | 194 (overlays-at pos))))) |
195 | |
196 (if (not (stringp cmd)) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
197 (error "Hmm... I don't see an Ediff command around here...")) |
16247 | 198 |
199 (ediff-documentation "Quick Help Commands") | |
200 | |
201 (let (case-fold-search) | |
202 (cond ((string= cmd "?") (re-search-forward "^`\\?'")) | |
203 ((string= cmd "G") (re-search-forward "^`G'")) | |
204 ((string= cmd "E") (re-search-forward "^`E'")) | |
205 ((string= cmd "wd") (re-search-forward "^`wd'")) | |
206 ((string= cmd "wx") (re-search-forward "^`wa'")) | |
207 ((string= cmd "a/b") (re-search-forward "^`a'")) | |
208 ((string= cmd "x") (re-search-forward "^`a'")) | |
209 ((string= cmd "xy") (re-search-forward "^`ab'")) | |
210 ((string= cmd "p,DEL") (re-search-forward "^`p'")) | |
211 ((string= cmd "n,SPC") (re-search-forward "^`n'")) | |
212 ((string= cmd "j") (re-search-forward "^`j'")) | |
213 ((string= cmd "gx") (re-search-forward "^`ga'")) | |
214 ((string= cmd "!") (re-search-forward "^`!'")) | |
215 ((string= cmd "*") (re-search-forward "^`\\*'")) | |
216 ((string= cmd "m") (re-search-forward "^`m'")) | |
217 ((string= cmd "|") (re-search-forward "^`|'")) | |
218 ((string= cmd "@") (re-search-forward "^`@'")) | |
219 ((string= cmd "h") (re-search-forward "^`h'")) | |
220 ((string= cmd "r") (re-search-forward "^`r'")) | |
221 ((string= cmd "rx") (re-search-forward "^`ra'")) | |
222 ((string= cmd "##") (re-search-forward "^`##'")) | |
223 ((string= cmd "#f/#h") (re-search-forward "^`#f'")) | |
224 ((string= cmd "X") (re-search-forward "^`A'")) | |
225 ((string= cmd "v/V") (re-search-forward "^`v'")) | |
226 ((string= cmd "</>") (re-search-forward "^`<'")) | |
227 ((string= cmd "~") (re-search-forward "^`~'")) | |
228 ((string= cmd "i") (re-search-forward "^`i'")) | |
229 ((string= cmd "D") (re-search-forward "^`D'")) | |
230 ((string= cmd "R") (re-search-forward "^`R'")) | |
231 ((string= cmd "M") (re-search-forward "^`M'")) | |
232 ((string= cmd "z/q") (re-search-forward "^`z'")) | |
233 ((string= cmd "%") (re-search-forward "^`%'")) | |
234 ((string= cmd "C-l") (re-search-forward "^`C-l'")) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
235 ((string= cmd "$$") (re-search-forward "^`\\$\\$'")) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
236 ((string= cmd "$*") (re-search-forward "^`\\$\\*'")) |
16247 | 237 ((string= cmd "/") (re-search-forward "^`/'")) |
238 ((string= cmd "&") (re-search-forward "^`&'")) | |
239 ((string= cmd "s") (re-search-forward "^`s'")) | |
240 ((string= cmd "+") (re-search-forward "^`\\+'")) | |
241 ((string= cmd "=") (re-search-forward "^`='")) | |
242 (t (error "Undocumented command! Type `G' in Ediff Control Panel to drop a note to the Ediff maintainer"))) | |
243 ) ; let case-fold-search | |
244 )) | |
245 | |
246 | |
247 ;; assuming we are in control window, calculate length of the first line in | |
248 ;; help message | |
249 (defun ediff-help-message-line-length () | |
250 (save-excursion | |
251 (goto-char (point-min)) | |
252 (if ediff-use-long-help-message | |
253 (next-line 1)) | |
254 (end-of-line) | |
255 (current-column))) | |
256 | |
257 | |
258 (defun ediff-indent-help-message () | |
259 (let* ((shift (/ (max 0 (- (window-width (selected-window)) | |
260 (ediff-help-message-line-length))) | |
261 2)) | |
262 (str (make-string shift ?\ ))) | |
263 (save-excursion | |
264 (goto-char (point-min)) | |
265 (while (< (point) (point-max)) | |
266 (insert str) | |
267 (beginning-of-line) | |
268 (forward-line 1))))) | |
269 | |
270 | |
271 ;; compose the help message as a string | |
272 (defun ediff-set-help-message () | |
273 (setq ediff-long-help-message | |
274 (cond ((and ediff-long-help-message-function | |
275 (or (symbolp ediff-long-help-message-function) | |
276 (consp ediff-long-help-message-function))) | |
277 (funcall ediff-long-help-message-function)) | |
278 (ediff-word-mode | |
279 (concat ediff-long-help-message-head | |
280 ediff-long-help-message-word-mode | |
281 ediff-long-help-message-tail)) | |
282 (ediff-narrow-job | |
283 (concat ediff-long-help-message-head | |
284 ediff-long-help-message-narrow2 | |
285 ediff-long-help-message-tail)) | |
286 (ediff-merge-job | |
287 (concat ediff-long-help-message-head | |
288 ediff-long-help-message-merge | |
289 ediff-long-help-message-tail)) | |
290 (ediff-diff3-job | |
291 (concat ediff-long-help-message-head | |
292 ediff-long-help-message-compare3 | |
293 ediff-long-help-message-tail)) | |
294 (t | |
295 (concat ediff-long-help-message-head | |
296 ediff-long-help-message-compare2 | |
297 ediff-long-help-message-tail)))) | |
298 (setq ediff-brief-help-message | |
299 (cond ((and ediff-brief-help-message-function | |
300 (or (symbolp ediff-brief-help-message-function) | |
301 (consp ediff-brief-help-message-function))) | |
302 (funcall ediff-brief-help-message-function)) | |
303 ((stringp ediff-brief-help-message-function) | |
304 ediff-brief-help-message-function) | |
305 ((ediff-multiframe-setup-p) ediff-brief-message-string) | |
306 (t ; long brief msg, not multiframe --- put in the middle | |
307 ediff-brief-message-string) | |
308 )) | |
309 (setq ediff-help-message (if ediff-use-long-help-message | |
310 ediff-long-help-message | |
311 ediff-brief-help-message)) | |
312 (run-hooks 'ediff-display-help-hook)) | |
313 | |
27899
42f9a58e0fc4
* viper-cmd.el (viper-envelop-ESC-key): added the option to
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
26263
diff
changeset
|
314 ;;;###autoload |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
315 (defun ediff-customize () |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
316 (interactive) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
317 (customize-group "ediff")) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
18054
diff
changeset
|
318 |
16247 | 319 |
320 ;;; ediff-help.el ends here |