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