emacs bindings for less
Charles Brown
charles at hpcvcd.HP
Wed Jan 21 07:51:23 AEST 1987
I tried to mail this to the moderator of mod.sources. Either I do
not have the correct mail address for him, or I just don't know how
to get from hplabs to mirror. So I am posting this here. These
diffs are from the version of less in mod.sources. They may not
apply to the version(s) recently posted here in net.sources.
-----------------------------------------------------------------
Date= Fri Dec 19 15:00:41 1986
From: Charles Brown hplabs!hp-pcd!charles
To: mod.sources moderator hp-pcd!hplabs!mirror!sources
Re: less
When porting less to our HP9000s500 we modified a few files.
To make it work correctly with HP terminals:
screen.c
HP terminals treat the screen as a window
into the terminal memory. It is possible to
move this window up and down within this
screen memory. When you scroll the screen
down, the text that disappears off the bottom
of the screen is still in memory. If you
then scroll the screen back up (such as
typing LF at the bottom of the screen) the
text re-appears. Usually this feature is
very desirable. Only occasionally will
programs show up which assume that text which
has scrolled down has been permanently
erased. I believe the enclosed change will
work with non-HP terminals.
To make things a little cleaner and esthetic:
makefile.sys5 (linked to makefile)
To add emacs bindings:
command.c
prim.c
version.c
less.nro
================================================================
diffs for screen.c
236c236
< sc_eol_clear = (dumb) ? NULL : tgetstr("ce", &sp);
---
> sc_eol_clear = (dumb) ? NULL : tgetstr("cd", &sp);
================================================================
diffs for makefile.sys5
92c92
< INSTALL_HELP = /usr/local/bin/less.help
---
> INSTALL_HELP = /usr/local/lib/less.help
95c95
< HELPFILE = /usr/local/bin/less.help
---
> HELPFILE = /usr/local/lib/less.help
================================================================
diffs for command.c
74c74,80
< putc(mcc);
---
> if( mcc == CONTROL('S') )
> puts("search forward:");
> else
> if( mcc == CONTROL('R') )
> puts("search reverse:");
> else
> putc(mcc);
277c283,286
< case '/': case '?':
---
> case '/':
> case '?':
> case CONTROL('S'):
> case CONTROL('R'):
281c290,294
< for (p = cmdbuf; *p == '+' || *p == ' '; p++) ;
---
> for (
> p = cmdbuf;
> *p == '+' || *p == ' ';
> p++
> ) ;
299a313
> case CONTROL('_'):
345a360
> case CONTROL('V'):
370a386
> case CONTROL('N'):
383a400
> case CONTROL('P'):
426d442
< case CONTROL('R'):
486a503
> case CONTROL('C'):
492a510,522
> case CONTROL('R'):
> /*
> * If vi then redraw, if emacs then reverse search
> */
> if( 0 == strcmp( editor, "emacs" ) )
> goto reverse;
> else
> {
> /* Repaint screen. */
> repaint();
> }
> break;
>
494a525,526
> case CONTROL('S'):
> case CONTROL(']'):
498a531
> reverse:
501a535
> if(c == CONTROL(']')) c = CONTROL('S'); /* kludge */
532a567
> examine:
543a579
> case CONTROL('_'):
593a630,721
> case CONTROL('X'):
> /*
> * ^X command prefix
> */
> puts("^X");
> c = getcc();
> switch(c)
> {
> case CONTROL('V'):
> goto examine;
> case 'n':
> /*
> * Examine next file.
> */
> n = cmd_int();
> if (n <= 0)
> n = 1;
> next_file(n);
> break;
> case 'p':
> /*
> * Examine previous file.
> */
> n = cmd_int();
> if (n <= 0)
> n = 1;
> prev_file(n);
> break;
> case CONTROL('X'):
> /*
> * Go to a mark.
> */
> lower_left();
> clear_eol();
> puts("goto mark: ");
> c = getcc();
> if (c == erase_char || c == kill_char)
> break;
> gomark(c);
> break;
> case CONTROL('C'):
> /*
> * Exit.
> */
> /*setjmp(main_loop);*/
> quit();
> default:
> bell();
> break;
> }
> break;
>
> case CONTROL('['):
> /*
> * Meta- command prefix
> */
> puts("Meta-");
> c = getcc();
> switch(c)
> {
> case 'v':
> /*
> * Backward one screen.
> */
> n = cmd_int();
> if (n <= 0)
> n = sc_window;
> backward(n, 1);
> break;
> case ' ':
> /*
> * Set mark.
> */
> goto mark;
> case '<':
> /*
> * Go to beginning of file.
> */
> jump_back(1);
> break;
> case '>':
> /*
> * Go to end of file.
> */
> jump_forw();
> break;
> default:
> bell();
> break;
> }
> break;
>
612a741
> case CONTROL('@'):
615a745
> mark:
================================================================
diffs for prim.c
534c534,535
< register int search_forward = (direction == '/');
---
> register int search_forward =
> (direction == '/' || direction == CONTROL('S'));
================================================================
diffs for version.c
104a105,106
> * v61.1: Change clear_eol to clear_eos (HP fix) 12/18/86 eric
> * Add emacs bindings charles
108c110
< char version[] = "@(#) less version 61";
---
> char version[] = "@(#) less version 61.1";
================================================================
diffs for less.nro
26,27c26,27
< Commands are based on both
< .I more
---
> Commands are based on
> .I more, emacs
46a47,49
> .IP "^V"
> Same as SPACE.
> .PP
50a54,56
> .IP "ESCAPE-v"
> Same as b.
> .PP
58a65,67
> Same as RETURN.
> .PP
> .IP "^N"
66a76,78
> .IP "^P"
> Same as y.
> .PP
77c89
< .IP "r or ^R or ^L"
---
> .IP "r or ^L"
79a92,96
> .IP "^R"
> If the environment variable EDITOR is set to emacs,
> then this is the same as "?".
> Otherwise, it is the same as "r".
> .PP
92a110,115
> .IP "ESCAPE-<"
> Go to line 1 in the file.
> .PP
> .IP "ESCAPE->"
> Go to the end of the file.
> .PP
105c128
< .IP m
---
> .IP "m or ^@ or ESCAPE-SPACE"
109c132
< .IP "'"
---
> .IP "' or ^X^X"
117c140
< .IP /pattern
---
> .IP "/pattern or ^]pattern or ^Spattern"
132c155
< .IP E [filename]
---
> .IP "E[filename] or ^X^V[filename]"
137c160
< .IP N
---
> .IP "N or ^Xn"
142c165
< .IP P
---
> .IP "P or ^Xp"
170c193
< .IP q
---
> .IP "q or ^C or ^X^C"
183c206
< .IP "! shell-command"
---
> .IP "![shell-command] or ^_[shell-command]"
================================================================
More information about the Comp.sources.unix
mailing list