unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Remap DEL and Shift-Up to kill to end of line
@ 2008-04-29  0:21 plus852
  2008-04-29  1:02 ` plus852
  0 siblings, 1 reply; 5+ messages in thread
From: plus852 @ 2008-04-29  0:21 UTC (permalink / raw)
  To: help-gnu-emacs

I'm not sure how to remap keys, but I'd like to remap DEL (not
backspace/delete) and Shift-Up to kill to end of line (in addition to
C-k); I'd also like DEL-DEL and Shift-Up Shift-Up (DEL or Shift-Up
typed twice without any other input) to kill to end of paragraph. Is
this possible?


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

* Re: Remap DEL and Shift-Up to kill to end of line
  2008-04-29  0:21 Remap DEL and Shift-Up to kill to end of line plus852
@ 2008-04-29  1:02 ` plus852
  2008-04-29  4:50   ` David Hansen
       [not found]   ` <mailman.10909.1209444810.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: plus852 @ 2008-04-29  1:02 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 28, 8:21 pm, plus...@gmail.com wrote:
> I'm not sure how to remap keys, but I'd like to remap DEL (not
> backspace/delete) and Shift-Up to kill to end of line (in addition to
> C-k); I'd also like DEL-DEL and Shift-Up Shift-Up (DEL or Shift-Up
> typed twice without any other input) to kill to end of paragraph. Is
> this possible?

I've tried adding to my .emacs file:

(global-set-key (kbd "<delete>") 'kill-line)

and

(global-set-key "\d" 'kill-line)

but neither works.

Also, I'd like Shift-Right to move 10 characters right and Shift-Left
to move 10 characters left. Thanks.


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

* Re: Remap DEL and Shift-Up to kill to end of line
  2008-04-29  1:02 ` plus852
@ 2008-04-29  4:50   ` David Hansen
       [not found]   ` <mailman.10909.1209444810.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: David Hansen @ 2008-04-29  4:50 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, 28 Apr 2008 18:02:26 -0700 (PDT) plus wrote:

> On Apr 28, 8:21 pm, plus...@gmail.com wrote:
>> I'm not sure how to remap keys, but I'd like to remap DEL (not
>> backspace/delete) and Shift-Up to kill to end of line (in addition to
>> C-k); I'd also like DEL-DEL and Shift-Up Shift-Up (DEL or Shift-Up
>> typed twice without any other input) to kill to end of paragraph. Is
>> this possible?
>
> I've tried adding to my .emacs file:
>
> (global-set-key (kbd "<delete>") 'kill-line)

Works fine here, which emacs version do you use?  Maybe some major-mode
or minor-mode keymap is in the way (maybe worth a bug report, but I'm
not sure what the policy about these useless keys is).

> Also, I'd like Shift-Right to move 10 characters right and Shift-Left
> to move 10 characters left. Thanks.

(global-set-key (kbd "<S-left>") #'(lambda ()
                                     (interactive)
                                     (backward-char 10)))

(global-set-key (kbd "<S-right>") #'(lambda ()
                                      (interactive)
                                      (forward-char 10)))

Just use the output of C-h k as an argument to `kbd', works always.

Do you know about universal argument?

C-u C-f -> forward 4 chars
C-u C-u C-f -> forward 4*4=16 chars
M-1 M-0 C-f -> forward 10 chars
C-4 C-2 C-f -> forward 42 chars

David





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

* Re: Remap DEL and Shift-Up to kill to end of line
       [not found]   ` <mailman.10909.1209444810.18990.help-gnu-emacs@gnu.org>
@ 2008-04-29 15:49     ` plus852
  2008-04-30  6:05       ` Kevin Rodgers
  0 siblings, 1 reply; 5+ messages in thread
From: plus852 @ 2008-04-29 15:49 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 29, 12:50 am, David Hansen <david.han...@gmx.net> wrote:
> On Mon, 28 Apr 2008 18:02:26 -0700 (PDT) plus wrote:
>
> > On Apr 28, 8:21 pm, plus...@gmail.com wrote:
> >> I'm not sure how to remap keys, but I'd like to remap DEL (not
> >> backspace/delete) and Shift-Up to kill to end of line (in addition to
> >> C-k); I'd also like DEL-DEL and Shift-Up Shift-Up (DEL or Shift-Up
> >> typed twice without any other input) to kill to end of paragraph. Is
> >> this possible?
>
> > I've tried adding to my .emacs file:
>
> > (global-set-key (kbd "<delete>") 'kill-line)
>
> Works fine here, which emacs version do you use?  Maybe some major-mode
> or minor-mode keymap is in the way (maybe worth a bug report, but I'm
> not sure what the policy about these useless keys is).
>
> > Also, I'd like Shift-Right to move 10 characters right and Shift-Left
> > to move 10 characters left. Thanks.
>
> (global-set-key (kbd "<S-left>") #'(lambda ()
>                                      (interactive)
>                                      (backward-char 10)))
>
> (global-set-key (kbd "<S-right>") #'(lambda ()
>                                       (interactive)
>                                       (forward-char 10)))
>
> Just use the output of C-h k as an argument to `kbd', works always.
>
> Do you know about universal argument?
>
> C-u C-f -> forward 4 chars
> C-u C-u C-f -> forward 4*4=16 chars
> M-1 M-0 C-f -> forward 10 chars
> C-4 C-2 C-f -> forward 42 chars
>
> David

Thanks very much -- the shift keys now work, including this one that I
added:

(global-set-key (kbd "<S-up>") 'kill-line)

But (global-set-key (kbd "<delete>") 'kill-line) still doesn't work -
all I get is a forward character delete (I'm running Emacs 22.1 on Mac
OS X)

Also, how would I bind Shift-Up Shift-Up to kill-paragraph (and Del-
Del if I can get Del working)? (global-set-key (kbd "<S-up><S-up>")
'kill-paragraph) doesn't do the job.

Thanks very much.


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

* Re: Remap DEL and Shift-Up to kill to end of line
  2008-04-29 15:49     ` plus852
@ 2008-04-30  6:05       ` Kevin Rodgers
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2008-04-30  6:05 UTC (permalink / raw)
  To: help-gnu-emacs

plus852@gmail.com wrote:
> But (global-set-key (kbd "<delete>") 'kill-line) still doesn't work -
> all I get is a forward character delete (I'm running Emacs 22.1 on Mac
> OS X)

Hmmm, works for me: GNU Emacs 22.2.1 (i386-apple-darwin8.11.1, Carbon 
Version 1.6.0)

> Also, how would I bind Shift-Up Shift-Up to kill-paragraph (and Del-
> Del if I can get Del working)? (global-set-key (kbd "<S-up><S-up>")
> 'kill-paragraph) doesn't do the job.

That will be tricky: binding <foo><bar> to a command implies that <foo>
is a prefix key i.e. bound to a keymap (see "prefix key" and "prefix
keymap" in the Emacs and Emacs Lisp manuals).

But you want <foo> bound to a command `bar' and <foo><foo> bound to a
different command `baz'.  I think the way around that is to bind <foo>
to a new custom command that checks whether the last command was `bar'
invoked by <foo>: if so, undo its changes and run `baz'.

-- 
Kevin Rodgers
Denver, Colorado, USA





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

end of thread, other threads:[~2008-04-30  6:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-29  0:21 Remap DEL and Shift-Up to kill to end of line plus852
2008-04-29  1:02 ` plus852
2008-04-29  4:50   ` David Hansen
     [not found]   ` <mailman.10909.1209444810.18990.help-gnu-emacs@gnu.org>
2008-04-29 15:49     ` plus852
2008-04-30  6:05       ` Kevin Rodgers

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).