From 6bfa6e2532c4d81fa717ff7cb3b9a2a1fdce2f19 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 3 Jan 2020 21:42:08 +0100 Subject: [PATCH] Simplify a bit of code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Co-authored-by: João Távora * eglot.el (eglot-move-to-lsp-abiding-column): use already existing function to refer to lsp-abiding-column GitHub-reference: close https://github.com/joaotavora/eglot/issues/397 --- lisp/progmodes/eglot.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index eafe22e224b..58980a1147e 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1012,9 +1012,10 @@ fully LSP-compliant servers, this should be set to `eglot-lsp-abiding-column' (the default), and `eglot-current-column' for all others.") -(defun eglot-lsp-abiding-column () - "Calculate current COLUMN as defined by the LSP spec." - (/ (- (length (encode-coding-region (line-beginning-position) +(defun eglot-lsp-abiding-column (&optional lbp) + "Calculate current COLUMN as defined by the LSP spec. +LBP defaults to `line-beginning-position'." + (/ (- (length (encode-coding-region (or lbp (line-beginning-position)) (point) 'utf-16 t)) 2) 2)) @@ -1057,9 +1058,7 @@ be set to `eglot-move-to-lsp-abiding-column' (the default), and (narrow-to-region lbp (line-end-position)) (move-to-column column) for diff = (- column - (/ (- (length (encode-coding-region lbp (point) 'utf-16 t)) - 2) - 2)) + (eglot-lsp-abiding-column lbp)) until (zerop diff) do (condition-case eob-err (forward-char (/ (if (> diff 0) (1+ diff) (1- diff)) 2)) -- 2.39.2