Article View: gnu.epoch.misc
Article #1974Re: keysym binding - how ??
From: Alan M. Carroll
Date: Mon, 20 May 1991 20:59
Date: Mon, 20 May 1991 20:59
64 lines
3398 bytes
3398 bytes
In article <1991May21.001313.1@summer.chem.su.oz.au>, moss_r@summer.chem.su.oz.au writes:
> First, can someone give me some code that shows how epoch::rebind-key
> works, as the doc. on it is a *bit* un-obvious.
I'd suggest looking at ./contrib/amc/keys.el. That's the file that I
was using for my keybindings when 3.2 was released.
> Second, the variable epoch::function-key-mapping supposedly turns off
> the translation of the X keysyms into escape sequences....
For compatability with Emacs, function keys are mapped to bizarre
escape sequences by default. This "feature" can be disabled by setting
the variable epoch::function-key-mapping to nil, in which case
function keys are ignored unless explicitly rebound via
epoch::rebind-key.
> If no translation is taking place, can you redefine the keysyms
> themselves, ie something like (global-set-key F1 'dired) - the sought of
> thing you would do in emacs ?
I don't think you can do something like that in Emacs. What you
actually must do is bind the function key to some other sequence of
characters, and then bind that sequence to the function you want. For
instance, I bind "Home" to "\C-^k7" with
(rebind-key "Home" 0 "\C-^k7")
and then bind that to move to the start of the line with
(global-set-key "\C-^k7" 'beginning-of-line)
> If translation is taking place, do you have to define a new \e-[ key map
> to stop the translations throwing random-ish ~[12 and [OA keysequences
> into text if you hit one of them accidently ?
Effectively, yes. That's why I put the mapping variable in.
> Lastly, is there some simple explantion ( or some sample code ) showing
> how you redefine such events as mouse key presses/releases ?
You can redefine a mouse event using the (global-set-mouse) or
(local-set-mouse) functions. Here is an example that tells the line
number of the line that the shifted left mouse button is clicked on:
(defun mouse-buffer-line (marg)
"Show the line number and buffer of the mouse EVENT"
;; marg is (point buffer window screen)
;; Pop over to the clicked buffer
(save-excursion (set-buffer (cadr marg))
;; Figure out how far down the mouse point is
(let ((n (count-lines (point-min) (car marg))))
;; display it. Include the buffer name for good measure.
(message (format "Line %d in %s" n (buffer-name (cadr marg))))
)))
;; Bind shift left down to display the line number.
(global-set-mouse mouse-left mouse-shift 'mouse-buffer-line)
--
Alan M. Carroll <-- Another casualty of applied metaphysics
Epoch Development Team
Urbana Il. "I hate shopping with the reality-impaired" - Susan
Technical Details
Message-ID:
<1991May20.205921.1756@m.cs.uiuc.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!news.cs.indiana.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!uiucdcs!carrollReferences:
<1991May21.001313.1@summer.chem.su.oz.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,f5a0e864671ee5b7 X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1991-05-20 22:16:05 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!news.cs.indiana.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!uiucdcs!carroll From: carroll@cs.uiuc.edu (Alan M. Carroll) Newsgroups: gnu.epoch.misc Subject: Re: keysym binding - how ?? Message-ID: <1991May20.205921.1756@m.cs.uiuc.edu> Date: 20 May 91 20:59:21 GMT References: <1991May21.001313.1@summer.chem.su.oz.au> Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager)) Organization: Technophiles Inc. - Engineers with Attitude Lines: 64 Nntp-Posting-Host: ash.cs.uiuc.edu