1

I want to call clone-indirect-buffer or clone-indirect-buffer-other-window within a function dependent on the prefix. To do this, I assign the appropriate clone function to a variable using let. However, when I try to abstract the name of the buffer I get a type error.

This simplified example works as expected, creating a buffer called "banana":

(let* ((fun #'clone-indirect-buffer)
       (buf (apply fun '("banana" nil))))
  (switch-to-buffer buf))  ; #<buffer banana> 

When I move the name "banana" into a variable, I get a type error:

(let* ((name "banana")
       (fun #'clone-indirect-buffer)
       (buf (apply fun '(name nil))))
  (switch-to-buffer buf))

;; (wrong-type-argument stringp name)

I notice that quasi-quote produces the expected result:

(let* ((name "banana")
       (fun #'clone-indirect-buffer)
       (buf (apply fun `(,name nil))))
  (switch-to-buffer buf)) ; #<buffer banana> 

AFAICT, name is a string. So, why the error?

Drew
  • 75,699
  • 9
  • 109
  • 225
Lorem Ipsum
  • 4,327
  • 2
  • 14
  • 35

0 Answers0