From: "Alex Wei" <swei@arrayinc.com>
To: "Dieter Wilhelm" <dieter@duenenhof-wilhelm.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to rebind keys "C-j" to join-line -- SOLVED!
Date: Wed, 8 Aug 2007 10:27:06 +0800 [thread overview]
Message-ID: <DD16DA04BF1F4E64A457074CF75E3569@array8f42e753d> (raw)
In-Reply-To: 87abt3jd50.fsf@debby.local.net
[-- Attachment #1.1: Type: text/plain, Size: 3007 bytes --]
Hi H. Dieter Wilhelm
Thanks for disgussing, your understandings are almost right.
for
C-o -- Yes, just C-e <RET>, the same effect as Vim's o command
C-- -- Kill whole line, same as C-a C-k C-k, kill whole line along with the last carriage return.
C-= -- Yes, I define it as copy whole line, the same effect as Vim's yy command
C-. -- Why binding this to set-mark-command, and not C-SPC, because It was defined by Windows to activate IME.
Why hook it up? Because other scripts override my key bindings after Emacs startup, .emacs was executed the first.
Appending my codes for your reference.
(defun copy-whole-line ()
"copy line"
(interactive)
(setq end-pos (if (< (line-end-position) (point-max)) (+ 1 (line-end-position)) (point-max)))
(copy-region-as-kill (line-beginning-position) end-pos)
(message "line copied.")
)
(defun kill-whole-line ()
"cut line"
(interactive)
(setq end-pos (if (< (line-end-position) (point-max)) (+ 1 (line-end-position)) (point-max)))
(kill-region (line-beginning-position) end-pos)
)
(defun open-newline ()
"open newline below and place the cursor at newline."
(interactive)
(goto-char (line-end-position))
(newline-and-indent)
)
Best Regards
Alex Wei
Sierra Atlantic
----- Original Message -----
From: Dieter Wilhelm
To: Alex Wei
Cc: help-gnu-emacs@gnu.org
Sent: Wednesday, August 08, 2007 4:36 AM
Subject: Re: How to rebind keys "C-j" to join-line -- SOLVED!
"Alex Wei" <swei@arrayinc.com> writes:
> Hi all
>
> I've figured out how to secure binding my keys :D , I found two hooks that will
> guarantee my key-bindings will not be overrided.
>
> (defun my-key-binding ()
> "Customize my key bindings after Emacs startup."
> (interactive)
> ;; Key
> bindings
> (local-set-key (kbd "<RET>") 'newline-and-indent)
> (local-set-key (kbd "C-.") 'set-mark-command)
Why not the standard binding (C-SPC)?
> (local-set-key (kbd "C--") 'kill-whole-line)
the same here C-S-backspace? (OK, I answer it myself: One needs three
keys.) But you are restricting yourself to M-- and C-u- for negative
prefix arguments.
> (local-set-key (kbd "C-=") 'copy-whole-line)
Yes, this is a function I'm also missing badly in Emacs.
> (local-set-key (kbd "C-o") 'open-newline)
What is open-newline, something like C-e RET?
> (local-set-key (kbd "C-j") 'join-line)
As I said M-^ is not so bad either ;-)
> (add-hook 'emacs-startup-hook 'my-key-binding)
> (add-hook 'change-major-mode-hook 'my-key-binding)
Sorry I do not know these hooks, but wouldn't for example:
(global-set-key "\C-o" 'open-newline)
in your .emacs have the same effect without adding hooks?
> Thanks anyway!
You are very welcome.
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
[-- Attachment #1.2: Type: text/html, Size: 5418 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
next prev parent reply other threads:[~2007-08-08 2:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-03 5:18 How to rebind keys "C-j" to join-line Alex Wei
2007-08-04 2:59 ` Dieter Wilhelm
2007-08-06 2:17 ` Alex Wei
2007-08-06 14:37 ` Nikolaj Schumacher
2007-08-07 2:15 ` Alex Wei
2007-08-08 4:46 ` Kevin Rodgers
2007-08-06 21:00 ` Dieter Wilhelm
2007-08-07 2:25 ` Alex Wei
2007-08-07 8:03 ` How to rebind keys "C-j" to join-line -- SOLVED! Alex Wei
2007-08-07 20:36 ` Dieter Wilhelm
2007-08-08 2:27 ` Alex Wei [this message]
[not found] ` <mailman.4479.1186473818.32220.help-gnu-emacs@gnu.org>
2007-08-07 11:30 ` Daniel Jensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DD16DA04BF1F4E64A457074CF75E3569@array8f42e753d \
--to=swei@arrayinc.com \
--cc=dieter@duenenhof-wilhelm.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).