From 33f2dd44514512a2f85898d208de2f6539fe1afc Mon Sep 17 00:00:00 2001 From: c Date: Thu, 14 Nov 2024 13:13:42 +0100 Subject: [PATCH] fix glitch with \t tabs --- .gitignore | 2 ++ tests/bench11.el | 28 ++++++++++++++++++++++++++++ uniline.el | 5 +++-- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 tests/bench11.el diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6302bc3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.elc diff --git a/tests/bench11.el b/tests/bench11.el new file mode 100644 index 0000000..e00f1b3 --- /dev/null +++ b/tests/bench11.el @@ -0,0 +1,28 @@ +;;; uniline.el --- Draw lines, boxes, & arrows with the keyboard -*- coding:utf-8; lexical-binding: t; -*- + +;; Copyright (C) 2024 Thierry Banel + +;; Author: Thierry Banel tbanelwebmin at free dot fr +;; Version: 1.0 +;; URL: https://github.com/tbanel/uniline + +;; Uniline is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; Uniline is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +(uniline-bench +"C-q t a b s SPC ? C-a C-q C-q 2 SPC t a b s s" +"\ + ╭─────tabs╮? + │ │ 2 tabs +╶─╯ □ +") diff --git a/uniline.el b/uniline.el index 0dc24b7..6e8e52a 100644 --- a/uniline.el +++ b/uniline.el @@ -154,8 +154,9 @@ Exchange left with right, up with down." Add blanks if line is too short: ensure that cursor points to a character, not \\n. Move to 0 if X negative." - (move-to-column (1+ (max x 0)) t) - (backward-char)) + (let ((x (max x 0))) ;; let is faster than setq when byte-compiled + (move-to-column (1+ x) t) + (move-to-column x t))) (defun uniline--move-to-delta-column (x) "Move X characters, staying on the same line.