Skip to content

A straight-forward way to disable truncate-lines in org-mode display #155

@Zalewa

Description

@Zalewa

Why I want truncate-lines nil:

Because the replies are output like this and I can't read them:

Image

With truncate-lines nil it's not much better to be honest, but the text is at least visible:

Image

How I wanted to do this:

I figured that since there is copilot-chat-org-prompt-mode-hook then I can just hook into it and disable truncate-lines, but it doesn't work because polymode overwrites this. I traced where the truncate-lines variable is changed and first my hook would disable it, then polymode would happily turn it back on.

There is a way to work around this by hooking into org-mode-hook instead, but it feels too convoluted for me and prone to destabilization.

Steps:

Use this minimal init.el:

;; Setup the package archives
(require 'package)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)

;; A straight-forward way to disable truncate-lines in Copilot Chat Org prompt mode.
;; The catch is... it doesn't work.
(defun my/turn-off-truncate-lines ()
  (message "Disabling truncate-lines")
  (setq-local truncate-lines nil))

(use-package copilot-chat
  :ensure t
  :defer t
  :hook (copilot-chat-org-prompt-mode . my/turn-off-truncate-lines))
  1. M-x copilot-chat-display
  2. Ensure the chat buffer is an org-mode buffer.
  3. C-h v truncate-lines - it will say that the value is t.
  4. Inspect the Messages buffer and see that "Disabling truncate-lines" is there.

Workaround:

Hook into org-mode-hook instead and check the buffer name. Also, pray that the buffer name won't change in future releases:

;; Setup the package archives
(require 'package)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)

;; The convoluted way that actually works:
(defun my/turn-off-copilot-org-truncate-lines ()
  "Disable `truncate-lines' in Copilot Chat buffer."
  (when (string-match-p "Copilot Chat" (buffer-name))
    (message "Disabling truncate-lines in Copilot Chat buffer")
    (setq-local truncate-lines nil)))

(use-package copilot-chat
  :ensure t
  :defer t
  :hook (org-mode . my/turn-off-copilot-org-truncate-lines))

Here's my full init.el for reference:
https://bitbucket.org/zalewa/dotfiles/src/2434e8ff09ebfe1d5ec32188eac9eab1cd988b51/.emacs.d/init.el?at=master

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions