all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.