help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there equivalent C-l for columns?


From: Emanuel Berg
Subject: Re: Is there equivalent C-l for columns?
Date: Wed, 15 Jun 2022 13:40:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Jean Louis wrote:

>> Seems it already has been invented:
>> `w3m-horizontal-recenter' in w3m and
>> `gnus-horizontal-recenter' in Gnus. The w3m command seems
>> to work fine, the Gnus command doesn't do anything for me.
>
> I wish it would work, and I tried it.
>
> Gnus one I cannot find after loading gnus library.

It is in gnus-util.el, line 567-590:

(defun gnus-horizontal-recenter ()
  "Recenter the current buffer horizontally."
  (if (< (current-column) (/ (window-width) 2))
      (set-window-hscroll (gnus-get-buffer-window (current-buffer) t) 0)
    (let* ((orig (point))
           (end (window-end (gnus-get-buffer-window (current-buffer) t)))
           (max 0))
      (when end
        ;; Find the longest line currently displayed in the window.
        (goto-char (window-start))
        (while (and (not (eobp))
                    (< (point) end))
          (end-of-line)
          (setq max (max max (current-column)))
          (forward-line 1))
        (goto-char orig)
        ;; Scroll horizontally to center (sort of) the point.
        (if (> max (window-width))
            (set-window-hscroll
             (gnus-get-buffer-window (current-buffer) t)
             (min (- (current-column) (/ (window-width) 3))
                  (+ 2 (- max (window-width)))))
          (set-window-hscroll (gnus-get-buffer-window (current-buffer) t) 0))
        max))))

To be Gnus a pretty short function LOL :)

  GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
  3.24.24, cairo version 1.16.0) of 2022-05-28
  [commit 79ae40c8e4dac5898d68c92f26f625ac400b960c]

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]