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

leaf + (emacs-lisp) flycheck #464

Closed
reuleaux opened this issue Nov 14, 2020 · 4 comments
Closed

leaf + (emacs-lisp) flycheck #464

reuleaux opened this issue Nov 14, 2020 · 4 comments

Comments

@reuleaux
Copy link

I am just starting out with leaf, so bear with me, please,
and I am rewriting my use-package config to use leaf.

All this is emacs-lisp code, of course, and I had - since a long time -
flycheck turned on to help me in this regard, like so

(add-hook 'emacs-lisp-mode-hook (lambda ()
                                  (progn

				    (setq flycheck-checker #'emacs-lisp)				    
				    (flycheck-mode)
			    
                                    ) ;; progn
				  ) ;; lambda
	  ) ;; add hook

Now, take my leaf config for ivy just as an example - created with the help of leaf-convert -
(the problem that I am about to describe holds for any other leaf config as well)

(leaf ivy
  :bind (

         (global-map
          ("C-c C-r" . ivy-resume))


         ;; exchange the default bindings for C-j and C-m (return)
         ;; i.e. tab-tab waits in minibuffer

         (ivy-minibuffer-map

          ;; ret (default C-j)
          ("<return>" . ivy-alt-done)

          ;; (default C-m , i.e. ret )
          ("C-j" . ivy-done)

          ;; tab-tab returns as done,   (default ivy-partial-or-done )
          ("<tab>" . #'ivy-partial)

          ;; corresponds to M-y for counsel-yank-pop
          ("M-y" . #'ivy-next-line))
         )


  :setq (
         (ivy-use-virtual-buffers . t)
         (ivy-display-style 'fancy)
         )

  :config
  (ivy-mode 1)
  )

This seems to work (emacs starts fine with this) - however my emacs-lisp flychecker complains:

In toplevel form:
_ivy-counsel-amx-swiper.el:5:1:Error: Wrong type argument: listp, ivy-alt-done

and I can make it happy by function-quoting ivy-alt-done and ivy-done in the :bind section

...
("<return>" . #'ivy-alt-done)
("C-j" . #'ivy-done)

instead of just

...
("<return>" . ivy-alt-done)
("C-j" . ivy-done)

however, now that flycheck is happy, my emacs won't start up properly any more

Warning (initialization): An error occurred while loading ‘/home/rx/.emacs.d/init.el’:

Wrong type argument: listp, <return>

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

It would certainly be nice to have both working: leaf and emacs-lisp flycheck.
Thanks,
Andreas

@conao3
Copy link
Owner

conao3 commented Nov 16, 2020

Thanks, report. But I think, I think your Emacs doesn't load leaf in compiling-time?
I try this init.el and byte-compille made missing variable and missing function warning.

;;; init.el --- Sample clean init.el  -*- lexical-binding: t; -*-

;; ~/.debug.emacs.d/leaf-byte-compile-ivy/init.el

;; you can run like 'emacs -q -l ~/.debug.emacs.d/leaf-byte-compile-ivy/init.el'
(when load-file-name
  (setq user-emacs-directory
        (expand-file-name (file-name-directory load-file-name))))

(eval-when-compile
  (setq user-emacs-directory
        (expand-file-name (file-name-directory default-directory))))

(eval-and-compile
  (prog1 "leaf"
    (custom-set-variables
     '(package-archives '(("org"   . "https://orgmode.org/elpa/")
                          ("melpa" . "https://melpa.org/packages/")
                          ("gnu"   . "https://elpa.gnu.org/packages/"))))
    (package-initialize)
    (unless (package-installed-p 'leaf)
      (package-refresh-contents)
      (package-install 'leaf))))



(load (locate-user-emacs-file "../essentials.el"))

(leaf ivy
  :bind ((global-map
          ("C-c C-r" . ivy-resume))
         (ivy-minibuffer-map
          ("<return>" . ivy-alt-done)
          ("C-j" . ivy-done)
          ("<tab>" . ivy-partial)
          ("M-y" . ivy-next-line)))
  :setq ((ivy-use-virtual-buffers . t)
         (ivy-display-style 'fancy))
  :config
  (ivy-mode 1))
$ emacs --version
GNU Emacs 27.1
Copyright (C) 2020 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

$ emacs --batch -f batch-byte-compile init.el
In toplevel form:
init.el:37:11:Warning: assignment to free variable ‘ivy-use-virtual-buffers’
init.el:38:11:Warning: assignment to free variable ‘ivy-display-style’

In end of data:
init.el:41:1:Warning: the function ‘ivy-mode’ is not known to be defined.

And please fix leaf form like below

(leaf ivy
  :bind ((global-map
          ("C-c C-r" . ivy-resume))
         (ivy-minibuffer-map
          ("<return>" . ivy-alt-done)
          ("C-j" . ivy-done)
          ("<tab>" . ivy-partial)
          ("M-y" . ivy-next-line)))
  :custom ((ivy-use-virtual-buffers . t)
           (ivy-display-style 'fancy))
  :global-minor-mode t)
$ emacs --batch -f batch-byte-compile init.el

byte-compile happy now.

@reuleaux
Copy link
Author

reuleaux commented Nov 16, 2020 via email

@reuleaux
Copy link
Author

reuleaux commented Nov 19, 2020 via email

@conao3
Copy link
Owner

conao3 commented Nov 29, 2020

It seems lambda in :bind issue. closing this for a duplicate.
Please reopen you have another point.

@conao3 conao3 closed this as completed Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants