fix(emacs): support tabs in a file

Fix #226
This commit is contained in:
Soonho Kong 2014-10-07 14:40:54 -07:00
parent e40ef9f6c5
commit 78e9854bae
4 changed files with 15 additions and 5 deletions

View file

@ -126,7 +126,7 @@
(defun company-lean--findg-candidates (prefix) (defun company-lean--findg-candidates (prefix)
(let ((line-number (line-number-at-pos)) (let ((line-number (line-number-at-pos))
(column-number (current-column)) (column-number (lean-line-offset))
pattern) pattern)
(lean-server-send-cmd-sync (lean-cmd-wait) '(lambda () ())) (lean-server-send-cmd-sync (lean-cmd-wait) '(lambda () ()))
(setq pattern (if current-prefix-arg (setq pattern (if current-prefix-arg
@ -203,7 +203,6 @@ triggers a completion immediately."
(defun company-lean--findp-candidates (prefix) (defun company-lean--findp-candidates (prefix)
(let ((line-number (line-number-at-pos)) (let ((line-number (line-number-at-pos))
(column-number (current-column))
pattern) pattern)
(lean-server-send-cmd-sync (lean-cmd-wait) '(lambda () ())) (lean-server-send-cmd-sync (lean-cmd-wait) '(lambda () ()))
(lean-server-send-cmd-sync (lean-cmd-findp line-number prefix) (lean-server-send-cmd-sync (lean-cmd-findp line-number prefix)

View file

@ -456,13 +456,13 @@ Take out \"BEGININFO\" and \"ENDINFO\" and Use \"ACK\" as a delim."
(save-excursion (save-excursion
(forward-char 1) (forward-char 1)
(backward-list 1) (backward-list 1)
`(,(line-number-at-pos) . ,(current-column)))) `(,(line-number-at-pos) . ,(lean-line-offset))))
(defun lean-get-info-record-at-point (cont) (defun lean-get-info-record-at-point (cont)
"Get info-record at the current point" "Get info-record at the current point"
(let* ((file-name (buffer-file-name)) (let* ((file-name (buffer-file-name))
(line-number (line-number-at-pos)) (line-number (line-number-at-pos))
(column-number (current-column)) (column-number (lean-line-offset))
(cmd (cond ((looking-at "(") (cmd (cond ((looking-at "(")
(lean-cmd-info line-number column-number)) (lean-cmd-info line-number column-number))
;; TODO(soonhok): give information on '(' ;; TODO(soonhok): give information on '('

View file

@ -480,7 +480,7 @@ If it's not the same with file-name (default: buffer-file-name), send VISIT cmd.
(defun lean-server-get-info-record-at-pos (body) (defun lean-server-get-info-record-at-pos (body)
(let* ((file-name (buffer-file-name)) (let* ((file-name (buffer-file-name))
(column (current-column))) (column (lean-line-offset)))
(when (and (or (looking-at (rx (or white "," ")" "}" "]"))) (when (and (or (looking-at (rx (or white "," ")" "}" "]")))
(eolp)) (eolp))
(> column 1)) (> column 1))

View file

@ -166,4 +166,15 @@
(when id-beg (when id-beg
(buffer-substring id-beg cur-pos)))))) (buffer-substring id-beg cur-pos))))))
(defun lean-line-offset ()
"Return the byte-offset of current position, counting from the
beginning of the line"
(interactive)
(let ((bol-pos
(save-excursion
(beginning-of-line)
(point)))
(pos (point)))
(- pos bol-pos)))
(provide 'lean-util) (provide 'lean-util)