1 ;; Generate key binding summary for Emacs
2 ;; Copyright (C) 1985 Free Software Foundation, Inc.
4 ;; This file is part of GNU Emacs.
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 1, or (at your option)
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 (defun make-command-summary ()
22 "Make a summary of current key bindings in the buffer *Summary*.
23 Previous contents of that buffer are killed first."
25 (message "Making command summary...")
26 ;; This puts a description of bindings in a buffer called *Help*.
27 (save-window-excursion
29 (with-output-to-temp-buffer "*Summary*"
31 (let ((cur-mode mode-name
))
32 (set-buffer standard-output
)
34 (insert-buffer-substring "*Help*")
35 (goto-char (point-min))
36 (delete-region (point) (progn (forward-line 1) (point)))
37 (while (search-forward " " nil t
)
39 (goto-char (point-min))
40 (while (search-forward "-@ " nil t
)
41 (replace-match "-SP"))
42 (goto-char (point-min))
43 (while (search-forward " .. ~ " nil t
)
44 (replace-match "SP .. ~"))
45 (goto-char (point-min))
46 (while (search-forward "C-?" nil t
)
47 (replace-match "DEL"))
48 (goto-char (point-min))
49 (while (search-forward "C-i" nil t
)
50 (replace-match "TAB"))
51 (goto-char (point-min))
52 (if (re-search-forward "^Local Bindings:" nil t
)
55 (insert " for " cur-mode
" Mode")
56 (while (search-forward "??\n" nil t
)
57 (delete-region (point)
61 (goto-char (point-min))
62 (insert "Emacs command summary, " (substring (current-time-string) 0 10)
64 ;; Delete "key binding" and underlining of dashes.
65 (delete-region (point) (progn (forward-line 2) (point)))
66 (forward-line 1) ;Skip blank line
69 (or (re-search-forward "^$" nil t
)
70 (goto-char (point-max)))
71 (double-column beg
(point))
73 (goto-char (point-min)))))
74 (message "Making command summary...done"))
76 (defun double-column (start end
)
80 (from-end (- (point-max) end
)))
81 (setq nlines
(count-lines start end
))
84 (setq half
(/ (1+ nlines
) 2))
88 (while (< half nlines
)
90 (setq line
(buffer-substring (point) (save-excursion (end-of-line) (point))))
91 (setq lines
(cons line lines
))
92 (delete-region (point) (progn (forward-line 1) (point)))))
93 (setq lines
(nreverse lines
))
99 (setq lines
(cdr lines
))))
100 (goto-char (- (point-max) from-end
))))