I've seen this sort of thing a few times:
(mapconcat 'identity '("" "home" "alex " "elisp" "erc") "/")
=> "/home/alex /elisp/erc"
which means mapconcat
wants a function in the second position, hence just shove it the "identity" function if you don't want anything done to your input list first. But this
(defun shk-yas/helm-prompt (prompt choices &optional display-fn)
"Use helm to select a snippet. Put this into `yas/prompt-functions.'"
(interactive)
(setq display-fn (or display-fn 'identity))
has me confused. Likewise this
(org-element-map (org-element-parse-buffer) 'headline #'identity)
I assume it has something to do with the code calling a function, but we don't want to give it one -- other than something reflexive like an identity. Again, the first example is clear, but not so much the next two.
identity
just returns its argument, unchanged. Presumably the functions that are being passedidentity
as an argument in your examples apply that argument as a function to something, and in this case they don't want to change that something at all. The functions it is passed to accept (presumably) any function as argument. It just so happens that these particular calls of those functions don't want them to use their function argument to do anything particular to the things it is applied to. So they pass a function that can be applied to do nothing. – Drew Nov 16 '15 at 2:58