help-gnu-emacs
[Top][All Lists]
Advanced

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

Optional arg via lambda


From: Sebastien Vauban
Subject: Optional arg via lambda
Date: Wed, 13 Nov 2013 12:19:35 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Hello,

In my config, I have written this to check whether Org 8 is installed when
trying to call the "export dispatcher" (bound, here, to `C-x C-e').

--8<---------------cut here---------------start------------->8---
    (define-key org-mode-map
      (kbd "C-c C-e")
      (lambda ()
        (interactive)
        (if (fboundp 'org-export-dispatch)
            (org-export-dispatch)
          (message "Upgrade to Org 8!"))))
--8<---------------cut here---------------end--------------->8---

However, the above code drops the optional `C-u' which we can use when calling
`org-export-dispatch'. IOW, `C-u C-x C-e' does the same as `C-x C-e'.

I've tried adding an optional arg to the `lambda' and to pass it to the funcall
of `org-export-dispatch', as shown here:

--8<---------------cut here---------------start------------->8---
    (define-key org-mode-map
      (kbd "C-c C-e")
      (lambda (&optional arg)
        (interactive)
        (if (fboundp 'org-export-dispatch)
            (progn
              (message "arg: %s" arg)
              (funcall 'org-export-dispatch arg))
          (message "Upgrade to Org 8!"))))
--8<---------------cut here---------------end--------------->8---

But this does not work: `org-export-dispatch' is well called when pressing both
`C-x C-e' and `C-u C-x C-e', but the `C-u' is never passed along to the
original `org-export-dispatch' function.

What am I missing?

Best regards,
  Seb

-- 
Sebastien Vauban


reply via email to

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