changelog shortlog tags changeset files revisions annotate raw

ascii-table.el

changeset 66: 5b737eefe5ea
author: kim.vanwyk
date: Wed Nov 10 15:19:03 2010 +0200 (18 months ago)
permissions: -rw-r--r--
description: Adding CSharp Mode and Google Weather
1;;; ascii-table.el --- simple ASCII table
2
3;; Copyright (C) 2002 Alex Schroeder
4
5;; Author: Alex Schroeder <alex@gnu.org>
6;; Maintainer: Alex Schroeder <alex@gnu.org>
7;; Version: 1.0.0
8;; Keywords: convenience
9;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?AsciiTable
10
11;; This file is not part of GNU Emacs.
12
13;; This is free software; you can redistribute it and/or modify
14;; it under the terms of the GNU General Public License as published by
15;; the Free Software Foundation; either version 2, or (at your option)
16;; any later version.
17
18;; This is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details.
22
23;; You should have received a copy of the GNU General Public License
24;; along with GNU Emacs; see the file COPYING. If not, write to the
25;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26;; Boston, MA 02111-1307, USA.
27
28;;; Commentary:
29
30;; `ascii-table' shows you an ASCII table.
31
32;;; Code:
33
34(defun ascii-table (&optional limit base)
35 "Print the ascii table (up to char 127).
36
37Given the optional argument LIMIT, print the characters up to char
38LIMIT. Try 254 for example.
39
40Optional argument BASE can be either 8 for octal, 10 for decimal, or
4116 for hex."
42 (interactive "P")
43 (switch-to-buffer "*ASCII*")
44 (erase-buffer)
45 (let ((fmt (cond ((eq base 16) "%4x %4s")
46 ((eq base 8) "%4o %4s")
47 (t "%4d %4s")))
48 (i 0))
49 (setq limit (or limit 127))
50 (insert (format "ASCII characters up to number %d.\n" limit))
51 (while (<= i limit)
52 (insert (format fmt i (single-key-description i)))
53 (setq i (+ i 1))
54 (if (= 0 (mod i 6))
55 (newline)
56 (insert " "))))
57 (beginning-of-buffer))
58
59(defalias 'ascii-table-decimal 'ascii-table)
60
61(defun ascii-table-octal (&optional limit)
62 "Print the ascii table up to LIMIT (default is 0177)."
63 (interactive "P")
64 (ascii-table limit 8))
65
66(defun ascii-table-hex (&optional limit)
67 "Print the ascii table up to LIMIT (default is 0x7f)."
68 (interactive "P")
69 (ascii-table limit 16))
70
71(provide 'ascii-table)
72
73;;; ascii-table.el ends here.