I want to write a function to check if a buffer is an Org buffer. Here is my attempt.
(defun org_bufferp (buffer)
(if (bufferp buffer)
((setq buffer_name (buffer-file-name buffer))
(if (stringp buffer_name)
(if (string-match ".*\.org$" buffer_name) t "nil1")
"nil2"))
"nil3"))
However, the result surprised me.
(org_bufferp '(current-buffer)) ;; => nil, but should be t!
(org_bufferp (current-buffer)) ;; ===> ERROR! Why?
Questions
- Why does
(org_bufferp '(current-buffer))
returnnil
? I don't even assign anynil
to possible returned values. - Why does
(org_bufferp (current-buffer))
return an error? - I'm new to Elisp, and find it hard to deal with the endless parentheses. What would you suggest in order to make the code cleaner?