0

The following expression:

(car input-method-function)

Give the following message:

Wrong type argument: listp, list

Why? input-method-function is list.

2
  • The value of input-method-function is the symbol list. A symbol is not a list: try evaluating (symbolp input-method-function) - it returns t; OTOH, evaluating (listp input-method-function) returns nil. IOW, it is a symbol, not a list - and you cannot take the car of a symbol.
    – NickD
    Commented Apr 2, 2022 at 0:47
  • 1
    @NickD -- I beat you by 3+ minutes :) ... Please feel free to edit my answer to incorproate your comments and any additional information that may be helpful to the O.P. or future users.
    – lawlist
    Commented Apr 2, 2022 at 0:49

1 Answer 1

2

When describing the variable input-method-function with C-h v aka M-x describe-variable, the *Help* buffer contains the following preamble:

input-method-function is a variable defined in ‘C source code’.
Its value is ‘list’

Documentation:
If non-nil, the function that implements the current input method.

Although the value is list, it is not actually a list - in the same way that if my name were Martian, that does not mean that I am a Martian. Instead, it is the function named list. As such, the symbol list cannot be treated as a list and car cannot be used in this situation.

Lisp provides predicates that can test whether something is a symbol or a list or a string or a number etc: (symbolp input-method-function) ==> t - this says that the value of input-method-function (i.e. list) is indeed a symbol. But (listp input-method-function) ==> nil - this says that the value of input-method-function (i.e. 'list') is not a list.

2
  • See what you think of the edit.
    – NickD
    Commented Apr 2, 2022 at 2:31
  • @NickD -- looks good -- thank you!
    – lawlist
    Commented Apr 2, 2022 at 2:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.