annotate lisp/disp-table.el @ 5169:6c6d78781d59

cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-24 Ben Wing <ben@xemacs.org> * array.h: * array.h (XD_LISP_DYNARR_DESC): * dumper.c (pdump_register_sub): * dumper.c (pdump_store_new_pointer_offsets): * dumper.c (pdump_reloc_one_mc): * elhash.c: * gc.c (lispdesc_one_description_line_size): * gc.c (kkcc_marking): * lrecord.h: * lrecord.h (IF_NEW_GC): * lrecord.h (enum memory_description_type): * lrecord.h (enum data_description_entry_flags): * lrecord.h (struct opaque_convert_functions): Rename XD_LISP_OBJECT_BLOCK_PTR to XD_INLINE_LISP_OBJECT_BLOCK_PTR and document it in lrecord.h. * data.c: * data.c (finish_marking_weak_lists): * data.c (continue_marking_ephemerons): * data.c (finish_marking_ephemerons): * elhash.c (MARK_OBJ): * gc.c: * gc.c (lispdesc_indirect_count_1): * gc.c (struct): * gc.c (kkcc_bt_push): * gc.c (kkcc_gc_stack_push): * gc.c (kkcc_gc_stack_push_lisp_object): * gc.c (kkcc_gc_stack_repush_dirty_object): * gc.c (KKCC_DO_CHECK_FREE): * gc.c (mark_object_maybe_checking_free): * gc.c (mark_struct_contents): * gc.c (mark_lisp_object_block_contents): * gc.c (register_for_finalization): * gc.c (mark_object): * gc.h: * lisp.h: * profile.c: * profile.c (mark_profiling_info_maphash): Clean up KKCC code related to DEBUG_XEMACS. Rename kkcc_backtrace() to kkcc_backtrace_1() and add two params: a `size' arg to control how many stack elements to print and a `detailed' arg to control whether Lisp objects are printed using `debug_print()'. Create front-ends to kkcc_backtrace_1() -- kkcc_detailed_backtrace(), kkcc_short_backtrace(), kkcc_detailed_backtrace_full(), kkcc_short_backtrace_full(), as well as shortened versions kbt(), kbts(), kbtf(), kbtsf() -- to call it with various parameter values. Add an `is_lisp' field to the stack and backtrace structures and use it to keep track of whether an object pushed onto the stack is a Lisp object or a non-Lisp structure; in kkcc_backtrace_1(), don't try to print a non-Lisp structure as a Lisp object. * elhash.c: * extents.c: * file-coding.c: * lrecord.h: * lrecord.h (IF_NEW_GC): * marker.c: * marker.c (Fmarker_buffer): * mule-coding.c: * number.c: * rangetab.c: * specifier.c: New macros IF_OLD_GC(), IF_NEW_GC() to simplify declaration of Lisp objects when a finalizer may exist in one but not the other. Use them appropriately. * extents.c (finalize_extent_info): Don't zero out data->soe and data->extents before trying to free, else we get memory leaks. * lrecord.h (enum lrecord_type): Make the first lrecord type have value 1 not 0 so that 0 remains without implementation and attempts to interpret zeroed memory as a Lisp object will be more obvious. * array.c (Dynarr_free): * device-msw.c (msprinter_delete_device): * device-tty.c (free_tty_device_struct): * device-tty.c (tty_delete_device): * dialog-msw.c (handle_directory_dialog_box): * dialog-x.c: * emacs.c (free_argc_argv): * emodules.c (attempt_module_delete): * file-coding.c (chain_finalize_coding_stream_1): * file-coding.c (chain_finalize_coding_stream): * glyphs-eimage.c: * glyphs-eimage.c (jpeg_instantiate_unwind): * glyphs-eimage.c (gif_instantiate_unwind): * glyphs-eimage.c (png_instantiate_unwind): * glyphs-eimage.c (tiff_instantiate_unwind): * imgproc.c: * imgproc.c (build_EImage_quantable): * insdel.c (uninit_buffer_text): * mule-coding.c (iso2022_finalize_detection_state): * objects-tty.c (tty_finalize_color_instance): * objects-tty.c (tty_finalize_font_instance): * objects-tty.c (tty_font_list): * process.c: * process.c (finalize_process): * redisplay.c (add_propagation_runes): * scrollbar-gtk.c: * scrollbar-gtk.c (gtk_free_scrollbar_instance): * scrollbar-gtk.c (gtk_release_scrollbar_instance): * scrollbar-msw.c: * scrollbar-msw.c (mswindows_free_scrollbar_instance): * scrollbar-msw.c (unshow_that_mofo): * scrollbar-x.c (x_free_scrollbar_instance): * scrollbar-x.c (x_release_scrollbar_instance): * select-x.c: * select-x.c (x_handle_selection_request): * syntax.c: * syntax.c (uninit_buffer_syntax_cache): * text.h (eifree): If possible, whenever we call xfree() on a field in a structure, set the field to 0 afterwards. A lot of code is written so that it checks the value being freed to see if it is non-zero before freeing it -- doing this and setting the value to 0 afterwards ensures (a) we won't try to free twice if the cleanup code is called twice; (b) if the object itself stays around, KKCC won't crash when attempting to mark the freed field. * rangetab.c: Add a finalization method when not NEW_GC to avoid memory leaks. (#### We still get memory leaks when NEW_GC; need to convert gap array to Lisp object).
author Ben Wing <ben@xemacs.org>
date Wed, 24 Mar 2010 01:22:51 -0500
parents e84ee15ca495
children 308d34e9f07d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
1 ;;; disp-table.el --- functions for dealing with char tables.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
2
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
3 ;; Copyright (C) 1987, 1994, 1997, 2007 Free Software Foundation, Inc.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Sun Microsystems.
5113
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
5 ;; Copyright (C) 2005 Ben Wing.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
6
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
8 ;; Keywords: i18n, internal
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
9
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
11
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
15 ;; any later version.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
16
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
20 ;; General Public License for more details.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
21
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
26
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
27 ;;; Synched up with: Not synched with FSF.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
28
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
29 ;;; Commentary:
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
30
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
31 ;; Rewritten for XEmacs July 1995, Ben Wing.
5113
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
32 ;; November 1998?, display tables generalized to char/range tables, Hrvoje
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
33 ;; Niksic.
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
34 ;; July 2007, rewrite this file to handle generalized display tables,
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
35 ;; Aidan Kehoe.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
36
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
37 ;;; Code:
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
38
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
39 ;;;###autoload
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
40 (defun make-display-table ()
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
41 "Return a new, empty display table.
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
42
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
43 This returns a generic character table; previously it returned a vector, but
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
44 that was not helpful when dealing with internationalized characters above
4454
1f0aa40cafe0 Small improvements in disp-table.el, mule/cyril-util.el.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4452
diff changeset
45 ?\xFF. See `make-char-table' for details of character tables in general. To
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
46 write code that works with both vectors and character tables, add something
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
47 like the following to the beginning of your file, and use
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
48 `put-display-table' to set what a given character is displayed as, and
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
49 `get-display-table' to examine what that character is currently displayed
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
50 as:
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
51
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
52 \(defun-when-void put-display-table (range value display-table)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
53 \"Set the value for char RANGE to VALUE in DISPLAY-TABLE. \"
4452
82f8351e71c8 Improve portable sample implementations for #'{put,get}-display-table
Aidan Kehoe <kehoea@parhasard.net>
parents: 4451
diff changeset
54 (if (sequencep display-table)
82f8351e71c8 Improve portable sample implementations for #'{put,get}-display-table
Aidan Kehoe <kehoea@parhasard.net>
parents: 4451
diff changeset
55 (aset display-table range value)
82f8351e71c8 Improve portable sample implementations for #'{put,get}-display-table
Aidan Kehoe <kehoea@parhasard.net>
parents: 4451
diff changeset
56 (put-char-table range value display-table)))
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
57
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
58 \(defun-when-void get-display-table (character display-table)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
59 \"Find value for CHARACTER in DISPLAY-TABLE. \"
4452
82f8351e71c8 Improve portable sample implementations for #'{put,get}-display-table
Aidan Kehoe <kehoea@parhasard.net>
parents: 4451
diff changeset
60 (if (sequencep display-table)
82f8351e71c8 Improve portable sample implementations for #'{put,get}-display-table
Aidan Kehoe <kehoea@parhasard.net>
parents: 4451
diff changeset
61 (aref display-table character)
82f8351e71c8 Improve portable sample implementations for #'{put,get}-display-table
Aidan Kehoe <kehoea@parhasard.net>
parents: 4451
diff changeset
62 (get-char-table character display-table)))
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
63
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
64 In this implementation, `put-display-table' and `get-display-table' are
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
65 aliases of `put-char-table' and `get-char-table' respectively, and are
4452
82f8351e71c8 Improve portable sample implementations for #'{put,get}-display-table
Aidan Kehoe <kehoea@parhasard.net>
parents: 4451
diff changeset
66 always available."
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
67 (make-char-table 'generic))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
68
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
69 ;;;###autoload
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
70 (defalias 'put-display-table #'put-char-table)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
71
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
72 ;;;###autoload
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
73 (defalias 'get-display-table #'get-char-table)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
74
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
75 (defun describe-display-table (dt)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
76 "Describe the display table DT in a help buffer."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
77 (with-displaying-help-buffer
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
78 (lambda ()
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
79 (map-char-table
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
80 (lambda (range value)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
81 (cond
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
82 ((eq range t)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
83 (princ "\nAll characters: \n")
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
84 (princ (format " %S" value)))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
85 ((eq 'charset (and (symbolp range) (type-of (find-charset range))))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
86 (princ (format "\n\nCharset %S: \n" (charset-name range)))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
87 (princ (format " %S" value)))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
88 ((vectorp range)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
89 (princ (format "\n\nCharset %S, row %d \n"
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
90 (charset-name (aref value 0))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
91 (aref value 1)))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
92 (princ (format " %S\n\n" value)))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
93 ((characterp range)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
94 (princ (format "\nCharacter U+%04X, %S: "
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
95 range (if (fboundp 'split-char)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
96 (split-char range)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
97 (list 'ascii (char-to-int range)))))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
98 (princ (format " %S" value))))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
99 nil) dt)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
100 (princ
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
101 "\n\nFor some of the various other glyphs that GNU Emacs uses the display
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
102 table for, see the XEmacs specifiers `truncation-glyph' ,
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
103 `continuation-glyph', `control-arrow-glyph', `octal-escape-glyph' and the
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
104 others described in the docstring of `make-glyph'. \n\n"))))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
105
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
106
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
107 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
108 (defun describe-current-display-table (&optional domain)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
109 "Describe the display table in use in the selected window and buffer."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
110 (interactive)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
111 (or domain (setq domain (selected-window)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
112 (let ((disptab (specifier-instance current-display-table domain)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
113 (if disptab
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
114 (describe-display-table disptab)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
115 (message "No display table"))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
116
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
117 ;; #### we need a generic frob-specifier function.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
118 ;; #### this also needs to be redone like frob-face-property.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
119
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
120 ;; Let me say one more time how much dynamic scoping sucks.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
121
5113
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
122 ;; #### Need more thinking about basic primitives for modifying a specifier.
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
123 ;; cf `modify-specifier-instances'.
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
124
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
125 ;;;###autoload
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
126 (defun frob-display-table (fdt-function fdt-locale &optional tag-set)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
127 (or fdt-locale (setq fdt-locale 'global))
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
128 (or (specifier-spec-list current-display-table fdt-locale tag-set)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
129 (add-spec-to-specifier current-display-table (make-display-table)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
130 fdt-locale tag-set))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
131 (add-spec-list-to-specifier
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
132 current-display-table
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
133 (list (cons fdt-locale
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
134 (mapcar
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
135 (lambda (fdt-x)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
136 (funcall fdt-function (cdr fdt-x))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
137 fdt-x)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
138 (cdar (specifier-spec-list current-display-table
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
139 fdt-locale tag-set)))))))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
140
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
141 (defun standard-display-8bit-1 (dt l h)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
142 (while (<= l h)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
143 (remove-char-table (int-to-char l) dt)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
144 (setq l (1+ l))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
145
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
146 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
147 (defun standard-display-8bit (l h &optional locale)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
148 "Display characters in the range L to H literally [sic].
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
149
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
150 GNU Emacs includes this function. There, `literally' has no good meaning.
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
151 Under XEmacs, this function makes characters with numeric values in the
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
152 range L to H display as themselves; that is, as ASCII, latin-iso8859-1,
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
153 latin-iso8859-2 or whatever. See `standard-display-default' for the inverse
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
154 function. "
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
155 (frob-display-table
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
156 (lambda (x)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
157 (standard-display-8bit-1 x l h))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
158 locale))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
159
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
160 (defun standard-display-default-1 (dt l h)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
161 "Misnamed function under XEmacs. See `standard-display-default'."
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
162 (while (<= l h)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
163 (put-char-table (int-to-char l) (format "\\%o" l) dt)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
164 (setq l (1+ l))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
165
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
166 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
167 (defun standard-display-default (l h &optional locale)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
168 "Display characters in the range L to H using octal escape notation.
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
169
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
170 In the XEmacs context this function is misnamed. Under GNU Emacs,
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
171 characters in the range #xA0 to #xFF display as octal escapes unless
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
172 `standard-display-european' has been called; this function neutralizes the
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
173 effects of `standard-display-european'. Under XEmacs, those characters
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
174 normally do not display as octal escapes (this ignores hackery like
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
175 specifying the X11 font character set on non-Mule builds) and this function
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
176 sets them to display as octal escapes. "
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
177 (frob-display-table
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
178 (lambda (x)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
179 (standard-display-default-1 x l h))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
180 locale))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
181
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
182 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
183 (defun standard-display-ascii (c s &optional locale)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
184 "Display character C using printable string S."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
185 (frob-display-table
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
186 (lambda (x)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
187 (put-char-table c s x))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
188 locale))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
189
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
190 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
191 (defun standard-display-g1 (c sc &optional locale)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
192 "Display character C as character SC in the g1 character set.
5113
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
193 This only has an effect on TTY devices and assumes that your terminal uses
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
194 the SO/SI characters."
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
195 (frob-display-table
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
196 (lambda (x)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
197 (put-char-table c (concat "\016" (char-to-string sc) "\017") x))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
198 locale '(tty)))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
199
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
200 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
201 (defun standard-display-graphic (c gc &optional locale)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
202 "Display character C as character GC in graphics character set.
5113
b2dcf6a6d8ab some changes to doc strings/comments in disp-table.el
Ben Wing <ben@xemacs.org>
parents: 4454
diff changeset
203 This only has an effect on TTY devices and assumes VT100-compatible escapes."
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
204 (frob-display-table
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
205 (lambda (x)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
206 (put-char-table c (concat "\e(0" (char-to-string gc) "\e(B") x))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
207 locale '(tty)))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
208
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
209 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
210 (defun standard-display-underline (c uc &optional locale)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
211 "Display character C as character UC plus underlining."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
212 (frob-display-table
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
213 (lambda (x)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
214 (let (glyph)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
215 (setq glyph (make-glyph (vector 'string :data (char-to-string uc))))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
216 (set-glyph-face glyph 'underline)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
217 (put-char-table c glyph x)))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
218 locale))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
220 ;;;###autoload
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
221 (defun standard-display-european (arg &optional locale)
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
222 "Toggle display of European characters encoded with ISO 8859-1.
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
223 When enabled (the default), characters in the range of 160 to 255 display
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
224 as accented characters. With negative prefix argument, display characters in
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
225 that range as octal escapes.
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
226
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
227 If you want to work in a Western European language under XEmacs, it
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
228 shouldn't be necessary to call this function--things should just work. But
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
229 it's in a sufficient number of init files that we're not in a hurry to
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
230 remove it. "
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
231 (interactive "P")
4451
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
232 (if (<= (prefix-numeric-value arg) 0)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
233 (frob-display-table
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
234 (lambda (x)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
235 (standard-display-default-1 x 160 255))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
236 locale)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
237 (frob-display-table
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
238 (lambda (x)
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
239 (standard-display-8bit-1 x 160 255))
e214ff9f9507 Use char-tables, not vectors, to instantiate the display table specifiers.
Aidan Kehoe <kehoea@parhasard.net>
parents: 219
diff changeset
240 locale)))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
241
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
242 (provide 'disp-table)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
243
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents:
diff changeset
244 ;;; disp-table.el ends here