annotate lisp/packages/makesum.el @ 76:c0c698873ce1 r20-0b33

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