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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit fe60d0f breaks org-babel #6678

Closed
izahn opened this issue Jul 25, 2016 · 8 comments
Closed

Commit fe60d0f breaks org-babel #6678

izahn opened this issue Jul 25, 2016 · 8 comments

Comments

@izahn
Copy link
Contributor

izahn commented Jul 25, 2016

Description :octocat:

Commit fe60d0f breaks org-babel

Reproduction guide 馃

  • Enable the ess layer in .spacemacs
  • Start Emacs
  • Evaluate (require 'ob-R) to enable R code blocks in orgmode
  • Visit a .org file and insert
#+BEGIN_SRC R :results output graphics :file tmp.png
  plot(rnorm(10), rnorm(10))
#+END_SRC
  • Press C-c C-c to evaluate the block

Observed behaviour: 馃憖 馃挃
Emacs says "Code block produced no output" and no figure is created

Expected behaviour: 鉂わ笍 馃槃
R should start and generate the figure.

Details
I bisected this to

fe60d0fc1e265756585836bd9f476e44fc7526d4 is the first bad commit
commit fe60d0fc1e265756585836bd9f476e44fc7526d4
Author: bmag <bmagamb@gmail.com>
Date:   Thu Jul 14 11:13:55 2016 +0300

    Set buffer-predicate to spacemacs/useful-buffer-p

    Prevent next-buffer, other-buffer, etc. from choosing useless buffers.
    No need for spacemacs/next-useful-buffer,
    spacemacs/previous-useful-buffer anymore.

    Also fix spacemacs/alternate-buffer to respect buffer-predicate.

    When spacemacs-layouts is used, buffer-predicate filters useful buffer
    that belong to the current layout.

:040000 040000 3f283c138e13dc4ec3dafd17b19d1bbdc5080182 6c1acc19dbb3d23112f96f7413449141f62cf8f7 M      doc
:040000 040000 f0e9b36f810cf03928ee5cc8017794a50a9aab2f 18760f7f5e64570557c55dd0196bfe1ff209f8fd M      layers

Before that it works as expected. After that commit, kaboom. I don't see what that commit has to do with orgmode or babel, but is clear that this is where things were broken. Hopefully @bmag or @TheBB have some idea about how to fix it.

System Info 馃捇

  • OS: gnu/linux
  • Emacs: 24.5.1
  • Spacemacs: 0.105.21
  • Spacemacs branch: nil (rev. 141be7f)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: emacs
  • Completion: ivy
  • Layers:
(ivy
 (ess :variables ess-ask-for-ess-directory nil)
 org emacs-lisp)

Backtrace 馃惥

@bmag
Copy link
Collaborator

bmag commented Jul 26, 2016

@izahn if you put this in user-config, does C-c C-c generate an image as expected? (this isn't a work-around, just a test)

(defun return-t (&rest _args) t)
(advice-add 'spacemacs/useful-buffer-p :override #'return-t)

Also, please check if there's anything relevant in the *Messages* buffer (C-h e).

@vashirov
Copy link

I have a similar issue with notmuch. When I open some buffers in notmuch and then close it with q, I'm redirected to *scratch* buffer instead of going to the previous one.
Snippet from @bmag helped.

@bmag
Copy link
Collaborator

bmag commented Jul 26, 2016

@vashirov I don't think it's a similar issue. In your case, it's probably that Spacemacs considers the earlier buffer as "useless" (spacemacs/useless-buffer-p returns true). Can you open a new issue, with details about what buffer you expected to see instead of *scratch*? We probably need to refine the value of spacemacs-useless-buffers-regexp.

@vashirov
Copy link

It's similar in a way that this commit broke notmuch, sorry for the confusion.
Sure, I'll open a new issue.

@bmag
Copy link
Collaborator

bmag commented Jul 26, 2016

@izahn I noticed that current implementation of spacemacs/useless-buffer-p has a side effect of changing the match data (it uses string-match instead of string-match-p). Please replace in your local installation the code for spacemacs/useless-buffer-p and spacemacs/useful-buffer-p in layers/+distributions/spacemacs-base/funcs.el with this one:

(defun spacemacs/useful-buffer-p (buffer)
  "Determines if a buffer is useful."
  (let ((buf-name (buffer-name buffer)))
    (or (with-current-buffer buffer
          (derived-mode-p 'comint-mode))
        (cl-loop for useful-regexp in spacemacs-useful-buffers-regexp
                 thereis (string-match-p useful-regexp buf-name))
        (cl-loop for useless-regexp in spacemacs-useless-buffers-regexp
                 never (string-match-p useless-regexp buf-name)))))

(defun spacemacs/useless-buffer-p (buffer)
  "Determines if a buffer is useless."
  (not (spacemacs/useful-buffer-p buffer)))

Does this fix the problem? If it doesn't, I'd like you to perform the earlier test I asked for and report back.

@izahn
Copy link
Contributor Author

izahn commented Jul 26, 2016

@bmag Replacing spacemacs/useless-buffer-p and spacemacs/useful-buffer-p with the definitions in your previous comment solves the problem!

@bmag
Copy link
Collaborator

bmag commented Jul 26, 2016

@izahn nice 馃槃 I opened a PR with the change: #6685

@TheBB
Copy link
Collaborator

TheBB commented Jul 27, 2016

Fix merged.

@TheBB TheBB closed this as completed Jul 27, 2016
@TheBB TheBB removed the PR pending label Jul 27, 2016
@TheBB TheBB reopened this Jul 27, 2016
@TheBB TheBB closed this as completed Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants