I want to set the variable truncate-lines
to t
in order to have truncated lines, but only in programming modes. So, following this thread, I put the following code in my configuration file:
(defun my-prog-mode-hook ()
(setq truncate-lines t))
(add-hook 'prog-mode-hook #'my-prog-mode-hook)
My problem is this does not work, because truncate-lines
is still nil
when I start Emacs in fortran-mode
(for example). The lambda
version of the above code gives the same result.
What am I missing?
prog-mode-hook
withF1 v
to make sure the function has been added to the hook. – wasamasa May 23 '17 at 17:20prog-mode
does not, itself, change the value oftruncate-lines
tonil
. You can also useM-x debug-on-entry my-prog-mode-hook
to follow along and see what happens when it is invoked. – Drew May 23 '17 at 22:38prog-mode-hook
containsmy-prog-mode-hook
, so I guess it is ok. Then when IM-x debug-on-entry my-prog-mode-hook
, a list of functions that are run is displayed, but after a quick look, I haven't find any occurrence oftruncate
in their definition. But something came to my mind: I have(global-visual-line-mode 1)
in my config file, could it be the culprit? – Giuseppe May 24 '17 at 9:30(global-visual-line-mode 1)
was most probably the problem. Thanks a lot to both of you anyway. – Giuseppe May 24 '17 at 9:57