This works in emacs 25:
(setq custom-keymap (copy-keymap global-map))
(defun custom-def (keys func &optional file &optional global-p)
(define-key custom-keymap keys func)
(if global-p (global-set-key keys func))
(if file (autoload func file "[custom autoload]" t)))
(custom-def [delete] 'delete-char)
But when I call custom-def
in emacs 26 I get an invalid-function
error. I isolated it to the &optional
parameters. I removed those two args and custom-def
works.
So what changed between 25 and 26? What am I missing here? I want the flexible ARGLIST that works in emacs 25.
Use optional
just once in the parameter list- the following parameters will all be optional [other keywords can follow as well - see info(elisp) Functions].
(defun custom-def (keys func &optional file global-p)
;; ...
)
[I'm not sure what the change was - perhaps duplicated parameter checking was added?]