From 83e9a9a5083135cacd0a651b350d0282f1536c63 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Sun, 13 Jul 2025 20:56:51 +0200 Subject: Add function to cycle through auto-hscroll-mode settings And set it to current-line by default; when I only have the odd line poking out of the window, I prefer not jerking the whole buffer horizontally. Should make C-c d h repeatable, someday. --- .config/emacs/init.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 3fe49c6..1d3f1e7 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -158,6 +158,20 @@ left-margin))) (set-window-margins window left-margin right-margin)))) +(defun my/auto-hscroll-toggle () + (interactive) + ;; Use indices to avoid confusing `if-let*' with nil. + (if-let* ((values '(nil t current-line)) + (prev (seq-position values auto-hscroll-mode)) + (next (% (1+ prev) (length values)))) + (progn + (message (concat + (propertize (format "%s" (nth prev values)) 'face 'shadow) + " → " + (propertize (format "%s" (nth next values)) 'face 'bold))) + (setopt auto-hscroll-mode (nth next values))) + (error "Unknown value for auto-hscroll-mode: %s" auto-hscroll-mode))) + (defun my/kill (stuff) (kill-new stuff) (message "%s" stuff)) @@ -280,6 +294,7 @@ list and require no escaping." (my/define-prefix-command my/display-map "Keymap for display-related commands." '(("c" my/centered-mode) + ("h" my/auto-hscroll-toggle) ("l" hl-line-mode) ("n" display-line-numbers-mode) ("t" toggle-truncate-lines) @@ -751,6 +766,10 @@ UPSTREAMS is a list of fetch URLs." (my/setopt-update-list package-archives '(("melpa" . "https://melpa.org/packages/")))) +(use-package emacs + :custom + (auto-hscroll-mode 'current-line)) + (use-package calendar :custom (calendar-intermonth-text '(my/calendar-iso-week year month day)) -- cgit v1.2.3