unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Global shifted keys rebinding conflicts with skeletons
@ 2007-07-26 16:21 Denis Bueno
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Bueno @ 2007-07-26 16:21 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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 "]")))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Global shifted keys rebinding conflicts with skeletons
       [not found] <mailman.4024.1185466940.32220.help-gnu-emacs@gnu.org>
@ 2007-07-26 23:21 ` weber
  2007-07-30 21:40   ` Denis Bueno
  0 siblings, 1 reply; 3+ messages in thread
From: weber @ 2007-07-26 23:21 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Global shifted keys rebinding conflicts with skeletons
  2007-07-26 23:21 ` Global shifted keys rebinding conflicts with skeletons weber
@ 2007-07-30 21:40   ` Denis Bueno
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Bueno @ 2007-07-30 21:40 UTC (permalink / raw)
  To: weber, help-gnu-emacs

On 07/26/2007 17:21, "weber" <hugows@gmail.com> wrote:

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

This worked famously.  Thanks very much.

-Denis

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-30 21:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4024.1185466940.32220.help-gnu-emacs@gnu.org>
2007-07-26 23:21 ` Global shifted keys rebinding conflicts with skeletons weber
2007-07-30 21:40   ` Denis Bueno
2007-07-26 16:21 Denis Bueno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).