Skip to content

el-patch validates against macro-expanded version of function #55

@leezu

Description

@leezu

Consider the following patch:

(el-patch-feature org-roam)
(with-eval-after-load 'org-roam
  (el-patch-defun org-roam-buffer-persistent-redisplay ()
    "Recompute contents of the persistent `org-roam-buffer'.
Has no effect when there's no `org-roam-node-at-point'."
    (when-let ((node (org-roam-node-at-point)))
      (unless (equal node org-roam-buffer-current-node)
        (setq org-roam-buffer-current-node node
              org-roam-buffer-current-directory org-roam-directory)
        (el-patch-remove (with-current-buffer (get-buffer-create org-roam-buffer)
                           (org-roam-buffer-render-contents)
                           (add-hook 'kill-buffer-hook #'org-roam-buffer--persistent-cleanup-h nil t)))
        (el-patch-add
          (if (get-buffer-window org-roam-buffer)
	      (delete-window (get-buffer-window org-roam-buffer)))
          (let ((buffer (get-buffer-create org-roam-buffer)))
	    (with-current-buffer buffer
	      (org-roam-buffer-render-contents)
	      (add-hook 'kill-buffer-hook #'org-roam-buffer--persistent-cleanup-h nil t))
	    (display-buffer buffer)))))))

Applying it at startup and validating the patch yields the following diff (in which macros are expanded in the expected buffer):

image

However, when commenting out the patch during startup and manually eval the el-patch-defun after startup completed, validation succeeds and the diff does not contain expanded macros:

image

Could the problem be related to the emacs native compilation feature? Verified the issue persists after rebuilding emacs without native compilation support.

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.29, cairo version 1.16.0)
 of 2021-11-05 built on leonard-xps13
Repository revision: 37632dae180e9d5196ef01343fefa9234c5f05b9
Repository branch: feature/pgtk
Repository: https://github.com/leezu/emacs
System Description: Gentoo/Linux

Configured using:
 'configure --with-cairo --with-x-toolkit=no --with-pgtk --with-modules --with-native-compilation'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM
GTK3 ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LC_CTYPE: zh_CN.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions