From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephan Schmitt Subject: Re: Re: Frequently used files/headings Date: Mon, 10 May 2010 23:08:28 +0200 Message-ID: <4BE875CC.20208@cs.tu-berlin.de> References: <87fx20at17.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=59767 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBaDS-0008Dj-AD for emacs-orgmode@gnu.org; Mon, 10 May 2010 17:08:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OBaDQ-0008EL-Fp for emacs-orgmode@gnu.org; Mon, 10 May 2010 17:08:42 -0400 Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]:48285) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBaDQ-0008Dz-8N for emacs-orgmode@gnu.org; Mon, 10 May 2010 17:08:40 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nathan Neff Cc: emacs-orgmode , =?UTF-8?B?xaB0xJtww6FuIE7Em21lYw==?= Hi Nathan, when the lambda form is evaluated (when you press f6) the variable shortcut-def doesn't exist any more. The problem is that elisp doesn't support closures. See this info page: (elisp) Top > Variables > Variable Scoping > Extent As a workaraound you can save the table in a global variable with setq and access that variable in the lambda form. Hth, Stephan Also sprach Nathan Neff: > On Mon, May 10, 2010 at 6:35 AM, Štěpán Němec wrote: >> Nathan Neff writes: >>> I tried something like this, but all I get is "Wrong type argument: >>> integer-or-marker-p, (quote (second shortcut-def))" >>> >>> #+srcname: map-nav(navigation-shortcuts=navigation-shortcuts) >>> #+begin_src emacs-lisp >>> (defun map-navigation-shortcuts (shortcut-def) >>> (global-set-key (kbd (second shortcut-def)) (lambda () "Goto Foo Org File" >>> (interactive) >>> (org-id-goto '(third shortcut-def))))) >>> >>> (mapcar #'map-navigation-shortcuts navigation-shortcuts) >>> >>> #+end_src >>> >>> Can anyone point out where I'm going wrong? >> >> I haven't tried your code, but the way you call `kbd' is obviously >> wrong. >> >> `kbd' is a macro and does not evaluate its arguments; try >> using `read-kbd-macro' instead. > > Stepan, > > Thanks for your help -- The keyboard shortcut is now being mapped > correctly, but > whenever I press a, I get "Symbol's value as a variable is void: > shortcut-def" > > I suspect that (lambda()) is not evaluating (org-id-goto (third > shortcut-def)). I need some way to do that. > > I would really like to know an "acceptable" or "standard" way to > implement this feature -- I think it would help me a lot with learning > Lisp& functional languages. Any help is appreciated! > > Here's my new code: > > #+tblname:navigation-shortcuts > | Vim | a | 733BD03F-0938-432F-B59A-BE235A2DE7E2 | > > #+srcname: map-nav(navigation-shortcuts=navigation-shortcuts) > #+begin_src emacs-lisp > (defun map-navigation-shortcuts (shortcut-def) > (global-set-key (read-kbd-macro (second shortcut-def)) > (lambda () > (interactive) > (org-id-goto (third shortcut-def)))) ;; this line is not > evaluated inside lambda() > ) > > Thanks, > --Nate > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode