2

I consistently get the following problem on Emacs 24.5.1 with folding package (version 20140401.3) for which I've found a workaround but would like to understand what was going on.

As you can see in the screenshot above, the emacs server started OK, but when I try to launch the emacsclient it just hangs there:

enter image description here

… after killing emacsclient with Ctrl+C I get into a situation where nothing is echoed on my terminal as I type a command and, moreover, the command's output is mangled (line feed characters are apparently missing): enter image description here

Upon further investigation I noticed that this behaviour was dependent on the type of file I was trying to open with emacsclient. Some files triggered it, some not. Further digging pointed me to a message emitted by the folding package (version 20140401.3) when I was trying to open the offending files.

The message on the mini-buffer read:

Folding error: mode is not in `folding-mode-marks-alist'

Upon adding the single line marked as "line-A" in my .emacs the problem went away:

(use-package folding
  :ensure t
  :config
  (folding-install-hooks)
  (defun my-always-fold ()
    (setq-local folded-file t))
  (advice-add #'folding-mode-find-file :before #'my-always-fold)
  (folding-add-to-marks-list 'json-mode "foo" "foo") ;; line-A
  )

However, even without the fix, directly opening the file using emacs (not emacsclient) does not result in this behaviour. Something a lot milder happens: the file is not placed in the buffer that's currently opened. Instead I am presented with the *scratch* buffer and the file I asked to open is placed in another buffer. This is what I see when I press C-x C-b:

enter image description here

… so I just use C-x C-b and navigate to my buffer to bring it up. And there is no mangling at all at the terminal. This leds me to believe that the problem may also be related to emacs daemon / emacsclient.

My questions are:

  1. was this problem related to emacsclient or folding mode ?
  2. how is it possible for emacsclient to mangle my terminal's output even after it's killed and how could I have fixed the terminal output?
  3. is there another way to solve this problem? I don't want to have to specify folding marks for JSON files because folding makes no sense in JSON.
  • 2
    I can provide some minor input for #2: Emacs can set various terminal capabilities in order to do various things, such as enabling line wrapping. If Emacs is killed, these settings may not be restored, leaving your terminal with possibly broken settings. You can however reset the terminal capabilities with certain commands, e.g., stty sane – Xaldew Nov 15 '16 at 21:49
  • @Xaldew I reproduced the problem and can confirm that stty sane addresses that symptom. – Marcus Junius Brutus Nov 15 '16 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.