emacs-circe / circe

Circe, a Client for IRC in Emacs
GNU General Public License v3.0
390 stars 51 forks source link

Cannot have fluid windows and left-padded nicknames...? #376

Open dertuxmalwieder opened 4 years ago

dertuxmalwieder commented 4 years ago

I’m lost, I could need help with my configuration. (I hope that this is the right place.)

Basically, what I want to achieve is a fluid with with left-padded nicknames, like this:

    [user_1] Lorem ipsum dolor sit amet and quite some more    [12:01]
             of the precious blind text.
[other_user] I say something too!

After reading other people's configurations and experimenting a bit, the only things I could get right were either fluid width or the nickname padding. My current circe-config.el looks like this:

(add-hook 'lui-mode-hook 'circe-setup)
(defvar circe-longest-nick 0)
(make-variable-buffer-local 'circe-longest-nick)

(defun circe-say-formatter (&rest keywords)
  (let* ((nick (concat "[" (plist-get keywords :nick) "]"))
         (len (- 2 (length nick))))
    (when (> len circe-longest-nick)
      (setq circe-longest-nick len)
      ;; One of the following is probably correct...
      (setq lui-fill-type (make-string (+ circe-longest-nick 3) ?\ ))
      (setq wrap-prefix (make-string (+ circe-longest-nick 3) ?\ )))
    (plist-put keywords :nick (s-pad-left circe-longest-nick " " nick))
    (lui-format "{nick} {body}" keywords)))

(defun circe-setup ()
  (setq circe-reduce-lurker-spam t
        lui-time-stamp-position 'right-margin
        lui-time-stamp-format "%H:%M"
        lui-fill-type nil
        word-wrap t
        wrap-prefix "        "
        fringes-outside-margins t
        right-margin-width 5
        circe-format-self-say #'circe-say-formatter
        circe-format-say #'circe-say-formatter))

This gives me a fluid width, but the output is not quite as expected as s-pad-left does not seem to be used at all:

[user_1] Lorem ipsum dolor sit amet and quite some more of    [12:01]
   the precious blind text.
[other_user] I say something too!

I could need a pointer here. Thank you in advance.

minikN commented 3 years ago

You may want to check doom's config, because it seems to be setup just the way you want it:

image

dertuxmalwieder commented 3 years ago

It is, indeed! But I wonder which part is relevant.

minikN commented 3 years ago
(defvar +irc-left-padding 13
  "By how much spaces the left hand side of the line should be padded.
Below a value of 12 this may result in uneven alignment between the various
types of messages.")

(use-package circe
  ;; ...
  :config
  (setq circe-format-say (format "{nick:+%ss} │ {body}" +irc-left-padding)))

Didn't test it. But this is the relevant part of the doom configuration. Change 13 to whatever you want.

dertuxmalwieder commented 3 years ago

I tried to adapt the (format ...) command and it did not quite solve the issue just yet - the padding is still wrong:

(defun circe-say-formatter (&rest keywords)
  "Formats in- and output on the IRC.  KEYWORDS contains the nickname."
  (let* ((nick (concat "[" (plist-get keywords :nick) "]"))
         (len (- 2 (length nick))))
    (when (> len circe-longest-nick)
      (setq circe-longest-nick len)
      (setq lui-fill-type (make-string (+ circe-longest-nick 3) ?\ ))
      (setq wrap-prefix (make-string (+ circe-longest-nick 3) ?\ )))
    (plist-put keywords :nick (s-pad-left circe-longest-nick " " nick))
    (lui-format (format "{nick:+%ss} {body}" 13) keywords)))

Yet:

Bildschirmfoto 2021-01-01 um 15 22 23
chasecaleb commented 2 years ago

For anyone else stuck on this like I was just now, you might want to make sure that adaptive-wrap-prefix-mode is not enabled for circe/lui buffers.