annotate lisp/rect.el @ 4953:304aebb79cd3

function renamings to track names of char typedefs -------------------- ChangeLog entries follow: -------------------- man/ChangeLog addition: 2010-01-27 Ben Wing <ben@xemacs.org> * internals/internals.texi (lrecords): * internals/internals.texi (The DFC API): * internals/internals.texi (Conversion to and from External Data): * internals/internals.texi (Mule-izing Code): * internals/internals.texi (Pervasive changes throughout XEmacs sources): * internals/internals.texi (Ben's README): * internals/internals.texi (Future Work -- Localized Text/Messages): * emodules.texi (Defining Variables): Rename: write_c_string -> write_cistring build_intstring -> build_istring build_string -> build_cistring build_ext_string -> build_extstring make_ext_string -> make_extstring buffer_insert_c_string -> buffer_insert_ascstring intern_int -> intern_istring See comment in src/ChangeLog about this. modules/ChangeLog addition: 2010-01-27 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c (print_pgconn): * postgresql/postgresql.c (print_pgresult): * postgresql/postgresql.c (Fpq_conn_defaults): * postgresql/postgresql.c (Fpq_pgconn): * postgresql/postgresql.c (Fpq_res_status): * postgresql/postgresql.c (Fpq_result_error_message): * postgresql/postgresql.c (Fpq_fname): * postgresql/postgresql.c (Fpq_get_value): * postgresql/postgresql.c (Fpq_cmd_status): * postgresql/postgresql.c (Fpq_cmd_tuples): * postgresql/postgresql.c (Fpq_notifies): * postgresql/postgresql.c (Fpq_get_line): * postgresql/postgresql.c (Fpq_get_line_async): * postgresql/postgresql.c (FROB): * postgresql/postgresql.c (init_postgresql_from_environment): * ldap/eldap.c: * ldap/eldap.c (Fldap_open): * ldap/eldap.c (Fldap_search_basic): * canna/canna_api.c: * canna/canna_api.c (make_euc_string): Rename: write_c_string -> write_cistring build_intstring -> build_istring build_string -> build_cistring build_ext_string -> build_extstring make_ext_string -> make_extstring buffer_insert_c_string -> buffer_insert_ascstring intern_int -> intern_istring See comment in src/ChangeLog about this. src/ChangeLog addition: 2010-01-27 Ben Wing <ben@xemacs.org> * .gdbinit.in.in: * README: * abbrev.c (write_abbrev): * abbrev.c (describe_abbrev): * alloc.c (make_extstring): * alloc.c (build_istring): * alloc.c (build_cistring): * alloc.c (build_ascstring): * alloc.c (build_extstring): * alloc.c (build_msg_istring): * alloc.c (build_defer_istring): * buffer.c (Fgenerate_new_buffer_name): * buffer.c (init_buffer_2): * console-tty.c (tty_init_console): * console-x.c (get_display_arg_connection): * console-x.c (x_perhaps_init_unseen_key_defaults): * database.c (dbm_map): * database.c (dbm_get): * database.c (berkdb_get): * database.c (berkdb_map): * device-gtk.c (FROB_PIXMAP): * device-gtk.c (Fgtk_style_info): * device-msw.c (msprinter_default_printer): * device-msw.c (sync_printer_with_devmode): * device-x.c (coding_system_of_xrm_database): * device-x.c (x_init_device): * device-x.c (signal_if_x_error): * device-x.c (Fx_get_resource): * device-x.c (Fx_server_vendor): * device-x.c (Fx_get_font_path): * dialog-x.c (maybe_run_dbox_text_callback): * doc.c (extract_object_file_name): * doc.c (unparesseuxify_doc_string): * doc.c (get_doc_string): * doc.c (get_object_file_name): * doc.c (Fdocumentation): * doc.c (Fsnarf_documentation): * doc.c (Fsubstitute_command_keys): * editfns.c (init_editfns): * editfns.c (Ftemp_directory): * editfns.c (Fuser_login_name): * editfns.c (Fuser_real_login_name): * editfns.c (Fuser_home_directory): * editfns.c (Fformat_time_string): * editfns.c (Fcurrent_time_string): * editfns.c (Fcurrent_time_zone): * emacs.c: * emacs.c (main_1): * emodules.c (Flist_modules): * emodules.c (emodules_load): * emodules.c (emodules_doc_sym): * emodules.c (vars_of_module): * event-Xt.c (x_has_keysym): * event-gtk.c (emacs_gtk_format_magic_event): * event-gtk.c (dragndrop_data_received): * event-gtk.c (gtk_reset_key_mapping): * event-msw.c (mswindows_dde_callback): * event-msw.c (mswindows_wnd_proc): * faces.c (complex_vars_of_faces): * file-coding.c (find_coding_system): * file-coding.c (setup_eol_coding_systems): * file-coding.c (make_coding_system_1): * file-coding.c (snarf_coding_system): * fileio.c: * fileio.c (lisp_strerror): * fileio.c (Ffile_name_directory): * fileio.c (Ffile_name_as_directory): * fileio.c (Fdirectory_file_name): * fileio.c (if): * fileio.c (Ffile_symlink_p): * fileio.c (Fencrypt_string): * fileio.c (Fdecrypt_string): * filelock.c (lock_file): * filelock.c (Ffile_locked_p): * floatfns.c (matherr): * font-mgr.c (build_fcapi_string): * font-mgr.c (make_xlfd_font_regexp): * frame-msw.c (mswindows_window_id): * frame-msw.c (mswindows_frame_property): * frame-x.c: * frame-x.c (color_to_string): * frame-x.c (maybe_set_frame_title_format): * frame-x.c (x_cde_transfer_callback): * frame-x.c (Fx_window_id): * glade.c (connector): * glade.c (Fglade_xml_textdomain): * glade.c (syms_of_glade): * glyphs-eimage.c (jpeg_instantiate): * glyphs-eimage.c (png_instantiate): * glyphs-eimage.c (tiff_instantiate): * glyphs-gtk.c (font_instantiate): * glyphs-gtk.c (BUILD_GLYPH_INST): * glyphs-x.c (x_locate_pixmap_file): * glyphs-x.c (font_instantiate): * glyphs-x.c (x_widget_property): * glyphs-x.c (BUILD_GLYPH_INST): * glyphs.c (print_image_instance): * glyphs.c (bitmap_to_lisp_data): * glyphs.c (pixmap_to_lisp_data): * gpmevent.c (turn_off_gpm): * gpmevent.c (Fgpm_enabled_p): * gpmevent.c (Fgpm_enable): * gtk-glue.c (__make_string_mapper): * gtk-glue.c (xemacs_gtklist_to_list): * gtk-xemacs.c (FROB_FACE): * gtk-xemacs.c (xemacs_gtk_convert_color): * hpplay.c (player_error_internal): * hpplay.c (myHandler): * insdel.c (buffer_insert_ascstring_1): * insdel.h: * insdel.h (buffer_insert_ascstring): * intl.c (Fcurrent_locale): * intl.c (Fset_current_locale): * keymap.c (make_key_description): * keymap.c (Ftext_char_description): * keymap.c (describe_command): * keymap.c (describe_map): * lisp.h: * lread.c: * lread.c (locate_file_in_directory_mapper): * lread.c (locate_file_construct_suffixed_files_mapper): * mule-charset.c (Fmake_charset): * nt.c (Fmswindows_short_file_name): * nt.c (Fmswindows_long_file_name): * objects-gtk.c (__get_gtk_font_truename): * objects-gtk.c (__gtk_font_list_internal): * objects-msw.c (font_enum_callback_2): * objects-msw.c (create_hfont_from_font_spec): * objects-msw.c (mswindows_font_list): * objects-msw.c (mswindows_font_spec_matches_charset_stage_2): * objects-tty.c (tty_initialize_font_instance): * objects-x.c (x_font_truename): * objects-x.c (x_font_instance_truename): * objects-x.c (x_font_instance_properties): * objects-x.c (x_font_list): * print.c (write_cistring): * print.c (print_vector_internal): * print.c (print_cons): * process-nt.c (nt_canonicalize_host_name): * process-unix.c (unix_create_process): * process-unix.c (unix_canonicalize_host_name): * process.c (status_message): * process.c (status_notify): * process.c (init_xemacs_process): * process.c (syms_of_process): * redisplay-tty.c (term_get_fkeys_1): * redisplay-tty.c (CONDITIONAL_REASSIGN): * search.c (compile_pattern_1): * select-common.h (selection_data_to_lisp_data): * select-gtk.c (atom_to_symbol): * select-gtk.c (PROCESSING_GTK_CODE): * select-msw.c (mswindows_get_foreign_selection): * select-x.c (x_atom_to_symbol): * select-x.c (Fx_get_cutbuffer_internal): * symbols.c (intern_istring): * symbols.c (intern): * symbols.c (intern_converting_underscores_to_dashes): * symbols.c (Fintern): * sysdep.c (init_system_name): * sysdll.c (dll_error): * sysdll.c (dll_open): * syswindows.h: * syswindows.h (build_tstr_string): * tests.c (DFC_CHECK_LENGTH): * tests.c (DFC_CHECK_CONTENT): * tests.c (DFC_RESULT_PASS): * tests.c (Ftest_data_format_conversion): * text.c: * text.c (new_dfc_convert_now_damn_it): * text.h: * text.h (build_wext_string): * tooltalk.c (tt_build_c_string): * tooltalk.c (Ftooltalk_default_procid): * tooltalk.c (Ftooltalk_default_session): * tooltalk.c (init_tooltalk): * ui-byhand.c (Fgtk_clist_get_text): * ui-byhand.c (Fgtk_clist_get_pixtext): * ui-byhand.c (Fgtk_label_get): * ui-byhand.c (Fgtk_notebook_query_tab_label_packing): * ui-gtk.c (emacs_gtk_object_printer): * ui-gtk.c (emacs_gtk_boxed_printer): * ui-gtk.c (gtk_type_to_lisp): * ui-gtk.c (symbol_to_enum): * ui-gtk.c (enum_to_symbol): * unexaix.c (report_error): * unexaix.c (ERROR0): * unexec.c (report_error): * unexec.c (ERROR0): * unicode.c (unicode_to_ichar): * win32.c (tstr_to_local_file_format): * win32.c (Fmswindows_cygwin_to_win32_path): * win32.c (struct read_link_hash): * xemacs.def.in.in: Rename: write_c_string -> write_cistring build_intstring -> build_istring build_string -> build_cistring build_ext_string -> build_extstring make_ext_string -> make_extstring buffer_insert_c_string -> buffer_insert_ascstring intern_int -> intern_istring These functions have been renamed so that the naming harmonizes with the typedefs for strings: `cistring' along with CIbyte *, `istring' along with Ibyte *, `extstring' along with Extbyte *, `ascstring' along with Ascbyte *. Also make buffer_insert_ascstring take Ascbyte * and assert that its argument is ASCII.
author Ben Wing <ben@xemacs.org>
date Wed, 27 Jan 2010 00:35:36 -0600
parents c82f9db998d7
children 308d34e9f07d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; rect.el --- rectangle functions for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3 ;; Copyright (C) 1985-2000 Free Software Foundation, Inc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5 ;; Maintainer: Didier Verna <didier@xemacs.org>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Keywords: internal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;;; Synched up with: to be incorporated in a forthcoming GNU Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;; This package provides the operations on rectangles that are documented
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; in the XEmacs Reference Manual.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
32 ;; #### NOTE: this file has been almost completely rewritten by Didier Verna
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
33 ;; <didier@xemacs.org>, Jul 99. The purpose of this rewrite is to be less
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; intrusive and fill lines with whitespaces only when needed. A few functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; are untouched though, as noted above their definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
40 ;; #### NOTE: this function is untouched, but not used anymore.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 ;; `apply-on-rectangle' is used instead. It's still there because it's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 ;; documented so people might use it in their code, so I've decided not to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 ;; touch it. --dv
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 ;; XEmacs: extra-args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (defun operate-on-rectangle (function start end coerce-tabs &rest extra-args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 "Call FUNCTION for each line of rectangle with corners at START, END.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 If COERCE-TABS is non-nil, convert multi-column characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 that span the starting or ending columns on any line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 to multiple spaces before calling FUNCTION.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 FUNCTION is called with three arguments:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 position of start of segment of this line within the rectangle,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 number of columns that belong to rectangle but are before that position,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 number of columns that belong to rectangle but are after point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 Point is at the end of the segment of this line within the rectangle."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (let (startcol startlinepos endcol endlinepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (goto-char start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (setq startcol (current-column))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (beginning-of-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (setq startlinepos (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (goto-char end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 (setq endcol (current-column))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 (forward-line 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (setq endlinepos (point-marker)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (if (< endcol startcol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 ;; XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 (let ((tem startcol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (setq startcol endcol endcol tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (goto-char startlinepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 (while (< (point) endlinepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (let (startpos begextra endextra)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (move-to-column startcol coerce-tabs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (setq begextra (- (current-column) startcol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (setq startpos (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 (move-to-column endcol coerce-tabs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 (setq endextra (- endcol (current-column)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (if (< begextra 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 (setq endextra (+ endextra begextra)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 begextra 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (if (< endextra 0) (setq endextra 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (apply function startpos begextra endextra extra-args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (forward-line 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (- endcol startcol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 ;; The replacement for `operate-on-rectangle' -- dv
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (defun apply-on-rectangle (function start end &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 "Call FUNCTION for each line of rectangle with corners at START and END.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 FUNCTION is called with two arguments: the start and end columns of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 rectangle, plus ARGS extra arguments. Point is at the beginning of line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 when the function is called."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (let (startcol startpt endcol endpt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (goto-char start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (setq startcol (current-column))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (beginning-of-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (setq startpt (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (goto-char end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 (setq endcol (current-column))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (forward-line 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (setq endpt (point-marker))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 ;; ensure the start column is the left one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (if (< endcol startcol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (let ((col startcol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (setq startcol endcol endcol col)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 ;; start looping over lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (goto-char startpt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 (while (< (point) endpt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (apply function startcol endcol args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (forward-line 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
115 (defun delete-rectangle-line (startcol endcol fill)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
116 (let ((pt (point-at-eol)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
117 (when (= (move-to-column startcol (or fill 'coerce)) startcol)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
118 (if (and (not fill) (<= pt endcol))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
119 (delete-region (point) pt)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
120 ;; else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
121 (setq pt (point))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
122 (move-to-column endcol t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
123 (delete-region pt (point))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
124 ))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (defun delete-rectangle (start end &optional fill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 "Delete the text in the region-rectangle without saving it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 The same range of columns is deleted in each line starting with the line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 where the region begins and ending with the line where the region ends.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 When called from a program, the rectangle's corners are START and END.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 With a prefix (or FILL) argument, also fill lines where nothing has to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 deleted."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (interactive "*r\nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 (apply-on-rectangle 'delete-rectangle-line start end fill))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 ;; I love ascii art ;-)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140 (defconst spaces-strings '[""
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 " "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 " "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 " "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 " "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 " "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 " "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 " "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 " "])
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 ;; This function is untouched --dv
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 (defun spaces-string (n)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 (if (<= n 8) (aref spaces-strings n)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 (let ((val ""))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154 (while (> n 8)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
155 (setq val (concat " " val)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 n (- n 8)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
157 (concat val (aref spaces-strings n)))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (defun delete-extract-rectangle-line (startcol endcol lines fill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (let ((pt (point-at-eol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (if (< (move-to-column startcol (or fill 'coerce)) startcol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (setcdr lines (cons (spaces-string (- endcol startcol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (cdr lines)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 ;; else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (setq pt (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (move-to-column endcol t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (setcdr lines (cons (buffer-substring pt (point)) (cdr lines)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (delete-region pt (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 ;;;###autoload
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 (defun delete-extract-rectangle (start end &optional fill)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 "Delete the contents of the rectangle with corners at START and END, and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175 return it as a list of strings, one for each line of the rectangle.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
177 With an optional FILL argument, also fill lines where nothing has to be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
178 deleted."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (let ((lines (list nil)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
180 (apply-on-rectangle 'delete-extract-rectangle-line start end lines fill)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (nreverse (cdr lines))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
184 ;; #### NOTE: this is actually the only function that needs to do complicated
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 ;; stuff like what's happening in `operate-on-rectangle', because the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 ;; might be read-only. --dv
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (defun extract-rectangle-line (startcol endcol lines)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (let (start end begextra endextra line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (move-to-column startcol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (setq start (point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 begextra (- (current-column) startcol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (move-to-column endcol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 (setq end (point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 endextra (- endcol (current-column)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (setq line (buffer-substring start (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (if (< begextra 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (setq endextra (+ endextra begextra)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 begextra 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 (if (< endextra 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (setq endextra 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (goto-char start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (while (search-forward "\t" end t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (let ((width (- (current-column)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
204 (save-excursion (backward-char 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 (current-column)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (setq line (concat (substring line 0 (- (point) end 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 (spaces-string width)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 (substring line (+ (length line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (- (point) end)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 (if (or (> begextra 0) (> endextra 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 (setq line (concat (spaces-string begextra)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 (spaces-string endextra))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (setcdr lines (cons line (cdr lines)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
216 ;;;###autoload
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
217 (defun extract-rectangle (start end)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 "Return the contents of the rectangle with corners at START and END,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
219 as a list of strings, one for each line of the rectangle."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
220 (let ((lines (list nil)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
221 (apply-on-rectangle 'extract-rectangle-line start end lines)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
222 (nreverse (cdr lines))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
223
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
224
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
225 ;;;###autoload
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
226 (defvar killed-rectangle nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
227 "Rectangle for `yank-rectangle' to insert.")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
228
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
229 ;;;###autoload
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
230 (defun kill-rectangle (start end &optional fill)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
231 "Delete the region-rectangle and save it as the last killed one.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
232 You might prefer to use `delete-extract-rectangle' from a program.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
233
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
234 When called from a program, the rectangle's corners are START and END.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
235 With a prefix (or FILL) argument, also fill lines where nothing has to be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
236 deleted."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
237 (interactive "*r\nP")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
238 (when buffer-read-only
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
239 (setq killed-rectangle (extract-rectangle start end))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
240 (barf-if-buffer-read-only))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
241 (setq killed-rectangle (delete-extract-rectangle start end fill)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
242
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 ;; This function is untouched --dv
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 (defun yank-rectangle ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 "Yank the last killed rectangle with upper left corner at point."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 (interactive "*")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 (insert-rectangle killed-rectangle))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
250
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 ;; This function is untouched --dv
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 (defun insert-rectangle (rectangle)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 "Insert text of RECTANGLE with upper left corner at point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 RECTANGLE's first line is inserted at point, its second
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 line is inserted at a point vertically under point, etc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 RECTANGLE should be a list of strings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 After this command, the mark is at the upper left corner
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 and point is at the lower right corner."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 (let ((lines rectangle)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 (insertcolumn (current-column))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 (first t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (push-mark)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 (while lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 (or first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 (forward-line 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 (or (bolp) (insert ?\n))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 (move-to-column insertcolumn t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 (setq first nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 (insert (car lines))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 (setq lines (cdr lines)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
274
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
275 (defun open-rectangle-line (startcol endcol fill)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
276 (when (= (move-to-column startcol (or fill 'coerce)) startcol)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
277 (unless (and (not fill)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
278 (= (point) (point-at-eol)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
279 (indent-to endcol))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
280
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 (defun open-rectangle (start end &optional fill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 "Blank out the region-rectangle, shifting text right.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 When called from a program, the rectangle's corners are START and END.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 With a prefix (or FILL) argument, fill with blanks even if there is no text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 on the right side of the rectangle."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (interactive "*r\nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 (apply-on-rectangle 'open-rectangle-line start end fill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 (goto-char start))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
292
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
293 (defun string-rectangle-line (startcol endcol string delete)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
294 (move-to-column startcol t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
295 (if delete
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 (delete-rectangle-line startcol endcol nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
297 (insert string))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (defun string-rectangle (start end string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 "Insert STRING on each line of the region-rectangle, shifting text right.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
302 The left edge of the rectangle specifies the column for insertion.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
304 If `pending-delete-mode' is active the string replace the region.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
305 Otherwise this command does not delete or overwrite any existing text.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 When called from a program, the rectangle's corners are START and END."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (interactive "*r\nsString rectangle: ")
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
309 (defvar pending-delete-mode)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
310 (apply-on-rectangle 'string-rectangle-line start end string
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
311 (and (boundp 'pending-delete-mode) pending-delete-mode)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
686
c82f9db998d7 [xemacs-hg @ 2001-12-03 18:02:47 by didierv]
didierv
parents: 446
diff changeset
313 ;;;###autoload
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
314 (defun replace-rectangle (start end string)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 "Like `string-rectangle', but unconditionally replace the original region,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 as if `pending-delete-mode' were active."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
317 (interactive "*r\nsString rectangle: ")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318 (apply-on-rectangle 'string-rectangle-line start end string t))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 (defun clear-rectangle-line (startcol endcol fill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 (let ((pt (point-at-eol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 spaces)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 (when (= (move-to-column startcol (or fill 'coerce)) startcol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (if (and (not fill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (<= (save-excursion (goto-char pt) (current-column)) endcol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 (delete-region (point) pt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 ;; else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 (setq pt (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 (move-to-column endcol t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (setq spaces (- (point) pt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 (delete-region pt (point))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (indent-to (+ (current-column) spaces))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
336 ;;;###autoload
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
337 (defun clear-rectangle (start end &optional fill)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
338 "Blank out the region-rectangle.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
339 The text previously in the region is overwritten with blanks.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
340
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
341 When called from a program, the rectangle's corners are START and END.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
342 With a prefix (or FILL) argument, also fill with blanks the parts of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
343 rectangle which were empty."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
344 (interactive "*r\nP")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
345 (apply-on-rectangle 'clear-rectangle-line start end fill))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
346
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
347
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (provide 'rect)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 ;;; rect.el ends here