millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

ein-20200202.218: show-trailing-whitespace problem #651

Closed sam-s closed 4 years ago

sam-s commented 4 years ago

When point is in an editable cell, show-trailing-whitespace is t and the output data highlights trailing whitespace. When point is in non-editable output area, show-trailing-whitespace is nil and everything is fine. This might be due to

(add-hook 'python-mode-hook 'sds-standard-hook)
(defun sds-standard-hook ()
  "Set some variables."
  (if buffer-read-only
      (setq abbrev-mode nil
            show-trailing-whitespace nil)
      (setq abbrev-mode t
            show-trailing-whitespace t)))
dickmao commented 4 years ago

Sounds like you have this well in hand.

You can always modify your personal sds-standard-hook to further condition on ein:notebook-mode being t, e.g., in line 8, (setq show-trailing-whitespace (not ein:notebook-mode))

sam-s commented 4 years ago

Not really. I do want the feature enabled, but only in the code cells, not in data cells. Please reopen the issue.

dickmao commented 4 years ago

It remains unclear how your personal mode hooks possibly impact other users (that is one criterion for keeping an issue open).

I am also confused about how the qualifiers "feature", "fine", "enabled", and "show" interrelate. Is showing whitespace the feature? And does not showing it mean "everything is fine"? Perhaps you could more simply describe what you expect and how the program doesn't meet that expectation.

sam-s commented 4 years ago

I want trailing whitespace to be shown (highlighted) by show-trailing-whitespace in the editable areas (source code cells), but not in read-only areas (output/data cells).

dickmao commented 4 years ago

My apologies, I interpreted your initial post as questioning why trailing ws was being highlighted at all.

The issue then is "holistic" buffer treatments such as those implemented in xdisp.c ought not bleed into indirect buffers. And that does have wider ramifications, so apologies again.

I have no solution for this. I've already cast the die on polymode, and I really would like to avoid going back to the erstwhile "poor man's" python-mode emulation.

The best I could suggest is this, which is not what you want.

(add-hook 'python-mode-hook
          (lambda () (setq show-trailing-whitespace
                           (or (not (boundp 'ein:notebook-mode))
                               (not ein:notebook-mode)))))