Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix `leaf-find' in embedded leaf block. #492

Merged
merged 4 commits into from Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions leaf.el
Expand Up @@ -5,7 +5,7 @@
;; Author: Naoya Yamashita <conao3@gmail.com>
;; Maintainer: Naoya Yamashita <conao3@gmail.com>
;; Keywords: lisp settings
;; Version: 4.4.6
;; Version: 4.4.7
;; URL: https://github.com/conao3/leaf.el
;; Package-Requires: ((emacs "24.1"))

Expand Down Expand Up @@ -63,6 +63,7 @@ Same as `list' but this macro does not evaluate any arguments."
(defvar leaf--body)
(defvar leaf--rest)
(defvar leaf--autoload)
(defvar leaf--load-file-name nil)

(defvar leaf-keywords
(leaf-list
Expand Down Expand Up @@ -153,7 +154,7 @@ Same as `list' but this macro does not evaluate any arguments."
`(,@(mapcar (lambda (elm) `(,(car elm) 1)) leaf--value) ,@leaf--body))

:leaf-defer (if (and leaf--body (eval (car leaf--value)) (leaf-list-memq leaf-defer-keywords (leaf-plist-keys leaf--raw)))
`((eval-after-load ',leaf--name '(progn ,@leaf--body))) `(,@leaf--body))
`((eval-after-load ',leaf--name '(let ((leaf--load-file-name ,load-file-name)) ,@leaf--body))) `(,@leaf--body))

:setq `(,@(mapcar (lambda (elm) `(setq ,(car elm) ,(cdr elm))) leaf--value) ,@leaf--body)
:setq-default `(,@(mapcar (lambda (elm) `(setq-default ,(car elm) ,(cdr elm))) leaf--value) ,@leaf--body)
Expand Down Expand Up @@ -637,7 +638,8 @@ see `alist-get'."

(defun leaf-this-file ()
"Return path to this file."
(or load-file-name
(or leaf--load-file-name
load-file-name
(and (boundp 'byte-compile-current-file) byte-compile-current-file)
buffer-file-name))

Expand Down Expand Up @@ -1065,9 +1067,7 @@ FN also accept list of FN."

(defmacro leaf-handler-leaf-path (name)
"Meta handler for :leaf-path for NAME."
`(let ((file (or load-file-name
buffer-file-name
byte-compile-current-file)))
`(let ((file (leaf-this-file)))
(unless (boundp 'leaf--paths) (defvar leaf--paths nil))
(when file
(add-to-list 'leaf--paths (cons ',name file)))))
Expand Down