Skip to main content
added 113 characters in body
Source Link
NickD
  • 33.6k
  • 3
  • 30
  • 47

Use funcallfuncall or apply:

(setq wrapped-copy (symbol-function 'emacs-version))
(fset 'fn (lambda () (funcall wrapped-copy)))

(fn)
"GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, cairo version 1.16.0)
 of 2020-06-15"

Although, in general, I would use an advice for wrapping a function.

Use funcall:

(setq wrapped-copy (symbol-function 'emacs-version))
(fset 'fn (lambda () (funcall wrapped-copy)))

(fn)
"GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, cairo version 1.16.0)
 of 2020-06-15"

Although, in general, I would use an advice for wrapping a function.

Use funcall or apply:

(setq wrapped-copy (symbol-function 'emacs-version))
(fset 'fn (lambda () (funcall wrapped-copy)))

(fn)
"GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, cairo version 1.16.0)
 of 2020-06-15"

Although, in general, I would use an advice for wrapping a function.

Source Link
NickD
  • 33.6k
  • 3
  • 30
  • 47

Use funcall:

(setq wrapped-copy (symbol-function 'emacs-version))
(fset 'fn (lambda () (funcall wrapped-copy)))

(fn)
"GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, cairo version 1.16.0)
 of 2020-06-15"

Although, in general, I would use an advice for wrapping a function.