From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: magicus Newsgroups: gmane.emacs.help Subject: Re: Elisp Question... Date: Sun, 27 Sep 2009 17:10:15 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <87ocowh0iu.fsf@kobe.laptop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1254105649 13210 80.91.229.12 (28 Sep 2009 02:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Sep 2009 02:40:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 28 04:40:43 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ms6AM-0005NF-7I for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Sep 2009 04:40:42 +0200 Original-Received: from localhost ([127.0.0.1]:37751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ms6AL-0002d3-Pr for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Sep 2009 22:40:41 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!goblin1!goblin.stu.neva.ru!feeder.eternal-september.org!eternal-september.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-X-Trace: news.eternal-september.org U2FsdGVkX1/t/TnVGcKBRi63oteVfCsGpdrj/SL5u9nvv0k9tqeK5NCn0UQhuKtGeJQc0cvy/0oMJSjFQ9zNDj73cj/3W9E9Fi7HPTdhJYUltlv/AaIUkWnEkSWwMlvyiHFdEAGMcwHnLS4uXgf3SA== Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Sun, 27 Sep 2009 17:10:15 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19eHRlcTkhW64SmQL2EAzDt2aDyxvUFqZg= Cancel-Lock: sha1:K1mwwV1quDjfxXEV3M7RdKJhs64= User-Agent: Pan/0.132 (Waxed in Black) Original-Xref: news.stanford.edu gnu.emacs.help:173379 X-Mailman-Approved-At: Sun, 27 Sep 2009 22:37:29 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68496 Archived-At: On Sun, 27 Sep 2009 18:26:17 +0300, Giorgos Keramidas wrote: > On Sun, 27 Sep 2009 14:32:22 +0000 (UTC), magicus > 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 "") 'flp-cr) >> >> >> (fset 'flp-copyright >> [f9 home ?\C- ?\C-e ?\M-w]) >> >> (global-set-key (kbd "") '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 "") (lambda () > (interactive) > (flp-insert-copyright nil))) > > (global-set-key (kbd "") (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). Thank you. I was only using the F9 so I could get it to work. I 'assume' that I can safely use either function key to do what I want so I can remove one w/o any problems. I'll dump it into my .emacs. ciao, f -- The most wasted of all days is one without laughter. -- e.e. cummings