From: Giorgos Keramidas <keramida@ceid.upatras.gr>
To: help-gnu-emacs@gnu.org
Subject: Re: Elisp Question...
Date: Sun, 27 Sep 2009 18:26:17 +0300 [thread overview]
Message-ID: <87ocowh0iu.fsf@kobe.laptop> (raw)
In-Reply-To: h9nt1m$11i$2@news.eternal-september.org
On Sun, 27 Sep 2009 14:32:22 +0000 (UTC), magicus <REMOVEmagicus23THIS@gmail.com> wrote:
> Hi,
>
> I posted this to comp.emacs when this might be a more useful newgroup.
>
> I am new to using elisp and I put together the following due to ignorance
> about how to do it in one function:
>
> ==================================================================== (fset
> 'flp-cr
> "Copyright © 2009 Furlan Lawrence Primus. All rights reserved.")
>
> (global-set-key (kbd "<f9>") 'flp-cr)
>
>
> (fset 'flp-copyright
> [f9 home ?\C- ?\C-e ?\M-w])
>
> (global-set-key (kbd "<f8>") 'flp-copyright)
> ====================================================================
>
> The main point here is that I wanted to be able to have it such that
> when I press F8 it displays the text AND copys it so that I can then
> use it outside of Emacs. The above seems to work and I'd like to make
> it a lot more compact. In addition, while it works in version 22.2.1
> it stops after printing "Copyright" in version GNU Emacs 23.1.50.24
> (i686-pc-linux- gnu, GTK+ Version 2.16.1) of 2009-09-27 on magicbox
> which I compile earlier from CVS.
With a small bit of Emacs Lisp you can do something like this:
(defun flp-insert-copyright (copy-text)
(let ((start (point)))
(insert "Copyright © 2009 Furlan Lawrence Primus. All rights reserved.")
(when copy-text
(copy-region-as-kill start (point)))))
(global-set-key (kbd "<f9>") (lambda ()
(interactive)
(flp-insert-copyright nil)))
(global-set-key (kbd "<f8>") (lambda ()
(interactive)
(flp-insert-copyright t)))
This should work fine, AFAICT. The same basic function can do both of
the things you described. Wrapping it in a `lambda' form that calls the
basic function with different arguments depending on the key you typed
is relatively easy (but it does require a bit of Emacs Lisp code, as you
can see the `global-set-key' calls I wrote).
next prev parent reply other threads:[~2009-09-27 15:26 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-27 14:32 Elisp Question magicus
2009-09-27 15:26 ` Giorgos Keramidas [this message]
2009-09-27 17:10 ` magicus
[not found] <mailman.941.1223918781.25473.help-gnu-emacs@gnu.org>
2008-10-13 18:11 ` elisp question Niels Giesen
2008-10-13 19:09 ` Seweryn Kokot
[not found] ` <mailman.948.1223924333.25473.help-gnu-emacs@gnu.org>
2008-10-13 19:40 ` Pascal J. Bourguignon
2008-10-13 20:47 ` Drew Adams
2008-10-13 21:11 ` Seweryn Kokot
-- strict thread matches above, loose matches on Subject: below --
2008-10-13 17:36 Seweryn Kokot
2008-04-30 21:23 harven
2008-05-01 13:08 ` Kevin Rodgers
[not found] ` <mailman.11020.1209647315.18990.help-gnu-emacs@gnu.org>
2008-05-01 13:54 ` harven
2008-05-03 15:38 ` Bastien
2005-11-30 23:13 Tim McNamara
2005-11-30 23:22 ` Lennart Borgman
2005-12-01 5:07 ` Stefan Monnier
2005-12-01 19:29 ` Tim McNamara
2005-12-01 21:00 ` Stefan Monnier
2005-12-02 1:02 ` Tim McNamara
2005-12-02 17:51 ` Kevin Rodgers
2005-12-01 6:24 ` N. Raghavendra
2005-12-01 19:32 ` Tim McNamara
2005-12-01 21:37 ` N. Raghavendra
2005-12-01 23:40 ` Thien-Thi Nguyen
2005-12-02 7:44 ` N. Raghavendra
2005-12-02 14:43 ` Thien-Thi Nguyen
2005-12-02 1:05 ` Tim McNamara
[not found] ` <mailman.17404.1133392955.20277.help-gnu-emacs@gnu.org>
2005-12-01 19:25 ` Tim McNamara
2003-08-20 7:37 Mike Ballard
2003-08-20 8:07 ` Joakim Hove
2003-08-22 5:52 ` Mike Ballard
2003-08-22 6:38 ` Joakim Hove
2003-08-20 15:07 ` Peter Lee
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=87ocowh0iu.fsf@kobe.laptop \
--to=keramida@ceid.upatras.gr \
--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).