Commit | Line | Data |
---|---|---|
6594deb0 ER |
1 | ;;; makesum.el --- generate key binding summary for Emacs |
2 | ||
84176303 | 3 | ;; Maintainer: FSF |
e5167999 | 4 | ;; Last-Modified: 09 May 1991 |
fd7fa35a | 5 | ;; Keywords: help |
84176303 | 6 | |
a2535589 JA |
7 | ;; Copyright (C) 1985 Free Software Foundation, Inc. |
8 | ||
9 | ;; This file is part of GNU Emacs. | |
10 | ||
11 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 | ;; it under the terms of the GNU General Public License as published by | |
e5167999 | 13 | ;; the Free Software Foundation; either version 2, or (at your option) |
a2535589 JA |
14 | ;; any later version. |
15 | ||
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | ||
84176303 | 25 | ;;; Code: |
a2535589 | 26 | |
f9f9507e | 27 | ;;;###autoload |
a2535589 JA |
28 | (defun make-command-summary () |
29 | "Make a summary of current key bindings in the buffer *Summary*. | |
30 | Previous contents of that buffer are killed first." | |
31 | (interactive) | |
32 | (message "Making command summary...") | |
33 | ;; This puts a description of bindings in a buffer called *Help*. | |
34 | (save-window-excursion | |
35 | (describe-bindings)) | |
36 | (with-output-to-temp-buffer "*Summary*" | |
37 | (save-excursion | |
38 | (let ((cur-mode mode-name)) | |
39 | (set-buffer standard-output) | |
40 | (erase-buffer) | |
41 | (insert-buffer-substring "*Help*") | |
42 | (goto-char (point-min)) | |
43 | (delete-region (point) (progn (forward-line 1) (point))) | |
44 | (while (search-forward " " nil t) | |
45 | (replace-match " ")) | |
46 | (goto-char (point-min)) | |
47 | (while (search-forward "-@ " nil t) | |
48 | (replace-match "-SP")) | |
49 | (goto-char (point-min)) | |
50 | (while (search-forward " .. ~ " nil t) | |
51 | (replace-match "SP .. ~")) | |
52 | (goto-char (point-min)) | |
53 | (while (search-forward "C-?" nil t) | |
54 | (replace-match "DEL")) | |
55 | (goto-char (point-min)) | |
56 | (while (search-forward "C-i" nil t) | |
57 | (replace-match "TAB")) | |
58 | (goto-char (point-min)) | |
59 | (if (re-search-forward "^Local Bindings:" nil t) | |
60 | (progn | |
61 | (forward-char -1) | |
62 | (insert " for " cur-mode " Mode") | |
63 | (while (search-forward "??\n" nil t) | |
64 | (delete-region (point) | |
65 | (progn | |
66 | (forward-line -1) | |
67 | (point)))))) | |
68 | (goto-char (point-min)) | |
69 | (insert "Emacs command summary, " (substring (current-time-string) 0 10) | |
70 | ".\n") | |
71 | ;; Delete "key binding" and underlining of dashes. | |
72 | (delete-region (point) (progn (forward-line 2) (point))) | |
73 | (forward-line 1) ;Skip blank line | |
74 | (while (not (eobp)) | |
75 | (let ((beg (point))) | |
76 | (or (re-search-forward "^$" nil t) | |
77 | (goto-char (point-max))) | |
78 | (double-column beg (point)) | |
79 | (forward-line 1))) | |
80 | (goto-char (point-min))))) | |
81 | (message "Making command summary...done")) | |
82 | ||
83 | (defun double-column (start end) | |
84 | (interactive "r") | |
85 | (let (half cnt | |
86 | line lines nlines | |
87 | (from-end (- (point-max) end))) | |
88 | (setq nlines (count-lines start end)) | |
89 | (if (<= nlines 1) | |
90 | nil | |
91 | (setq half (/ (1+ nlines) 2)) | |
92 | (goto-char start) | |
93 | (save-excursion | |
94 | (forward-line half) | |
95 | (while (< half nlines) | |
96 | (setq half (1+ half)) | |
97 | (setq line (buffer-substring (point) (save-excursion (end-of-line) (point)))) | |
98 | (setq lines (cons line lines)) | |
99 | (delete-region (point) (progn (forward-line 1) (point))))) | |
100 | (setq lines (nreverse lines)) | |
101 | (while lines | |
102 | (end-of-line) | |
103 | (indent-to 41) | |
104 | (insert (car lines)) | |
105 | (forward-line 1) | |
106 | (setq lines (cdr lines)))) | |
107 | (goto-char (- (point-max) from-end)))) | |
6594deb0 ER |
108 | |
109 | ;;; makesum.el ends here |