summaryrefslogtreecommitdiff
path: root/.config/emacs
diff options
context:
space:
mode:
authorKรฉvin Le Gouguec <kevin.legouguec@gmail.com>2025-07-13 20:56:51 +0200
committerKรฉvin Le Gouguec <kevin.legouguec@gmail.com>2025-07-13 20:56:51 +0200
commit83e9a9a5083135cacd0a651b350d0282f1536c63 (patch)
tree65d95ba3e430b757dd998966f02ca53f04916c00 /.config/emacs
parent1165856c53d605104cfe5402056af0fbbce5a681 (diff)
downloaddotfiles-83e9a9a5083135cacd0a651b350d0282f1536c63.tar.xz
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.
Diffstat (limited to '.config/emacs')
-rw-r--r--.config/emacs/init.el19
1 files changed, 19 insertions, 0 deletions
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))