1

I'm attempting to have emacs compilation-mode always use visual-line-mode. The code I'm using is:

(add-hook 'compilation-mode-hook (visual-line-mode))

I've tried various other permutations. Such as the version in:

Or globally enabling visual-line-mode

(setq-default global-visual-line-mode t) 

Yet emacs insists on truncating lines. I've confirmed the hook is executing. Is there a known resolution for this?

Update 0

The primary issue is a Lisp newbie problem: The function visual-line-mode was not quoted. This results in an immediate evaluation and not evaluation when the hook is fired.

This did not resolve the issue: compilation mode still does not wrap lines. I've confirmed the hook is being executed at the expected time by placing a undefined identifier instead of t. Emacs complains, as expected, of the undefined identifier when compilation mode is entered.

Is there a way to trace execution of compile? Using (trace-function 'compile) produces:

======================================================================
1 -> compile: command="make" comint=nil
1 <- compile: #<buffer *compilation*>

and nothing more.

Update 1

Solved!

As well as incorrect quoting, the issue was with another part of my emacs config:

(add-hook 'after-change-major-mode-hook
      (function
        (lambda ()
            (fci-mode)
            (turn-on-auto-fill)
        )
      )
)

which, effectively, undid the visual-line-mode setting!

1

The answer provided by lawlist is the correct one, however, there is also a compilation minor mode that is used by some major modes (CIDER's stacktrace-mode, for example). Thus, I have the following:

(add-hook 'compilation-mode-hook
          (lambda () (visual-line-mode 1)))

(add-hook 'compilation-minor-mode-hook
          (lambda () (visual-line-mode 1)))

I mention this because the minor code also presents as "Compilation" on the status bar, and it took me a little while to figure out that it was the minor, and not the major mode.

(I'd have preferred to simply comment on lawlist's answer, but I don't currently have enough rep to do so.)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.