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