syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

Commit fe60d0f breaks org-babel #6678

Closed izahn closed 8 years ago

izahn commented 8 years ago

Description :octocat:

Commit fe60d0f breaks org-babel

Reproduction guide :beetle:

#+BEGIN_SRC R :results output graphics :file tmp.png
  plot(rnorm(10), rnorm(10))
#+END_SRC

Observed behaviour: :eyes: :broken_heart:
Emacs says "Code block produced no output" and no figure is created

Expected behaviour: :heart: :smile: 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 :computer:

(ivy
 (ess :variables ess-ask-for-ess-directory nil)
 org emacs-lisp)

Backtrace :paw_prints:

bmag commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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

bmag commented 8 years ago

@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 commented 8 years ago

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

bmag commented 8 years ago

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

TheBB commented 8 years ago

Fix merged.