Mercurial > hg > xemacs-beta
annotate lisp/finder.el @ 5127:a9c41067dd88 ben-lisp-object
more cleanups, terminology clarification, lots of doc work
-------------------- ChangeLog entries follow: --------------------
man/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* internals/internals.texi (Introduction to Allocation):
* internals/internals.texi (Integers and Characters):
* internals/internals.texi (Allocation from Frob Blocks):
* internals/internals.texi (lrecords):
* internals/internals.texi (Low-level allocation):
Rewrite section on allocation of Lisp objects to reflect the new
reality. Remove references to nonexistent XSETINT and XSETCHAR.
modules/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c (allocate_pgconn):
* postgresql/postgresql.c (allocate_pgresult):
* postgresql/postgresql.h (struct Lisp_PGconn):
* postgresql/postgresql.h (struct Lisp_PGresult):
* ldap/eldap.c (allocate_ldap):
* ldap/eldap.h (struct Lisp_LDAP):
Same changes as in src/ dir. See large log there in ChangeLog,
but basically:
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
../hlo/src/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (old_alloc_sized_lcrecord):
* alloc.c (very_old_free_lcrecord):
* alloc.c (copy_lisp_object):
* alloc.c (zero_sized_lisp_object):
* alloc.c (zero_nonsized_lisp_object):
* alloc.c (lisp_object_storage_size):
* alloc.c (free_normal_lisp_object):
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC):
* alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT):
* alloc.c (Fcons):
* alloc.c (noseeum_cons):
* alloc.c (make_float):
* alloc.c (make_bignum):
* alloc.c (make_bignum_bg):
* alloc.c (make_ratio):
* alloc.c (make_ratio_bg):
* alloc.c (make_ratio_rt):
* alloc.c (make_bigfloat):
* alloc.c (make_bigfloat_bf):
* alloc.c (size_vector):
* alloc.c (make_compiled_function):
* alloc.c (Fmake_symbol):
* alloc.c (allocate_extent):
* alloc.c (allocate_event):
* alloc.c (make_key_data):
* alloc.c (make_button_data):
* alloc.c (make_motion_data):
* alloc.c (make_process_data):
* alloc.c (make_timeout_data):
* alloc.c (make_magic_data):
* alloc.c (make_magic_eval_data):
* alloc.c (make_eval_data):
* alloc.c (make_misc_user_data):
* alloc.c (Fmake_marker):
* alloc.c (noseeum_make_marker):
* alloc.c (size_string_direct_data):
* alloc.c (make_uninit_string):
* alloc.c (make_string_nocopy):
* alloc.c (mark_lcrecord_list):
* alloc.c (alloc_managed_lcrecord):
* alloc.c (free_managed_lcrecord):
* alloc.c (sweep_lcrecords_1):
* alloc.c (malloced_storage_size):
* buffer.c (allocate_buffer):
* buffer.c (compute_buffer_usage):
* buffer.c (DEFVAR_BUFFER_LOCAL_1):
* buffer.c (nuke_all_buffer_slots):
* buffer.c (common_init_complex_vars_of_buffer):
* buffer.h (struct buffer_text):
* buffer.h (struct buffer):
* bytecode.c:
* bytecode.c (make_compiled_function_args):
* bytecode.c (size_compiled_function_args):
* bytecode.h (struct compiled_function_args):
* casetab.c (allocate_case_table):
* casetab.h (struct Lisp_Case_Table):
* charset.h (struct Lisp_Charset):
* chartab.c (fill_char_table):
* chartab.c (Fmake_char_table):
* chartab.c (make_char_table_entry):
* chartab.c (copy_char_table_entry):
* chartab.c (Fcopy_char_table):
* chartab.c (put_char_table):
* chartab.h (struct Lisp_Char_Table_Entry):
* chartab.h (struct Lisp_Char_Table):
* console-gtk-impl.h (struct gtk_device):
* console-gtk-impl.h (struct gtk_frame):
* console-impl.h (struct console):
* console-msw-impl.h (struct Lisp_Devmode):
* console-msw-impl.h (struct mswindows_device):
* console-msw-impl.h (struct msprinter_device):
* console-msw-impl.h (struct mswindows_frame):
* console-msw-impl.h (struct mswindows_dialog_id):
* console-stream-impl.h (struct stream_console):
* console-stream.c (stream_init_console):
* console-tty-impl.h (struct tty_console):
* console-tty-impl.h (struct tty_device):
* console-tty.c (allocate_tty_console_struct):
* console-x-impl.h (struct x_device):
* console-x-impl.h (struct x_frame):
* console.c (allocate_console):
* console.c (nuke_all_console_slots):
* console.c (DEFVAR_CONSOLE_LOCAL_1):
* console.c (common_init_complex_vars_of_console):
* data.c (make_weak_list):
* data.c (make_weak_box):
* data.c (make_ephemeron):
* database.c:
* database.c (struct Lisp_Database):
* database.c (allocate_database):
* database.c (finalize_database):
* device-gtk.c (allocate_gtk_device_struct):
* device-impl.h (struct device):
* device-msw.c:
* device-msw.c (mswindows_init_device):
* device-msw.c (msprinter_init_device):
* device-msw.c (finalize_devmode):
* device-msw.c (allocate_devmode):
* device-tty.c (allocate_tty_device_struct):
* device-x.c (allocate_x_device_struct):
* device.c:
* device.c (nuke_all_device_slots):
* device.c (allocate_device):
* dialog-msw.c (handle_question_dialog_box):
* elhash.c:
* elhash.c (struct Lisp_Hash_Table):
* elhash.c (finalize_hash_table):
* elhash.c (make_general_lisp_hash_table):
* elhash.c (Fcopy_hash_table):
* elhash.h (htentry):
* emacs.c (main_1):
* eval.c:
* eval.c (size_multiple_value):
* event-stream.c (finalize_command_builder):
* event-stream.c (allocate_command_builder):
* event-stream.c (free_command_builder):
* event-stream.c (event_stream_generate_wakeup):
* event-stream.c (event_stream_resignal_wakeup):
* event-stream.c (event_stream_disable_wakeup):
* event-stream.c (event_stream_wakeup_pending_p):
* events.h (struct Lisp_Timeout):
* events.h (struct command_builder):
* extents-impl.h:
* extents-impl.h (struct extent_auxiliary):
* extents-impl.h (struct extent_info):
* extents-impl.h (set_extent_no_chase_aux_field):
* extents-impl.h (set_extent_no_chase_normal_field):
* extents.c:
* extents.c (gap_array_marker):
* extents.c (gap_array):
* extents.c (extent_list_marker):
* extents.c (extent_list):
* extents.c (stack_of_extents):
* extents.c (gap_array_make_marker):
* extents.c (extent_list_make_marker):
* extents.c (allocate_extent_list):
* extents.c (SLOT):
* extents.c (mark_extent_auxiliary):
* extents.c (allocate_extent_auxiliary):
* extents.c (attach_extent_auxiliary):
* extents.c (size_gap_array):
* extents.c (finalize_extent_info):
* extents.c (allocate_extent_info):
* extents.c (uninit_buffer_extents):
* extents.c (allocate_soe):
* extents.c (copy_extent):
* extents.c (vars_of_extents):
* extents.h:
* faces.c (allocate_face):
* faces.h (struct Lisp_Face):
* faces.h (struct face_cachel):
* file-coding.c:
* file-coding.c (finalize_coding_system):
* file-coding.c (sizeof_coding_system):
* file-coding.c (Fcopy_coding_system):
* file-coding.h (struct Lisp_Coding_System):
* file-coding.h (MARKED_SLOT):
* fns.c (size_bit_vector):
* font-mgr.c:
* font-mgr.c (finalize_fc_pattern):
* font-mgr.c (print_fc_pattern):
* font-mgr.c (Ffc_pattern_p):
* font-mgr.c (Ffc_pattern_create):
* font-mgr.c (Ffc_name_parse):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.c (Ffc_pattern_duplicate):
* font-mgr.c (Ffc_pattern_add):
* font-mgr.c (Ffc_pattern_del):
* font-mgr.c (Ffc_pattern_get):
* font-mgr.c (fc_config_create_using):
* font-mgr.c (fc_strlist_to_lisp_using):
* font-mgr.c (fontset_to_list):
* font-mgr.c (Ffc_config_p):
* font-mgr.c (Ffc_config_up_to_date):
* font-mgr.c (Ffc_config_build_fonts):
* font-mgr.c (Ffc_config_get_cache):
* font-mgr.c (Ffc_config_get_fonts):
* font-mgr.c (Ffc_config_set_current):
* font-mgr.c (Ffc_config_get_blanks):
* font-mgr.c (Ffc_config_get_rescan_interval):
* font-mgr.c (Ffc_config_set_rescan_interval):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_app_font_clear):
* font-mgr.c (size):
* font-mgr.c (Ffc_config_substitute):
* font-mgr.c (Ffc_font_render_prepare):
* font-mgr.c (Ffc_font_match):
* font-mgr.c (Ffc_font_sort):
* font-mgr.c (finalize_fc_config):
* font-mgr.c (print_fc_config):
* font-mgr.h:
* font-mgr.h (struct fc_pattern):
* font-mgr.h (XFC_PATTERN):
* font-mgr.h (struct fc_config):
* font-mgr.h (XFC_CONFIG):
* frame-gtk.c (allocate_gtk_frame_struct):
* frame-impl.h (struct frame):
* frame-msw.c (mswindows_init_frame_1):
* frame-x.c (allocate_x_frame_struct):
* frame.c (nuke_all_frame_slots):
* frame.c (allocate_frame_core):
* gc.c:
* gc.c (GC_CHECK_NOT_FREE):
* glyphs.c (finalize_image_instance):
* glyphs.c (allocate_image_instance):
* glyphs.c (Fcolorize_image_instance):
* glyphs.c (allocate_glyph):
* glyphs.c (unmap_subwindow_instance_cache_mapper):
* glyphs.c (register_ignored_expose):
* glyphs.h (struct Lisp_Image_Instance):
* glyphs.h (struct Lisp_Glyph):
* glyphs.h (struct glyph_cachel):
* glyphs.h (struct expose_ignore):
* gui.c (allocate_gui_item):
* gui.h (struct Lisp_Gui_Item):
* keymap.c (struct Lisp_Keymap):
* keymap.c (make_keymap):
* lisp.h:
* lisp.h (struct Lisp_String_Direct_Data):
* lisp.h (struct Lisp_String_Indirect_Data):
* lisp.h (struct Lisp_Vector):
* lisp.h (struct Lisp_Bit_Vector):
* lisp.h (DECLARE_INLINE_LISP_BIT_VECTOR):
* lisp.h (struct weak_box):
* lisp.h (struct ephemeron):
* lisp.h (struct weak_list):
* lrecord.h:
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER):
* lrecord.h (struct lcrecord_list):
* lstream.c (finalize_lstream):
* lstream.c (sizeof_lstream):
* lstream.c (Lstream_new):
* lstream.c (Lstream_delete):
* lstream.h (struct lstream):
* marker.c:
* marker.c (finalize_marker):
* marker.c (compute_buffer_marker_usage):
* mule-charset.c:
* mule-charset.c (make_charset):
* mule-charset.c (compute_charset_usage):
* objects-impl.h (struct Lisp_Color_Instance):
* objects-impl.h (struct Lisp_Font_Instance):
* objects-tty-impl.h (struct tty_color_instance_data):
* objects-tty-impl.h (struct tty_font_instance_data):
* objects-tty.c (tty_initialize_color_instance):
* objects-tty.c (tty_initialize_font_instance):
* objects.c (finalize_color_instance):
* objects.c (Fmake_color_instance):
* objects.c (finalize_font_instance):
* objects.c (Fmake_font_instance):
* objects.c (reinit_vars_of_objects):
* opaque.c:
* opaque.c (sizeof_opaque):
* opaque.c (make_opaque_ptr):
* opaque.c (free_opaque_ptr):
* opaque.h:
* opaque.h (Lisp_Opaque):
* opaque.h (Lisp_Opaque_Ptr):
* print.c (printing_unreadable_lcrecord):
* print.c (external_object_printer):
* print.c (debug_p4):
* process.c (finalize_process):
* process.c (make_process_internal):
* procimpl.h (struct Lisp_Process):
* rangetab.c (Fmake_range_table):
* rangetab.c (Fcopy_range_table):
* rangetab.h (struct Lisp_Range_Table):
* scrollbar.c:
* scrollbar.c (create_scrollbar_instance):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h (struct scrollbar_instance):
* specifier.c (finalize_specifier):
* specifier.c (sizeof_specifier):
* specifier.c (set_specifier_caching):
* specifier.h (struct Lisp_Specifier):
* specifier.h (struct specifier_caching):
* symeval.h:
* symeval.h (SYMBOL_VALUE_MAGIC_P):
* symeval.h (DEFVAR_SYMVAL_FWD):
* symsinit.h:
* syntax.c (init_buffer_syntax_cache):
* syntax.h (struct syntax_cache):
* toolbar.c:
* toolbar.c (allocate_toolbar_button):
* toolbar.c (update_toolbar_button):
* toolbar.h (struct toolbar_button):
* tooltalk.c (struct Lisp_Tooltalk_Message):
* tooltalk.c (make_tooltalk_message):
* tooltalk.c (struct Lisp_Tooltalk_Pattern):
* tooltalk.c (make_tooltalk_pattern):
* ui-gtk.c:
* ui-gtk.c (allocate_ffi_data):
* ui-gtk.c (emacs_gtk_object_finalizer):
* ui-gtk.c (allocate_emacs_gtk_object_data):
* ui-gtk.c (allocate_emacs_gtk_boxed_data):
* ui-gtk.h:
* window-impl.h (struct window):
* window-impl.h (struct window_mirror):
* window.c (finalize_window):
* window.c (allocate_window):
* window.c (new_window_mirror):
* window.c (mark_window_as_deleted):
* window.c (make_dummy_parent):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
Overall point of this change and previous ones in this repository:
(1) Introduce new, clearer terminology: everything other than int
or char is a "record" object, which comes in two types: "normal
objects" and "frob-block objects". Fix up all places that
referred to frob-block objects as "simple", "basic", etc.
(2) Provide an advertised interface for doing operations on Lisp
objects, including creating new types, that is clean and
consistent in its naming, uses the above-referenced terms and
avoids referencing "lrecords", "old lcrecords", etc., which should
hide under the surface.
(3) Make the size_in_bytes and finalizer methods take a
Lisp_Object rather than a void * for consistency with other methods.
(4) Separate finalizer method into finalizer and disksaver, so
that normal finalize methods don't have to worry about disksaving.
Other specifics:
(1) Renaming:
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
implementation->basic_p -> implementation->frob_block_p
ALLOCATE_FIXED_TYPE_AND_SET_IMPL -> ALLOC_FROB_BLOCK_LISP_OBJECT
*FCCONFIG*, wrap_fcconfig -> *FC_CONFIG*, wrap_fc_config
*FCPATTERN*, wrap_fcpattern -> *FC_PATTERN*, wrap_fc_pattern
(the last two changes make the naming of these macros consistent
with the naming of all other macros, since the objects are named
fc-config and fc-pattern with a hyphen)
(2) Lots of documentation fixes in lrecord.h.
(3) Eliminate macros for copying, freeing, zeroing objects, getting
their storage size. Instead, new functions:
zero_sized_lisp_object()
zero_nonsized_lisp_object()
lisp_object_storage_size()
free_normal_lisp_object()
(copy_lisp_object() already exists)
LISP_OBJECT_FROB_BLOCK_P() (actually a macro)
Eliminated:
free_lrecord()
zero_lrecord()
copy_lrecord()
copy_sized_lrecord()
old_copy_lcrecord()
old_copy_sized_lcrecord()
old_zero_lcrecord()
old_zero_sized_lcrecord()
LISP_OBJECT_STORAGE_SIZE()
COPY_SIZED_LISP_OBJECT()
COPY_SIZED_LCRECORD()
COPY_LISP_OBJECT()
ZERO_LISP_OBJECT()
FREE_LISP_OBJECT()
(4) Catch the remaining places where lrecord stuff was used directly
and use the advertised interface, e.g. alloc_sized_lrecord() ->
ALLOC_SIZED_LISP_OBJECT().
(5) Make certain statically-declared pseudo-objects
(buffer_local_flags, console_local_flags) have their lheader
initialized correctly, so things like copy_lisp_object() can work
on them. Make extent_auxiliary_defaults a proper heap object
Vextent_auxiliary_defaults, and make extent auxiliaries dumpable
so that this object can be dumped. allocate_extent_auxiliary()
now just creates the object, and attach_extent_auxiliary()
creates an extent auxiliary and attaches to an extent, like the
old allocate_extent_auxiliary().
(6) Create EXTENT_AUXILIARY_SLOTS macro, similar to the foo-slots.h
files but in a macro instead of a file. The purpose is to avoid
duplication when iterating over all the slots in an extent auxiliary.
Use it.
(7) In lstream.c, don't zero out object after allocation because
allocation routines take care of this.
(8) In marker.c, fix a mistake in computing marker overhead.
(9) In print.c, clean up printing_unreadable_lcrecord(),
external_object_printer() to avoid lots of ifdef NEW_GC's.
(10) Separate toolbar-button allocation into a separate
allocate_toolbar_button() function for use in the example code
in lrecord.h.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Mar 2010 04:08:17 -0600 |
parents | e29fcfd8df5f |
children | 308d34e9f07d |
rev | line source |
---|---|
2984 | 1 ;;; finder.el --- topic & keyword-based code finder |
2 | |
3 ;; Copyright (C) 1992 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | |
6 ;; Created: 16 Jun 1992 | |
7 ;; Version: 1.0 | |
8 ;; Keywords: help | |
9 ;; X-Modified-by: Bob Weiner <weiner@mot.com>, 4/18/95, to include Lisp | |
10 ;; library directory names in finder-program-info, for fast display of | |
11 ;; Lisp libraries and associated commentaries. Added {v}, finder-view, | |
12 ;; and {e}, finder-edit commands for displaying libraries. | |
13 ;; | |
14 ;; Added user variable, 'finder-abbreviate-directory-list', used to | |
15 ;; abbreviate directories before they are saved to finder-program-info. | |
16 ;; Such relative directories can be portable from one Emacs installation | |
17 ;; to another. Default value is based upon the value of Emacs' | |
18 ;; data-directory variable. | |
19 | |
20 ;; This file is part of XEmacs. | |
21 | |
22 ;; XEmacs is free software; you can redistribute it and/or modify it | |
23 ;; under the terms of the GNU General Public License as published by | |
24 ;; the Free Software Foundation; either version 2, or (at your option) | |
25 ;; any later version. | |
26 | |
27 ;; XEmacs is distributed in the hope that it will be useful, but | |
28 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
29 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
30 ;; General Public License for more details. | |
31 | |
32 ;; You should have received a copy of the GNU General Public License | |
33 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
34 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
35 ;; 02111-1307, USA. | |
36 | |
37 ;;; Synched up with: FSF 19.34. | |
38 | |
39 ;;; Commentary: | |
40 | |
41 ;; This mode uses the Keywords library header to provide code-finding | |
42 ;; services by keyword. | |
43 ;; | |
44 ;; Things to do: | |
45 ;; 1. Support multiple keywords per search. This could be extremely hairy; | |
46 ;; there doesn't seem to be any way to get completing-read to exit on | |
47 ;; an EOL with no substring pending, which is what we'd want to end the loop. | |
48 ;; 2. Search by string in synopsis line? | |
49 ;; 3. Function to check finder-package-info for unknown keywords. | |
50 | |
51 ;;; Code: | |
52 | |
53 (require 'lisp-mnt) | |
54 (condition-case nil | |
55 (require 'finder-inf) | |
56 (t nil)) | |
57 ;; XEmacs addition | |
58 (require 'picture) | |
59 (require 'mode-motion) | |
60 | |
61 (defvar finder-emacs-root-directory | |
62 (file-name-directory (directory-file-name data-directory)) | |
63 "Root directory of current emacs tree.") | |
64 | |
65 (defvar finder-abbreviate-directory-list | |
66 (list finder-emacs-root-directory) | |
67 "*List of directory roots to remove from finder-package-info directory entries. | |
68 The first element in the list is used when expanding relative package | |
69 directories to view or extract information from package source code.") | |
70 | |
71 (defvar finder-file-regexp "\\.el$" | |
72 "Regexp which matches file names but not Emacs Lisp finder keywords.") | |
73 | |
74 ;; Local variable in finder buffer. | |
75 (defvar finder-headmark) | |
76 | |
77 (defvar finder-known-keywords | |
78 `( | |
79 (abbrev . "abbreviation handling, typing shortcuts, macros") | |
80 (bib . "code related to the `bib' bibliography processor") | |
81 (build . "code used to build XEmacs") | |
82 (c . "C, C++, and Objective-C language support") | |
83 (calendar . "calendar and time management support") | |
84 (comm . "communications, networking, remote access to files") | |
85 (content . "contains content (menu/dialog box descs, text, images, &c)") | |
86 (data . "support for editing files of data") | |
87 (docs . "support for XEmacs documentation") | |
88 (dumped . "files preloaded into XEmacs") | |
89 (emulations . "emulations of other editors") | |
90 (extensions . "Emacs Lisp language extensions") | |
91 (faces . "support for multiple fonts") | |
92 (frames . "support for XEmacs frames and window systems") | |
93 (games . "games, jokes and amusements") | |
94 (gui . "support for menubars, dialog boxes, and other GUI features") | |
95 (hardware . "support for interfacing with exotic hardware") | |
96 (help . "support for on-line help systems") | |
97 (hypermedia . "support for links between text or other media types") | |
98 (i18n . "internationalization and alternate character-set support") | |
99 (internal . "code implementing core functionality in XEmacs") | |
100 (languages . "specialized modes for editing programming languages") | |
101 (lisp . "Lisp support, including Emacs Lisp") | |
102 (local . "code local to your site") | |
103 (mail . "modes for electronic-mail handling") | |
104 (maint . "maintenance aids for the Emacs development group") | |
105 (matching . "various sorts of searching and matching") | |
106 (mouse . "mouse support") | |
107 (mswin . "support for anything running on MS Windows") | |
108 ,(when (featurep 'mule) | |
109 (cons 'mule "multi-language extensions")) | |
110 (news . "support for netnews reading and posting") | |
111 (oop . "support for object-oriented programming") | |
112 (outlines . "support for hierarchical outlining") | |
113 (processes . "process, subshell, compilation, and job control support") | |
114 (services . "provides services for use by other programs (cf `user')") | |
115 (terminals . "support for terminal types") | |
116 (tex . "code related to the TeX formatter") | |
117 (tools . "programming tools") | |
118 (unix . "front-ends/assistants for, or emulators of, UNIX features") | |
119 (user . "program interacts directly with the user (cf `services'") | |
120 (vms . "support code for vms") | |
121 (wp . "word processing") | |
122 (www . "support for the Web (WWW, the World Wide Web)") | |
123 )) | |
124 | |
125 (defvar finder-mode-map nil) | |
126 (or finder-mode-map | |
127 (let ((map (make-sparse-keymap))) | |
128 (define-key map " " 'finder-select) | |
129 (define-key map "f" 'finder-select) | |
130 (define-key map "\C-m" 'finder-select) | |
131 ;; XEmacs changes | |
132 (define-key map "e" 'finder-edit) | |
133 (define-key map "v" 'finder-view) | |
134 (define-key map "?" 'finder-summary) | |
135 (define-key map "q" 'finder-exit) | |
136 (define-key map "d" 'finder-list-keywords) | |
137 ;; XEmacs change | |
138 (define-key map [button2] 'finder-mouse-select) | |
139 (setq finder-mode-map map))) | |
140 | |
141 | |
142 ;;; Code for regenerating the keyword list. | |
143 | |
144 (defvar finder-package-info nil | |
145 "Assoc list mapping file names to description & keyword lists.") | |
146 | |
147 (defvar finder-compile-keywords-quiet nil | |
148 "If non-nil finder-compile-keywords will not print any messages.") | |
149 | |
150 (defun finder-compile-keywords (&rest dirs) | |
151 "Regenerate the keywords association list into the file `finder-inf.el'. | |
152 Optional arguments are a list of Emacs Lisp directories to compile from; no | |
153 arguments compiles from `load-path'." | |
154 (save-excursion | |
155 ;; XEmacs change | |
156 (find-file (expand-file-name "finder-inf.el" lisp-directory)) | |
157 (let ((processed nil) | |
158 (directory-abbrev-alist | |
159 (append | |
160 (mapcar (function (lambda (dir) | |
161 (cons (concat "^" (regexp-quote dir)) | |
162 ""))) | |
163 finder-abbreviate-directory-list) | |
164 directory-abbrev-alist)) | |
165 (using-load-path)) | |
166 (or dirs (setq dirs load-path)) | |
167 (setq using-load-path (equal dirs load-path)) | |
168 (erase-buffer) | |
169 (insert ";;; finder-inf.el --- keyword-to-package mapping\n") | |
170 (insert ";; Keywords: help\n") | |
171 (insert ";;; Commentary:\n") | |
172 (insert ";; Don't edit this file. It's generated by finder.el\n\n") | |
173 (insert ";;; Code:\n") | |
174 (insert "\n(defconst finder-package-info '(\n") | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2984
diff
changeset
|
175 (mapc |
2984 | 176 (lambda (d) |
177 (mapcar | |
178 (lambda (f) | |
179 (when (and (not (member f processed)) (file-readable-p f)) | |
180 (let (summary keystart keywords) | |
181 (setq processed (cons f processed)) | |
182 (if (not finder-compile-keywords-quiet) | |
183 (message "Processing %s ..." f)) | |
184 (save-excursion | |
185 (set-buffer (get-buffer-create "*finder-scratch*")) | |
186 (buffer-disable-undo (current-buffer)) | |
187 (erase-buffer) | |
188 (insert-file-contents (expand-file-name f d)) | |
189 (with-trapping-errors | |
190 :operation (format "processing %s in finder" f) | |
191 :class 'finder | |
192 (setq summary (lm-synopsis) | |
193 keywords (lm-keywords)))) | |
194 (when summary | |
195 (insert (format " (\"%s\"\n " f)) | |
196 (prin1 summary (current-buffer)) | |
197 (insert "\n ") | |
198 (setq keystart (point)) | |
199 (insert (if keywords (format "(%s)" keywords) "nil")) | |
200 (subst-char-in-region keystart (point) ?, ? ) | |
201 (insert "\n ") | |
202 (prin1 (abbreviate-file-name d) (current-buffer)) | |
203 (insert ")\n"))))) | |
204 ;; | |
205 ;; Skip null, non-existent or relative pathnames, e.g. "./", if | |
206 ;; using load-path, so that they do not interfere with a scan of | |
207 ;; library directories only. | |
208 (if (and using-load-path | |
209 (not (and d (file-name-absolute-p d) (file-exists-p d)))) | |
210 nil | |
211 (setq d (file-name-as-directory (or d "."))) | |
212 (directory-files d nil "^[^=].*\\.el$")))) | |
213 dirs) | |
214 (insert "))\n\n(provide 'finder-inf)\n\n;;; finder-inf.el ends here\n") | |
215 (kill-buffer "*finder-scratch*") | |
216 (unless noninteractive | |
217 (eval-current-buffer)) ; So we get the new keyword list immediately | |
218 (basic-save-buffer)))) | |
219 | |
220 (defun finder-compile-keywords-make-dist () | |
221 "Regenerate `finder-inf.el' for the Emacs distribution." | |
222 (finder-compile-keywords default-directory)) | |
223 | |
224 ;;; Now the retrieval code | |
225 | |
226 (defun finder-insert-at-column (column &rest strings) | |
227 "Insert list of STRINGS, at column COLUMN." | |
228 (if (>= (current-column) column) (insert "\n")) | |
229 (move-to-column column) | |
230 (let ((col (current-column))) | |
231 (if (< col column) | |
232 (indent-to column) | |
233 (if (and (/= col column) | |
234 (= (preceding-char) ?\t)) | |
235 (let (indent-tabs-mode) | |
236 (delete-char -1) | |
237 (indent-to col) | |
238 (move-to-column column))))) | |
239 (apply 'insert strings)) | |
240 | |
241 (defun finder-list-keywords () | |
242 "Display descriptions of the keywords in the Finder buffer." | |
243 (interactive) | |
244 (setq buffer-read-only nil) | |
245 (erase-buffer) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2984
diff
changeset
|
246 (mapc |
2984 | 247 (lambda (assoc) |
248 (let ((keyword (car assoc))) | |
249 (insert (symbol-name keyword)) | |
250 (finder-insert-at-column 14 (concat (cdr assoc) "\n")) | |
251 (cons (symbol-name keyword) keyword))) | |
252 finder-known-keywords) | |
253 (goto-char (point-min)) | |
254 (setq finder-headmark (point)) | |
255 (setq buffer-read-only t) | |
256 (set-buffer-modified-p nil) | |
257 ;; XEmacs change | |
258 (if (not (one-window-p)) | |
259 (balance-windows)) | |
260 (finder-summary)) | |
261 | |
262 (defun finder-list-matches (key) | |
263 (setq buffer-read-only nil) | |
264 (erase-buffer) | |
265 (let ((id (intern key))) | |
266 (insert | |
267 "The following packages match the keyword `" key "':\n\n") | |
268 (setq finder-headmark (point)) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2984
diff
changeset
|
269 (mapc |
2984 | 270 (lambda (x) |
271 (if (memq id (car (cdr (cdr x)))) | |
272 (progn | |
273 (insert (car x)) | |
274 (finder-insert-at-column 16 (concat (car (cdr x)) "\n"))))) | |
275 finder-package-info) | |
276 (goto-char (point-min)) | |
277 (forward-line) | |
278 (setq buffer-read-only t) | |
279 (set-buffer-modified-p nil) | |
280 (shrink-window-if-larger-than-buffer) | |
281 (finder-summary))) | |
282 | |
283 ;; Search for a file named FILE the same way `load' would search. | |
284 (defun finder-find-library (file) | |
285 (if (file-name-absolute-p file) | |
286 file | |
287 (let ((dirs load-path) | |
288 found) | |
289 (while (and dirs (not found)) | |
290 (if (file-exists-p (expand-file-name (concat file ".el") (car dirs))) | |
291 (setq found (expand-file-name (concat file ".el") (car dirs))) | |
292 (if (file-exists-p (expand-file-name file (car dirs))) | |
293 (setq found (expand-file-name file (car dirs))))) | |
294 (setq dirs (cdr dirs))) | |
295 found))) | |
296 | |
297 ;;;###autoload | |
298 (defun finder-commentary (file) | |
299 "Display FILE's commentary section. | |
300 FILE should be in a form suitable for passing to `locate-library'." | |
301 (interactive "sLibrary name: ") | |
302 (let* ((str (lm-commentary (or (finder-find-library file) | |
303 (finder-find-library (concat file ".el")) | |
304 (error "Can't find library %s" file))))) | |
305 (if (null str) | |
306 (error "Can't find any Commentary section")) | |
307 (pop-to-buffer "*Finder*") | |
308 ;; XEmacs change | |
309 (setq buffer-read-only nil | |
310 mode-motion-hook 'mode-motion-highlight-line) | |
311 (erase-buffer) | |
312 (insert str) | |
313 (goto-char (point-min)) | |
314 (delete-blank-lines) | |
315 (goto-char (point-max)) | |
316 (delete-blank-lines) | |
317 (goto-char (point-min)) | |
318 (while (re-search-forward "^;+ ?" nil t) | |
319 (replace-match "" nil nil)) | |
320 (goto-char (point-min)) | |
321 (setq buffer-read-only t) | |
322 (set-buffer-modified-p nil) | |
323 (shrink-window-if-larger-than-buffer) | |
324 (finder-summary))) | |
325 | |
326 (defun finder-current-item () | |
327 (if (and finder-headmark (< (point) finder-headmark)) | |
328 (error "No keyword or filename on this line") | |
329 (save-excursion | |
330 (beginning-of-line) | |
331 (current-word)))) | |
332 | |
333 ;; XEmacs change | |
334 (defun finder-edit () | |
335 (interactive) | |
336 (let ((entry (finder-current-item))) | |
337 (if (string-match finder-file-regexp entry) | |
338 (let ((path (finder-find-library entry))) | |
339 (if path | |
340 (find-file-other-window path) | |
341 (error "Can't find Emacs Lisp library: '%s'" entry))) | |
342 ;; a finder keyword | |
343 (error "Finder-edit works on Emacs Lisp libraries only")))) | |
344 | |
345 ;; XEmacs change | |
346 (defun finder-view () | |
347 (interactive) | |
348 (let ((entry (finder-current-item))) | |
349 (if (string-match finder-file-regexp entry) | |
350 (let ((path (finder-find-library entry))) | |
351 (if path | |
352 (view-file-other-window path) | |
353 (error "Can't find Emacs Lisp library: '%s'" entry))) | |
354 ;; a finder keyword | |
355 (error "Finder-view works on Emacs Lisp libraries only")))) | |
356 | |
357 (defun finder-select () | |
358 (interactive) | |
359 (let ((key (finder-current-item))) | |
360 ;; XEmacs change | |
361 (if (string-match finder-file-regexp key) | |
362 (finder-commentary key) | |
363 (finder-list-matches key)))) | |
364 | |
365 ;; XEmacs change | |
366 (defun finder-mouse-select (ev) | |
367 (interactive "e") | |
368 (goto-char (event-point ev)) | |
369 (finder-select)) | |
370 | |
371 ;; XEmacs change | |
372 ;;;###autoload | |
373 (defun finder-by-keyword () | |
374 "Find packages matching a given keyword." | |
375 (interactive) | |
376 (finder-mode) | |
377 (finder-list-keywords)) | |
378 | |
379 (defun finder-mode () | |
380 "Major mode for browsing package documentation. | |
381 \\<finder-mode-map> | |
382 \\[finder-select] more help for the item on the current line | |
383 \\[finder-edit] edit Lisp library in another window | |
384 \\[finder-view] view Lisp library in another window | |
385 \\[finder-exit] exit Finder mode and kill the Finder buffer. | |
386 " | |
387 (interactive) | |
388 (pop-to-buffer "*Finder*") | |
389 ;; XEmacs change | |
390 (setq buffer-read-only nil | |
391 mode-motion-hook 'mode-motion-highlight-line) | |
392 (erase-buffer) | |
393 (use-local-map finder-mode-map) | |
394 (set-syntax-table emacs-lisp-mode-syntax-table) | |
395 (setq mode-name "Finder") | |
396 (setq major-mode 'finder-mode) | |
397 (make-local-variable 'finder-headmark) | |
398 (setq finder-headmark nil)) | |
399 | |
400 (defun finder-summary () | |
401 "Summarize basic Finder commands." | |
402 (interactive) | |
403 (message "%s" | |
404 (substitute-command-keys | |
405 ;; XEmacs change | |
406 "\\<finder-mode-map>\\[finder-select] = select, \\[finder-list-keywords] = keywords, \\[finder-edit] = edit, \\[finder-view] = view, \\[finder-exit] = quit, \\[finder-summary] = help"))) | |
407 | |
408 (defun finder-exit () | |
409 "Exit Finder mode and kill the buffer." | |
410 (interactive) | |
411 ;; XEmacs change | |
412 (or (one-window-p t 0) | |
413 (delete-window)) | |
414 (kill-buffer "*Finder*")) | |
415 | |
416 (provide 'finder) | |
417 | |
418 ;;; finder.el ends here |