From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Doug Lewan Newsgroups: gmane.emacs.help Subject: RE: how to store a elisp procedure in a file and recall it typing a key Date: Thu, 4 Sep 2014 13:50:04 +0000 Message-ID: <155DEC68569B714B86C2C7075F5EDA9892B1AC7A@DAKIYA1.pegasus.local> References: <069edcf2-9cff-44cb-ac09-010733fe9ceb@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1409838666 6726 80.91.229.3 (4 Sep 2014 13:51:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Sep 2014 13:51:06 +0000 (UTC) To: "renato.pontefice@gmail.com" , "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 04 15:50:59 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XPXRC-0006lt-Jy for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Sep 2014 15:50:58 +0200 Original-Received: from localhost ([::1]:51137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPXRB-0005mW-RI for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Sep 2014 09:50:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPXQR-0005bK-HN for help-gnu-emacs@gnu.org; Thu, 04 Sep 2014 09:50:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPXQL-00082j-8c for help-gnu-emacs@gnu.org; Thu, 04 Sep 2014 09:50:11 -0400 Original-Received: from webmail.shubertorg.com ([207.246.209.200]:65426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPXQK-0007xi-Ua for help-gnu-emacs@gnu.org; Thu, 04 Sep 2014 09:50:05 -0400 Original-Received: from dakiya1.pegasus.local ([172.16.208.201]) by DAKIYA1.pegasus.local ([172.16.208.201]) with mapi id 14.02.0247.003; Thu, 4 Sep 2014 09:50:05 -0400 Thread-Topic: how to store a elisp procedure in a file and recall it typing a key Thread-Index: AQHPx19I97+nT98sSEiyROm99gbTDJvw/HvQ In-Reply-To: <069edcf2-9cff-44cb-ac09-010733fe9ceb@googlegroups.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.21.202] X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 207.246.209.200 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99635 Archived-At: > -----Original Message----- > Sent: Wednesday, 2014 September 03 06:05 > > Subject: how to store a elisp procedure in a file and recall it typing > a key >=20 > Hi, > I would store, the piece of code made in elisp, and recall it by > pressing a some special key: > i.e. > my elisp procedure does a control on the file where it is executed, so > if I open a text file, I would made that control on that file. > How can i recall it? > I do not find the way, asking togoogle :-( Renato, This sounds like autoload to me: info '(elisp) Autoload'. >From the *info*:=20 This function defines the function (or macro) named FUNCTION so as to load automatically from FILENAME. Here's an example. File ~/tmp/aaa.el: (defun blah () (interactive) (message "Congratulations! M-x blah is now loaded.")) Now, in your *scratch* buffer evaluate the following: (autoload 'blah "~/tmp/aaa.el" "Demonstrate autoloading." t nil) (local-set-key "\M-\C-Y" 'blah) The key sequence M-C-Y will now run the command blah, loading it if necessa= ry. ,Doug Douglas Lewan Shubert Ticketing (201) 489-8600 ext 224 or ext 4335 "This is a slow pup," he said continuing his ascent.