Function: elisp--safe-macroexpand-all

elisp--safe-macroexpand-all is a byte-compiled function defined in elisp-mode.el.gz.

Signature

(elisp--safe-macroexpand-all SEXP)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/elisp-mode.el.gz
(defun elisp--safe-macroexpand-all (sexp)
  (if (not (trusted-content-p))
      ;; FIXME: We should try and do better here, either using a notion
      ;; of "safe" macros, or with `bwrap', or ...
      (progn
        (when elisp--macroexpand-untrusted-warning
          (setq-local elisp--macroexpand-untrusted-warning nil) ;Don't spam!
          (let ((inhibit-message t))      ;Only log.
            (message "Completion of local vars is disabled in %s (untrusted content)"
                     (buffer-name))))
        sexp)
    (let ((macroexpand-advice
           (lambda (expander form &rest args)
             (condition-case err
                 (apply expander form args)
               (error
                (message "Ignoring macroexpansion error: %S" err) form)))))
      (unwind-protect
          ;; Silence any macro expansion errors when
          ;; attempting completion at point (bug#58148).
          (let ((inhibit-message t)
                (macroexp-inhibit-compiler-macros t)
                (warning-minimum-log-level :emergency))
            (advice-add 'macroexpand-1 :around macroexpand-advice)
            (macroexpand-all sexp elisp--local-macroenv))
        (advice-remove 'macroexpand-1 macroexpand-advice)))))