From 29d16bb0dcc2b672f19ef17d2d2ce54a41075dd1 Mon Sep 17 00:00:00 2001 From: bth Date: Sun, 7 Jun 2026 12:22:10 -0700 Subject: [PATCH] um-transpose-section : fix for trailing section case --- um.el | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/um.el b/um.el index 1a96d0e..24cceb3 100644 --- a/um.el +++ b/um.el @@ -469,13 +469,29 @@ A tag with a value of \"+\" is rendered as the descriptor portion of the filenam A negative prefix argument moves it backward. " (interactive "p") - (let ((direction (if (< arg 0) - -1 1 - ))) - (um-mark-section) - (kill-region nil nil t) - (um--goto-section direction) - (yank) + (let* ((direction (if (< arg 0) + -1 1 + )) + (origpos (point)) + (last (save-excursion + (not (search-forward um--section nil t)))) + (secondlast (save-excursion + (not (search-forward um--section nil t 2))))) + (cond ((and last (= -1 direction)) + (um--goto-section -1) + (um-transpose-section 1)) + ((and secondlast (= 1 direction)) + (um-mark-section) + (kill-region nil nil t) + (goto-char (point-max)) + (um-section) + (yank) + (um--delete-section)) + (t + (um-mark-section) + (kill-region nil nil t) + (um--goto-section direction) + (yank))) ;; to get us back to the top of the section region (set-mark-command 1) ))