]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify a bit of code
authorTheodor Thornhill <theo@thornhill.no>
Fri, 3 Jan 2020 20:42:08 +0000 (21:42 +0100)
committerJoão Távora <joaotavora@gmail.com>
Thu, 16 Apr 2020 18:53:48 +0000 (19:53 +0100)
Co-authored-by: João Távora <joaotavora@gmail.com>
* 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

index eafe22e224b7689bf7cd4dc6edaaeeb0b093d49f..58980a1147e545d660be1c7136274513c9925d72 100644 (file)
@@ -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))