From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: weber Newsgroups: gmane.emacs.help Subject: Re: Global shifted keys rebinding conflicts with skeletons Date: Thu, 26 Jul 2007 23:21:43 -0000 Organization: http://groups.google.com Message-ID: <1185492103.541749.63830@d55g2000hsg.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1185493271 30621 80.91.229.12 (26 Jul 2007 23:41:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 26 Jul 2007 23:41:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 27 01:41:06 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IECx8-0001YP-0J for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Jul 2007 01:41:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IECx7-0008JQ-9i for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Jul 2007 19:41:05 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!d55g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 80 Original-NNTP-Posting-Host: 189.6.212.239 Original-X-Trace: posting.google.com 1185492103 8842 127.0.0.1 (26 Jul 2007 23:21:43 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 26 Jul 2007 23:21:43 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1) Gecko/20061023 SUSE/2.0-30 Firefox/2.0,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: d55g2000hsg.googlegroups.com; posting-host=189.6.212.239; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.help:150529 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:46108 Archived-At: On Jul 26, 12:21 pm, "Denis Bueno" 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