From: August <fusionfive@comhem.se>
Subject: Re: Trying to bind a new key in C mode
Date: Sat, 12 Feb 2005 03:41:49 +0100 [thread overview]
Message-ID: <1108176109.6148.14.camel@c83-250-206-179.bredband.comhem.se> (raw)
In-Reply-To: <87is4y3agp.fsf@paradigmshift.homelinux.net>
On fre, 2005-02-11 at 18:09 -0600, Jim Hunter wrote:
> I would like to bind C-c c to run the 'compile' function in C mode
> (and, ultimately, C-c r to run 'recompile'), but cannot get it to
> work. Unfortunately, I know nothing about Lisp, so I simply copied
> the example from the Emacs info page "Local Keymaps" and modified it
> to this (in my .emacs file):
>
> (add-hook 'c-mode-hook
> '(lambda ()
> (define-key c-mode-map "\C-cc" 'compile)))
>
Try
(add-hook 'c-mode-hook
'(lambda () (local-set-key "\C-cc" 'compile)))
Since compiling and running a program are such common operations I
instead have the following definitions in my `.emacs'. The global key
settings apply to all buffers in all modes.
(global-set-key [f11] 'compile)
(global-set-key [f12] 'my-shell-command)
(defun my-shell-command ()
"Similar to `shell-command', but shows previous command as initial
contents or (if there is no previous command) guesses the name of the
program you want to run based on the name of the current buffer and
inserts that as initial contents."
(interactive)
(shell-command
(read-from-minibuffer "Shell command: "
(let ((f (buffer-file-name)))
(when f
(let ((bin (file-name-sans-extension
(file-name-nondirectory f))))
(cond (shell-command-history
(car shell-command-history))
(t
(concat "./" bin " &"))))))
nil nil 'shell-command-history)))
--
August
next prev parent reply other threads:[~2005-02-12 2:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-12 0:09 Trying to bind a new key in C mode Jim Hunter
2005-02-12 2:41 ` August [this message]
[not found] ` <mailman.1836.1108176936.2841.help-gnu-emacs@gnu.org>
2005-02-12 17:59 ` Jim Hunter
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=1108176109.6148.14.camel@c83-250-206-179.bredband.comhem.se \
--to=fusionfive@comhem.se \
/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).