* Why function works but *not* in *C-language mode*???
@ 2002-09-24 17:45 seberino
0 siblings, 0 replies; 5+ messages in thread
From: seberino @ 2002-09-24 17:45 UTC (permalink / raw)
The following function deletes a line when I type
C-d and works great but I noticed it behaves
differently in C language mode where it deletes
one character rather than one *line*. Why???
(global-set-key "\C-d" 'cs-kill-line)
(defun cs-kill-line(&optional arg) (interactive "P")
(let ((current-pos (point)))
(kill-region (line-beginning-position)
(min (point-max) (+ (line-end-position arg) 1)))
(goto-char (min current-pos (line-end-position)))))
Here is my C language mode settings...
(add-hook 'c-mode-hook 'turn-on-font-lock)
(setq auto-mode-alist '(("\\.c\\'" . cs-c-mode)
("\\.C\\'" . cs-c-mode)
("\\.cpp\\'" . cs-c-mode)
("\\.h\\'" . cs-c-mode)
("\\.java\\'" . cs-c-mode)))
(defun cs-c-mode() (interactive)
(c-mode)
(c-set-style "K&R")
(setq c-basic-offset 3))
Thanks,
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why function works but *not* in *C-language mode*???
[not found] <mailman.1032889585.14887.help-gnu-emacs@gnu.org>
@ 2002-09-24 17:58 ` Barry Margolin
2002-09-24 20:23 ` seberino
2002-09-24 20:09 ` Kai Großjohann
[not found] ` <87n0q7b3po.fsf@blarg.net>
2 siblings, 1 reply; 5+ messages in thread
From: Barry Margolin @ 2002-09-24 17:58 UTC (permalink / raw)
In article <mailman.1032889585.14887.help-gnu-emacs@gnu.org>,
<seberino@spawar.navy.mil> wrote:
>The following function deletes a line when I type
>C-d and works great but I noticed it behaves
>differently in C language mode where it deletes
>one character rather than one *line*. Why???
C mode is probably creating a local key binding that's overriding your
global binding. What does 'C-h c C-d' show in C mode?
--
Barry Margolin, barmar@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why function works but *not* in *C-language mode*???
[not found] <mailman.1032889585.14887.help-gnu-emacs@gnu.org>
2002-09-24 17:58 ` Barry Margolin
@ 2002-09-24 20:09 ` Kai Großjohann
[not found] ` <87n0q7b3po.fsf@blarg.net>
2 siblings, 0 replies; 5+ messages in thread
From: Kai Großjohann @ 2002-09-24 20:09 UTC (permalink / raw)
seberino@spawar.navy.mil writes:
> The following function deletes a line when I type
> C-d and works great but I noticed it behaves
> differently in C language mode where it deletes
> one character rather than one *line*. Why???
Because C mode has its own binding for C-d. Bind C-d in c-mode-map,
too.
kai
--
~/.signature is: umop 3p!sdn (Frank Nobis)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why function works but *not* in *C-language mode*???
[not found] ` <87n0q7b3po.fsf@blarg.net>
@ 2002-09-24 20:22 ` seberino
0 siblings, 0 replies; 5+ messages in thread
From: seberino @ 2002-09-24 20:22 UTC (permalink / raw)
Cc: help-gnu-emacs
thanks... this did the trick.
CS
On Tue, Sep 24, 2002 at 12:13:55PM -0700, Eric Hanchrow wrote:
> c-mode probably replaces your binding of C-d with its own
> (c-electric-delete-forward).
>
> Just add
>
> (local-set-key "\C-d" 'cs-kill-line)
>
> to your c-mode-hook and it ought to work.
> --
> PGP Fingerprint: 3E7B A3F3 96CA 8958 ACC5 C8BD 6337 0041 C01C 5276
--
_______________________________________
Dr. Christian Seberino
SPAWAR Systems Center San Diego
Code 2363
49590 Lassing Rd. Rm. A339
San Diego, CA 92152-6147
U.S.A.
Phone: (619) 553-7940
Fax: (619) 553-1269
Email: seberino@spawar.navy.mil
_______________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why function works but *not* in *C-language mode*???
2002-09-24 17:58 ` Barry Margolin
@ 2002-09-24 20:23 ` seberino
0 siblings, 0 replies; 5+ messages in thread
From: seberino @ 2002-09-24 20:23 UTC (permalink / raw)
Cc: help-gnu-emacs
Apparently I can just override whatever
c-mode sets C-d to be. I didn't realize
that c-mode defines key combos until
your email. Thanks for the help.
Chris
On Tue, Sep 24, 2002 at 05:58:40PM +0000, Barry Margolin wrote:
> In article <mailman.1032889585.14887.help-gnu-emacs@gnu.org>,
> <seberino@spawar.navy.mil> wrote:
> >The following function deletes a line when I type
> >C-d and works great but I noticed it behaves
> >differently in C language mode where it deletes
> >one character rather than one *line*. Why???
>
> C mode is probably creating a local key binding that's overriding your
> global binding. What does 'C-h c C-d' show in C mode?
>
> --
> Barry Margolin, barmar@genuity.net
> Genuity, Woburn, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
> Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
--
_______________________________________
Dr. Christian Seberino
SPAWAR Systems Center San Diego
Code 2363
49590 Lassing Rd. Rm. A339
San Diego, CA 92152-6147
U.S.A.
Phone: (619) 553-7940
Fax: (619) 553-1269
Email: seberino@spawar.navy.mil
_______________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-09-24 20:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-24 17:45 Why function works but *not* in *C-language mode*??? seberino
[not found] <mailman.1032889585.14887.help-gnu-emacs@gnu.org>
2002-09-24 17:58 ` Barry Margolin
2002-09-24 20:23 ` seberino
2002-09-24 20:09 ` Kai Großjohann
[not found] ` <87n0q7b3po.fsf@blarg.net>
2002-09-24 20:22 ` seberino
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).