help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Global shifted keys rebinding conflicts with skeletons


From: weber
Subject: Re: Global shifted keys rebinding conflicts with skeletons
Date: Thu, 26 Jul 2007 23:21:43 -0000
User-agent: G2/1.0

On Jul 26, 12:21 pm, "Denis Bueno" <denb...@sandia.gov> wrote:
> Hi all,
>
> Upon prompting from my tired fingers, I've decided to switch some
> keybindings in emacs.  Specifically, I'd like to have access to (, ), {, },
> without using Shift, and use Shift to get 9, 0, [, ].  This is of course
> easy[1] to do.  But certain modes (at least sh-mode) uses skeleton by
> default and thus doesn't obey the global-set-keys I used to implement the
> rebundings above.  I would like use skeletons to insert pairs of [] and {},
> etc., but I want access to {} unshifted and [] shifted (as well as ()
> unshifted).
>
> Anyone who has already run into this problem and solved it is likely to know
> that he has the solution before reading on; what follows is a more precise
> description.
>
> After executing the global-set-keys [1] and starting to edit a bash script,
> *some* of my bindings had been clobbered:
>
>   [ -> [  ;; instead of {
>   ] -> }  ;; as expected
>   9 -> (  ;; as expected
>   0 -> )  ;; as expected
>   shift-9 -> ( ;; should be 9
>
> I believe this is due to skeleton-mode, and I'm convinced that I can solve
> the problem either using `skeleton-transformation-function' or
> `skeleton-pair-alist', but I can't seem to get either approach to work;
> probably because I don't understand exactly how they work.  (skeleton-pair
> is t.)
>
> I tried the following as the value of `skeleton-transformation-function':
>
>     (defun shift-unshifted-trans (str)
>       (case str
>         (?\[ ?\{)
>         (?\{ ?\[)
>         (?\] ?\})
>         (?\} ?\])
>
>         ("[" "{")
>         ("{" "[")
>         ("]" "}")
>         ("}" "]")
>
>         (t nil)))
>
> But this didn't change any behavior in sh-mode.
>
> I tried the following as the value of `skeleton-pair-alist':
>
>     (defvar dlb-skeleton-pair-alist
>       (list
>        (list ?\[ ?\{ '_ ?\})
>        (list ?\{ ?\[ '_ ?\])))
>
> Again without observable change.  GNU Emacs 22.1.50.2
> (i386-apple-darwin8.10.1, Carbon Version 1.6.0) of 2007-07-17.
>
> Any ideas?
>
> -Denis
>
> [1]
> ;; swap 90 and ()
> (global-set-key "9" '(lambda () (interactive) (insert "(")))
> (global-set-key "0" '(lambda () (interactive) (insert ")")))
> (global-set-key "(" '(lambda () (interactive) (insert "9")))
> (global-set-key ")" '(lambda () (interactive) (insert "0")))
> ;; swap [] and {}
> (global-set-key "[" '(lambda () (interactive) (insert "{")))
> (global-set-key "]" '(lambda () (interactive) (insert "}")))
> (global-set-key "{" '(lambda () (interactive) (insert "[")))
> (global-set-key "}" '(lambda () (interactive) (insert "]")))

Maybe you could do something more low level ?
See this : http://www.zafar.se/bkz/Articles/EmacsTips
 HTH,
weber



reply via email to

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