emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: Frequently used files/headings


From: Stephan Schmitt
Subject: Re: [Orgmode] Re: Frequently used files/headings
Date: Mon, 10 May 2010 23:08:28 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4

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<address@hidden>  wrote:
Nathan Neff<address@hidden>  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<f6>  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                 |<f6>  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.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]