bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55038: 29.0.50; Does macroexp-file-name return nil unnecessarily?


From: Philip Kaludercic
Subject: bug#55038: 29.0.50; Does macroexp-file-name return nil unnecessarily?
Date: Wed, 20 Apr 2022 14:10:00 +0000

Consider a macro like

        (defmacro foo ()
          `(message "Defined in %s" ,(macroexp-file-name)))

Why does this expand to

        (message "Defined in %s" nil)

when evaluated directly in a file (say using `eval-buffer' or
`eval-last-sexp`).  Shouldn't it be fair to return the file name of the
buffer, if nothing else can be used:

diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index e4bc2df280..5df9d4b221 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -143,7 +143,8 @@ macroexp-file-name
   ;; so prefer using it over using `load-file-name'.
   (let ((file (car (last current-load-list))))
     (or (if (stringp file) file)
-        (bound-and-true-p byte-compile-current-file))))
+        (bound-and-true-p byte-compile-current-file)
+        (buffer-file-name))))
 
 (defvar macroexp--warned (make-hash-table :test #'equal :weakness 'key))
 
Or is there something that would go wrong in that case?


In GNU Emacs 29.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo 
version 1.16.0)
 of 2022-04-19 built on viero
Repository revision: d168decab4a03cd48b8b96257c36ffa575c720e6
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Guix System

Configured using:
 'configure
 
PKG_CONFIG_PATH=/home/philip/.guix-profile/lib/pkgconfig:/home/philip/.guix-profile/share/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LIBOTF LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH: 
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  outline-minor-mode: t
  corfu-mode: t
  flymake-mode: t
  yas-minor-mode: t
  flyspell-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  repeat-mode: t
  display-battery-mode: t
  display-time-mode: t
  diff-hl-flydiff-mode: t
  diff-hl-mode: t
  winner-mode: t
  windmove-mode: t
  electric-pair-mode: t
  save-place-mode: t
  savehist-mode: t
  xterm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  auto-save-visited-mode: t

Load-path shadows:
/home/philip/Source/sp-tutor/sp-tutor hides 
/home/philip/.config/emacs/site-lisp/sp-tutor/sp-tutor
/home/philip/Source/sp-tutor/waffel hides 
/home/philip/.config/emacs/site-lisp/sp-tutor/waffel
/home/philip/.config/emacs/site-lisp/modus-themes/modus-vivendi-theme hides 
/home/philip/.config/emacs/elpa/modus-themes-2.3.0/modus-vivendi-theme
/home/philip/.config/emacs/site-lisp/modus-themes/modus-operandi-theme hides 
/home/philip/.config/emacs/elpa/modus-themes-2.3.0/modus-operandi-theme
/home/philip/.config/emacs/site-lisp/modus-themes/modus-themes hides 
/home/philip/.config/emacs/elpa/modus-themes-2.3.0/modus-themes
/home/philip/.config/emacs/elpa/transient-0.3.7/transient hides 
/home/philip/Source/emacs/lisp/transient
~/.config/emacs/site-lisp/autoload hides 
/home/philip/Source/emacs/lisp/emacs-lisp/autoload

Features:
(shadow avy emacsbug shortdoc macros kmacro mailalias smtpmail
autocrypt-message ecomplete misearch multi-isearch vc-backup log-view
pcvs-util vc-fossil copyright time-stamp ietf-drums-date sort smiley
gnus-cite mail-extr textsec uni-scripts idna-mapping ucs-normalize
uni-confusable textsec-check gnus-async gnus-bcklg qp gnus-ml
autocrypt-gnus autocrypt nndraft nnmh utf-7 nnfolder epa-file
network-stream nsm gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig nntp
gnus-cache gnus-sum shr pixel-fill kinsoku url-file url-dired svg dom
gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail
mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range message
yank-media rmc puny rfc822 mml mml-sec epa epg rfc6068 epg-config
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader gnus-win noutline outline corfu checkdoc flymake-proc flymake
project warnings thingatpt yasnippet-snippets yasnippet cl-extra
flyspell ispell auth-source-pass tramp-cache tramp-sh tramp
tramp-loaddefs trampver tramp-integration cus-edit pp files-x
tramp-compat shell pcomplete parse-time iso8601 ls-lisp recentf
tree-widget repeat format-spec battery dbus xml dired-x dired
dired-loaddefs time sendmail rfc2047 rfc2045 ietf-drums gnus nnheader
gnus-util time-date mail-utils range mm-util mail-prsvr wid-edit
help-at-pt diff-hl-flydiff diff diff-hl face-remap vc-hg vc-git vc-dir
ewoc vc vc-dispatcher diff-mode derived easy-mmode hippie-exp winner
windmove rx elec-pair saveplace savehist xt-mouse modus-operandi-theme
modus-themes pcase rot13 disp-table cus-load setup compile
text-property-search comint ansi-color autoload lisp-mnt tex-site
geiser-impl help-fns radix-tree help-mode geiser-custom geiser-base ring
slime-autoloads info package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x
byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl
tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice
simple cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese composite
emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help
abbrev obarray oclosure cl-preloaded button loaddefs faces cus-face
macroexp files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 494138 82143)
 (symbols 48 27418 4)
 (strings 32 98942 6272)
 (string-bytes 1 2898983)
 (vectors 16 69570)
 (vector-slots 8 1609050 98329)
 (floats 8 428 731)
 (intervals 56 685 128)
 (buffers 992 19))

-- 
        Philip Kaludercic

reply via email to

[Prev in Thread] Current Thread [Next in Thread]