* How to rebind keys "C-j" to join-line @ 2007-08-03 5:18 Alex Wei 2007-08-04 2:59 ` Dieter Wilhelm 0 siblings, 1 reply; 12+ messages in thread From: Alex Wei @ 2007-08-03 5:18 UTC (permalink / raw) To: help-gnu-emacs [-- Attachment #1.1: Type: text/plain, Size: 272 bytes --] Hi All I add the following lines into my .emacs file, but it dosen't work, How can I rebind the key "C-j" to join-line ? (global-set-key (kbd "C-j") 'join-line) (local-set-key (kbd "C-j") 'join-line) Thanks in advance for ur kind helps Sunding Wei [-- Attachment #1.2: Type: text/html, Size: 989 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line 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 0 siblings, 1 reply; 12+ messages in thread From: Dieter Wilhelm @ 2007-08-04 2:59 UTC (permalink / raw) To: Alex Wei; +Cc: help-gnu-emacs "Alex Wei" <swei@arrayinc.com> writes: > I add the following lines into my .emacs file, but it dosen't work, How can I > rebind the key "C-j" to join-line ? May I ask why the standard key-binding of join-line (M-^) is not sufficient for you? -- Best wishes H. Dieter Wilhelm Darmstadt, Germany ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line 2007-08-04 2:59 ` Dieter Wilhelm @ 2007-08-06 2:17 ` Alex Wei 2007-08-06 14:37 ` Nikolaj Schumacher 2007-08-06 21:00 ` Dieter Wilhelm 0 siblings, 2 replies; 12+ messages in thread From: Alex Wei @ 2007-08-06 2:17 UTC (permalink / raw) To: Dieter Wilhelm; +Cc: help-gnu-emacs [-- Attachment #1.1: Type: text/plain, Size: 1000 bytes --] Thanks H. Dieter Wilhelm I don't need the original C-j keybinding, the "M-^" needs to press 3 keys at same time, so I want to rebind the C-j to join-line. I am just wondering how to rebind the key or how can I find the hook. After opening the Emacs, I type (local-set-key (kbd "C-j") 'join-line) and then Cx Ce, It works!! But it dosen't work at .emacs, can you help, I guess I need to find the last setup's hook. Thanks Alex Wei ----- Original Message ----- From: Dieter Wilhelm To: Alex Wei Cc: help-gnu-emacs@gnu.org Sent: Saturday, August 04, 2007 10:59 AM Subject: Re: How to rebind keys "C-j" to join-line "Alex Wei" <swei@arrayinc.com> writes: > I add the following lines into my .emacs file, but it dosen't work, How can I > rebind the key "C-j" to join-line ? May I ask why the standard key-binding of join-line (M-^) is not sufficient for you? -- Best wishes H. Dieter Wilhelm Darmstadt, Germany [-- Attachment #1.2: Type: text/html, Size: 2555 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line 2007-08-06 2:17 ` Alex Wei @ 2007-08-06 14:37 ` Nikolaj Schumacher 2007-08-07 2:15 ` Alex Wei 2007-08-06 21:00 ` Dieter Wilhelm 1 sibling, 1 reply; 12+ messages in thread From: Nikolaj Schumacher @ 2007-08-06 14:37 UTC (permalink / raw) To: Alex Wei; +Cc: help-gnu-emacs "Alex Wei" <swei@arrayinc.com> wrote: > After opening the Emacs, I type (local-set-key (kbd "C-j") 'join-line) > and then Cx Ce, It works!! But it dosen't work at .emacs, Does adding anything else work? Maybe you have an old .emacs.elc in the directory that gets loaded first? regards, Nikolaj Schumacher ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line 2007-08-06 14:37 ` Nikolaj Schumacher @ 2007-08-07 2:15 ` Alex Wei 2007-08-08 4:46 ` Kevin Rodgers 0 siblings, 1 reply; 12+ messages in thread From: Alex Wei @ 2007-08-07 2:15 UTC (permalink / raw) To: Nikolaj Schumacher; +Cc: help-gnu-emacs [-- Attachment #1.1: Type: text/plain, Size: 760 bytes --] Hi Thanks for your reply, I don't have .emacs.elc in my home direcory, I am using the emacs-22.1. There's only one .emacs there, not sure why I can't rebind the C-j key to join-line. Alex Wei Aug. 7, 2007 ----- Original Message ----- From: Nikolaj Schumacher To: Alex Wei Cc: help-gnu-emacs@gnu.org Sent: Monday, August 06, 2007 10:37 PM Subject: Re: How to rebind keys "C-j" to join-line "Alex Wei" <swei@arrayinc.com> wrote: > After opening the Emacs, I type (local-set-key (kbd "C-j") 'join-line) > and then Cx Ce, It works!! But it dosen't work at .emacs, Does adding anything else work? Maybe you have an old .emacs.elc in the directory that gets loaded first? regards, Nikolaj Schumacher [-- Attachment #1.2: Type: text/html, Size: 2161 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line 2007-08-07 2:15 ` Alex Wei @ 2007-08-08 4:46 ` Kevin Rodgers 0 siblings, 0 replies; 12+ messages in thread From: Kevin Rodgers @ 2007-08-08 4:46 UTC (permalink / raw) To: help-gnu-emacs Alex Wei wrote: > Hi > > Thanks for your reply, I don't have .emacs.elc in my home direcory, I am > using the emacs-22.1. > There's only one .emacs there, not sure why I can't rebind the C-j key > to join-line. What does `C-h v initial-major-mode' say? What major mode do you do most of your editing in? -- Kevin Rodgers Denver, Colorado, USA ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line 2007-08-06 2:17 ` Alex Wei 2007-08-06 14:37 ` Nikolaj Schumacher @ 2007-08-06 21:00 ` Dieter Wilhelm 2007-08-07 2:25 ` Alex Wei ` (2 more replies) 1 sibling, 3 replies; 12+ messages in thread From: Dieter Wilhelm @ 2007-08-06 21:00 UTC (permalink / raw) To: Alex Wei; +Cc: help-gnu-emacs "Alex Wei" <swei@arrayinc.com> writes: > Thanks H. Dieter Wilhelm > > I don't need the original C-j keybinding, the "M-^" needs to press 3 keys at I see, (I, personally, count M+SHIFT as one key, pressed at the same time ;-) > same time, so I want to rebind the C-j to join-line. I am just wondering how to > rebind the key or how can I find the hook. > > After opening the Emacs, I type (local-set-key (kbd "C-j") 'join-line) and > then Cx Ce, It works!! Have you tried (global-set-key)? Maybe local-set-key works only in the *scratch* buffer at start-up? Sorry I'm not sure. -- Best wishes H. Dieter Wilhelm Darmstadt, Germany ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line 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 [not found] ` <mailman.4479.1186473818.32220.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 12+ messages in thread From: Alex Wei @ 2007-08-07 2:25 UTC (permalink / raw) To: Dieter Wilhelm; +Cc: help-gnu-emacs [-- Attachment #1.1: Type: text/plain, Size: 1222 bytes --] Hi Thanks for your replay, I still can't figure out why yet, both global-set-key and local-set-key can't rebind the C-j keys to join-line, only local-set-key works by issueing C-x C-e after Emacs started. I guess I need to find the last setup's hook. Best Regards Alex Wei Sierra Atlantic ----- Original Message ----- From: Dieter Wilhelm To: Alex Wei Cc: help-gnu-emacs@gnu.org Sent: Tuesday, August 07, 2007 5:00 AM Subject: Re: How to rebind keys "C-j" to join-line "Alex Wei" <swei@arrayinc.com> writes: > Thanks H. Dieter Wilhelm > > I don't need the original C-j keybinding, the "M-^" needs to press 3 keys at I see, (I, personally, count M+SHIFT as one key, pressed at the same time ;-) > same time, so I want to rebind the C-j to join-line. I am just wondering how to > rebind the key or how can I find the hook. > > After opening the Emacs, I type (local-set-key (kbd "C-j") 'join-line) and > then Cx Ce, It works!! Have you tried (global-set-key)? Maybe local-set-key works only in the *scratch* buffer at start-up? Sorry I'm not sure. -- Best wishes H. Dieter Wilhelm Darmstadt, Germany [-- Attachment #1.2: Type: text/html, Size: 2815 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line -- SOLVED! 2007-08-06 21:00 ` Dieter Wilhelm 2007-08-07 2:25 ` Alex Wei @ 2007-08-07 8:03 ` Alex Wei 2007-08-07 20:36 ` Dieter Wilhelm [not found] ` <mailman.4479.1186473818.32220.help-gnu-emacs@gnu.org> 2 siblings, 1 reply; 12+ messages in thread From: Alex Wei @ 2007-08-07 8:03 UTC (permalink / raw) To: Dieter Wilhelm; +Cc: help-gnu-emacs [-- Attachment #1.1: Type: text/plain, Size: 1692 bytes --] 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) (local-set-key (kbd "C--") 'kill-whole-line) (local-set-key (kbd "C-=") 'copy-whole-line) (local-set-key (kbd "C-o") 'open-newline) (local-set-key (kbd "C-j") 'join-line) ) (add-hook 'emacs-startup-hook 'my-key-binding) (add-hook 'change-major-mode-hook 'my-key-binding) Thanks anyway! Best Regards Alex Wei Sierra Atlantic ----- Original Message ----- From: Dieter Wilhelm To: Alex Wei Cc: help-gnu-emacs@gnu.org Sent: Tuesday, August 07, 2007 5:00 AM Subject: Re: How to rebind keys "C-j" to join-line "Alex Wei" <swei@arrayinc.com> writes: > Thanks H. Dieter Wilhelm > > I don't need the original C-j keybinding, the "M-^" needs to press 3 keys at I see, (I, personally, count M+SHIFT as one key, pressed at the same time ;-) > same time, so I want to rebind the C-j to join-line. I am just wondering how to > rebind the key or how can I find the hook. > > After opening the Emacs, I type (local-set-key (kbd "C-j") 'join-line) and > then Cx Ce, It works!! Have you tried (global-set-key)? Maybe local-set-key works only in the *scratch* buffer at start-up? Sorry I'm not sure. -- Best wishes H. Dieter Wilhelm Darmstadt, Germany [-- Attachment #1.2: Type: text/html, Size: 3726 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line -- SOLVED! 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 0 siblings, 1 reply; 12+ messages in thread From: Dieter Wilhelm @ 2007-08-07 20:36 UTC (permalink / raw) To: Alex Wei; +Cc: help-gnu-emacs "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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to rebind keys "C-j" to join-line -- SOLVED! 2007-08-07 20:36 ` Dieter Wilhelm @ 2007-08-08 2:27 ` Alex Wei 0 siblings, 0 replies; 12+ messages in thread From: Alex Wei @ 2007-08-08 2:27 UTC (permalink / raw) To: Dieter Wilhelm; +Cc: help-gnu-emacs [-- 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.4479.1186473818.32220.help-gnu-emacs@gnu.org>]
* Re: How to rebind keys "C-j" to join-line -- SOLVED! [not found] ` <mailman.4479.1186473818.32220.help-gnu-emacs@gnu.org> @ 2007-08-07 11:30 ` Daniel Jensen 0 siblings, 0 replies; 12+ messages in thread From: Daniel Jensen @ 2007-08-07 11:30 UTC (permalink / raw) To: help-gnu-emacs "Alex Wei" <swei@arrayinc.com> writes: > (add-hook 'change-major-mode-hook 'my-key-binding) This is really bad. Do you see why? If not, you will surely find out soon. Your key bindings take effect in places that you don't want them to. For example, RET is a useful key in the minibuffer, it's a shame to rebind it there. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2007-08-08 4:46 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 [not found] ` <mailman.4479.1186473818.32220.help-gnu-emacs@gnu.org> 2007-08-07 11:30 ` Daniel Jensen
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.