[comp.emacs] isearch-forward

cgs@umd5 (Chris Sylvain) (12/03/86)

[]

Because of certain hardware limitations, I've used global-set-key so
that I can invoke isearch-forward with CTRL-\ instead of CTRL-S.
I'd like to have CTRL-\ act the same way CTRL-S does with all the "magic"
such as when it is typed more than once -- you can search for the string
you searched for the last time. As it stands now, CTRL-\ just prompts for
a new search string repeatedly. Can I do this with a macro, or do I have
to use a different function name than isearch-forward ?

-- 
--==---==---==--
.. And hast thou slain the Jabberwock? ..

ARPA: cgs@umd5.UMD.EDU     BITNET: cgs%umd5@umd2
UUCP: ..!seismo!umd5.umd.edu!cgs

trent@cit-vax.Caltech.Edu (Ray Trent) (12/03/86)

In article <1381@umd5> cgs@umd5 (Chris Sylvain) writes:

>I'd like to have CTRL-\ act the same way CTRL-S does with all the "magic"
>such as when it is typed more than once -- you can search for the string
>you searched for the last time. As it stands now, CTRL-\ just prompts for
>a new search string repeatedly. Can I do this with a macro, or do I have

The following is an elisp program that does what was requested. It
does its translation before the rest of gnuemacs sees the character,
so everything that worked with C-s and C-q now work with C-\ and C-^.
It was posted to the net a while ago...but since no one seems to
remember it, I thought I'd repost it. The documentation is pretty
self-explanatory.  As I remember, it was distributed under the terms
of the Gnu License. (q.v.)

--------------------cut here-------------------

;Kuling :/usr/alla/christer/emacs/xonxoff.el, Thu Apr 10 20:50:38 1986,
; Edit by: Christer Johansson (christer@kuling)
; Changed DOCSTRING of Xon-xoff-mode. Removed -*- line. 
;Edited: Tue Nov 19 1985 by christer@kuling (Christer Johansson)
; /usr/alla/christer/emacs/xonxoff.el Added variables C-{S,Q}-Replacement.
;Edited: Mon Nov 11 1985 by christer@kuling (Christer Johansson)
; /usr/alla/christer/emacs/xonxoff.el Works under ver. 16.60

;; Make the identity translation table.
(progn (setq keyboard-translate-table (make-string 128 0))
       (let ((i 0))
	 (while (< i 128)
	   (aset keyboard-translate-table i i)
	   (setq i (1+ i)))))

(defvar xon-xoff-mode t
  "Controls the xon-xoff mode.
If this variable is nil, xon-xoff-mode is off.")
       
(defun xon-xoff-mode (arg)
  "Xon-xoff mode's good if you want too use ^s and ^q for flow-control.
Turns Xon-xoff mode on if ARG > 0, off if ARG < 0.
With ARG = 0, Xon-xoff-mode toggles. 
If Xon-xoff-mode is on, all ^^ typed by the user will be translated to ^q
before they are interpreted in any way. Likewise ^\ will be translated to ^s.
If the options C-Q-Replacement and C-S-Replacement are set, there values will
be used instead of ^^ and ^\. ^q and ^s will be used for flow-controll in
xon-xoff-mode.
"
  (interactive "p")

  (setq xon-xoff-mode
	(if (and (zerop arg)
		 (boundp xon-xoff-mode))
	  (not xon-xoff-mode)
	  (> arg 0)))

  (set-input-mode nil xon-xoff-mode)

  (if xon-xoff-mode
      (progn (aset keyboard-translate-table
		   (if (boundp 'C-S-Replacement)
		       C-S-Replacement
		     ?\^^)
		   ?\^s)
	     (aset keyboard-translate-table 
		   (if (boundp 'C-Q-Replacement)
		       C-Q-Replacement
		     ?\^\\)
		   ?\^q))

    (aset keyboard-translate-table ?\^s ?\^s)
    (aset keyboard-translate-table ?\^q ?\^q)))

(xon-xoff-mode 1)
-- 
"A journey of a thousand miles..."
					../ray\..
 (trent@csvax.caltech.edu, rat@caltech.bitnet, ...seismo!cit-vax!trent)

cgs@umd5 (Chris Sylvain) (12/03/86)

In article <1267@cit-vax.Caltech.Edu> trent@cit-vax.UUCP (Ray Trent) writes:
>In article <1381@umd5> cgs@umd5 (Chris Sylvain) writes:
>
>>I'd like to have CTRL-\ act the same way CTRL-S does with all the "magic"
>
>The following is an elisp program that does what was requested. It
>does its translation before the rest of gnuemacs sees the character
> ... ... The documentation is pretty self-explanatory. As I remember,
> it was distributed under the terms of the Gnu License. (q.v.)
>

Actually, although the documentation is self-explanatory, it does need
the following corrections:
>
>If Xon-xoff-mode is on, all ^^ typed by the user will be translated to ^q
                           change to: ^\ typed is translated to ^q
>before they are interpreted in any way. Likewise ^\ will be translated to ^s.
                                     likewise, change ^\ to ^^
>If the options C-Q-Replacement and C-S-Replacement are set, thier values will
                                                               ^^
>be used instead of ^^ and ^\. ^q and ^s will be used for flow-controll in
                   reverse the order of ^^ and ^\

Of course, the code could be changed to reflect the documentation.

Thanks to everyone who responded.


-- 
--==---==---==--
.. And hast thou slain the Jabberwock? ..

ARPA: cgs@umd5.UMD.EDU     BITNET: cgs%umd5@umd2
UUCP: ..!seismo!umd5.umd.edu!cgs

matt@oddjob.UChicago.EDU (Matt Crawford) (12/06/86)

Here is a shorter incantation than Ray's.  Usually you always
want the ^S/^Q remapped on certain terminals, so put the
following in your ~/.emacs file:
================
(cond
 ((string-match "^vt1" (getenv "TERM"))
  (set-input-mode nil t)
  (setq keyboard-translate-table
"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\023\035\021\037")))
================
This is pretty rigid.  You have to rewrite the string to change
which characters will take the place of ^S and ^Q.  With this
string ^\ becomes ^S and ^^ becomes ^Q.
_____________________________________________________
Matt		University	crawford@anl-mcs.arpa
Crawford	of Chicago	ihnp4!oddjob!matt

The PINK SOCKS were ORIGINALLY from 1952!!
But they went to MARS around 1953!!

christer@kuling.UUCP (Christer Johansson) (12/08/86)

In article <1267@cit-vax.Caltech.Edu> of Wed, 3-Dec-86 08:01:32 GMT
trent@cit-vax.UUCP (Ray Trent) writes:

>The following is an elisp program that, [...] as I remember, [...] was
>distributed under the terms of the Gnu License.

[code removed]

Sweden doesn't have the broken copyright laws that the US has, so we don't
need such things as gnu licenses. The swedish copyrigt law only applies to
programs if they're works of art. (In a lawsuit recently visicalc was found not
to be a work of art. The same would probably hold for emacs).
-- 
SMail: Christer Johansson  Email:  Christer@Aida.Uppsala.se
       Sernanders v 9:136  UUCP:  {seismo,seismo!mcvax}!enea!kuling!christer
       S-752 62  Uppsala   ARPA:  enea!kuling!christer@SEISMO.CSS.GOV (???)
           SWEDEN          Phone: Int. +46 - 18 46 31 54
				  Nat. 018 - 46 31 54