2

I'm trying to define a key binding that executes a sequence of commands. I add this code to my ~/.emacs file

(require 'origami)
(defun open-close-node ()
  "Open/Close node origami mode"
  (interactive)
  ('origami-open-node)
  ('origami-close-node))

(define-key origami-mode-map (kbd "C-c C-f") 'open-close-node)

Emacs start with no errors, but when i try to use the key binding, shows this open-close-node: Invalid function: (quote origami-open-node)

EDIT:

What i really trying is to adapt this to my case. By the way, I'm pretty new with lisp language.

I just want a fast key binding to open/close the nodes within origami-mode

4
  • 4
    Not sure what you're attempting to do with your function, but the errors you're getting are because you have a quoted symbol ('origami-open-node) within the parentheses where elisp is expecting an unquoted symbol. I'd suggest you have a look at an elisp tutorial to get a better feel for how lisp syntax works.
    – Dan
    Dec 3, 2017 at 15:52
  • @Dan: Please consider posting that as an answer, so the question doesn't remain unanswered.
    – Drew
    Dec 3, 2017 at 16:28
  • @GabrielSandoval: Please explain why you wrote the code the way you did. I.e. where did you find the ('origami-open-node) syntax?
    – Stefan
    Dec 4, 2017 at 3:09
  • @Stefan I'm really dumb with lisp language, i was trying to avoid the initial errors when emacs start.
    – user17767
    Dec 5, 2017 at 2:48

1 Answer 1

3

It's not clear what you're attempting to do with your command. However, the error message you're getting is due to the fact that you have a quoted symbol ('origami-open-node) where elisp is expecting an unquoted symbol.

Here's a rough way to think about how lisp understands what you want it to do:

(verb noun noun noun noun...)

The first element of the lisp expression is a function (unless you use a quote, which is itself a verb), which does something (often using the other elements of the list). When you quote a function, you turn it into the noun form of the verb. Hence, you told lisp to use the nouned form of origami-open-node rather than to use origami-open-node as a verb.

Have a look at an elisp tutorial to get a better feel for lisp syntax.

1
  • You could mention that ('origami-open-node) expands to ((quote origami-open-node)),
    – Tobias
    Dec 3, 2017 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.