conao3 / leaf.el

Flexible, declarative, and modern init.el package configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot seem to get leaf working with auctex

dXu23 opened this issue · comments

commented

Auctex not being loaded

I've been trying to get auctex working with leaf. The common use-package declaration for auctex is

(use-package tex
  :defer t
  :ensure auctex
  :config
  (setq TeX-auto-save t))

I checked with use-package, and TeX-auto-save gets set to t. However, when I try the same declaration with leaf and elpaca,
it doesn't seem to be loading auctex, since TeX-auto-save is not even loaded as a variable. Here is what my leaf declaration is:

(elpaca-leaf tex
  :defer t
  :ensure auctex
  :config
  (setq TeX-auto-save t))

I have no idea what the expected output of macroexpand-1 for elpaca-leaf should be.

Thanks for using my leaf!

First, I don't know elpaca-leaf. Please tell me about this? Where is repo?

commented

I'm pretty sure that the elpaca-leaf declaration is pretty much the same as

(leaf tex
  :defer t
  :ensure auctex
  :config
  (setq TeX-auto-save t))

But here's part of my config if it helps:

;;; Bootstrap Elpaca package manager
(defvar elpaca-installer-version 0.3)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
                              :ref nil
                              :files (:defaults (:exclude "extensions"))
                              :build (:not elpaca--activate-package)))
(let* ((repo  (expand-file-name "elpaca/" elpaca-repos-directory))
       (build (expand-file-name "elpaca/" elpaca-builds-directory))
       (order (cdr elpaca-order))
       (default-directory repo))
  (add-to-list 'load-path (if (file-exists-p build) build repo))
  (unless (file-exists-p repo)
    (make-directory repo t)
    (condition-case-unless-debug err
        (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
                 ((zerop (call-process "git" nil buffer t "clone"
                                       (plist-get order :repo) repo)))
                 ((zerop (call-process "git" nil buffer t "checkout"
                                       (or (plist-get order :ref) "--"))))
                 (emacs (concat invocation-directory invocation-name))
                 ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
                                       "--eval" "(byte-recompile-directory \".\" 0 'force)")))
                 ((require 'elpaca))
                 ((elpaca-generate-autoloads "elpaca" repo)))
            (kill-buffer buffer)
          (error "%s" (with-current-buffer buffer (buffer-string))))
      ((error) (warn "%s" err) (delete-directory repo 'recursive))))
  (unless (require 'elpaca-autoloads nil t)
    (require 'elpaca)
    (elpaca-generate-autoloads "elpaca" repo)
    (load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))



(defmacro elpaca-leaf (order &rest body)
  "Execute BODY in `leaf' declaration after ORDER is finished.
If the :disabled keyword is present in body, the package is completely ignored.
This happens regardless of the value associated with :disabled.
The expansion is a string indicating the package has been disabled."
  (declare (indent 1))
  (if (memq :disabled body)
      (format "%S :disabled by elpaca-leaf" order)
    (let ((o order))
      (when-let ((ensure (seq-position body :ensure)))
	(setq o (if (null (nth (1+ ensure) body)) nil order)
	      body (append (seq-subseq body 0 ensure)
			   (seq-subseq body (+ ensure 2)))))
      `(elpaca ,o (leaf
		   ,(if-let (((memq (car-safe order) '(quote \`)))
			     (feature (flatten-tree order)))
			(cadr feature)
		      (elpaca--first order))
		   ,@body)))))

(elpaca leaf (require 'leaf))
(elpaca leaf-keywords (require 'leaf-keywords))

(elpaca-leaf nil
	     :init (leaf leaf-keywords
			 :init (leaf-keywords-init)))

OK, so you are saying you want to make your leaf work on top of leaf? I am having a little difficulty with your advice.
leaf is a macro, and a macro first assumes the S-expression you want to expand, and then designs the S-expression to expand it.
In other words, the S-expression to be expanded should be given at the beginning, and that is for the macro writer to think about.

To support elpaca as a leaf, please suggest the :elpaca keyword in leaf-keyword. There, too, the S-expression after expansion is required. I am not using elpaca, so I don't know what kind of S-expression is needed.

commented

It already works for most packages. It's just auctex in particular that I'm having trouble trying to get it to work with, since auctex tends to break some emacs package conventions. My emacs config is located at https://github.com/dXu23/.emacs.d if you don't believe me.

hmm, leaf has a :leaf-defer instead of use-package's :defer. Do you know about this?
https://github.com/conao3/leaf.el#leaf-defer-keyword

commented

Forgot about :leaf-defer, thanks. I tried it with :leaf-defer instead of :leaf and it still didn't work. If it's of any help, here's what I get using macroexpand-1:

(macroexpand-1 (elpaca-leaf tex
		 :leaf-defer t
		 :ensure auctex
		 :config
		 (setq TeX-auto-save t)))
(elpaca< tex "tex" tex (queued) "/home/sisyphus/.emacs.d/elpaca/repos/tex/" "/home/sisyphus/.emacs.d/elpaca/builds/tex" nil nil (elpaca--clone elpaca--configure-remotes elpaca--checkout-ref elpaca--run-pre-build-commands elpaca--clone-dependencies elpaca--link-build-files elpaca--generate-autoloads-async elpaca--byte-compile elpaca--compile-info elpaca--install-info elpaca--add-info-path elpaca--run-post-build-commands ...) (:protocol https :inherit t :depth 1 :package "tex") nil ...)

I suspect that the issue here is that it's not loading the right directory. There is no tex directory in $HOME/.emacs.d/elpaca/repos. Maybe I'll try raising an issue in profolio's elpaca repo, and see if he/she can help.

commented

I think I managed to get it working. The following declaration

(elpaca-leaf auctex
  :leaf-defer t
  :require t
  :ensure auctex
  :config
  (setq TeX-auto-save t))

seems to work. Probably should have been the first thing I tried.