1 ;;; makesum.el --- generate key binding summary for Emacs
3 ;; Copyright (C) 1985, 2001-2017 Free Software Foundation, Inc.
5 ;; Maintainer: emacs-devel@gnu.org
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; Displays a nice human-readable summary of all keybindings in a
31 (defun make-command-summary ()
32 "Make a summary of current key bindings in the buffer *Summary*.
33 Previous contents of that buffer are killed first."
35 (message "Making command summary...")
36 ;; This puts a description of bindings in a buffer called *Help*.
37 (save-window-excursion
39 (with-output-to-temp-buffer "*Summary*"
41 (let ((cur-mode mode-name
))
42 (set-buffer standard-output
)
44 (insert-buffer-substring "*Help*")
45 (goto-char (point-min))
46 (delete-region (point) (progn (forward-line 1) (point)))
47 (while (search-forward " " nil t
)
49 (goto-char (point-min))
50 (while (search-forward "-@ " nil t
)
51 (replace-match "-SP"))
52 (goto-char (point-min))
53 (while (search-forward " .. ~ " nil t
)
54 (replace-match "SP .. ~"))
55 (goto-char (point-min))
56 (while (search-forward "C-?" nil t
)
57 (replace-match "DEL"))
58 (goto-char (point-min))
59 (while (search-forward "C-i" nil t
)
60 (replace-match "TAB"))
61 (goto-char (point-min))
62 (if (re-search-forward "^Local Bindings:" nil t
)
65 (insert " for " (format-mode-line cur-mode
) " Mode")
66 (while (search-forward "??\n" nil t
)
67 (delete-region (point)
71 (goto-char (point-min))
72 (insert "Emacs command summary, " (substring (current-time-string) 0 10)
74 ;; Delete "key binding" and underlining of dashes.
75 (delete-region (point) (progn (forward-line 2) (point)))
76 (forward-line 1) ;Skip blank line
79 (or (re-search-forward "^$" nil t
)
80 (goto-char (point-max)))
81 (double-column beg
(point))
83 (goto-char (point-min)))))
84 (message "Making command summary...done"))
86 (defun double-column (start end
)
88 (let (half line lines nlines
89 (from-end (- (point-max) end
)))
90 (setq nlines
(count-lines start end
))
93 (setq half
(/ (1+ nlines
) 2))
97 (while (< half nlines
)
99 (setq line
(buffer-substring (point) (line-end-position)))
100 (setq lines
(cons line lines
))
101 (delete-region (point) (progn (forward-line 1) (point)))))
102 (setq lines
(nreverse lines
))
108 (setq lines
(cdr lines
))))
109 (goto-char (- (point-max) from-end
))))
113 ;;; makesum.el ends here