0

My emacs configuration has global visual line mode enabled via (global-visual-line-mode 1). I want to disable this mode, but only when in org-agenda-mode.

When I do this manually, via M-x org-agenda, then a, and then M-x visual-line-mode, then this works as desired.

However, I do not want to do this manually every time. Therefore I tried

(add-hook 'org-agenda-mode-hook (lambda () 'visual-line-mode))

but this does not have the desired effect. How can I selectively disable visual-line-mode only in org-agenda-mode?

0

Looking at the docstring for visual-line-mode (C-h f visual-line-mode RET):

(visual-line-mode &optional ARG)

Toggle visual line based editing (Visual Line mode) in the current buffer.

...

If called from Lisp, toggle the mode if ARG is ‘toggle’, disable the mode if ARG is a non-positive integer, and enable the mode otherwise (including if ARG is omitted or nil or a positive integer).

so you have to provide a non positive integer argument.

Note this is the recommended behavior for minor mode commands, as the elisp manual states:

The mode command should accept one optional argument. If called interactively with no prefix argument, it should toggle the mode (i.e., enable if it is disabled, and disable if it is enabled). If called interactively with a prefix argument, it should enable the mode if the argument is positive and disable it otherwise.

If the mode command is called from Lisp (i.e., non-interactively), it should enable the mode if the argument is omitted or nil; it should toggle the mode if the argument is the symbol toggle; otherwise it should treat the argument in the same way as for an interactive call with a numeric prefix argument, as described above.

1
  • Thank you! Now with (add-hook 'org-agenda-mode-hook (lambda () (visual-line-mode -1) (setq truncate-lines 1))) I get the intended behaviour.
    – Timo
    Aug 18 at 9:36

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.