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

org + lispy + evil Possible issue | Not able to cycle subtree/heading #141

Closed
nixmaniack opened this issue Nov 14, 2015 · 5 comments
Closed

Comments

@nixmaniack
Copy link

Following is ~/.emacs

(require 'package)
(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages/") t)
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(require 'use-package)
(use-package lispy
  :ensure t
  :init
  (progn
    (defun turn-on-lispy-mode ()
      (when (member major-mode
                    '(emacs-lisp-mode lisp-interaction-mode clojure-mode racket-mode))
        (lispy-mode)))
    (defun turn-off-lispy-mode () (lispy-mode -1))

    (add-hook 'evil-insert-state-entry-hook  'turn-on-lispy-mode)
    (add-hook 'evil-insert-state-exit-hook 'turn-off-lispy-mode)
    ;; (define-key evil-insert-state-map (kbd "s-m") 'lispy-mark-symbol)
    ))

(use-package evil
  :ensure t
  :init (evil-mode 1))

Following is sample.org

* This is heading
* This is another heading

** This is sub heading

** And one more sub heading

** So is this one

*** This is level 3 sub heading

- [X] item 1
- [ ] item 2
- [ ] item 3
- [ ] item 4

Open sample.org, navigate to "This is level 3 sub heading", you can use <tab> to cycle it while in normal evil state, go to insert state with i, you can still cycle subtree, now go back to normal mode, and now you can't cycle anymore. Following error/message is generated.

byte-code: Before first headline at position 118 in buffer sample.org

Following is from view-lossage if at all it's helpful, after opening sample.org, the last threw error.

j <tab>
j j j j <tab> j j <tab> i <escape> i <tab> 

If you comment out, lispy in ~/.emacs, everything works as expected, you can cycle headings normally.

I'm not entirely sure if it's lispy or something else, but based on repro steps, I can only point at lispy hence filing issue here.

And, thank you for making this awesome lisp editing package.

@abo-abo
Copy link
Owner

abo-abo commented Nov 15, 2015

Thanks, I improved the code. The issue could also be fixed with:

(defun turn-off-lispy-mode ()
  (when lispy-mode
    (lispy-mode -1)))

Since you're calling turn-off-lispy-mode for an org-mode buffer, even though lispy-mode wasn't turned on for that buffer.

@nixmaniack
Copy link
Author

Thanks! Adding when guard fixed it.

Also I added the patch to test it out without when guard, but it produced following error.
setq: Wrong type argument: listp, "Store the old values ofoutline-regexp' and outline-level'.
Might need to improve more?

@abo-abo
Copy link
Owner

abo-abo commented Nov 15, 2015

Thanks for catching that :)

@nixmaniack
Copy link
Author

Fixed. Awesome!

@jsomedon
Copy link

Thanks, I improved the code. The issue could also be fixed with:

(defun turn-off-lispy-mode ()
  (when lispy-mode
    (lispy-mode -1)))

Since you're calling turn-off-lispy-mode for an org-mode buffer, even though lispy-mode wasn't turned on for that buffer.

I thought calling (lispy-mode -1) while you are not in lispy-mode just returns nil without doing anything? Wonder why this could be erroneous? (Just came here while I was searching for config for lispy+evil+insert state.. )

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

3 participants