Modes for ved 
Author Message
 Modes for ved

One of the features I particularly like about emacs is its use of modes.  A
mode is the way that the editor defines the functionality of a buffer and
the associated set of key bindings that go along with it.

A very simple example is the differences in use of RETURN, line length and
tab positions between a programming language mode and an email mode. I.e.
when writing code one wants certain keywords to be separated by a certain
number of spaces on subsequent lines, and not really care how long the line
length is.

So for example, if I am using emacs in pop11-mode, and write an IF
statement, when I press RETURN it will automatically place my cursor on the
next line at the correct place to start typing (regardless of nesting),
without the need to use TABs or the space bar, eg

if foo > 1 then RETURN
  X

(X = cursor position)

Blissful :-)

However when writing email, the line length is critical, and spaces on
subsequent lines are not. It is trivial to temporarily swap modes so that
one can write some code within an email message (I have all my favourite
modes bound into my key map, so I can change them in seconds).

Some questions come to mind: Why are there no modes in ved? (I am unaware of
any drawbacks of having them), and How do I emulate my emacs modes within
ved as it stands at the moment? I would particularly like the pop11-mode, I
get really fed up having to do it manually.

 Tim
--
    --------------------------------------------------------------------

    Room LG23, School of Computer Science, The University of Birmingham,
    B15 2TT, England, Phone: +44-(0)21-414-4766, Fax: +44-(0)21-414-4281
    --------------------------------------------------------------------



Thu, 25 May 1995 00:09:22 GMT  
 Modes for ved

Quote:

> Organization: School of Computer Science, University of Birmingham, UK
> Date: Sat, 5 Dec 1992 16:09:22 GMT

> One of the features I particularly like about emacs is its use of modes.  A
> mode is the way that the editor defines the functionality of a buffer and
> the associated set of key bindings that go along with it.

I believe some HCI people argue that mode-less systems are best. My
view is that modelessness should be the default, but that users
should be able to specify that they would like associate particular
modes with certain sorts of files, or certain sorts of contexts. If
it's forced on people it will almost certainly not suit all users.

VED already has some of these modes determined by variables like
vedbreak, vedindentstep, etc. and there's scope for matching them
to file names using vedfiletypes (See HELP VEDFILETYPES)

Other modes users can turn on and off include cursor wiggling
to indicate matching brackets. See HELP VED_WIGGLE
(Unfortunately, I don't think you can easily make this work
differently for different files. However you could probably
fiddle with the procedure vedinitfile and veddo to achieve this.)

Quote:
> ....
> So for example, if I am using emacs in pop11-mode, and write an IF
> statement, when I press RETURN it will automatically place my cursor on the
> next line at the correct place to start typing (regardless of nesting),
> without the need to use TABs or the space bar, eg

> if foo > 1 then RETURN
>   X

> (X = cursor position)

> Blissful :-)

There is a much unused Pop-11/VED local library developed at Sussex
by Chris Slymon nearly 10 years ago (I think I modified it a bit
some time later). We actually have it here in Birmingham, and I
expect some other sites have it. It's LIB AUTOINDENT.
See HELP AUTOINDENT
A comment near the top says

| This file describes an experimental package, that alters the action
| of the <RETURN>, <TAB>, <LF>, INSERT-LINE-ABOVE, INSERT-LINE-BELOW
| and <DELETE> keys, to produce semi-automatic indentation of POP
| procedures, that will, hopefully, be identical to that produced by
| ENTER tidy.
|
| ***DISCLAIMER***
| This package does not attempt to remove final responsibility for
| program indentation from the user. You still have to do some work,
| but not much.
| ***END OF DISCLAIMER***

It seems to work with things that have since been added to Pop-11
syntax (e.g. things like #| ... |#) as long as they are in
vedopeners and vedclosers. E.g. after loading the library I typed
the #| indented on the next line, and the remaining lines were
automatically indented.
    #|
        if foo then
            baz(a, b)
        else
            grumble()
        endif
    |#

(When you type RETURN on a line starting with a closer it de-indents
it.)

Someone should put this into $popcontrib or the PLUG archive, maybe
after improving it and checking whether it screws up VED key
mappings in VEDNEWKEYS.

I've known about it for years, but never use it because I prefer
modeless editing (and I type very fast). I wonder how many people do
use it?

Quote:
> However when writing email, the line length is critical, and spaces on
> subsequent lines are not. It is trivial to temporarily swap modes so that
> one can write some code within an email message (I have all my favourite
> modes bound into my key map, so I can change them in seconds).

You can do this with the above package by invoking one of the two
procedures
        vedpopnewlines();
        vedvednewlines();
which you can, of course, map onto keys for rapid mode switching.

Quote:
> Some questions come to mind: Why are there no modes in ved? (I am unaware of
> any drawbacks of having them),

Except that some people hate them....

Quote:
> and How do I emulate my emacs modes within
> ved as it stands at the moment? I would particularly like the pop11-mode, I
> get really fed up having to do it manually.

You are lucky to have this readily available here. I'll ask Sussex
people if they object to it being made more widely available.
Aaron
--
Aaron Sloman, School of Computer Science,
The University of Birmingham, B15 2TT, England

Phone: +44-(0)21-414-3711       Fax:   +44-(0)21-414-4281


Thu, 25 May 1995 01:25:02 GMT  
 Modes for ved

Quote:
> One of the features I particularly like about emacs is its use of modes.  A
> mode is the way that the editor defines the functionality of a buffer and
> the associated set of key bindings that go along with it.

Well doubtless Aaron will come up with a dozen different ways of doing
this in VED, together with an explanation of why you shouldn't in the
first place.  However, as I've always been one to pour oil on a fire, read
on ....

Modes?  Modes?! [Say this second one with a horrified squeak.]  VED is one
of the few editors carefully crafted to avoid modes to the best possible
extent.  When it does have modes (e.g. interactive mode) it gives you
clear feedback on the fact.  

Naturally, by hacking vedfiletypes you can invent all the disgusting
modes you like (BLETCH).  But why bother?

Quote:
> A very simple example is the differences in use of RETURN, line length and
> tab positions between a programming language mode and an email mode.

[Example deleted]

So just redefine the mapping for RETURN and TAB.  Not exactly difficult.
If you want to have several different modes, bind modes to different kinds
of buffers for automatic selection, bind modes to different keystrokes for
exceptional choices, this is just a SMOP[*].

A legitimate complaint might be, why haven't these mode-things been added
to VED already?  The somewhat weak answer is that no one has thought them
useful enough to write and publish.  If anyone has done something similar
they have probably stuffed it in their personal library and forgotten about
it.  I did.

Quote:
> Some questions come to mind: Why are there no modes in ved? (I am unaware of
> any drawbacks of having them), and How do I emulate my emacs modes within
> ved as it stands at the moment? I would particularly like the pop11-mode, I
> get really fed up having to do it manually.

Most people feel that modes are a Bad Thing because it means that you have
to learn different bindings for different contexts.  Unless these contexts
are easily distinguished (which, to be fair, they generally are in EMACS)
then this makes the system clumsy and difficult to learn.  Great for power
users, though.

My belief is that VED hasn't got modes because it isn't used as a general
purpose text interface in the way that EMACS is.  EMACS is much much more
than a text editor -- I always think of it as the world's best mailer.
I don't think much of it as an editor, but it beats the heck out of most
mailers that I've seen.  Since VED only gets used for 2 tasks, in the main,
there is too little requirement for multiple modes.

To get the effect of auto-indentation, I suggest rebinding the return
key to a procedure that inspects the current line and makes a sensible
decision on how to indent.  If Aaron hasn't done this already I shall
have a go later on ....

Steve

[*] SMOP -- a Small Matter Of Programming.  My favourite Merry-ism.



Fri, 26 May 1995 03:32:23 GMT  
 Modes for ved

Quote:


>> Organization: School of Computer Science, University of Birmingham, UK
>> Date: Sat, 5 Dec 1992 16:09:22 GMT

>> One of the features I particularly like about emacs is its use of modes.  A
>> mode is the way that the editor defines the functionality of a buffer and
>> the associated set of key bindings that go along with it.

>I believe some HCI people argue that mode-less systems are best.

True, but the only *truly* modeless  system is one  which is unplugged
:-) The clever bit comes  in preventing the  users from realising this
fact.

Quote:

>VED already has some of these modes determined by variables like
>vedbreak, vedindentstep, etc. and there's scope for matching them
>to file names using vedfiletypes (See HELP VEDFILETYPES)

The problem is, that in ved one has a  set of independent options, and
must hence set these variables independently  (of couse, one can write
ved_email_mode and put in in one's  vedinit.p,  but that's a different
thing. An emacs mode could  be considered to be a  binding of a set of
these   attribute settings, with the  addition  of such  things as key
bindings etc.
The power of emacs modes is that you have comething approaching
a  class hierachy  -  thus electric-c-mode  (which  does all  the neat
indenting for you without even having to press return) is a minor mode
of c-mode, which  itself is a  minor mode of....  all the way  down to
fundamental  mode. True, there's nothing  here which can't be done  in
ved: the point is, it *hasn't* been done in ved.

--
&ndy Holyer, School of Cognitive and     |Due to recent events in the USA,
Computing Studies, University of Sussex, |I find I can no longer use this

                                         |be resumed when I find another one.



Fri, 26 May 1995 20:16:04 GMT  
 Modes for ved

Quote:

> Well doubtless Aaron will come up with a dozen different ways of doing
> this in VED, together with an explanation of why you shouldn't in the
> first place.  However, as I've always been one to pour oil on a fire, read
> on ....

Witty, dangerous but very witty :-) And his suggestions were as usual very
helpful!

Quote:
> So just redefine the mapping for RETURN and TAB.  Not exactly difficult.

True, but the point is I don't want to have to press TAB after pressing the
RETURN key.

Quote:
> Most people feel that modes are a Bad Thing because it means that you have
> to learn different bindings for different contexts.  

Not most EMACS users.

Quote:
> Unless these contexts are easily distinguished (which, to be fair, they
> generally are in EMACS)

Being fair about EMACS Steve, now there's a novelty....  :-)

Quote:
> My belief is that VED hasn't got modes because it isn't used as a general
> purpose text interface in the way that EMACS is.  EMACS is much much more
> than a text editor -- I always think of it as the world's best mailer.
> I don't think much of it as an editor, but it beats the heck out of most
> mailers that I've seen.  Since VED only gets used for 2 tasks, in the main,
> there is too little requirement for multiple modes.

It's also a great news reader, online manual browser (info files), interface
to a lot of system applications (eg a transparent ftp tool) and provides
modes for most of the major languages. I believe there is even a spread
sheet mode on the way.. Its downside for doing POP11 is that it doesn't have
a `close contact' with the language, and things like the de{*filter*} don't work
with it. How about a move toward an editor neutral version of poplog? Where
hooks are provided to fit with whatever editor one has come to know and
love.

 Tim
--
    --------------------------------------------------------------------

    Room LG23, School of Computer Science, The University of Birmingham,
    B15 2TT, England, Phone: +44-(0)21-414-4766, Fax: +44-(0)21-414-4281
    --------------------------------------------------------------------



Fri, 26 May 1995 23:42:39 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VED in VT100 mode

2. VED in VT100 mode

3. ved and modes

4. modes, ved, emacs, UI

5. Running Ved from Ved

6. Syntactic errors when compiling from a ved buffer

7. making the world safe for ved

8. ved and rxvt (Boring)

9. DRAFT Ved utility for editing files whose names have spaces

10. ved key-mapping to conventional use.

11. linux , non-X, ved ?

12. ved key-mapping ?

 

 
Powered by phpBB® Forum Software