emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Highlighting rectangles?


From: Ehud Karni
Subject: Re: Highlighting rectangles?
Date: Fri, 2 Nov 2001 15:33:20 +0200

On Thu, 1 Nov 2001 16:07:39 -0700 (MST), Richard Stallman <address@hidden> 
wrote:
> 
>     My marking system signal error if the 1st mark type != 2nd mark type.
>     It check the mark type and give an error message if the type does not
>     match the operation.
> 
> I see.  I guess that prevents certain kinds of confusion.
> 
> What happens with the many Emacs commands that operate on the
> (linear) region?  If you mark a rectangle with your package
> and then use (say) fill-region, what happens?

The solution (work around ?) for operations on the block mark that
need the block as one continuous string is like this:
  1. It is copied to a temp buffer.
  2. The operation is done on the temp buffer.
  3. The original block is deleted and the temp buffer is inserted
     (as a block).
  4. The temp buffer is killed.


Since my system uses its own variables (a cons of marker and column
number) for the marked area, it needs its own functions to work on the
marked area.

Here is the documentation of reflow-marked which does fill-region:

Reflow the marked area by use of `fill-region-as-paragraph'
Can be done on all kinds of mark but it behave differently:
  line marked are the normal fill-region (in R2L mode use the
       right2left-1st-col as the fill column.
  character marked - the fill column is set to the 2nd mark, In R2L
   fill column is: right2left-1st-col + 1 - 2nd mark column.
  block mark - reflow the BLOCK only, with columns set to block width.
Optional prefix JUSTIFY means add extra spaces to justify on both sides.

Note. R2L is for right 2 left - this function work on Hebrew texts too.


The general function to work on marked area is:

(defun call-func-on-marked (types err-msg pop-blk range restore func &rest args)
  "Runs lisp function on marked area. Argument are:
TYPES   - marks type allowed. Add all allowed (1-lines, 2-char, 4-block)
ERR-MSG - string to display by error if type mis-match.
POP-BLK - if non nil, pop to temp block buffer or mark buffer before calling
                      Also - do NOT narrow to marked region.
RANGE   - if non nil, add 2 arguments to the funcall before ARGS - start end.
RESTORE - if non nil, restore blocked area and reset marks.
FUNC    - lisp function name to call.
ARGS    - more arguments to pass to the called func."

This function does all the overhead: checks mark existence and type,
narrowing/copying to temp buffer, widening/restoring blocks.

It is fully developed package, and I can post it to sources. However the
incorporation into mainstream Emacs is difficult because it is based on
different concept that Emacs "region".

This package may be easier for persons moving to Emacs from Editors
that use similar marking concept (I did it myself).

Ehud.


-- 
 Ehud Karni     Mivtach - Simon  Insurance   /"\
 Tel: +972-3-7966-561 Fax: +972-3-7966-667   \ /  ASCII Ribbon Campaign
 (USA) Fax and  voice  mail: 1-815-5509341    X   Against  HTML  Mail
     Better     Safe     Than     Sorry      / \
     mailto:address@hidden    http://www.simonwiesel.co.il



reply via email to

[Prev in Thread] Current Thread [Next in Thread]